libxsl-ruby 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. data/CHANGELOG +14 -0
  2. data/LICENSE +21 -0
  3. data/README +50 -0
  4. data/Rakefile +245 -0
  5. data/TODO +32 -0
  6. data/ext/xml/extconf.rb +97 -0
  7. data/ext/xml/libxml-ruby/libxml.h +92 -0
  8. data/ext/xml/libxml-ruby/ruby_xml_attr.h +31 -0
  9. data/ext/xml/libxml-ruby/ruby_xml_attribute.h +31 -0
  10. data/ext/xml/libxml-ruby/ruby_xml_document.h +37 -0
  11. data/ext/xml/libxml-ruby/ruby_xml_dtd.h +27 -0
  12. data/ext/xml/libxml-ruby/ruby_xml_input_cbg.h +31 -0
  13. data/ext/xml/libxml-ruby/ruby_xml_node.h +38 -0
  14. data/ext/xml/libxml-ruby/ruby_xml_node_set.h +36 -0
  15. data/ext/xml/libxml-ruby/ruby_xml_ns.h +31 -0
  16. data/ext/xml/libxml-ruby/ruby_xml_parser.h +41 -0
  17. data/ext/xml/libxml-ruby/ruby_xml_parser_context.h +32 -0
  18. data/ext/xml/libxml-ruby/ruby_xml_sax_parser.h +31 -0
  19. data/ext/xml/libxml-ruby/ruby_xml_schema.h +26 -0
  20. data/ext/xml/libxml-ruby/ruby_xml_tree.h +22 -0
  21. data/ext/xml/libxml-ruby/ruby_xml_xinclude.h +23 -0
  22. data/ext/xml/libxml-ruby/ruby_xml_xpath.h +34 -0
  23. data/ext/xml/libxml-ruby/ruby_xml_xpath_context.h +34 -0
  24. data/ext/xml/libxml-ruby/ruby_xml_xpointer.h +37 -0
  25. data/ext/xml/libxml-ruby/ruby_xml_xpointer_context.h +28 -0
  26. data/ext/xml/libxslt.c +247 -0
  27. data/ext/xml/libxslt.h +52 -0
  28. data/ext/xml/ruby_xslt_stylesheet.c +298 -0
  29. data/ext/xml/ruby_xslt_stylesheet.h +21 -0
  30. data/ext/xml/ruby_xslt_transform_context.c +63 -0
  31. data/ext/xml/ruby_xslt_transform_context.h +22 -0
  32. data/tests/commentary.dtd +34 -0
  33. data/tests/fuzface.rb +15 -0
  34. data/tests/fuzface.xml +154 -0
  35. data/tests/fuzface.xsl +4 -0
  36. data/tests/ramblings.xsl +46 -0
  37. data/tests/tc_libxslt.rb +65 -0
  38. data/tests/tc_xslt_stylesheet.rb +41 -0
  39. data/tests/tc_xslt_stylesheet2.rb +41 -0
  40. metadata +101 -0
@@ -0,0 +1,14 @@
1
+ 27.02.2006 Ross Bamford <rosco at roscopeco.co.uk>
2
+ * Source layout for Rubygem release
3
+ * Fixed unit tests (set_up to setup, directory handling)
4
+ * Updated extconf to remove shell-script dependency
5
+ * Fixed multiple symbol declarations for -fno-common
6
+
7
+ 15.12.2003 Martin Povolny <martin@solnet.cz>
8
+ * libxslt.c: added call to exsltRegisterAll to enable exslt extensions
9
+ * extconf.rb: added -lexslt
10
+
11
+ 2.1.2004 Martin Povolny <martin@solnet.cz>
12
+ * libxslt.c: added call to ruby_init_xslt_transform_context() to make it
13
+ work on ruby1.8
14
+
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ # $Id: LICENSE,v 1.1 2006/03/24 10:54:55 roscopeco Exp $
2
+
3
+ Copyright (c) 2002-2006 Sean Chittenden <sean@chittenden.org> and contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README ADDED
@@ -0,0 +1,50 @@
1
+ == INSTALLATION
2
+
3
+ Installation is simple. Follow the following steps:
4
+
5
+ === Rubygems
6
+
7
+ gem install libxsl-ruby
8
+
9
+ === Tarball/zip
10
+
11
+ $ rake test
12
+ $ rake install
13
+
14
+ If extconf yacks up an error, follow the instructions it provides.
15
+ You will need to chdir to ext/xml and run 'ruby extconf.rb' to provide
16
+ options, after which you can either use Rake for everything or
17
+ do with make (make && make install).
18
+
19
+ Once installed, look at the test scripts (tests/*.rb), and run
20
+ 'rake doc' to generate API documentation.
21
+
22
+ == DOCUMENTATION
23
+
24
+ RDoc comments are included - run 'rake doc' to generate documentation.
25
+ You can find the latest documentation at:
26
+
27
+ * http://libxsl.rubyforge.org/doc
28
+
29
+ == USAGE EXAMPLE
30
+
31
+ *Note*: To use libxsl-ruby, you have to require both 'xml/libxml' and
32
+ 'xml/libxslt'.
33
+
34
+ $ cd tests
35
+ $ ruby fuzface.rb
36
+
37
+ == If you checked out from CVS
38
+
39
+ If you checked out the source from CVS, you must install a copy of
40
+ the current (or matching) libxml-ruby headers in:
41
+
42
+ ext/xml/libxml-ruby
43
+
44
+ prior to running the above. This can be done via rake, and will
45
+ happen automatically if ../libxml/ext/xml is found, or the
46
+ LIBXMLH=/path/to/headers commandline option is supplied.
47
+
48
+ # $Id: README,v 1.2 2006/03/24 11:19:58 roscopeco Exp $
49
+
50
+ # See the LICENSE file for copyright and distribution information
@@ -0,0 +1,245 @@
1
+ require 'net/ftp'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+ require 'rake/gempackagetask'
6
+
7
+ CLEAN.include '**/*.o'
8
+ CLEAN.include '**/*.so'
9
+ CLEAN.include 'html'
10
+ CLEAN.include 'tests/fuzface.html'
11
+ CLOBBER.include '**/*.log'
12
+ CLOBBER.include '**/Makefile'
13
+ CLOBBER.include '**/extconf.h'
14
+
15
+ desc "Default Task (Build release)"
16
+ task :default => :test
17
+
18
+ # Determine the current version of the software
19
+ if File.read('ext/xml/libxslt.h') =~ /\s*RUBY_LIBXSLT_VERSION\s*['"](\d.+)['"]/
20
+ CURRENT_VERSION = $1
21
+ else
22
+ CURRENT_VERSION = "0.0.0"
23
+ end
24
+
25
+ PKG_VERSION = ENV['REL'] || CURRENT_VERSION
26
+ LIBXMLH = ENV['LIBXMLH'] || '../libxml/ext/xml'
27
+
28
+ task :test_ver do
29
+ puts PKG_VERSION
30
+ end
31
+
32
+ # Make tasks -----------------------------------------------------
33
+ MAKECMD = ENV['MAKE_CMD'] || 'make'
34
+ MAKEOPTS = ENV['MAKE_OPTS'] || ''
35
+
36
+ # Copy libxml headers in if needed or official release
37
+ task :copy_libxml_headers do
38
+ rm_rf 'ext/xml/libxml-ruby' if ENV['REL'] || ENV['ALLCLEAN']
39
+
40
+ unless File.exist?('ext/xml/libxml-ruby')
41
+ unless File.exist?(LIBXMLH)
42
+ fail <<-EOM
43
+
44
+ LibXML-Ruby headers are required to build a release.
45
+
46
+ Install libxml-ruby source at ../libxml, or supply
47
+ LIBXMLH option to rake (e.g. LIBXMLH=../myinc/path)
48
+
49
+ EOM
50
+ end
51
+
52
+ mkdir 'ext/xml/libxml-ruby'
53
+
54
+ Dir[File.join(LIBXMLH, '*.h')].each do |fn|
55
+ unless fn =~ /extconf.h$/
56
+ File.open(File.join('ext/xml/libxml-ruby', File.basename(fn)), 'w+') do |f|
57
+ f << "/* DO NOT EDIT THIS FILE - UPDATE FROM LIBXML-RUBY ONLY */\n"
58
+ f << "/* Generated: #{Time.now} */\n"
59
+ f << "/* Release : #{CURRENT_VERSION} */\n\n\n\n\n\n\n\n"
60
+ f << File.read(fn)
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ file 'ext/xml/extconf.rb' => :copy_libxml_headers
68
+
69
+ file 'ext/xml/Makefile' => 'ext/xml/extconf.rb' do
70
+ Dir.chdir('ext/xml') do
71
+ ruby 'extconf.rb'
72
+ end
73
+ end
74
+
75
+ def make(target = '')
76
+ Dir.chdir('ext/xml') do
77
+ pid = fork { exec "#{MAKECMD} #{MAKEOPTS} #{target}" }
78
+ Process.waitpid pid
79
+ end
80
+ $?.exitstatus
81
+ end
82
+
83
+ # Let make handle dependencies between c/o/so - we'll just run it.
84
+ file 'ext/xml/libxslt.so' => 'ext/xml/Makefile' do
85
+ m = make
86
+ fail "Make failed (status #{m})" unless m == 0
87
+ end
88
+
89
+ desc "Compile the shared object"
90
+ task :compile => 'ext/xml/libxslt.so'
91
+
92
+ desc "Install to your site_ruby directory"
93
+ task :install => :compile do
94
+ m = make 'install'
95
+ fail "Make install failed (status #{m})" unless m == 0
96
+ end
97
+
98
+ # Test Tasks ---------------------------------------------------------
99
+ task :ta => :alltests
100
+ task :tu => :unittests
101
+ task :test => :unittests
102
+
103
+ Rake::TestTask.new(:alltests) do |t|
104
+ t.test_files = FileList[
105
+ 'tests/tc_*.rb',
106
+ 'tests/contrib/*.rb',
107
+ ]
108
+ t.verbose = true
109
+ end
110
+
111
+ Rake::TestTask.new(:unittests) do |t|
112
+ t.test_files = FileList['tests/tc_*.rb']
113
+ t.verbose = false
114
+ end
115
+
116
+ #Rake::TestTask.new(:funtests) do |t|
117
+ # t.test_files = FileList['test/fun*.rb']
118
+ #t.warning = true
119
+ #t.warning = true
120
+ #end
121
+
122
+ task :unittests => :compile
123
+ task :alltests => :compile
124
+
125
+ # RDoc Tasks ---------------------------------------------------------
126
+ desc "Create the RDOC documentation tree"
127
+ rd = Rake::RDocTask.new(:doc) do |rdoc|
128
+ rdoc.rdoc_dir = 'html'
129
+ rdoc.title = "Libxsl-Ruby API"
130
+ rdoc.options << '--main' << 'README'
131
+ rdoc.rdoc_files.include('README', 'LICENSE', 'TODO')
132
+ rdoc.rdoc_files.include('ext/xml/ruby_xslt*.c', 'ext/xml/libxslt.c', '*.rdoc')
133
+ end
134
+
135
+ desc "Publish the RDoc documentation to project web site"
136
+ task :pubdoc => [ :doc ] do
137
+ unless ENV['RUBYFORGE_ACCT']
138
+ raise "Need to set RUBYFORGE_ACCT to your rubyforge.org user name (e.g. 'fred')"
139
+ end
140
+ require 'rake/contrib/sshpublisher'
141
+ Rake::SshDirPublisher.new(
142
+ "#{ENV['RUBYFORGE_ACCT']}@rubyforge.org",
143
+ "/var/www/gforge-projects/libxsl",
144
+ "html"
145
+ ).upload
146
+ end
147
+
148
+ # Packaging / Version number tasks -----------------------------------
149
+ #
150
+ # You can create a Rubygem with 'rake package'
151
+ #
152
+ # You can build a release package set with 'rake release'
153
+ #
154
+ # The project can build official release packages with
155
+ # 'rake release REL=x.y.z' in a working copy (with correct
156
+ # libxml-ruby headers in ../libxml/ext/xml or alternative dir
157
+ # specified with LIBXMLH=/path/to/headers/ )
158
+
159
+ # Used during release packaging if a REL is supplied
160
+ task :update_version do
161
+ unless PKG_VERSION == CURRENT_VERSION
162
+ maj, min, mic = /(\d+)\.(\d+)(?:\.(\d+))?/.match(PKG_VERSION).captures
163
+ File.open('ext/xml/libxslt.h.new','w+') do |f|
164
+ f << File.read('ext/xml/libxslt.h').
165
+ gsub(/RUBY_LIBXSLT_VERSION\s+"(\d.+)"/) { "RUBY_LIBXSLT_VERSION \"#{PKG_VERSION}\"" }.
166
+ gsub(/RUBY_LIBXSLT_VERNUM\s+\d+/) { "RUBY_LIBXSLT_VERNUM #{PKG_VERSION.tr('.','')}" }.
167
+ gsub(/RUBY_LIBXSLT_VER_MAJ\s+\d+/) { "RUBY_LIBXSLT_VER_MAJ #{maj}" }.
168
+ gsub(/RUBY_LIBXSLT_VER_MIN\s+\d+/) { "RUBY_LIBXSLT_VER_MIN #{min}" }.
169
+ gsub(/RUBY_LIBXSLT_VER_MIC\s+\d+/) { "RUBY_LIBXSLT_VER_MIC #{mic || 0}" }
170
+ end
171
+ mv('ext/xml/libxslt.h.new', 'ext/xml/libxslt.h')
172
+ end
173
+ end
174
+
175
+ PKG_FILES = FileList[
176
+ 'ext/xml/extconf.rb',
177
+ '[A-Z]*',
178
+ 'ext/xml/*.c',
179
+ 'ext/xml/libxml-ruby/*.h',
180
+ 'ext/xml/ruby_xslt*.h',
181
+ 'ext/xml/libxslt.h',
182
+ 'tests/**/*',
183
+ ]
184
+
185
+ if ! defined?(Gem)
186
+ warn "Package Target requires RubyGEMs"
187
+ else
188
+ spec = Gem::Specification.new do |s|
189
+
190
+ #### Basic information.
191
+
192
+ s.name = 'libxsl-ruby'
193
+ s.version = PKG_VERSION
194
+ s.summary = "LibXSLT bindings for Ruby"
195
+ s.description = <<-EOF
196
+ C-language bindings for Gnome LibXSLT and Ruby.
197
+ Part of the LibXML-Ruby project.
198
+ EOF
199
+ s.extensions = 'ext/xml/extconf.rb'
200
+
201
+ #### Which files are to be included in this gem?
202
+ s.files = PKG_FILES.to_a
203
+
204
+ #### dependencies
205
+ s.add_dependency('libxml-ruby', '>= 0.3.6')
206
+
207
+ #### Load-time details
208
+ s.require_path = 'ext'
209
+
210
+ #### Documentation and testing.
211
+ s.has_rdoc = true
212
+ s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
213
+ s.rdoc_options <<
214
+ '--title' << 'Libxsl-Ruby API' <<
215
+ '--main' << 'README' <<
216
+ '-o' << 'rdoc'
217
+
218
+ s.test_files = Dir.glob('tests/*runner.rb')
219
+
220
+ #### Author and project details.
221
+
222
+ s.author = "Sean Chittenden"
223
+ s.email = "libxsl-devel@rubyforge.org"
224
+ s.homepage = "http://libxsl.rubyforge.org"
225
+ s.rubyforge_project = "libxsl"
226
+ end
227
+
228
+ # Quick fix for Ruby 1.8.3 / YAML bug
229
+ if (RUBY_VERSION == '1.8.3')
230
+ def spec.to_yaml
231
+ out = super
232
+ out = '--- ' + out unless out =~ /^---/
233
+ out
234
+ end
235
+ end
236
+
237
+ package_task = Rake::GemPackageTask.new(spec) do |pkg|
238
+ pkg.need_zip = true
239
+ pkg.need_tar_gz = true
240
+ pkg.package_dir = 'pkg'
241
+ end
242
+
243
+ desc "Build a full release"
244
+ task :release => [:clobber, :update_version, :compile, :test, :package]
245
+ end
data/TODO ADDED
@@ -0,0 +1,32 @@
1
+ $Id: TODO,v 1.1 2006/03/24 10:54:55 roscopeco Exp $
2
+
3
+ XML::XSLT needs a class method that'll let it use a stylesheet that's
4
+ already in memory. Something like: xsl = XML::XSLT.string(stylesheet)
5
+
6
+ Need version constants to be available for both LIBXML and LIBXSLT
7
+
8
+ Need a way of changing the IO stream used for printing the output
9
+
10
+ Should have some way of turning on more debugging that what's there
11
+
12
+ Need to add the ability to save to a file
13
+
14
+ Ability to dump the tree instead of the result to a given IO stream (partially completed, iirc)
15
+
16
+ Ability to dump the registered extension elements and functions to a given IO stream
17
+
18
+ Ability to turn on and off the DTD loading phase
19
+
20
+ Ability to increase the maximum depth of applying templates
21
+
22
+ Some way of specifying that the incoming document is xhtml and not xml
23
+
24
+ Some way of specifying that the incoming document is SGML docbook
25
+
26
+ A way of setting parameters (key/value pairs) before the stylesheet gets processed
27
+
28
+ A way of not telling the XSL engine to not fetch DTDs over a network
29
+
30
+ A way of specifying the SGML catalogs to use
31
+
32
+ A way of turning on XInclude processing of the document input
@@ -0,0 +1,97 @@
1
+ #!/usr/local/bin/ruby -w
2
+
3
+ # $Id: extconf.rb,v 1.1 2006/03/24 10:54:55 roscopeco Exp $
4
+ #
5
+ # See the LICENSE file for copyright and distribution information
6
+
7
+ require "mkmf"
8
+
9
+ $preload = nil
10
+ $LIBPATH.push(Config::CONFIG['libdir'])
11
+
12
+ def crash(str)
13
+ print(" extconf failure: %s\n", str)
14
+ exit 1
15
+ end
16
+
17
+ dir_config('xml2')
18
+ dir_config('xslt')
19
+ #dir_config('libxml-ruby', '../../../libxml', '../../../libxml/ext/xml')
20
+
21
+ unless have_library('m', 'atan')
22
+ # try again for gcc 4.0
23
+ saveflags = $CFLAGS
24
+ $CFLAGS += ' -fno-builtin'
25
+ unless have_library('m', 'atan')
26
+ crash('need libm')
27
+ end
28
+ $CFLAGS = saveflags
29
+ end
30
+
31
+ unless have_library("z", "inflate")
32
+ crash("need zlib")
33
+ else
34
+ $defs.push('-DHAVE_ZLIB_H')
35
+ end
36
+
37
+ unless (have_library('xml2', 'xmlXPtrNewRange') or
38
+ find_library('xml2', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
39
+ (have_header('libxml/xmlversion.h') or
40
+ find_header('libxml/xmlversion.h',
41
+ '/opt/include/libxml2',
42
+ '/usr/local/include/libxml2',
43
+ '/usr/include/libxml2'))
44
+ crash(<<EOL)
45
+ need libxml2.
46
+
47
+ Install the library or try one of the following options to extconf.rb:
48
+
49
+ --with-xml2-dir=/path/to/libxml2
50
+ --with-xml2-lib=/path/to/libxml2/lib
51
+ --with-xml2-include=/path/to/libxml2/include
52
+ EOL
53
+ end
54
+
55
+ unless (have_library('xslt','xsltApplyStylesheet') or
56
+ find_library('xslt', '/opt/lib', '/usr/local/lib', '/usr/lib')) and
57
+ (have_header('xslt.h') or
58
+ find_header('xslt.h',
59
+ '/opt/include/libxslt',
60
+ '/usr/local/include/libxslt',
61
+ '/usr/include/libxslt'))
62
+ crash(<<EOL)
63
+ need libxslt.
64
+
65
+ Install the library or try one of the following options to extconf.rb:
66
+
67
+ --with-xslt-dir=/path/to/libxslt
68
+ --with-xslt-lib=/path/to/libxslt/lib
69
+ --with-xslt-include=/path/to/libxslt/include
70
+ EOL
71
+ end
72
+
73
+ unless have_header('libxml-ruby/libxml.h')
74
+ crash(<<EOL)
75
+ need headers for libxml-ruby.
76
+
77
+ If you downloaded a release, this is a bug - please inform
78
+ libxml-devel@rubyforge.org including the release version and
79
+ download URL you obtained it from.
80
+
81
+ If you checked libxslt-ruby out from CVS, you will need to
82
+ obtain the headers from CVS (using the same version tag if
83
+ applicable) and place them in directory 'ext/xml/libxml-ruby'.
84
+ EOL
85
+ end
86
+
87
+ $LDFLAGS << ' -lexslt'
88
+ #$LDFLAGS << ' -lxml'
89
+ #$LDFLAGS << ' ' + `xslt-config --libs`.chomp
90
+ #$LDFLAGS << ' ' + `xml2-config --libs`.chomp
91
+ #$CFLAGS << ' ' + `xslt-config --cflags`.chomp
92
+ #$CFLAGS << ' ' + `xml2-config --cflags`.chomp
93
+ $CFLAGS = '-g -Wall ' + $CFLAGS + ' ' + $INCFLAGS
94
+
95
+
96
+ create_header()
97
+ create_makefile("xml/libxslt")