libxslt-ruby 1.1.1-x64-mingw32 → 1.2.0-x64-mingw32
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.
- checksums.yaml +5 -5
- data/CHANGES +161 -154
- data/LICENSE +21 -21
- data/README.rdoc +170 -160
- data/Rakefile +90 -90
- data/ext/libxslt/extconf.h +6 -0
- data/ext/libxslt/extconf.rb +112 -157
- data/ext/libxslt/libxslt.c +68 -69
- data/ext/libxslt/libxslt.h +37 -37
- data/ext/libxslt/ruby_exslt.c +149 -149
- data/ext/libxslt/ruby_exslt.h +8 -8
- data/ext/libxslt/ruby_xslt_stylesheet.c +302 -302
- data/ext/libxslt/ruby_xslt_stylesheet.h +10 -10
- data/ext/libxslt/version.h +5 -5
- data/ext/vc/libxslt_ruby.sln +12 -8
- data/ext/vc/libxslt_ruby.vcxproj +87 -3
- data/lib/2.7/libxslt_ruby.so +0 -0
- data/lib/libxslt-ruby.rb +14 -0
- data/lib/libxslt.rb +3 -16
- data/lib/libxslt/stylesheet.rb +32 -30
- data/lib/xslt.rb +15 -15
- data/libxslt-ruby.gemspec +45 -43
- data/setup.rb +1585 -1585
- data/test/files/commentary.dtd +34 -34
- data/test/files/fuzface.xml +154 -154
- data/test/files/fuzface.xsl +4 -4
- data/test/files/params.xml +2 -2
- data/test/files/params.xsl +10 -10
- data/test/files/ramblings.xsl +46 -46
- data/test/test_exslt.rb +69 -70
- data/test/test_helper.rb +5 -15
- data/test/test_libxslt.rb +20 -22
- data/test/test_stylesheet.rb +213 -214
- metadata +35 -11
- data/lib/2.1/libxslt_ruby.so +0 -0
- data/lib/libxslt/deprecated.rb +0 -68
- data/test/test_deprecated.rb +0 -100
- data/test/test_suite.rb +0 -11
data/test/test_exslt.rb
CHANGED
@@ -1,70 +1,69 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
assert
|
20
|
-
assert LibXSLT::XSLT.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
assert_equal @func, LibXSLT::XSLT.register_module_function(@namespace, @name, &@func)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
assert
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
assert !LibXSLT::XSLT.
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
<xsl:
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
require_relative './test_helper'
|
3
|
+
|
4
|
+
class TestExslt < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@namespace = 'http://test.ext'
|
7
|
+
@name = 'ext-func'
|
8
|
+
@func = lambda { |xp| xp.to_a.join('|') }
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
LibXSLT::XSLT.instance_variable_get(:@module_function_registry).clear
|
13
|
+
# or
|
14
|
+
#LibXSLT::XSLT.unregister_module_function(@namespace, @name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_register
|
18
|
+
assert !LibXSLT::XSLT.registered_module_function?(@namespace, @name)
|
19
|
+
assert LibXSLT::XSLT.register_module_function(@namespace, @name, &@func)
|
20
|
+
assert LibXSLT::XSLT.registered_module_function?(@namespace, @name)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_register_no_block
|
24
|
+
assert_raises(ArgumentError, 'no block given') {
|
25
|
+
LibXSLT::XSLT.register_module_function(@namespace, @name)
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_register_repeated
|
30
|
+
assert_equal @func, LibXSLT::XSLT.register_module_function(@namespace, @name, &@func)
|
31
|
+
assert_equal @func, LibXSLT::XSLT.register_module_function(@namespace, @name, &@func)
|
32
|
+
refute_equal @func, LibXSLT::XSLT.register_module_function(@namespace, @name) { |*| }
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_unregister
|
36
|
+
test_register # need to register before we can unregister
|
37
|
+
assert LibXSLT::XSLT.unregister_module_function(@namespace, @name)
|
38
|
+
assert !LibXSLT::XSLT.registered_module_function?(@namespace, @name)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_unregister_no_register
|
42
|
+
assert !LibXSLT::XSLT.registered_module_function?(@namespace, @name)
|
43
|
+
assert !LibXSLT::XSLT.unregister_module_function(@namespace, @name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_unregister_repeated
|
47
|
+
test_register # need to register before we can unregister
|
48
|
+
assert_equal @func, LibXSLT::XSLT.unregister_module_function(@namespace, @name)
|
49
|
+
assert_nil LibXSLT::XSLT.unregister_module_function(@namespace, @name)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_callback
|
53
|
+
doc = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'files/fuzface.xml'))
|
54
|
+
xpath = '/commentary/meta/author/*'
|
55
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.new(LibXML::XML::Document.string(<<-EOT))
|
56
|
+
<?xml version="1.0" ?>
|
57
|
+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="#{@namespace}">
|
58
|
+
<xsl:template match="/">
|
59
|
+
<xsl:element name="root">
|
60
|
+
<xsl:value-of select="ext:#{@name}(#{xpath})" />
|
61
|
+
</xsl:element>
|
62
|
+
</xsl:template>
|
63
|
+
</xsl:stylesheet>
|
64
|
+
EOT
|
65
|
+
|
66
|
+
assert LibXSLT::XSLT.register_module_function(@namespace, @name, &@func)
|
67
|
+
assert_equal @func[doc.find(xpath)], stylesheet.apply(doc).root.content
|
68
|
+
end
|
69
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -1,15 +1,5 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
lib = File.expand_path(File.join(root, 'lib'))
|
7
|
-
|
8
|
-
$LOAD_PATH << lib
|
9
|
-
|
10
|
-
begin
|
11
|
-
require 'xslt'
|
12
|
-
rescue LoadError
|
13
|
-
require 'rubygems'
|
14
|
-
require 'xslt'
|
15
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'minitest/autorun'
|
5
|
+
require 'libxslt-ruby'
|
data/test/test_libxslt.rb
CHANGED
@@ -1,22 +1,20 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
assert_instance_of(Fixnum, XSLT::
|
8
|
-
assert_instance_of(
|
9
|
-
assert_instance_of(
|
10
|
-
assert_instance_of(Fixnum, XSLT::
|
11
|
-
assert_instance_of(
|
12
|
-
assert_instance_of(String, XSLT::
|
13
|
-
assert_instance_of(String, XSLT::
|
14
|
-
assert_instance_of(String, XSLT::
|
15
|
-
assert_instance_of(String, XSLT::
|
16
|
-
assert_instance_of(String, XSLT::
|
17
|
-
assert_instance_of(String, XSLT::
|
18
|
-
assert_instance_of(String, XSLT::
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
require_relative './test_helper'
|
3
|
+
|
4
|
+
class TextLibXslt < Minitest::Test
|
5
|
+
def test_constants
|
6
|
+
assert_instance_of(Fixnum, LibXSLT::XSLT::MAX_DEPTH)
|
7
|
+
assert_instance_of(Fixnum, LibXSLT::XSLT::MAX_SORT)
|
8
|
+
assert_instance_of(String, LibXSLT::XSLT::ENGINE_VERSION)
|
9
|
+
assert_instance_of(Fixnum, LibXSLT::XSLT::LIBXSLT_VERSION)
|
10
|
+
assert_instance_of(Fixnum, LibXSLT::XSLT::LIBXML_VERSION)
|
11
|
+
assert_instance_of(String, LibXSLT::XSLT::XSLT_NAMESPACE)
|
12
|
+
assert_instance_of(String, LibXSLT::XSLT::DEFAULT_URL)
|
13
|
+
assert_instance_of(String, LibXSLT::XSLT::DEFAULT_VENDOR)
|
14
|
+
assert_instance_of(String, LibXSLT::XSLT::DEFAULT_VERSION)
|
15
|
+
assert_instance_of(String, LibXSLT::XSLT::NAMESPACE_LIBXSLT)
|
16
|
+
assert_instance_of(String, LibXSLT::XSLT::NAMESPACE_SAXON)
|
17
|
+
assert_instance_of(String, LibXSLT::XSLT::NAMESPACE_XT)
|
18
|
+
assert_instance_of(String, LibXSLT::XSLT::NAMESPACE_XALAN)
|
19
|
+
end
|
20
|
+
end
|
data/test/test_stylesheet.rb
CHANGED
@@ -1,214 +1,213 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
result
|
27
|
-
|
28
|
-
|
29
|
-
paragraphs
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
result
|
49
|
-
|
50
|
-
|
51
|
-
#
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
#
|
57
|
-
#
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
rdoc
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
rdoc =
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
assert xml =~
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
<!
|
154
|
-
|
155
|
-
|
156
|
-
<xsl:
|
157
|
-
|
158
|
-
<
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
#
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
<xsl:
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
end
|
1
|
+
# encoding: UTF-8
|
2
|
+
require_relative './test_helper'
|
3
|
+
|
4
|
+
class TestStylesheet < Minitest::Test
|
5
|
+
def setup
|
6
|
+
filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
|
7
|
+
doc = LibXML::XML::Document.file(filename)
|
8
|
+
@stylesheet = LibXSLT::XSLT::Stylesheet.new(doc)
|
9
|
+
end
|
10
|
+
|
11
|
+
def tear_down
|
12
|
+
@stylesheet = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def doc
|
16
|
+
filename = File.join(File.dirname(__FILE__), 'files/fuzface.xml')
|
17
|
+
LibXML::XML::Document.file(filename)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_class
|
21
|
+
assert_instance_of(LibXSLT::XSLT::Stylesheet, @stylesheet)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_apply
|
25
|
+
result = @stylesheet.apply(doc)
|
26
|
+
assert_instance_of(LibXML::XML::Document, result)
|
27
|
+
|
28
|
+
paragraphs = result.find('//p')
|
29
|
+
assert_equal(11, paragraphs.length)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_apply_multiple
|
33
|
+
10.times do
|
34
|
+
test_apply
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_params
|
39
|
+
filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
|
40
|
+
sdoc = LibXML::XML::Document.file(filename)
|
41
|
+
|
42
|
+
filename = File.join(File.dirname(__FILE__), 'files/params.xml')
|
43
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.new(sdoc)
|
44
|
+
doc = LibXML::XML::Document.file(filename)
|
45
|
+
|
46
|
+
# Start with no params
|
47
|
+
result = stylesheet.apply(doc)
|
48
|
+
assert_equal('<article>failure</article>', result.root.to_s)
|
49
|
+
|
50
|
+
# Now try with params as hash. /doc is evaluated
|
51
|
+
# as an xpath expression
|
52
|
+
result = stylesheet.apply(doc, 'bar' => "/doc")
|
53
|
+
assert_equal('<article>abc</article>', result.root.to_s)
|
54
|
+
|
55
|
+
# Now try with params as hash. Note the double quote
|
56
|
+
# on success - we want to pass a literal string and
|
57
|
+
# not an xpath expression.
|
58
|
+
result = stylesheet.apply(doc, 'bar' => "'success'")
|
59
|
+
assert_equal('<article>success</article>', result.root.to_s)
|
60
|
+
|
61
|
+
# Now try with params as an array.
|
62
|
+
result = stylesheet.apply(doc, ['bar', "'success'"])
|
63
|
+
assert_equal('<article>success</article>', result.root.to_s)
|
64
|
+
|
65
|
+
# Now try with invalid array.
|
66
|
+
result = stylesheet.apply(doc, ['bar'])
|
67
|
+
assert_equal('<article>failure</article>', result.root.to_s)
|
68
|
+
end
|
69
|
+
|
70
|
+
# -- Memory Tests ----
|
71
|
+
def test_doc_ownership
|
72
|
+
10.times do
|
73
|
+
filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
|
74
|
+
sdoc = LibXML::XML::Document.file(filename)
|
75
|
+
GC.start
|
76
|
+
assert_equal(173, sdoc.to_s.length)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_stylesheet_ownership
|
81
|
+
10.times do
|
82
|
+
filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
|
83
|
+
sdoc = LibXML::XML::Document.file(filename)
|
84
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.new(sdoc)
|
85
|
+
|
86
|
+
sdoc = nil
|
87
|
+
GC.start
|
88
|
+
|
89
|
+
rdoc = stylesheet.apply(doc)
|
90
|
+
assert_equal(5963, rdoc.to_s.length)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_result_ownership
|
95
|
+
10.times do
|
96
|
+
filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
|
97
|
+
sdoc = LibXML::XML::Document.file(filename)
|
98
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.new(sdoc)
|
99
|
+
|
100
|
+
rdoc = stylesheet.apply(doc)
|
101
|
+
rdoc = nil
|
102
|
+
GC.start
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
#RAF#
|
107
|
+
def test_stylesheet_string
|
108
|
+
filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
|
109
|
+
style = File.open(filename).readline(nil)
|
110
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.string(style)
|
111
|
+
assert_instance_of(LibXSLT::XSLT::Stylesheet, stylesheet)
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_stylesheet_file
|
115
|
+
filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
|
116
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.file(filename)
|
117
|
+
assert_instance_of(LibXSLT::XSLT::Stylesheet, stylesheet)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_stylesheet_io
|
121
|
+
filename = File.join(File.dirname(__FILE__), 'files/params.xsl')
|
122
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.io(File.open(filename))
|
123
|
+
assert_instance_of(LibXSLT::XSLT::Stylesheet, stylesheet)
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_output
|
127
|
+
filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
|
128
|
+
sdoc = LibXML::XML::Document.file(filename)
|
129
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.new(sdoc)
|
130
|
+
|
131
|
+
rdoc = stylesheet.apply(doc)
|
132
|
+
|
133
|
+
xml = stylesheet.output(rdoc)
|
134
|
+
|
135
|
+
# output method is html -> no xml decl, empty tags not closed...
|
136
|
+
assert xml =~ /^<html>/
|
137
|
+
assert xml =~ /<meta http-equiv="Content-Type" content="text\/html; charset=UTF-8">\n<title>/
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_transform
|
141
|
+
filename = File.join(File.dirname(__FILE__), 'files/fuzface.xsl')
|
142
|
+
sdoc = LibXML::XML::Document.file(filename)
|
143
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.new(sdoc)
|
144
|
+
|
145
|
+
xml = stylesheet.transform(doc)
|
146
|
+
|
147
|
+
assert xml =~ /<meta http-equiv="Content-Type" content="text\/html; charset=UTF-8">\n<title>/
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_entities
|
151
|
+
style = <<EOF
|
152
|
+
<!DOCTYPE xsl:stylesheet [
|
153
|
+
<!ENTITY foo 'bar'>
|
154
|
+
]>
|
155
|
+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
156
|
+
<xsl:template match="a">
|
157
|
+
<out><xsl:text>&foo;</xsl:text>
|
158
|
+
<xsl:apply-templates/></out>
|
159
|
+
</xsl:template>
|
160
|
+
</xsl:stylesheet>
|
161
|
+
EOF
|
162
|
+
|
163
|
+
styledoc = LibXML::XML::Parser.string(style, :options => LibXSLT::XSLT::Stylesheet::PARSE_OPTIONS).parse
|
164
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.new(styledoc)
|
165
|
+
|
166
|
+
xml = "<!DOCTYPE a [<!ENTITY bla 'fasel'>]><a>&bla;</a>"
|
167
|
+
doc = LibXML::XML::Parser.string(xml, :options => LibXSLT::XSLT::Stylesheet::PARSE_OPTIONS).parse
|
168
|
+
|
169
|
+
out = stylesheet.apply( doc )
|
170
|
+
dump = stylesheet.output( out )
|
171
|
+
assert_match( /<out>barfasel<\/out>/, dump)
|
172
|
+
|
173
|
+
# no entity replacement in document
|
174
|
+
doc = LibXML::XML::Parser.string(xml, :options => 0).parse
|
175
|
+
out = stylesheet.apply( doc )
|
176
|
+
dump = stylesheet.output( out )
|
177
|
+
|
178
|
+
assert_match(/<out>bar<\/out>/, dump) # entity content is missing
|
179
|
+
|
180
|
+
# note: having entities in your stylesheet that are not replaced during
|
181
|
+
# parse, will crash libxslt (segfault)
|
182
|
+
# seems to be a libxslt problem; you should not do that anyway
|
183
|
+
# styledoc = LibXML::XML::Parser.string(style, : options => 0).parse
|
184
|
+
# stylesheet = LibXSLT::XSLT::Stylesheet.new(styledoc)
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_cdatasection
|
188
|
+
doc = LibXML::XML::Parser.string("<a/>").parse
|
189
|
+
|
190
|
+
style = <<EOF
|
191
|
+
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
192
|
+
<xsl:template match="a">
|
193
|
+
<out><xsl:text disable-output-escaping="yes"><![CDATA[<>]]></xsl:text></out>
|
194
|
+
</xsl:template>
|
195
|
+
</xsl:stylesheet>
|
196
|
+
EOF
|
197
|
+
|
198
|
+
styledoc = LibXML::XML::Parser.string(style, :options => LibXSLT::XSLT::Stylesheet::PARSE_OPTIONS).parse
|
199
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.new(styledoc)
|
200
|
+
|
201
|
+
out = stylesheet.apply( doc )
|
202
|
+
dump = stylesheet.output( out )
|
203
|
+
assert_match( /<out><><\/out>/, dump)
|
204
|
+
|
205
|
+
# without propper parse options (result is wrong from an xml/xslt point of view)
|
206
|
+
styledoc = LibXML::XML::Parser.string(style).parse
|
207
|
+
stylesheet = LibXSLT::XSLT::Stylesheet.new(styledoc)
|
208
|
+
|
209
|
+
out = stylesheet.apply( doc )
|
210
|
+
dump = stylesheet.output( out )
|
211
|
+
assert_match( /<out><><\/out>/, dump)
|
212
|
+
end
|
213
|
+
end
|