libxml-ruby 3.0.0-x64-mingw32 → 3.2.2-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/HISTORY +37 -0
- data/MANIFEST +34 -34
- data/README.rdoc +65 -36
- data/Rakefile +21 -3
- data/ext/libxml/extconf.rb +30 -26
- data/ext/libxml/ruby_libxml.h +0 -8
- data/ext/libxml/ruby_xml.c +40 -0
- data/ext/libxml/ruby_xml_document.c +1 -5
- data/ext/libxml/ruby_xml_dtd.c +6 -8
- data/ext/libxml/ruby_xml_encoding.c +1 -13
- data/ext/libxml/ruby_xml_encoding.h +0 -3
- data/ext/libxml/ruby_xml_error.c +1 -1
- data/ext/libxml/ruby_xml_error.h +1 -1
- data/ext/libxml/ruby_xml_io.c +14 -18
- data/ext/libxml/ruby_xml_io.h +1 -1
- data/ext/libxml/ruby_xml_node.c +16 -17
- data/ext/libxml/ruby_xml_parser_context.c +1 -1
- data/ext/libxml/ruby_xml_reader.c +7 -2
- data/ext/libxml/ruby_xml_schema.c +44 -66
- data/ext/libxml/ruby_xml_schema_element.c +15 -14
- data/ext/libxml/ruby_xml_schema_type.c +66 -93
- data/ext/libxml/ruby_xml_version.h +4 -4
- data/ext/libxml/ruby_xml_writer.c +189 -192
- data/lib/3.0/libxml_ruby.so +0 -0
- data/lib/libxml/schema/element.rb +0 -8
- data/lib/libxml/schema/type.rb +0 -8
- data/lib/libxml/schema.rb +0 -19
- data/lib/libxml-ruby.rb +30 -0
- data/lib/libxml.rb +3 -28
- data/libxml-ruby.gemspec +5 -4
- data/setup.rb +0 -1
- data/test/model/cwm_1_0.xml +11336 -0
- data/test/{tc_attr.rb → test_attr.rb} +18 -18
- data/test/{tc_attr_decl.rb → test_attr_decl.rb} +8 -8
- data/test/{tc_attributes.rb → test_attributes.rb} +10 -10
- data/test/{tc_canonicalize.rb → test_canonicalize.rb} +35 -39
- data/test/test_deprecated_require.rb +12 -0
- data/test/{tc_document.rb → test_document.rb} +31 -24
- data/test/test_document_write.rb +146 -0
- data/test/{tc_dtd.rb → test_dtd.rb} +26 -25
- data/test/{tc_encoding.rb → test_encoding.rb} +20 -17
- data/test/{tc_encoding_sax.rb → test_encoding_sax.rb} +3 -3
- data/test/test_error.rb +178 -0
- data/test/test_helper.rb +4 -11
- data/test/{tc_html_parser.rb → test_html_parser.rb} +31 -30
- data/test/test_html_parser_context.rb +23 -0
- data/test/test_namespace.rb +60 -0
- data/test/{tc_namespaces.rb → test_namespaces.rb} +29 -38
- data/test/{tc_node.rb → test_node.rb} +37 -31
- data/test/{tc_node_cdata.rb → test_node_cdata.rb} +10 -10
- data/test/{tc_node_comment.rb → test_node_comment.rb} +6 -6
- data/test/{tc_node_copy.rb → test_node_copy.rb} +3 -4
- data/test/{tc_node_edit.rb → test_node_edit.rb} +20 -21
- data/test/{tc_node_pi.rb → test_node_pi.rb} +8 -10
- data/test/{tc_node_text.rb → test_node_text.rb} +8 -9
- data/test/{tc_node_write.rb → test_node_write.rb} +16 -26
- data/test/test_node_xlink.rb +28 -0
- data/test/{tc_parser.rb → test_parser.rb} +72 -75
- data/test/{tc_parser_context.rb → test_parser_context.rb} +38 -44
- data/test/{tc_properties.rb → test_properties.rb} +5 -5
- data/test/test_reader.rb +364 -0
- data/test/{tc_relaxng.rb → test_relaxng.rb} +11 -11
- data/test/{tc_sax_parser.rb → test_sax_parser.rb} +38 -31
- data/test/{tc_schema.rb → test_schema.rb} +40 -33
- data/test/test_suite.rb +39 -40
- data/test/{tc_traversal.rb → test_traversal.rb} +4 -4
- data/test/{tc_writer.rb → test_writer.rb} +95 -74
- data/test/{tc_xinclude.rb → test_xinclude.rb} +3 -3
- data/test/test_xml.rb +263 -0
- data/test/{tc_xpath.rb → test_xpath.rb} +25 -25
- data/test/{tc_xpath_context.rb → test_xpath_context.rb} +5 -5
- data/test/{tc_xpath_expression.rb → test_xpath_expression.rb} +7 -7
- data/test/{tc_xpointer.rb → test_xpointer.rb} +15 -15
- metadata +92 -106
- data/lib/2.4/libxml_ruby.so +0 -0
- data/lib/libs/libiconv-2.dll +0 -0
- data/lib/libs/libxml2-2.dll +0 -0
- data/lib/libs/zlib1.dll +0 -0
- data/test/tc_deprecated_require.rb +0 -12
- data/test/tc_document_write.rb +0 -195
- data/test/tc_error.rb +0 -178
- data/test/tc_html_parser_context.rb +0 -23
- data/test/tc_namespace.rb +0 -61
- data/test/tc_node_xlink.rb +0 -28
- data/test/tc_reader.rb +0 -358
- data/test/tc_xml.rb +0 -225
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
require_relative './test_helper'
|
4
4
|
require 'stringio'
|
5
5
|
|
6
6
|
class TestWriter < Minitest::Test
|
@@ -8,33 +8,56 @@ class TestWriter < Minitest::Test
|
|
8
8
|
XSL_URI = 'http://www.w3.org/1999/XSL/Transform'
|
9
9
|
|
10
10
|
def test_generic_failure
|
11
|
-
writer = XML::Writer.string
|
11
|
+
writer = LibXML::XML::Writer.string
|
12
12
|
writer.start_document
|
13
13
|
assert(!writer.end_element)
|
14
14
|
writer.end_document
|
15
15
|
end
|
16
16
|
|
17
17
|
def test_empty_doc
|
18
|
-
writer = XML::Writer.string
|
19
|
-
document
|
18
|
+
writer = LibXML::XML::Writer.string
|
19
|
+
document(writer)
|
20
20
|
assert_equal(writer.result.strip!, '<?xml version="1.0"?>')
|
21
21
|
|
22
|
-
writer = XML::Writer.string
|
23
|
-
document
|
22
|
+
writer = LibXML::XML::Writer.string
|
23
|
+
document(writer, :encoding => LibXML::XML::Encoding::ISO_8859_1)
|
24
24
|
assert_equal(writer.result.strip!, '<?xml version="1.0" encoding="ISO-8859-1"?>')
|
25
25
|
|
26
|
-
writer = XML::Writer.string
|
27
|
-
document
|
26
|
+
writer = LibXML::XML::Writer.string
|
27
|
+
document(writer, :standalone => 1)
|
28
28
|
assert_equal(writer.result.strip!, '<?xml version="1.0" standalone="yes"?>')
|
29
29
|
|
30
|
-
writer = XML::Writer.string
|
31
|
-
document
|
30
|
+
writer = LibXML::XML::Writer.string
|
31
|
+
document(writer, :standalone => 1, :encoding => LibXML::XML::Encoding::ISO_8859_1, :foo => :bar)
|
32
32
|
assert_equal(writer.result.strip!, '<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>')
|
33
33
|
end
|
34
34
|
|
35
|
+
def test_file_encoding
|
36
|
+
value = "François".encode(Encoding::UTF_8)
|
37
|
+
|
38
|
+
File.open('test.xml', 'wb', encoding: 'UTF-8') do |file|
|
39
|
+
writer = LibXML::XML::Writer::io(file)
|
40
|
+
document(writer, encoding: LibXML::XML::Encoding::UTF_8) do
|
41
|
+
writer.write_element('Name', value)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_io_encoding
|
47
|
+
value = "François".encode(Encoding::UTF_8)
|
48
|
+
expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Name>François</Name>".encode(Encoding::UTF_8)
|
49
|
+
|
50
|
+
io = StringIO.new
|
51
|
+
writer = LibXML::XML::Writer::io(io)
|
52
|
+
document(writer, encoding: LibXML::XML::Encoding::UTF_8) do
|
53
|
+
writer.write_element('Name', value)
|
54
|
+
end
|
55
|
+
assert_equal(expected, io.string.strip)
|
56
|
+
end
|
57
|
+
|
35
58
|
def test_single_root
|
36
|
-
writer = XML::Writer.string
|
37
|
-
document
|
59
|
+
writer = LibXML::XML::Writer.string
|
60
|
+
document(writer) do
|
38
61
|
element writer, 'root'
|
39
62
|
end
|
40
63
|
|
@@ -44,16 +67,16 @@ class TestWriter < Minitest::Test
|
|
44
67
|
def test_pi
|
45
68
|
expected = "<?xml version=\"1.0\"?>\n<?php echo \"foo\";?>"
|
46
69
|
|
47
|
-
writer = XML::Writer.string
|
48
|
-
document
|
70
|
+
writer = LibXML::XML::Writer.string
|
71
|
+
document(writer) do
|
49
72
|
assert(writer.start_pi('php'))
|
50
73
|
assert(writer.write_string('echo "foo";'))
|
51
74
|
assert(writer.end_pi)
|
52
75
|
end
|
53
76
|
assert_equal(writer.result.strip!, expected)
|
54
77
|
|
55
|
-
writer = XML::Writer.string
|
56
|
-
document
|
78
|
+
writer = LibXML::XML::Writer.string
|
79
|
+
document(writer) do
|
57
80
|
assert(writer.write_pi('php', 'echo "foo";'))
|
58
81
|
end
|
59
82
|
assert_equal(writer.result.strip!, expected)
|
@@ -62,16 +85,16 @@ class TestWriter < Minitest::Test
|
|
62
85
|
def test_comment
|
63
86
|
expected = "<?xml version=\"1.0\"?>\n<!--foo-->"
|
64
87
|
|
65
|
-
writer = XML::Writer.string
|
66
|
-
document
|
88
|
+
writer = LibXML::XML::Writer.string
|
89
|
+
document(writer) do
|
67
90
|
assert(writer.start_comment)
|
68
91
|
assert(writer.write_string 'foo')
|
69
92
|
assert(writer.end_comment)
|
70
93
|
end
|
71
94
|
assert_equal(writer.result.strip!, expected)
|
72
95
|
|
73
|
-
writer = XML::Writer.string
|
74
|
-
document
|
96
|
+
writer = LibXML::XML::Writer.string
|
97
|
+
document(writer) do
|
75
98
|
assert(writer.write_comment 'foo')
|
76
99
|
end
|
77
100
|
assert_equal(writer.result.strip!, expected)
|
@@ -80,8 +103,8 @@ class TestWriter < Minitest::Test
|
|
80
103
|
def test_cdata
|
81
104
|
expected = "<?xml version=\"1.0\"?>\n<root><![CDATA[<?php echo $foo; ?>]]></root>"
|
82
105
|
|
83
|
-
writer = XML::Writer.string
|
84
|
-
document
|
106
|
+
writer = LibXML::XML::Writer.string
|
107
|
+
document(writer) do
|
85
108
|
element writer, 'root' do
|
86
109
|
assert(writer.start_cdata)
|
87
110
|
assert(writer.write_string '<?php echo $foo; ?>')
|
@@ -90,8 +113,8 @@ class TestWriter < Minitest::Test
|
|
90
113
|
end
|
91
114
|
assert_equal(writer.result.strip!, expected)
|
92
115
|
|
93
|
-
writer = XML::Writer.string
|
94
|
-
document
|
116
|
+
writer = LibXML::XML::Writer.string
|
117
|
+
document(writer) do
|
95
118
|
element writer, 'root' do
|
96
119
|
assert(writer.write_cdata '<?php echo $foo; ?>')
|
97
120
|
end
|
@@ -100,14 +123,14 @@ class TestWriter < Minitest::Test
|
|
100
123
|
end
|
101
124
|
|
102
125
|
def test_write_empty_elements
|
103
|
-
writer = XML::Writer.string
|
104
|
-
document
|
126
|
+
writer = LibXML::XML::Writer.string
|
127
|
+
document(writer) do
|
105
128
|
assert(writer.write_element 'foo')
|
106
129
|
end
|
107
130
|
assert_equal(writer.result.strip!, "<?xml version=\"1.0\"?>\n<foo/>")
|
108
131
|
|
109
|
-
writer = XML::Writer.string
|
110
|
-
document
|
132
|
+
writer = LibXML::XML::Writer.string
|
133
|
+
document(writer) do
|
111
134
|
assert(writer.write_element_ns XSL_PREFIX, 'stylesheet', XSL_URI)
|
112
135
|
end
|
113
136
|
assert_equal(writer.result.strip!, "<?xml version=\"1.0\"?>\n<" + XSL_PREFIX + ":stylesheet xmlns:xsl=\"" + XSL_URI + "\"/>")
|
@@ -116,8 +139,8 @@ class TestWriter < Minitest::Test
|
|
116
139
|
def test_valued_element
|
117
140
|
expected = "<?xml version=\"1.0\"?>\n<abc>123<def>456<ghi>789</ghi>cueillir des cerises</def>nous irons au bois</abc>"
|
118
141
|
|
119
|
-
writer = XML::Writer.string
|
120
|
-
document
|
142
|
+
writer = LibXML::XML::Writer.string
|
143
|
+
document(writer) do
|
121
144
|
assert(writer.start_element 'abc')
|
122
145
|
assert(writer.write_string '123')
|
123
146
|
assert(writer.start_element 'def')
|
@@ -132,8 +155,8 @@ class TestWriter < Minitest::Test
|
|
132
155
|
end
|
133
156
|
assert_equal(writer.result.strip!, expected)
|
134
157
|
|
135
|
-
writer = XML::Writer.string
|
136
|
-
document
|
158
|
+
writer = LibXML::XML::Writer.string
|
159
|
+
document(writer) do
|
137
160
|
assert(writer.start_element 'abc')
|
138
161
|
assert(writer.write_string '123')
|
139
162
|
assert(writer.start_element 'def')
|
@@ -156,8 +179,8 @@ class TestWriter < Minitest::Test
|
|
156
179
|
"</xsl:attribute-set>" +
|
157
180
|
"</xsl:stylesheet>"
|
158
181
|
|
159
|
-
writer = XML::Writer.string
|
160
|
-
document
|
182
|
+
writer = LibXML::XML::Writer.string
|
183
|
+
document(writer) do
|
161
184
|
assert(writer.start_element_ns XSL_PREFIX, 'stylesheet', XSL_URI)
|
162
185
|
assert(writer.start_element_ns XSL_PREFIX, 'attribute-set')
|
163
186
|
assert(writer.start_element_ns XSL_PREFIX, 'attribute')
|
@@ -171,8 +194,8 @@ class TestWriter < Minitest::Test
|
|
171
194
|
end
|
172
195
|
assert_equal(writer.result.strip!, expected)
|
173
196
|
|
174
|
-
writer = XML::Writer.string
|
175
|
-
document
|
197
|
+
writer = LibXML::XML::Writer.string
|
198
|
+
document(writer) do
|
176
199
|
assert(writer.start_element_ns XSL_PREFIX, 'stylesheet', XSL_URI)
|
177
200
|
assert(writer.start_element_ns XSL_PREFIX, 'attribute-set')
|
178
201
|
assert(writer.write_element_ns XSL_PREFIX, 'attribute', nil, '20px')
|
@@ -184,8 +207,8 @@ class TestWriter < Minitest::Test
|
|
184
207
|
end
|
185
208
|
|
186
209
|
def test_attribute
|
187
|
-
writer = XML::Writer.string
|
188
|
-
document
|
210
|
+
writer = LibXML::XML::Writer.string
|
211
|
+
document(writer) do
|
189
212
|
element writer, 'root' do
|
190
213
|
element writer, 'child' do
|
191
214
|
assert(writer.start_attribute 'foo')
|
@@ -196,8 +219,8 @@ class TestWriter < Minitest::Test
|
|
196
219
|
end
|
197
220
|
assert_equal(writer.result.strip!, "<?xml version=\"1.0\"?>\n<root><child foo=\"bar\"/></root>")
|
198
221
|
|
199
|
-
writer = XML::Writer.string
|
200
|
-
document
|
222
|
+
writer = LibXML::XML::Writer.string
|
223
|
+
document(writer) do
|
201
224
|
element writer, 'root' do
|
202
225
|
element writer, 'child' do
|
203
226
|
assert(writer.write_attribute 'abc', 'def')
|
@@ -211,8 +234,8 @@ class TestWriter < Minitest::Test
|
|
211
234
|
def test_attribute_ns
|
212
235
|
expected = "<?xml version=\"1.0\"?>\n<root><link xlink:href=\"abc\" xhtml:class=\"def\"/></root>"
|
213
236
|
|
214
|
-
writer = XML::Writer.string
|
215
|
-
document
|
237
|
+
writer = LibXML::XML::Writer.string
|
238
|
+
document(writer) do
|
216
239
|
element writer, 'root' do
|
217
240
|
element writer, 'link' do
|
218
241
|
assert(writer.write_attribute_ns 'xlink', 'href', nil, 'abc')
|
@@ -222,8 +245,8 @@ class TestWriter < Minitest::Test
|
|
222
245
|
end
|
223
246
|
assert_equal(writer.result.strip!, expected)
|
224
247
|
|
225
|
-
writer = XML::Writer.string
|
226
|
-
document
|
248
|
+
writer = LibXML::XML::Writer.string
|
249
|
+
document(writer) do
|
227
250
|
element writer, 'root' do
|
228
251
|
element writer, 'link' do
|
229
252
|
assert(writer.start_attribute_ns 'xlink', 'href')
|
@@ -239,10 +262,10 @@ class TestWriter < Minitest::Test
|
|
239
262
|
end
|
240
263
|
|
241
264
|
def test_quote_char
|
242
|
-
if XML::Writer.method_defined? :set_quote_char
|
243
|
-
writer = XML::Writer.string
|
265
|
+
if LibXML::XML::Writer.method_defined? :set_quote_char
|
266
|
+
writer = LibXML::XML::Writer.string
|
244
267
|
writer.set_quote_char "'"
|
245
|
-
document
|
268
|
+
document(writer) do
|
246
269
|
element writer, 'root' do
|
247
270
|
assert(writer.start_attribute 'abc')
|
248
271
|
assert(writer.write_string 'def')
|
@@ -254,10 +277,10 @@ class TestWriter < Minitest::Test
|
|
254
277
|
end
|
255
278
|
|
256
279
|
def test_indentation_on
|
257
|
-
if XML::Writer.method_defined? :set_indent
|
258
|
-
writer = XML::Writer.string
|
280
|
+
if LibXML::XML::Writer.method_defined? :set_indent
|
281
|
+
writer = LibXML::XML::Writer.string
|
259
282
|
assert(writer.set_indent true)
|
260
|
-
document
|
283
|
+
document(writer) do
|
261
284
|
element writer, 'root' do
|
262
285
|
element writer, 'child' do
|
263
286
|
assert(writer.start_attribute 'abc')
|
@@ -271,11 +294,11 @@ class TestWriter < Minitest::Test
|
|
271
294
|
end
|
272
295
|
|
273
296
|
def test_indentation_string
|
274
|
-
if XML::Writer.method_defined? :set_indent_string
|
275
|
-
writer = XML::Writer.string
|
297
|
+
if LibXML::XML::Writer.method_defined? :set_indent_string
|
298
|
+
writer = LibXML::XML::Writer.string
|
276
299
|
assert(writer.set_indent true)
|
277
300
|
assert(writer.set_indent_string ' ' * 4)
|
278
|
-
document
|
301
|
+
document(writer) do
|
279
302
|
element writer, 'root' do
|
280
303
|
element writer, 'child' do
|
281
304
|
assert(writer.start_attribute 'abc')
|
@@ -289,11 +312,11 @@ class TestWriter < Minitest::Test
|
|
289
312
|
end
|
290
313
|
|
291
314
|
def test_dtd_declaration
|
292
|
-
writer = XML::Writer.string
|
315
|
+
writer = LibXML::XML::Writer.string
|
293
316
|
dtd writer, 'html'
|
294
317
|
assert_equal(writer.result, '<!DOCTYPE html>')
|
295
318
|
|
296
|
-
writer = XML::Writer.string
|
319
|
+
writer = LibXML::XML::Writer.string
|
297
320
|
dtd writer, 'html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
|
298
321
|
assert_equal(writer.result, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">')
|
299
322
|
end
|
@@ -301,7 +324,7 @@ class TestWriter < Minitest::Test
|
|
301
324
|
def test_dtd_attlist
|
302
325
|
expected = '<!DOCTYPE http [<!ATTLIST method (get|post) "get">]>'
|
303
326
|
|
304
|
-
writer = XML::Writer.string
|
327
|
+
writer = LibXML::XML::Writer.string
|
305
328
|
dtd writer, 'http' do
|
306
329
|
assert(writer.start_dtd_attlist 'method')
|
307
330
|
assert(writer.write_string '(get|post) "get"')
|
@@ -309,7 +332,7 @@ class TestWriter < Minitest::Test
|
|
309
332
|
end
|
310
333
|
assert_equal(writer.result, expected)
|
311
334
|
|
312
|
-
writer = XML::Writer.string
|
335
|
+
writer = LibXML::XML::Writer.string
|
313
336
|
dtd writer, 'http' do
|
314
337
|
assert(writer.write_dtd_attlist 'method', '(get|post) "get"')
|
315
338
|
end
|
@@ -319,7 +342,7 @@ class TestWriter < Minitest::Test
|
|
319
342
|
def test_dtd_element
|
320
343
|
expected = '<!DOCTYPE html [<!ELEMENT dl (dt|dd)+>]>'
|
321
344
|
|
322
|
-
writer = XML::Writer.string
|
345
|
+
writer = LibXML::XML::Writer.string
|
323
346
|
dtd writer, 'html' do
|
324
347
|
assert(writer.start_dtd_element 'dl')
|
325
348
|
assert(writer.write_string '(dt|dd)+')
|
@@ -327,7 +350,7 @@ class TestWriter < Minitest::Test
|
|
327
350
|
end
|
328
351
|
assert_equal(writer.result, expected)
|
329
352
|
|
330
|
-
writer = XML::Writer.string
|
353
|
+
writer = LibXML::XML::Writer.string
|
331
354
|
dtd writer, 'html' do
|
332
355
|
assert(writer.write_dtd_element 'dl', '(dt|dd)+')
|
333
356
|
end
|
@@ -338,7 +361,7 @@ class TestWriter < Minitest::Test
|
|
338
361
|
# parameterized entity
|
339
362
|
expected = '<!DOCTYPE html [<!ENTITY % special.pre "br | span | bdo | map"><!ENTITY % special "%special.pre; | object | img">]>'
|
340
363
|
|
341
|
-
writer = XML::Writer.string
|
364
|
+
writer = LibXML::XML::Writer.string
|
342
365
|
dtd writer, 'html' do
|
343
366
|
assert(writer.start_dtd_entity 'special.pre', true)
|
344
367
|
assert(writer.write_string 'br | span | bdo | map')
|
@@ -349,7 +372,7 @@ class TestWriter < Minitest::Test
|
|
349
372
|
end
|
350
373
|
assert_equal(writer.result, expected)
|
351
374
|
|
352
|
-
writer = XML::Writer.string
|
375
|
+
writer = LibXML::XML::Writer.string
|
353
376
|
dtd writer, 'html' do
|
354
377
|
assert(writer.write_dtd_internal_entity 'special.pre', 'br | span | bdo | map', true)
|
355
378
|
assert(writer.write_dtd_internal_entity 'special', '%special.pre; | object | img', true)
|
@@ -359,7 +382,7 @@ class TestWriter < Minitest::Test
|
|
359
382
|
# non parameterized entity
|
360
383
|
expected = '<!DOCTYPE html [<!ENTITY Alpha "Α">]>'
|
361
384
|
|
362
|
-
writer = XML::Writer.string
|
385
|
+
writer = LibXML::XML::Writer.string
|
363
386
|
dtd writer, 'html' do
|
364
387
|
assert(writer.start_dtd_entity 'Alpha')
|
365
388
|
assert(writer.write_string 'Α')
|
@@ -367,7 +390,7 @@ class TestWriter < Minitest::Test
|
|
367
390
|
end
|
368
391
|
assert_equal(writer.result, expected)
|
369
392
|
|
370
|
-
writer = XML::Writer.string
|
393
|
+
writer = LibXML::XML::Writer.string
|
371
394
|
dtd writer, 'html' do
|
372
395
|
assert(writer.start_dtd_entity 'Alpha', false)
|
373
396
|
assert(writer.write_string 'Α')
|
@@ -375,7 +398,7 @@ class TestWriter < Minitest::Test
|
|
375
398
|
end
|
376
399
|
assert_equal(writer.result, expected)
|
377
400
|
|
378
|
-
writer = XML::Writer.string
|
401
|
+
writer = LibXML::XML::Writer.string
|
379
402
|
dtd writer, 'html' do
|
380
403
|
assert(writer.write_dtd_internal_entity 'Alpha', 'Α', false)
|
381
404
|
end
|
@@ -383,7 +406,7 @@ class TestWriter < Minitest::Test
|
|
383
406
|
end
|
384
407
|
|
385
408
|
def test_dtd_notation
|
386
|
-
writer = XML::Writer.string
|
409
|
+
writer = LibXML::XML::Writer.string
|
387
410
|
dtd writer, 'pictures' do
|
388
411
|
assert(writer.write_dtd_notation 'GIF89a', '-//Compuserve//NOTATION Graphics Interchange Format 89a//EN', nil)
|
389
412
|
assert(writer.write_dtd_external_entity 'pictures', nil, 'images/plage.gif', 'GIF89a', false)
|
@@ -392,19 +415,17 @@ class TestWriter < Minitest::Test
|
|
392
415
|
end
|
393
416
|
|
394
417
|
def test_encoding
|
395
|
-
|
396
|
-
iso = 'éloïse'.encode 'ISO-8859-1'
|
418
|
+
iso = 'éloïse'.encode 'ISO-8859-1'
|
397
419
|
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
end
|
402
|
-
assert_equal(writer.result.strip!, "<?xml version=\"1.0\"?>\n<éloïse/>")
|
420
|
+
writer = LibXML::XML::Writer.string
|
421
|
+
document(writer) do
|
422
|
+
assert(writer.write_element iso)
|
403
423
|
end
|
424
|
+
assert_equal(writer.result.strip!, "<?xml version=\"1.0\"?>\n<éloïse/>")
|
404
425
|
end
|
405
426
|
|
406
427
|
def test_flush
|
407
|
-
writer = XML::Writer.string
|
428
|
+
writer = LibXML::XML::Writer.string
|
408
429
|
assert(writer.start_document)
|
409
430
|
assert_equal(writer.flush.strip!, '<?xml version="1.0"?>')
|
410
431
|
assert(writer.start_element 'foo')
|
@@ -417,7 +438,7 @@ class TestWriter < Minitest::Test
|
|
417
438
|
def test_nil_pe_issue
|
418
439
|
expected = '<!DOCTYPE html [<!ENTITY special.pre "br | span | bdo | map"><!ENTITY special "%special.pre; | object | img">]>'
|
419
440
|
|
420
|
-
writer = XML::Writer.string
|
441
|
+
writer = LibXML::XML::Writer.string
|
421
442
|
dtd writer, 'html' do
|
422
443
|
assert(writer.write_dtd_internal_entity 'special.pre', 'br | span | bdo | map', nil)
|
423
444
|
assert(writer.write_dtd_internal_entity 'special', '%special.pre; | object | img', nil)
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
require_relative './test_helper'
|
4
4
|
|
5
5
|
class TestXInclude < Minitest::Test
|
6
6
|
def setup
|
7
|
-
@doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/xinclude.xml'))
|
8
|
-
assert_instance_of(XML::Document, @doc)
|
7
|
+
@doc = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'model/xinclude.xml'))
|
8
|
+
assert_instance_of(LibXML::XML::Document, @doc)
|
9
9
|
end
|
10
10
|
|
11
11
|
def teardown
|
data/test/test_xml.rb
ADDED
@@ -0,0 +1,263 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require_relative './test_helper'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
class TestXml < Minitest::Test
|
7
|
+
# ----- Constants ------
|
8
|
+
def test_lib_versions
|
9
|
+
assert(LibXML::XML.check_lib_versions)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_debug_entities
|
13
|
+
original = LibXML::XML.debug_entities
|
14
|
+
|
15
|
+
LibXML::XML.debug_entities = false
|
16
|
+
refute(LibXML::XML.debug_entities)
|
17
|
+
|
18
|
+
LibXML::XML.debug_entities = true
|
19
|
+
assert(LibXML::XML.debug_entities)
|
20
|
+
|
21
|
+
LibXML::XML.debug_entities = false
|
22
|
+
refute(LibXML::XML.debug_entities)
|
23
|
+
|
24
|
+
LibXML::XML.debug_entities = original
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_default_compression
|
28
|
+
return unless LibXML::XML.default_compression
|
29
|
+
|
30
|
+
original = LibXML::XML.default_compression
|
31
|
+
|
32
|
+
0.upto(9) do |i|
|
33
|
+
LibXML::XML.default_compression = i
|
34
|
+
assert_equal(i, LibXML::XML.default_compression)
|
35
|
+
end
|
36
|
+
|
37
|
+
9.downto(0) do |i|
|
38
|
+
assert_equal(i, LibXML::XML.default_compression = i)
|
39
|
+
assert_equal(i, LibXML::XML.default_compression)
|
40
|
+
end
|
41
|
+
|
42
|
+
0.downto(-10) do |i|
|
43
|
+
assert_equal(i, LibXML::XML.default_compression = i)
|
44
|
+
assert_equal(0, LibXML::XML.default_compression)
|
45
|
+
end
|
46
|
+
|
47
|
+
10.upto(20) do |i|
|
48
|
+
assert_equal(i, LibXML::XML.default_compression = i)
|
49
|
+
assert_equal(9, LibXML::XML.default_compression)
|
50
|
+
end
|
51
|
+
|
52
|
+
LibXML::XML.default_compression = original
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_default_keep_blanks
|
56
|
+
original = LibXML::XML.default_keep_blanks
|
57
|
+
|
58
|
+
LibXML::XML.default_keep_blanks = false
|
59
|
+
refute(LibXML::XML.default_keep_blanks)
|
60
|
+
assert_equal(LibXML::XML::Parser::Options::NOBLANKS, LibXML::XML.default_options)
|
61
|
+
|
62
|
+
LibXML::XML.default_keep_blanks = true
|
63
|
+
assert(LibXML::XML.default_keep_blanks)
|
64
|
+
assert_equal(0, LibXML::XML.default_options)
|
65
|
+
|
66
|
+
LibXML::XML.default_keep_blanks = original
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_default_line_numbers
|
70
|
+
original = LibXML::XML.default_line_numbers
|
71
|
+
|
72
|
+
LibXML::XML.default_line_numbers = false
|
73
|
+
refute(LibXML::XML.default_line_numbers)
|
74
|
+
|
75
|
+
LibXML::XML.default_line_numbers = true
|
76
|
+
assert(LibXML::XML.default_line_numbers)
|
77
|
+
|
78
|
+
LibXML::XML.default_line_numbers = false
|
79
|
+
refute(LibXML::XML.default_line_numbers)
|
80
|
+
|
81
|
+
LibXML::XML.default_line_numbers = original
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_default_substitute_entities
|
85
|
+
original = LibXML::XML.default_substitute_entities
|
86
|
+
|
87
|
+
LibXML::XML.default_substitute_entities = false
|
88
|
+
refute(LibXML::XML.default_substitute_entities)
|
89
|
+
assert_equal(0, LibXML::XML.default_options)
|
90
|
+
|
91
|
+
LibXML::XML.default_substitute_entities = true
|
92
|
+
assert(LibXML::XML.default_substitute_entities)
|
93
|
+
assert_equal(LibXML::XML::Parser::Options::NOENT, LibXML::XML.default_options)
|
94
|
+
|
95
|
+
LibXML::XML.default_substitute_entities = false
|
96
|
+
refute(LibXML::XML.default_substitute_entities)
|
97
|
+
|
98
|
+
LibXML::XML.default_substitute_entities = original
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_default_tree_indent_string
|
102
|
+
original = LibXML::XML.default_tree_indent_string
|
103
|
+
|
104
|
+
s = LibXML::XML.default_tree_indent_string
|
105
|
+
assert_instance_of(String, s)
|
106
|
+
assert_equal(' ', s)
|
107
|
+
LibXML::XML.default_tree_indent_string = 'uga'
|
108
|
+
s = LibXML::XML.default_tree_indent_string
|
109
|
+
assert_instance_of(String, s)
|
110
|
+
assert_equal('uga', s)
|
111
|
+
LibXML::XML.default_tree_indent_string = ' '
|
112
|
+
s = LibXML::XML.default_tree_indent_string
|
113
|
+
assert_instance_of(String, s)
|
114
|
+
assert_equal(' ', s)
|
115
|
+
|
116
|
+
LibXML::XML.default_tree_indent_string = original
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_default_validity_checking
|
120
|
+
original = LibXML::XML.default_validity_checking
|
121
|
+
|
122
|
+
LibXML::XML.default_validity_checking = false
|
123
|
+
refute(LibXML::XML.default_validity_checking)
|
124
|
+
assert_equal(0, LibXML::XML.default_options)
|
125
|
+
|
126
|
+
LibXML::XML.default_validity_checking = true
|
127
|
+
assert(LibXML::XML.default_validity_checking)
|
128
|
+
assert_equal(LibXML::XML::Parser::Options::DTDVALID, LibXML::XML.default_options)
|
129
|
+
|
130
|
+
LibXML::XML.default_validity_checking = false
|
131
|
+
refute(LibXML::XML.default_validity_checking)
|
132
|
+
|
133
|
+
LibXML::XML.default_validity_checking = original
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_default_warnings
|
137
|
+
original = LibXML::XML.default_warnings
|
138
|
+
|
139
|
+
LibXML::XML.default_warnings = false
|
140
|
+
refute(LibXML::XML.default_warnings)
|
141
|
+
assert_equal(LibXML::XML::Parser::Options::NOWARNING, LibXML::XML.default_options)
|
142
|
+
|
143
|
+
LibXML::XML.default_warnings = true
|
144
|
+
assert(LibXML::XML.default_warnings)
|
145
|
+
assert_equal(0, LibXML::XML.default_options)
|
146
|
+
|
147
|
+
LibXML::XML.default_warnings = false
|
148
|
+
refute(LibXML::XML.default_warnings)
|
149
|
+
|
150
|
+
LibXML::XML.default_warnings = original
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_enabled_automata
|
154
|
+
assert(LibXML::XML.enabled_automata?)
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_enabled_c14n
|
158
|
+
assert(LibXML::XML.enabled_c14n?)
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_enabled_catalog
|
162
|
+
assert(LibXML::XML.enabled_catalog?)
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_enabled_debug
|
166
|
+
assert(LibXML::XML.enabled_debug?)
|
167
|
+
end
|
168
|
+
|
169
|
+
def test_enabled_docbook
|
170
|
+
assert(LibXML::XML.enabled_docbook?)
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_enabled_ftp
|
174
|
+
assert(LibXML::XML.enabled_ftp?)
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_enabled_http
|
178
|
+
assert(LibXML::XML.enabled_http?)
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_enabled_html
|
182
|
+
assert(LibXML::XML.enabled_html?)
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_enabled_iconv
|
186
|
+
iconv_enabled = RUBY_PLATFORM !~ /darwin/
|
187
|
+
assert_equal(iconv_enabled, LibXML::XML.enabled_iconv?)
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_enabled_memory_debug
|
191
|
+
assert_equal(false, LibXML::XML.enabled_memory_debug?)
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_enabled_regexp
|
195
|
+
assert(LibXML::XML.enabled_regexp?)
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_enabled_schemas
|
199
|
+
assert(LibXML::XML.enabled_schemas?)
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_enabled_thread
|
203
|
+
assert(LibXML::XML.enabled_thread?)
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_enabled_unicode
|
207
|
+
assert(LibXML::XML.enabled_unicode?)
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_enabled_xinclude
|
211
|
+
assert(LibXML::XML.enabled_xinclude?)
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_enabled_xpath
|
215
|
+
assert(LibXML::XML.enabled_xpath?)
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_enabled_xpointer
|
219
|
+
assert(LibXML::XML.enabled_xpointer?)
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_enabled_zlib
|
223
|
+
assert(LibXML::XML.enabled_zlib?.is_a?(TrueClass) || LibXML::XML.enabled_zlib?.is_a?(FalseClass))
|
224
|
+
end
|
225
|
+
|
226
|
+
def test_intent_tree_output
|
227
|
+
assert(TrueClass, LibXML::XML.indent_tree_output)
|
228
|
+
|
229
|
+
LibXML::XML.indent_tree_output = false
|
230
|
+
assert(FalseClass, LibXML::XML.indent_tree_output)
|
231
|
+
|
232
|
+
LibXML::XML.indent_tree_output = true
|
233
|
+
assert(TrueClass, LibXML::XML.indent_tree_output)
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_version
|
237
|
+
assert_instance_of(String, LibXML::XML::VERSION)
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_vernum
|
241
|
+
assert_instance_of(Integer, LibXML::XML::VERNUM)
|
242
|
+
end
|
243
|
+
|
244
|
+
def test_libxml_parser_features
|
245
|
+
assert_instance_of(Array, LibXML::XML.features)
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_default_options
|
249
|
+
assert_equal(0, LibXML::XML.default_options)
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_default_save_no_empty_tags
|
253
|
+
original = LibXML::XML.default_save_no_empty_tags
|
254
|
+
|
255
|
+
LibXML::XML.default_save_no_empty_tags = false
|
256
|
+
refute(LibXML::XML.default_save_no_empty_tags)
|
257
|
+
|
258
|
+
LibXML::XML.default_save_no_empty_tags = true
|
259
|
+
assert(LibXML::XML.default_save_no_empty_tags)
|
260
|
+
|
261
|
+
LibXML::XML.default_save_no_empty_tags = original
|
262
|
+
end
|
263
|
+
end
|