libxml-ruby 5.0.6 → 6.0.0
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 +4 -4
- data/{HISTORY → CHANGELOG.md} +875 -930
- data/LICENSE +20 -20
- data/README.md +67 -0
- data/Rakefile +13 -34
- data/ext/libxml/extconf.rb +34 -20
- data/ext/libxml/libxml.c +2 -14
- data/ext/libxml/ruby_libxml.h +1 -1
- data/ext/libxml/ruby_xml_attr.c +27 -22
- data/ext/libxml/ruby_xml_attr.h +1 -0
- data/ext/libxml/ruby_xml_attr_decl.c +19 -12
- data/ext/libxml/ruby_xml_attributes.c +18 -9
- data/ext/libxml/ruby_xml_document.c +111 -98
- data/ext/libxml/ruby_xml_document.h +1 -0
- data/ext/libxml/ruby_xml_dtd.c +49 -19
- data/ext/libxml/ruby_xml_dtd.h +1 -0
- data/ext/libxml/ruby_xml_html_parser.c +1 -1
- data/ext/libxml/ruby_xml_html_parser_context.c +19 -6
- data/ext/libxml/ruby_xml_html_parser_context.h +1 -0
- data/ext/libxml/ruby_xml_input_cbg.c +45 -17
- data/ext/libxml/ruby_xml_io.c +3 -1
- data/ext/libxml/ruby_xml_namespace.c +20 -12
- data/ext/libxml/ruby_xml_namespace.h +1 -0
- data/ext/libxml/ruby_xml_namespaces.c +40 -20
- data/ext/libxml/ruby_xml_node.c +71 -32
- data/ext/libxml/ruby_xml_node.h +2 -0
- data/ext/libxml/ruby_xml_parser.c +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +54 -47
- data/ext/libxml/ruby_xml_parser_context.h +1 -0
- data/ext/libxml/ruby_xml_reader.c +25 -15
- data/ext/libxml/ruby_xml_registry.c +31 -0
- data/ext/libxml/ruby_xml_registry.h +22 -0
- data/ext/libxml/ruby_xml_relaxng.c +21 -5
- data/ext/libxml/ruby_xml_relaxng.h +1 -0
- data/ext/libxml/ruby_xml_sax_parser.c +1 -1
- data/ext/libxml/ruby_xml_schema.c +18 -11
- data/ext/libxml/ruby_xml_schema.h +1 -0
- data/ext/libxml/ruby_xml_schema_attribute.c +7 -7
- data/ext/libxml/ruby_xml_schema_element.c +8 -8
- data/ext/libxml/ruby_xml_schema_facet.c +7 -7
- data/ext/libxml/ruby_xml_schema_type.c +12 -19
- data/ext/libxml/ruby_xml_version.h +4 -4
- data/ext/libxml/ruby_xml_writer.c +18 -6
- data/ext/libxml/ruby_xml_xpath.c +2 -2
- data/ext/libxml/ruby_xml_xpath.h +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +72 -26
- data/ext/libxml/ruby_xml_xpath_expression.c +11 -5
- data/ext/libxml/ruby_xml_xpath_expression.h +1 -0
- data/ext/libxml/ruby_xml_xpath_object.c +69 -54
- data/ext/libxml/ruby_xml_xpath_object.h +3 -1
- data/ext/vc/libxml_ruby/libxml_ruby.vcxproj +271 -0
- data/ext/xcode/libxml-ruby.xcodeproj/project.pbxproj +633 -0
- data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- data/ext/xcode/libxml-ruby.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- data/ext/xcode/libxml-ruby.xcodeproj/xcshareddata/xcschemes/libxml-ruby.xcscheme +80 -0
- data/lib/libxml/document.rb +0 -29
- data/lib/libxml/error.rb +30 -3
- data/lib/libxml/html_parser.rb +0 -16
- data/lib/libxml/node.rb +1 -3
- data/lib/libxml/parser.rb +0 -8
- data/lib/libxml/schema/attribute.rb +27 -19
- data/lib/libxml/schema/element.rb +20 -0
- data/lib/libxml/schema/type.rb +44 -21
- data/lib/libxml/schema.rb +47 -47
- data/lib/libxml-ruby.rb +30 -30
- data/libxml-ruby.gemspec +12 -16
- data/test/c14n/result/1-1-without-comments/example-1 +3 -3
- data/test/c14n/result/1-1-without-comments/example-2 +10 -10
- data/test/c14n/result/1-1-without-comments/example-3 +13 -13
- data/test/c14n/result/1-1-without-comments/example-4 +8 -8
- data/test/c14n/result/1-1-without-comments/example-5 +2 -2
- data/test/c14n/result/with-comments/example-1 +5 -5
- data/test/c14n/result/with-comments/example-2 +10 -10
- data/test/c14n/result/with-comments/example-3 +13 -13
- data/test/c14n/result/with-comments/example-4 +8 -8
- data/test/c14n/result/with-comments/example-5 +3 -3
- data/test/c14n/result/without-comments/example-1 +3 -3
- data/test/c14n/result/without-comments/example-2 +10 -10
- data/test/c14n/result/without-comments/example-3 +13 -13
- data/test/c14n/result/without-comments/example-4 +8 -8
- data/test/c14n/result/without-comments/example-5 +2 -2
- data/test/test_attr.rb +179 -180
- data/test/test_attr_decl.rb +131 -131
- data/test/test_attributes.rb +135 -135
- data/test/test_canonicalize.rb +122 -120
- data/test/test_document.rb +2 -4
- data/test/test_dtd.rb +12 -4
- data/test/test_encoding_sax.rb +114 -114
- data/test/test_error.rb +1 -1
- data/test/test_html_parser.rb +6 -2
- data/test/test_html_parser_context.rb +22 -22
- data/test/test_input_callbacks.rb +36 -0
- data/test/test_namespace.rb +1 -1
- data/test/test_namespaces.rb +200 -200
- data/test/test_node.rb +16 -0
- data/test/test_node_cdata.rb +50 -50
- data/test/test_node_comment.rb +32 -32
- data/test/test_node_copy.rb +40 -40
- data/test/test_node_edit.rb +176 -158
- data/test/test_node_pi.rb +37 -37
- data/test/test_node_text.rb +69 -69
- data/test/test_node_xlink.rb +28 -28
- data/test/test_parser.rb +5 -41
- data/test/test_parser_context.rb +198 -198
- data/test/test_properties.rb +38 -38
- data/test/test_reader.rb +55 -6
- data/test/test_relaxng.rb +59 -53
- data/test/test_sax_parser.rb +345 -345
- data/test/test_schema.rb +28 -0
- data/test/test_traversal.rb +152 -152
- data/test/test_writer.rb +0 -31
- data/test/test_xinclude.rb +20 -20
- data/test/test_xml.rb +3 -7
- data/test/test_xpath.rb +244 -244
- data/test/test_xpath_context.rb +87 -87
- data/test/test_xpath_expression.rb +37 -37
- metadata +32 -25
- data/README.rdoc +0 -208
- data/ext/libxml/extconf.h +0 -4
- data/ext/libxml/ruby_xml_cbg.c +0 -85
- data/lib/libxml/hpricot.rb +0 -78
- data/lib/libxml.rb +0 -5
- data/lib/xml/libxml.rb +0 -10
- data/lib/xml.rb +0 -14
- data/script/benchmark/depixelate +0 -634
- data/script/benchmark/hamlet.xml +0 -9055
- data/script/benchmark/parsecount +0 -170
- data/script/benchmark/sock_entries.xml +0 -507
- data/script/benchmark/throughput +0 -41
- data/script/test +0 -6
- data/test/test_deprecated_require.rb +0 -12
data/test/test_reader.rb
CHANGED
|
@@ -172,11 +172,42 @@ class TestReader < Minitest::Test
|
|
|
172
172
|
|
|
173
173
|
# Read a node
|
|
174
174
|
node = reader.expand
|
|
175
|
-
|
|
175
|
+
# node.doc is nil until reader.doc is called to wrap the document
|
|
176
|
+
assert_nil(node.doc)
|
|
176
177
|
assert_equal('feed', node.name)
|
|
177
178
|
assert_equal(::Encoding::UTF_8, node.name.encoding) if defined?(::Encoding)
|
|
178
179
|
end
|
|
179
180
|
|
|
181
|
+
def test_expand_attribute_doc_requires_reader_doc
|
|
182
|
+
reader = LibXML::XML::Reader.string('<root a="1"/>')
|
|
183
|
+
reader.read
|
|
184
|
+
|
|
185
|
+
node = reader.expand
|
|
186
|
+
attr = node.attributes.get_attribute('a')
|
|
187
|
+
|
|
188
|
+
assert_nil(node.doc)
|
|
189
|
+
assert_nil(attr.doc)
|
|
190
|
+
|
|
191
|
+
doc = reader.doc
|
|
192
|
+
assert_same(doc, node.doc)
|
|
193
|
+
assert_same(doc, attr.doc)
|
|
194
|
+
ensure
|
|
195
|
+
begin
|
|
196
|
+
reader.doc if reader
|
|
197
|
+
rescue StandardError
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def test_expand_attribute_doc
|
|
202
|
+
reader = LibXML::XML::Reader.string('<root a="1"/>')
|
|
203
|
+
reader.read
|
|
204
|
+
|
|
205
|
+
node = reader.expand
|
|
206
|
+
attr = node.attributes.get_attribute('a')
|
|
207
|
+
|
|
208
|
+
assert_nil(attr.doc)
|
|
209
|
+
end
|
|
210
|
+
|
|
180
211
|
def test_expand_find
|
|
181
212
|
reader = LibXML::XML::Reader.file(XML_FILE)
|
|
182
213
|
reader.read.to_s
|
|
@@ -229,7 +260,6 @@ class TestReader < Minitest::Test
|
|
|
229
260
|
while reader.read
|
|
230
261
|
node = reader.expand
|
|
231
262
|
refute_nil(node)
|
|
232
|
-
refute_nil(node.doc)
|
|
233
263
|
|
|
234
264
|
# NOTE - DO NOT do this in real code, these nodes are invalid after the next read. This *will* cause
|
|
235
265
|
# a segmentation fault next time the garbage collector runs. The reason is the parent node will be
|
|
@@ -338,8 +368,7 @@ class TestReader < Minitest::Test
|
|
|
338
368
|
reader.read
|
|
339
369
|
end
|
|
340
370
|
|
|
341
|
-
|
|
342
|
-
error.to_s)
|
|
371
|
+
assert_match(/Fatal error:.*at :2\./m, error.to_s)
|
|
343
372
|
|
|
344
373
|
end
|
|
345
374
|
|
|
@@ -358,7 +387,27 @@ class TestReader < Minitest::Test
|
|
|
358
387
|
reader = LibXML::XML::Reader.string(xml, :encoding => LibXML::XML::Encoding::ISO_8859_1)
|
|
359
388
|
reader.read
|
|
360
389
|
|
|
361
|
-
|
|
362
|
-
|
|
390
|
+
if Gem::Version.new(LibXML::XML::LIBXML_VERSION) >= Gem::Version.new("2.12")
|
|
391
|
+
assert_equal(LibXML::XML::Encoding::ISO_8859_1, reader.encoding)
|
|
392
|
+
else
|
|
393
|
+
assert_equal(LibXML::XML::Encoding::NONE, reader.encoding)
|
|
394
|
+
end
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
def test_expand_gc_after_advance
|
|
398
|
+
GC.stress = true
|
|
399
|
+
expand_and_advance
|
|
400
|
+
ensure
|
|
401
|
+
GC.stress = false
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
private
|
|
405
|
+
|
|
406
|
+
def expand_and_advance
|
|
407
|
+
reader = LibXML::XML::Reader.string("<root><a/><b/></root>")
|
|
408
|
+
reader.read # root
|
|
409
|
+
reader.read # a
|
|
410
|
+
reader.expand
|
|
411
|
+
reader.next
|
|
363
412
|
end
|
|
364
413
|
end
|
data/test/test_relaxng.rb
CHANGED
|
@@ -1,53 +1,59 @@
|
|
|
1
|
-
# encoding: UTF-8
|
|
2
|
-
|
|
3
|
-
require_relative './test_helper'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class TestRelaxNG < Minitest::Test
|
|
7
|
-
def setup
|
|
8
|
-
file = File.join(File.dirname(__FILE__), 'model/shiporder.xml')
|
|
9
|
-
@doc = LibXML::XML::Document.file(file)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def teardown
|
|
13
|
-
@doc = nil
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def relaxng
|
|
17
|
-
document = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.rng'))
|
|
18
|
-
LibXML::XML::RelaxNG.document(document)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def test_from_doc
|
|
22
|
-
assert_instance_of(LibXML::XML::RelaxNG, relaxng)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def test_valid
|
|
26
|
-
assert(@doc.validate_relaxng(relaxng))
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
assert_equal(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
assert_equal('invalid', error.
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
require_relative './test_helper'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TestRelaxNG < Minitest::Test
|
|
7
|
+
def setup
|
|
8
|
+
file = File.join(File.dirname(__FILE__), 'model/shiporder.xml')
|
|
9
|
+
@doc = LibXML::XML::Document.file(file)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def teardown
|
|
13
|
+
@doc = nil
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def relaxng
|
|
17
|
+
document = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.rng'))
|
|
18
|
+
LibXML::XML::RelaxNG.document(document)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_from_doc
|
|
22
|
+
assert_instance_of(LibXML::XML::RelaxNG, relaxng)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def test_valid
|
|
26
|
+
assert(@doc.validate_relaxng(relaxng))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def test_parse_failure_raises
|
|
30
|
+
assert_raises(LibXML::XML::Error) do
|
|
31
|
+
LibXML::XML::RelaxNG.new("<invalid/>")
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_invalid
|
|
36
|
+
new_node = LibXML::XML::Node.new('invalid', 'this will mess up validation')
|
|
37
|
+
@doc.root << new_node
|
|
38
|
+
|
|
39
|
+
error = assert_raises(LibXML::XML::Error) do
|
|
40
|
+
@doc.validate_relaxng(relaxng)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
refute_nil(error)
|
|
44
|
+
assert_kind_of(LibXML::XML::Error, error)
|
|
45
|
+
assert(error.message.match(/Error: Did not expect element invalid there/))
|
|
46
|
+
assert_equal(LibXML::XML::Error::RELAXNGV, error.domain)
|
|
47
|
+
assert_equal(LibXML::XML::Error::LT_IN_ATTRIBUTE, error.code)
|
|
48
|
+
assert_equal(LibXML::XML::Error::ERROR, error.level)
|
|
49
|
+
assert(error.file.match(/shiporder\.xml/))
|
|
50
|
+
assert_nil(error.line)
|
|
51
|
+
assert_equal('invalid', error.str1)
|
|
52
|
+
assert_nil(error.str2)
|
|
53
|
+
assert_nil(error.str3)
|
|
54
|
+
assert_equal(0, error.int1)
|
|
55
|
+
assert_equal(0, error.int2)
|
|
56
|
+
refute_nil(error.node)
|
|
57
|
+
assert_equal('invalid', error.node.name)
|
|
58
|
+
end
|
|
59
|
+
end
|