libxml-ruby 3.0.0-x64-mingw32 → 3.2.2-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/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,10 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
require_relative './test_helper'
|
4
4
|
|
5
5
|
class AttrNodeTest < Minitest::Test
|
6
6
|
def setup
|
7
|
-
xp = XML::Parser.string(<<-EOS)
|
7
|
+
xp = LibXML::XML::Parser.string(<<-EOS)
|
8
8
|
<CityModel
|
9
9
|
xmlns="http://www.opengis.net/examples"
|
10
10
|
xmlns:city="http://www.opengis.net/examples"
|
@@ -34,19 +34,19 @@ class AttrNodeTest < Minitest::Test
|
|
34
34
|
|
35
35
|
def test_doc
|
36
36
|
refute_nil(@doc)
|
37
|
-
assert_equal(XML::Encoding::NONE, @doc.encoding)
|
37
|
+
assert_equal(LibXML::XML::Encoding::NONE, @doc.encoding)
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_types
|
41
41
|
attribute = city_member.attributes.get_attribute('name')
|
42
|
-
assert_instance_of(XML::Attr, attribute)
|
42
|
+
assert_instance_of(LibXML::XML::Attr, attribute)
|
43
43
|
assert_equal('attribute', attribute.node_type_name)
|
44
44
|
end
|
45
45
|
|
46
46
|
def test_name
|
47
47
|
attribute = city_member.attributes.get_attribute('name')
|
48
48
|
assert_equal('name', attribute.name)
|
49
|
-
assert_equal(Encoding::UTF_8, attribute.name.encoding)
|
49
|
+
assert_equal(Encoding::UTF_8, attribute.name.encoding)
|
50
50
|
|
51
51
|
attribute = city_member.attributes.get_attribute('href')
|
52
52
|
assert_equal('href', attribute.name)
|
@@ -62,7 +62,7 @@ class AttrNodeTest < Minitest::Test
|
|
62
62
|
def test_value
|
63
63
|
attribute = city_member.attributes.get_attribute('name')
|
64
64
|
assert_equal('Cambridge', attribute.value)
|
65
|
-
assert_equal(Encoding::UTF_8, attribute.value.encoding)
|
65
|
+
assert_equal(Encoding::UTF_8, attribute.value.encoding)
|
66
66
|
|
67
67
|
attribute = city_member.attributes.get_attribute('href')
|
68
68
|
assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
|
@@ -72,12 +72,12 @@ class AttrNodeTest < Minitest::Test
|
|
72
72
|
attribute = city_member.attributes.get_attribute('name')
|
73
73
|
attribute.value = 'London'
|
74
74
|
assert_equal('London', attribute.value)
|
75
|
-
assert_equal(Encoding::UTF_8, attribute.value.encoding)
|
75
|
+
assert_equal(Encoding::UTF_8, attribute.value.encoding)
|
76
76
|
|
77
77
|
attribute = city_member.attributes.get_attribute('href')
|
78
78
|
attribute.value = 'http://i.have.changed'
|
79
79
|
assert_equal('http://i.have.changed', attribute.value)
|
80
|
-
assert_equal(Encoding::UTF_8, attribute.value.encoding)
|
80
|
+
assert_equal(Encoding::UTF_8, attribute.value.encoding)
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_set_nil
|
@@ -91,8 +91,8 @@ class AttrNodeTest < Minitest::Test
|
|
91
91
|
attributes = city_member.attributes
|
92
92
|
assert_equal(5, attributes.length)
|
93
93
|
|
94
|
-
attr = XML::Attr.new(city_member, 'size', '50,000')
|
95
|
-
assert_instance_of(XML::Attr, attr)
|
94
|
+
attr = LibXML::XML::Attr.new(city_member, 'size', '50,000')
|
95
|
+
assert_instance_of(LibXML::XML::Attr, attr)
|
96
96
|
|
97
97
|
attributes = city_member.attributes
|
98
98
|
assert_equal(6, attributes.length)
|
@@ -115,9 +115,9 @@ class AttrNodeTest < Minitest::Test
|
|
115
115
|
def test_create_ns
|
116
116
|
assert_equal(5, city_member.attributes.length)
|
117
117
|
|
118
|
-
ns = XML::Namespace.new(city_member, 'my_namepace', 'http://www.mynamespace.com')
|
119
|
-
attr = XML::Attr.new(city_member, 'rating', 'rocks', ns)
|
120
|
-
assert_instance_of(XML::Attr, attr)
|
118
|
+
ns = LibXML::XML::Namespace.new(city_member, 'my_namepace', 'http://www.mynamespace.com')
|
119
|
+
attr = LibXML::XML::Attr.new(city_member, 'rating', 'rocks', ns)
|
120
|
+
assert_instance_of(LibXML::XML::Attr, attr)
|
121
121
|
assert_equal('rating', attr.name)
|
122
122
|
assert_equal('rocks', attr.value)
|
123
123
|
|
@@ -144,27 +144,27 @@ class AttrNodeTest < Minitest::Test
|
|
144
144
|
|
145
145
|
def test_first
|
146
146
|
attribute = city_member.attributes.first
|
147
|
-
assert_instance_of(XML::Attr, attribute)
|
147
|
+
assert_instance_of(LibXML::XML::Attr, attribute)
|
148
148
|
assert_equal('name', attribute.name)
|
149
149
|
assert_equal('Cambridge', attribute.value)
|
150
150
|
|
151
151
|
attribute = attribute.next
|
152
|
-
assert_instance_of(XML::Attr, attribute)
|
152
|
+
assert_instance_of(LibXML::XML::Attr, attribute)
|
153
153
|
assert_equal('type', attribute.name)
|
154
154
|
assert_equal('simple', attribute.value)
|
155
155
|
|
156
156
|
attribute = attribute.next
|
157
|
-
assert_instance_of(XML::Attr, attribute)
|
157
|
+
assert_instance_of(LibXML::XML::Attr, attribute)
|
158
158
|
assert_equal('title', attribute.name)
|
159
159
|
assert_equal('Trinity Lane', attribute.value)
|
160
160
|
|
161
161
|
attribute = attribute.next
|
162
|
-
assert_instance_of(XML::Attr, attribute)
|
162
|
+
assert_instance_of(LibXML::XML::Attr, attribute)
|
163
163
|
assert_equal('href', attribute.name)
|
164
164
|
assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
|
165
165
|
|
166
166
|
attribute = attribute.next
|
167
|
-
assert_instance_of(XML::Attr, attribute)
|
167
|
+
assert_instance_of(LibXML::XML::Attr, attribute)
|
168
168
|
assert_equal('remoteSchema', attribute.name)
|
169
169
|
assert_equal("city.xsd#xpointer(//complexType[@name='RoadType'])", attribute.value)
|
170
170
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
require_relative './test_helper'
|
4
4
|
|
5
5
|
class AttrDeclTest < Minitest::Test
|
6
6
|
def setup
|
7
|
-
xp = XML::Parser.string(<<-EOS)
|
7
|
+
xp = LibXML::XML::Parser.string(<<-EOS)
|
8
8
|
<!DOCTYPE test [
|
9
9
|
<!ELEMENT root (property*)>
|
10
10
|
<!ELEMENT property EMPTY>
|
@@ -42,7 +42,7 @@ class AttrDeclTest < Minitest::Test
|
|
42
42
|
# Get the attr_decl
|
43
43
|
attr = elem.attributes.get_attribute('access')
|
44
44
|
refute_nil(attr)
|
45
|
-
assert_equal(XML::Node::ATTRIBUTE_NODE, attr.node_type)
|
45
|
+
assert_equal(LibXML::XML::Node::ATTRIBUTE_NODE, attr.node_type)
|
46
46
|
assert_equal('attribute', attr.node_type_name)
|
47
47
|
|
48
48
|
# Get its value
|
@@ -56,7 +56,7 @@ class AttrDeclTest < Minitest::Test
|
|
56
56
|
# Get the attr_decl
|
57
57
|
attr_decl = elem.attributes.get_attribute('access')
|
58
58
|
refute_nil(attr_decl)
|
59
|
-
assert_equal(XML::Node::ATTRIBUTE_DECL, attr_decl.node_type)
|
59
|
+
assert_equal(LibXML::XML::Node::ATTRIBUTE_DECL, attr_decl.node_type)
|
60
60
|
assert_equal('attribute declaration', attr_decl.node_type_name)
|
61
61
|
|
62
62
|
# Get its value
|
@@ -69,7 +69,7 @@ class AttrDeclTest < Minitest::Test
|
|
69
69
|
attr_decl = elem.attributes.get_attribute('access')
|
70
70
|
|
71
71
|
refute_nil(attr_decl)
|
72
|
-
assert_equal(XML::Node::ATTRIBUTE_DECL, attr_decl.node_type)
|
72
|
+
assert_equal(LibXML::XML::Node::ATTRIBUTE_DECL, attr_decl.node_type)
|
73
73
|
assert_equal('attribute declaration', attr_decl.node_type_name)
|
74
74
|
end
|
75
75
|
|
@@ -99,12 +99,12 @@ class AttrDeclTest < Minitest::Test
|
|
99
99
|
attr_decl = elem.attributes.get_attribute('access')
|
100
100
|
|
101
101
|
first_decl = attr_decl.prev
|
102
|
-
assert_equal(XML::Node::ATTRIBUTE_DECL, first_decl.node_type)
|
102
|
+
assert_equal(LibXML::XML::Node::ATTRIBUTE_DECL, first_decl.node_type)
|
103
103
|
assert_equal('name', first_decl.name)
|
104
104
|
assert_nil(first_decl.value)
|
105
105
|
|
106
106
|
elem_decl = first_decl.prev
|
107
|
-
assert_equal(XML::Node::ELEMENT_DECL, elem_decl.node_type)
|
107
|
+
assert_equal(LibXML::XML::Node::ELEMENT_DECL, elem_decl.node_type)
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_next
|
@@ -127,6 +127,6 @@ class AttrDeclTest < Minitest::Test
|
|
127
127
|
attr_decl = elem.attributes.get_attribute('access')
|
128
128
|
|
129
129
|
parent = attr_decl.parent
|
130
|
-
assert_instance_of(XML::Dtd, parent)
|
130
|
+
assert_instance_of(LibXML::XML::Dtd, parent)
|
131
131
|
end
|
132
132
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
|
-
|
3
|
+
require_relative './test_helper'
|
4
4
|
|
5
5
|
class AttributesTest < Minitest::Test
|
6
6
|
def setup
|
7
|
-
xp = XML::Parser.string(<<-EOS)
|
7
|
+
xp = LibXML::XML::Parser.string(<<-EOS)
|
8
8
|
<CityModel name="value"
|
9
9
|
xmlns="http://www.opengis.net/examples"
|
10
10
|
xmlns:city="http://www.opengis.net/examples"
|
@@ -33,14 +33,14 @@ class AttributesTest < Minitest::Test
|
|
33
33
|
|
34
34
|
def test_attributes
|
35
35
|
attributes = city_member.attributes
|
36
|
-
assert_instance_of(XML::Attributes, attributes)
|
36
|
+
assert_instance_of(LibXML::XML::Attributes, attributes)
|
37
37
|
assert_equal(5, attributes.length)
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_each
|
41
41
|
attributes = city_member.attributes
|
42
42
|
length = attributes.inject(0) do |result, attr|
|
43
|
-
assert_instance_of(XML::Attr, attr)
|
43
|
+
assert_instance_of(LibXML::XML::Attr, attr)
|
44
44
|
result + 1
|
45
45
|
end
|
46
46
|
assert_equal(5, length)
|
@@ -50,25 +50,25 @@ class AttributesTest < Minitest::Test
|
|
50
50
|
attributes = city_member.attributes
|
51
51
|
|
52
52
|
attr = attributes.get_attribute('name')
|
53
|
-
assert_instance_of(XML::Attr, attr)
|
53
|
+
assert_instance_of(LibXML::XML::Attr, attr)
|
54
54
|
|
55
55
|
attr = attributes.get_attribute('does_not_exist')
|
56
56
|
assert_nil(attr)
|
57
57
|
|
58
58
|
attr = attributes.get_attribute('name')
|
59
|
-
assert_instance_of(XML::Attr, attr)
|
59
|
+
assert_instance_of(LibXML::XML::Attr, attr)
|
60
60
|
|
61
61
|
attr = attributes.get_attribute('href')
|
62
|
-
assert_instance_of(XML::Attr, attr)
|
63
|
-
assert_instance_of(XML::Namespace, attr.ns)
|
62
|
+
assert_instance_of(LibXML::XML::Attr, attr)
|
63
|
+
assert_instance_of(LibXML::XML::Namespace, attr.ns)
|
64
64
|
assert_equal('xlink', attr.ns.prefix)
|
65
65
|
assert_equal('http://www.w3.org/1999/xlink', attr.ns.href)
|
66
66
|
|
67
67
|
attr = attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
|
68
|
-
assert_instance_of(XML::Attr, attr)
|
68
|
+
assert_instance_of(LibXML::XML::Attr, attr)
|
69
69
|
|
70
70
|
attr = attributes.get_attribute_ns('http://www.opengis.net/gml', 'remoteSchema')
|
71
|
-
assert_instance_of(XML::Attr, attr)
|
71
|
+
assert_instance_of(LibXML::XML::Attr, attr)
|
72
72
|
|
73
73
|
attr = attributes.get_attribute_ns('http://i.dont.exist', 'nor do i')
|
74
74
|
assert_nil(attr)
|
@@ -1,24 +1,28 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
|
2
|
+
require_relative './test_helper'
|
3
3
|
|
4
4
|
class TestCanonicalize < Minitest::Test
|
5
|
+
def path(file)
|
6
|
+
File.join(File.dirname(__FILE__), file)
|
7
|
+
end
|
8
|
+
|
5
9
|
# (www.w3.org) 3.1 PIs, Comments, and Outside of Document Element
|
6
10
|
# http://www.w3.org/TR/xml-c14n#Example-OutsideDoc
|
7
11
|
def test_canonicalize_with_w3c_c14n_3_1
|
8
|
-
given_doc = XML::Document.file('c14n/given/example-1.xml')
|
12
|
+
given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-1.xml'))
|
9
13
|
|
10
14
|
# With Comments
|
11
|
-
expected_with_comments = IO.read('c14n/result/with-comments/example-1')
|
15
|
+
expected_with_comments = IO.read(self.path('c14n/result/with-comments/example-1'))
|
12
16
|
assert_equal(expected_with_comments, given_doc.canonicalize(:comments => true))
|
13
17
|
|
14
18
|
# Without Comments
|
15
|
-
expected_without_comments = IO.read('c14n/result/without-comments/example-1')
|
19
|
+
expected_without_comments = IO.read(self.path('c14n/result/without-comments/example-1'))
|
16
20
|
assert_equal(expected_without_comments, given_doc.canonicalize)
|
17
21
|
assert_equal(expected_without_comments, given_doc.canonicalize(:comments => false))
|
18
22
|
|
19
23
|
# Without Comments (XML_C14N_1_1)
|
20
|
-
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-1')
|
21
|
-
mode = XML::Document::XML_C14N_1_1
|
24
|
+
expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-1'))
|
25
|
+
mode = LibXML::XML::Document::XML_C14N_1_1
|
22
26
|
assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
23
27
|
end#test_canonicalize_with_w3c_c14n_3_1
|
24
28
|
|
@@ -26,12 +30,12 @@ class TestCanonicalize < Minitest::Test
|
|
26
30
|
# (www.w3.org) 3.2 Whitespace in Document Content
|
27
31
|
# http://www.w3.org/TR/xml-c14n#Example-WhitespaceInContent
|
28
32
|
def test_canonicalize_with_w3c_c14n_3_2
|
29
|
-
given_doc = XML::Document.file('c14n/given/example-2.xml')
|
30
|
-
expected = IO.read('c14n/result/without-comments/example-2')
|
33
|
+
given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-2.xml'))
|
34
|
+
expected = IO.read(self.path('c14n/result/without-comments/example-2'))
|
31
35
|
assert_equal(expected, given_doc.canonicalize)
|
32
36
|
|
33
|
-
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-2')
|
34
|
-
mode = XML::Document::XML_C14N_1_1
|
37
|
+
expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-2'))
|
38
|
+
mode = LibXML::XML::Document::XML_C14N_1_1
|
35
39
|
assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
36
40
|
end
|
37
41
|
|
@@ -41,24 +45,24 @@ class TestCanonicalize < Minitest::Test
|
|
41
45
|
# - Embedded DTD not parsed out of XML, therefore default attributes are
|
42
46
|
# not applied to canonicalization.
|
43
47
|
def test_canonicalize_with_w3c_c14n_3_3
|
44
|
-
given_doc = XML::Document.file('c14n/given/example-3.xml')
|
45
|
-
expected = IO.read('c14n/result/without-comments/example-3')
|
48
|
+
given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-3.xml'))
|
49
|
+
expected = IO.read(self.path('c14n/result/without-comments/example-3'))
|
46
50
|
assert_equal(expected, given_doc.canonicalize)
|
47
51
|
|
48
|
-
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-3')
|
49
|
-
mode = XML::Document::XML_C14N_1_1
|
52
|
+
expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-3'))
|
53
|
+
mode = LibXML::XML::Document::XML_C14N_1_1
|
50
54
|
assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
51
55
|
end
|
52
56
|
|
53
57
|
# (www.w3.org) 3.4 Character Modifications and Character References
|
54
58
|
# http://www.w3.org/TR/xml-c14n#Example-Chars
|
55
59
|
def test_canonicalize_with_w3c_c14n_3_4
|
56
|
-
given_doc = XML::Document.file('c14n/given/example-4.xml')
|
57
|
-
expected = IO.read('c14n/result/without-comments/example-4')
|
60
|
+
given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-4.xml'))
|
61
|
+
expected = IO.read(self.path('c14n/result/without-comments/example-4'))
|
58
62
|
assert_equal(expected, given_doc.canonicalize)
|
59
63
|
|
60
|
-
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-4')
|
61
|
-
mode = XML::Document::XML_C14N_1_1
|
64
|
+
expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-4'))
|
65
|
+
mode = LibXML::XML::Document::XML_C14N_1_1
|
62
66
|
assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
63
67
|
end
|
64
68
|
|
@@ -67,20 +71,20 @@ class TestCanonicalize < Minitest::Test
|
|
67
71
|
# (2012-02-20) Failing likely due to a logic error
|
68
72
|
# - libxml2(c14n.c:1788) XML_ENTITY_REF_NODE is invalid node for parsing.
|
69
73
|
def test_canonicalize_with_w3c_c14n_3_5
|
70
|
-
given_doc = XML::Document.file('c14n/given/example-5.xml')
|
74
|
+
#given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-5.xml'))
|
71
75
|
|
72
76
|
# With Comments
|
73
|
-
expected_with_comments = IO.read('c14n/result/with-comments/example-5')
|
77
|
+
#expected_with_comments = IO.read(self.path('c14n/result/with-comments/example-5'))
|
74
78
|
|
75
79
|
# TODO - CANNOT COMPLETE TEST unless libxml2 supports additional node types.
|
76
80
|
#assert_equal(expected_with_comments, given_doc.canonicalize(:comments => true))
|
77
81
|
|
78
82
|
# Without Comments
|
79
|
-
expected_without_comments = IO.read('c14n/result/without-comments/example-5')
|
83
|
+
#expected_without_comments = IO.read(self.path('c14n/result/without-comments/example-5'))
|
80
84
|
# TODO - CANNOT COMPLETE TEST unless libxml2 supports additional node types.
|
81
85
|
#assert_equal(expected_without_comments, given_doc.canonicalize(:comments => false))
|
82
|
-
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-5')
|
83
|
-
mode = XML::Document::XML_C14N_1_1
|
86
|
+
#expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-5'))
|
87
|
+
#mode = LibXML::XML::Document::XML_C14N_1_1
|
84
88
|
|
85
89
|
# TODO - CANNOT COMPLETE TEST unless libxml2 supports additional node types.
|
86
90
|
#assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
@@ -89,20 +93,12 @@ class TestCanonicalize < Minitest::Test
|
|
89
93
|
# (www.w3.org) 3.6 UTF-8 Encoding
|
90
94
|
# http://www.w3.org/TR/xml-c14n#Example-UTF8
|
91
95
|
def test_canonicalize_with_w3c_c14n_3_6
|
92
|
-
given_doc = XML::Document.file('c14n/given/example-6.xml')
|
93
|
-
|
94
|
-
expected = IO.read('c14n/result/without-comments/example-6', :encoding => Encoding::UTF_8)
|
95
|
-
else
|
96
|
-
expected = IO.read('c14n/result/without-comments/example-6')
|
97
|
-
end
|
96
|
+
given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-6.xml'))
|
97
|
+
expected = IO.read(self.path('c14n/result/without-comments/example-6'), :encoding => Encoding::UTF_8)
|
98
98
|
assert_equal(expected, given_doc.canonicalize)
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
else
|
103
|
-
expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-6')
|
104
|
-
end
|
105
|
-
mode = XML::Document::XML_C14N_1_1
|
100
|
+
expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-6'), :encoding => Encoding::UTF_8)
|
101
|
+
mode = LibXML::XML::Document::XML_C14N_1_1
|
106
102
|
assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
|
107
103
|
end
|
108
104
|
|
@@ -110,13 +106,13 @@ class TestCanonicalize < Minitest::Test
|
|
110
106
|
# http://www.w3.org/TR/xml-c14n#Example-DocSubsets
|
111
107
|
def test_canonicalize_with_w3c_c14n_3_7
|
112
108
|
# Non Canonicalized Document
|
113
|
-
given_doc = XML::Document.file('c14n/given/example-7.xml')
|
114
|
-
expected = IO.read('c14n/result/without-comments/example-7')
|
109
|
+
# given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-7.xml'))
|
110
|
+
#expected = IO.read(self.path('c14n/result/without-comments/example-7'))
|
115
111
|
|
116
|
-
e1_node = given_doc.find_first('ietf:e1', 'ietf:http://www.ietf.org')
|
112
|
+
# e1_node = given_doc.find_first('ietf:e1', 'ietf:http://www.ietf.org')
|
117
113
|
|
118
114
|
# Select current node, all child nodes, all attributes and namespace nodes
|
119
|
-
subdoc_nodes = e1_node.find("(.//.|.//@id|namespace::*)")
|
115
|
+
#subdoc_nodes = e1_node.find("(.//.|.//@id|namespace::*)")
|
120
116
|
|
121
117
|
# TODO - This fails because the namespace nodes aren't taken into account
|
122
118
|
# assert_equal(expected, given_doc.canonicalize(:nodes => subdoc_nodes))
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'xml/libxml'
|
4
|
+
|
5
|
+
class TestDeprecatedRequire < Minitest::Test
|
6
|
+
def test_basic
|
7
|
+
xp = LibXML::XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
8
|
+
assert_instance_of(LibXML::XML::Parser, xp)
|
9
|
+
@doc = xp.parse
|
10
|
+
assert_instance_of(LibXML::XML::Document, @doc)
|
11
|
+
end
|
12
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# encoding: UTF-8
|
2
|
-
|
2
|
+
require_relative './test_helper'
|
3
3
|
|
4
4
|
class TestDocument < Minitest::Test
|
5
5
|
def setup
|
6
|
-
xp = XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
7
|
-
assert_instance_of(XML::Parser, xp)
|
6
|
+
xp = LibXML::XML::Parser.string('<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>')
|
7
|
+
assert_instance_of(LibXML::XML::Parser, xp)
|
8
8
|
@doc = xp.parse
|
9
|
-
assert_instance_of(XML::Document, @doc)
|
9
|
+
assert_instance_of(LibXML::XML::Document, @doc)
|
10
10
|
end
|
11
11
|
|
12
12
|
def teardown
|
@@ -14,24 +14,24 @@ class TestDocument < Minitest::Test
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_klass
|
17
|
-
assert_instance_of(XML::Document, @doc)
|
17
|
+
assert_instance_of(LibXML::XML::Document, @doc)
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_context
|
21
21
|
context = @doc.context
|
22
|
-
assert_instance_of(XML::XPath::Context, context)
|
22
|
+
assert_instance_of(LibXML::XML::XPath::Context, context)
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_find
|
26
26
|
set = @doc.find('/ruby_array/fixnum')
|
27
|
-
assert_instance_of(XML::XPath::Object, set)
|
27
|
+
assert_instance_of(LibXML::XML::XPath::Object, set)
|
28
28
|
assert_raises(NoMethodError) {
|
29
|
-
|
29
|
+
set.xpath
|
30
30
|
}
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_compression
|
34
|
-
if XML.enabled_zlib?
|
34
|
+
if LibXML::XML.enabled_zlib?
|
35
35
|
0.upto(9) do |i|
|
36
36
|
assert_equal(i, @doc.compression = i)
|
37
37
|
assert_equal(i, @doc.compression)
|
@@ -59,41 +59,41 @@ class TestDocument < Minitest::Test
|
|
59
59
|
def test_version
|
60
60
|
assert_equal('1.0', @doc.version)
|
61
61
|
|
62
|
-
doc = XML::Document.new('6.9')
|
62
|
+
doc = LibXML::XML::Document.new('6.9')
|
63
63
|
assert_equal('6.9', doc.version)
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_write_root
|
67
|
-
@doc.root = XML::Node.new('rubynet')
|
68
|
-
assert_instance_of(XML::Node, @doc.root)
|
69
|
-
assert_instance_of(XML::Document, @doc.root.doc)
|
67
|
+
@doc.root = LibXML::XML::Node.new('rubynet')
|
68
|
+
assert_instance_of(LibXML::XML::Node, @doc.root)
|
69
|
+
assert_instance_of(LibXML::XML::Document, @doc.root.doc)
|
70
70
|
assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rubynet/>\n",
|
71
71
|
@doc.to_s(:indent => false))
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_doc_node_type
|
75
|
-
assert_equal(XML::Node::DOCUMENT_NODE, XML::Document.new.node_type)
|
75
|
+
assert_equal(LibXML::XML::Node::DOCUMENT_NODE, LibXML::XML::Document.new.node_type)
|
76
76
|
end
|
77
77
|
|
78
78
|
def test_doc_node_type_name
|
79
|
-
assert_equal('document_xml', XML::Document.new.node_type_name)
|
79
|
+
assert_equal('document_xml', LibXML::XML::Document.new.node_type_name)
|
80
80
|
end
|
81
81
|
|
82
82
|
def test_xhtml
|
83
|
-
doc = XML::Document.new
|
83
|
+
doc = LibXML::XML::Document.new
|
84
84
|
assert(!doc.xhtml?)
|
85
|
-
XML::Dtd.new "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", nil, doc, true
|
85
|
+
LibXML::XML::Dtd.new "-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", nil, doc, true
|
86
86
|
assert(doc.xhtml?)
|
87
|
-
|
87
|
+
end
|
88
88
|
|
89
89
|
def test_document_root
|
90
90
|
doc1 = LibXML::XML::Document.string("<one/>")
|
91
91
|
doc2 = LibXML::XML::Document.string("<two/>")
|
92
92
|
|
93
|
-
error = assert_raises(XML::Error) do
|
93
|
+
error = assert_raises(LibXML::XML::Error) do
|
94
94
|
doc1.root = doc2.root
|
95
95
|
end
|
96
|
-
assert_equal(" Nodes belong to different documents. You must first import the node by calling XML::Document.import.",
|
96
|
+
assert_equal(" Nodes belong to different documents. You must first import the node by calling LibXML::XML::Document.import.",
|
97
97
|
error.to_s)
|
98
98
|
|
99
99
|
doc2.root << doc2.import(doc1.root)
|
@@ -105,16 +105,16 @@ class TestDocument < Minitest::Test
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_import_node
|
108
|
-
doc1 = XML::Parser.string('<nums><one></one></nums>').parse
|
109
|
-
doc2 = XML::Parser.string('<nums><two></two></nums>').parse
|
108
|
+
doc1 = LibXML::XML::Parser.string('<nums><one></one></nums>').parse
|
109
|
+
doc2 = LibXML::XML::Parser.string('<nums><two></two></nums>').parse
|
110
110
|
|
111
111
|
node = doc1.root.child
|
112
112
|
|
113
|
-
error = assert_raises(XML::Error) do
|
113
|
+
error = assert_raises(LibXML::XML::Error) do
|
114
114
|
doc2.root << node
|
115
115
|
end
|
116
116
|
|
117
|
-
assert_equal(" Nodes belong to different documents. You must first import the node by calling XML::Document.import.",
|
117
|
+
assert_equal(" Nodes belong to different documents. You must first import the node by calling LibXML::XML::Document.import.",
|
118
118
|
error.to_s)
|
119
119
|
|
120
120
|
doc2.root << doc2.import(node)
|
@@ -122,4 +122,11 @@ class TestDocument < Minitest::Test
|
|
122
122
|
assert_equal("<nums><two/><one/></nums>",
|
123
123
|
doc2.root.to_s(:indent => false))
|
124
124
|
end
|
125
|
+
|
126
|
+
def test_nonet
|
127
|
+
xml_string = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
128
|
+
xml = LibXML::XML::Document.string(xml_string, options: LibXML::XML::Parser::Options::NONET)
|
129
|
+
file = File.join(File.dirname(__FILE__), 'model/atom.xml')
|
130
|
+
schema_document = LibXML::XML::Document.file(file, options: LibXML::XML::Parser::Options::NONET)
|
131
|
+
end
|
125
132
|
end
|