libxslt-ruby 1.1.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ # encoding: UTF-8
2
+ require 'test/unit'
3
+ require 'test_helper'
4
+
5
+ class TextLibXslt < Test::Unit::TestCase
6
+ def test_constants
7
+ assert_instance_of(Fixnum, XSLT::MAX_DEPTH)
8
+ assert_instance_of(Fixnum, XSLT::MAX_SORT)
9
+ assert_instance_of(String, XSLT::ENGINE_VERSION)
10
+ assert_instance_of(Fixnum, XSLT::LIBXSLT_VERSION)
11
+ assert_instance_of(Fixnum, XSLT::LIBXML_VERSION)
12
+ assert_instance_of(String, XSLT::XSLT_NAMESPACE)
13
+ assert_instance_of(String, XSLT::DEFAULT_URL)
14
+ assert_instance_of(String, XSLT::DEFAULT_VENDOR)
15
+ assert_instance_of(String, XSLT::DEFAULT_VERSION)
16
+ assert_instance_of(String, XSLT::NAMESPACE_LIBXSLT)
17
+ assert_instance_of(String, XSLT::NAMESPACE_SAXON)
18
+ assert_instance_of(String, XSLT::NAMESPACE_XT)
19
+ assert_instance_of(String, XSLT::NAMESPACE_XALAN)
20
+ assert_instance_of(String, XSLT::NAMESPACE_NORM_SAXON)
21
+ end
22
+ end
@@ -0,0 +1,214 @@
1
+ # encoding: UTF-8
2
+ require 'test/unit'
3
+ require 'test_helper'
4
+
5
+ class TestStylesheet < Test::Unit::TestCase
6
+ def setup
7
+ filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
8
+ doc = XML::Document.file(filename)
9
+ @stylesheet = XSLT::Stylesheet.new(doc)
10
+ end
11
+
12
+ def tear_down
13
+ @stylesheet = nil
14
+ end
15
+
16
+ def doc
17
+ filename = File.join(File.dirname(__FILE__), 'files/fuzface.xml')
18
+ XML::Document.file(filename)
19
+ end
20
+
21
+ def test_class
22
+ assert_instance_of(XSLT::Stylesheet, @stylesheet)
23
+ end
24
+
25
+ def test_apply
26
+ result = @stylesheet.apply(doc)
27
+ assert_instance_of(XML::Document, result)
28
+
29
+ paragraphs = result.find('//p')
30
+ assert_equal(11, paragraphs.length)
31
+ end
32
+
33
+ def test_apply_multiple
34
+ 10.times do
35
+ test_apply
36
+ end
37
+ end
38
+
39
+ def test_params
40
+ filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
41
+ sdoc = XML::Document.file(filename)
42
+
43
+ filename = File.join(File.dirname(__FILE__), 'files/params.xml')
44
+ stylesheet = XSLT::Stylesheet.new(sdoc)
45
+ doc = XML::Document.file(filename)
46
+
47
+ # Start with no params
48
+ result = stylesheet.apply(doc)
49
+ assert_equal('<article>failure</article>', result.root.to_s)
50
+
51
+ # Now try with params as hash. /doc is evaluated
52
+ # as an xpath expression
53
+ result = stylesheet.apply(doc, 'bar' => "/doc")
54
+ assert_equal('<article>abc</article>', result.root.to_s)
55
+
56
+ # Now try with params as hash. Note the double quote
57
+ # on success - we want to pass a literal string and
58
+ # not an xpath expression.
59
+ result = stylesheet.apply(doc, 'bar' => "'success'")
60
+ assert_equal('<article>success</article>', result.root.to_s)
61
+
62
+ # Now try with params as an array.
63
+ result = stylesheet.apply(doc, ['bar', "'success'"])
64
+ assert_equal('<article>success</article>', result.root.to_s)
65
+
66
+ # Now try with invalid array.
67
+ result = stylesheet.apply(doc, ['bar'])
68
+ assert_equal('<article>failure</article>', result.root.to_s)
69
+ end
70
+
71
+ # -- Memory Tests ----
72
+ def test_doc_ownership
73
+ 10.times do
74
+ filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
75
+ sdoc = XML::Document.file(filename)
76
+ GC.start
77
+ assert_equal(173, sdoc.to_s.length)
78
+ end
79
+ end
80
+
81
+ def test_stylesheet_ownership
82
+ 10.times do
83
+ filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
84
+ sdoc = XML::Document.file(filename)
85
+ stylesheet = XSLT::Stylesheet.new(sdoc)
86
+
87
+ sdoc = nil
88
+ GC.start
89
+
90
+ rdoc = stylesheet.apply(doc)
91
+ assert_equal(5963, rdoc.to_s.length)
92
+ end
93
+ end
94
+
95
+ def test_result_ownership
96
+ 10.times do
97
+ filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
98
+ sdoc = XML::Document.file(filename)
99
+ stylesheet = XSLT::Stylesheet.new(sdoc)
100
+
101
+ rdoc = stylesheet.apply(doc)
102
+ rdoc = nil
103
+ GC.start
104
+ end
105
+ end
106
+
107
+ #RAF#
108
+ def test_stylesheet_string
109
+ filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
110
+ style = File.open(filename).readline(nil)
111
+ stylesheet = XSLT::Stylesheet.string(style)
112
+ assert_instance_of(XSLT::Stylesheet, stylesheet)
113
+ end
114
+
115
+ def test_stylesheet_file
116
+ filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
117
+ stylesheet = XSLT::Stylesheet.file(filename)
118
+ assert_instance_of(XSLT::Stylesheet, stylesheet)
119
+ end
120
+
121
+ def test_stylesheet_io
122
+ filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
123
+ stylesheet = XSLT::Stylesheet.io(File.open(filename))
124
+ assert_instance_of(XSLT::Stylesheet, stylesheet)
125
+ end
126
+
127
+ def test_output
128
+ filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
129
+ sdoc = XML::Document.file(filename)
130
+ stylesheet = XSLT::Stylesheet.new(sdoc)
131
+
132
+ rdoc = stylesheet.apply(doc)
133
+
134
+ xml = stylesheet.output(rdoc)
135
+
136
+ # output method is html -> no xml decl, empty tags not closed...
137
+ assert xml =~ /^<html>/
138
+ assert xml =~ /<meta http-equiv="Content-Type" content="text\/html; charset=UTF-8">\n<title>/
139
+ end
140
+
141
+ def test_transform
142
+ filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
143
+ sdoc = XML::Document.file(filename)
144
+ stylesheet = XSLT::Stylesheet.new(sdoc)
145
+
146
+ xml = stylesheet.transform(doc)
147
+
148
+ assert xml =~ /<meta http-equiv="Content-Type" content="text\/html; charset=UTF-8">\n<title>/
149
+ end
150
+
151
+ def test_entities
152
+ style = <<EOF
153
+ <!DOCTYPE xsl:stylesheet [
154
+ <!ENTITY foo 'bar'>
155
+ ]>
156
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
157
+ <xsl:template match="a">
158
+ <out><xsl:text>&foo;</xsl:text>
159
+ <xsl:apply-templates/></out>
160
+ </xsl:template>
161
+ </xsl:stylesheet>
162
+ EOF
163
+
164
+ styledoc = LibXML::XML::Parser.string(style, :options => XSLT::Stylesheet::PARSE_OPTIONS).parse
165
+ stylesheet = XSLT::Stylesheet.new(styledoc)
166
+
167
+ xml = "<!DOCTYPE a [<!ENTITY bla 'fasel'>]><a>&bla;</a>"
168
+ doc = XML::Parser.string(xml, :options => XSLT::Stylesheet::PARSE_OPTIONS).parse
169
+
170
+ out = stylesheet.apply( doc )
171
+ dump = stylesheet.output( out )
172
+ assert_match( /<out>barfasel<\/out>/, dump)
173
+
174
+ # no entity replacement in document
175
+ doc = XML::Parser.string(xml, :options => 0).parse
176
+ out = stylesheet.apply( doc )
177
+ dump = stylesheet.output( out )
178
+
179
+ assert_match(/<out>bar<\/out>/, dump) # entity content is missing
180
+
181
+ # note: having entities in your stylesheet that are not replaced during
182
+ # parse, will crash libxslt (segfault)
183
+ # seems to be a libxslt problem; you should not do that anyway
184
+ # styledoc = LibXML::XML::Parser.string(style, : options => 0).parse
185
+ # stylesheet = XSLT::Stylesheet.new(styledoc)
186
+ end
187
+
188
+ def test_cdatasection
189
+ doc = XML::Parser.string("<a/>").parse
190
+
191
+ style = <<EOF
192
+ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
193
+ <xsl:template match="a">
194
+ <out><xsl:text disable-output-escaping="yes"><![CDATA[<>]]></xsl:text></out>
195
+ </xsl:template>
196
+ </xsl:stylesheet>
197
+ EOF
198
+
199
+ styledoc = LibXML::XML::Parser.string(style, :options => XSLT::Stylesheet::PARSE_OPTIONS).parse
200
+ stylesheet = XSLT::Stylesheet.new(styledoc)
201
+
202
+ out = stylesheet.apply( doc )
203
+ dump = stylesheet.output( out )
204
+ assert_match( /<out><><\/out>/, dump)
205
+
206
+ # without propper parse options (result is wrong from an xml/xslt point of view)
207
+ styledoc = LibXML::XML::Parser.string(style).parse
208
+ stylesheet = XSLT::Stylesheet.new(styledoc)
209
+
210
+ out = stylesheet.apply( doc )
211
+ dump = stylesheet.output( out )
212
+ assert_match( /<out>&lt;&gt;<\/out>/, dump)
213
+ end
214
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: UTF-8
2
+
3
+ # Change to current directory so relative
4
+ # requires work.
5
+ dir = File.dirname(__FILE__)
6
+ Dir.chdir(dir)
7
+
8
+ require './test_libxslt'
9
+ require './test_stylesheet'
10
+ require './test_deprecated'
11
+ require './test_exslt'
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: libxslt-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.1
5
+ platform: x64-mingw32
6
+ authors:
7
+ - Charlie Savage
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: libxml-ruby
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.4.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.4.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake-compiler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: |2
42
+ The Libxslt-Ruby project provides Ruby language bindings for the GNOME
43
+ XSLT C library. It is free software, released under the MIT License.
44
+ email: libxml-devel@rubyforge.org
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - CHANGES
50
+ - LICENSE
51
+ - README.rdoc
52
+ - Rakefile
53
+ - ext/libxslt/extconf.rb
54
+ - ext/libxslt/libxslt.c
55
+ - ext/libxslt/libxslt.h
56
+ - ext/libxslt/ruby_exslt.c
57
+ - ext/libxslt/ruby_exslt.h
58
+ - ext/libxslt/ruby_xslt_stylesheet.c
59
+ - ext/libxslt/ruby_xslt_stylesheet.h
60
+ - ext/libxslt/version.h
61
+ - ext/vc/libxslt_ruby.sln
62
+ - ext/vc/libxslt_ruby.vcxproj
63
+ - lib/2.1/libxslt_ruby.so
64
+ - lib/libs/libexslt-0.dll
65
+ - lib/libs/libxslt-1.dll
66
+ - lib/libxslt.rb
67
+ - lib/libxslt/deprecated.rb
68
+ - lib/libxslt/stylesheet.rb
69
+ - lib/xslt.rb
70
+ - libxslt-ruby.gemspec
71
+ - setup.rb
72
+ - test/files/commentary.dtd
73
+ - test/files/fuzface.xml
74
+ - test/files/fuzface.xsl
75
+ - test/files/params.xml
76
+ - test/files/params.xsl
77
+ - test/files/ramblings.xsl
78
+ - test/test_deprecated.rb
79
+ - test/test_exslt.rb
80
+ - test/test_helper.rb
81
+ - test/test_libxslt.rb
82
+ - test/test_stylesheet.rb
83
+ - test/test_suite.rb
84
+ homepage: http://libxslt.rubyforge.org/
85
+ licenses: []
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ - ext/libxslt
92
+ required_ruby_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.9.3
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ requirements: []
103
+ rubyforge_project: libxslt-ruby
104
+ rubygems_version: 2.2.2
105
+ signing_key:
106
+ specification_version: 4
107
+ summary: Ruby libxslt bindings
108
+ test_files:
109
+ - test/test_deprecated.rb
110
+ - test/test_exslt.rb
111
+ - test/test_helper.rb
112
+ - test/test_libxslt.rb
113
+ - test/test_stylesheet.rb
114
+ - test/test_suite.rb