libxml-ruby 3.2.1 → 3.2.4
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 +22 -0
- data/Rakefile +24 -16
- data/ext/libxml/ruby_libxml.h +0 -22
- data/ext/libxml/ruby_xml.c +6 -0
- data/ext/libxml/ruby_xml_document.c +6 -0
- data/ext/libxml/ruby_xml_encoding.h +2 -0
- data/ext/libxml/ruby_xml_error.h +2 -0
- data/ext/libxml/ruby_xml_html_parser.c +2 -0
- data/ext/libxml/ruby_xml_html_parser_context.c +1 -0
- data/ext/libxml/ruby_xml_html_parser_options.c +2 -0
- data/ext/libxml/ruby_xml_namespace.c +1 -0
- data/ext/libxml/ruby_xml_node.c +12 -4
- data/ext/libxml/ruby_xml_parser_context.c +2 -0
- data/ext/libxml/ruby_xml_reader.c +3 -0
- data/ext/libxml/ruby_xml_reader.h +0 -3
- data/ext/libxml/ruby_xml_relaxng.c +2 -0
- data/ext/libxml/ruby_xml_relaxng.h +0 -2
- data/ext/libxml/ruby_xml_schema.c +223 -81
- data/ext/libxml/ruby_xml_schema.h +4 -788
- data/ext/libxml/ruby_xml_schema_attribute.c +69 -71
- data/ext/libxml/ruby_xml_schema_attribute.h +25 -3
- data/ext/libxml/ruby_xml_schema_element.c +28 -54
- data/ext/libxml/ruby_xml_schema_element.h +0 -3
- data/ext/libxml/ruby_xml_schema_facet.c +19 -21
- data/ext/libxml/ruby_xml_schema_facet.h +0 -4
- data/ext/libxml/ruby_xml_schema_type.c +56 -37
- data/ext/libxml/ruby_xml_version.h +3 -3
- data/ext/libxml/ruby_xml_writer.c +4 -0
- data/ext/libxml/ruby_xml_writer.h +0 -4
- data/ext/libxml/ruby_xml_xinclude.c +4 -0
- data/ext/libxml/ruby_xml_xpath.c +1 -0
- data/ext/libxml/ruby_xml_xpath.h +2 -0
- data/ext/libxml/ruby_xml_xpath_context.c +2 -0
- data/ext/libxml/ruby_xml_xpath_object.c +1 -0
- data/ext/libxml/ruby_xml_xpointer.c +5 -1
- data/lib/libxml-ruby.rb +1 -1
- data/libxml-ruby.gemspec +1 -1
- data/test/model/shiporder.rnc +2 -2
- data/test/model/shiporder.rng +2 -2
- data/test/model/shiporder.xsd +7 -3
- data/test/model/shiporder_bad.xsd +40 -0
- data/test/model/shiporder_import.xsd +45 -0
- data/test/test_document.rb +2 -1
- data/test/test_dtd.rb +2 -1
- data/test/test_helper.rb +6 -0
- data/test/test_parser.rb +1 -1
- data/test/test_parser_context.rb +1 -7
- data/test/test_reader.rb +2 -1
- data/test/test_sax_parser.rb +13 -6
- data/test/test_schema.rb +92 -29
- data/test/test_xml.rb +17 -4
- metadata +11 -10
- data/test/test.xml +0 -2
data/test/model/shiporder.rnc
CHANGED
@@ -5,9 +5,9 @@
|
|
5
5
|
#
|
6
6
|
namespace xsi = "http://www.w3.org/2001/XMLSchema-instance"
|
7
7
|
|
8
|
-
start =
|
8
|
+
start = shiporderType
|
9
9
|
|
10
|
-
|
10
|
+
shiporderType = element shiporder { attribute orderid { text },
|
11
11
|
attribute xsi:noNamespaceSchemaLocation { text },
|
12
12
|
orderperson, shipto, item* }
|
13
13
|
|
data/test/model/shiporder.rng
CHANGED
@@ -7,9 +7,9 @@
|
|
7
7
|
-->
|
8
8
|
<grammar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://relaxng.org/ns/structure/1.0">
|
9
9
|
<start>
|
10
|
-
<ref name="
|
10
|
+
<ref name="shiporderType"/>
|
11
11
|
</start>
|
12
|
-
<define name="
|
12
|
+
<define name="shiporderType">
|
13
13
|
<element name="shiporder">
|
14
14
|
<attribute name="orderid"/>
|
15
15
|
<attribute name="xsi:noNamespaceSchemaLocation"/>
|
data/test/model/shiporder.xsd
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
<?xml version="1.0" encoding="iso-8859-1" ?>
|
2
2
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
3
|
-
<xs:element name="shiporder" type="shiporder"/>
|
4
3
|
|
5
|
-
<xs:
|
4
|
+
<xs:import namespace="http://xml4r.org/ibxml-ruby/test/shiporder"
|
5
|
+
schemaLocation="shiporder_import.xsd"/>
|
6
|
+
|
7
|
+
<xs:element name="shiporder" type="shiporderType"/>
|
8
|
+
|
9
|
+
<xs:complexType name="shiporderType">
|
6
10
|
<xs:annotation>
|
7
11
|
<xs:documentation>Shiporder type documentation</xs:documentation>
|
8
12
|
</xs:annotation>
|
@@ -37,4 +41,4 @@
|
|
37
41
|
<xs:attribute name="foo" default="1" type="xs:integer" use="optional"/>
|
38
42
|
<xs:attribute name="bar" use="prohibited"/>
|
39
43
|
</xs:complexType>
|
40
|
-
</xs:schema>
|
44
|
+
</xs:schema>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1" ?>
|
2
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
3
|
+
<xs:element name="shiporder" type="shiporderType"/>
|
4
|
+
|
5
|
+
<xs:complexType name="shiporderType">
|
6
|
+
<xs:anntation>
|
7
|
+
<xs:documentation>Shiporder type documentation</xs:documentation>
|
8
|
+
</xs:anntation>
|
9
|
+
<xs:sequence>
|
10
|
+
<xs:element name="orderperson" type="xs:string">
|
11
|
+
<xs:annotation>
|
12
|
+
<xs:documentation>orderperson element documentation</xs:documentation>
|
13
|
+
</xs:annotation>
|
14
|
+
</xs:element>
|
15
|
+
<xs:element name="shipto">
|
16
|
+
<xs:complexType>
|
17
|
+
<xs:sequence>
|
18
|
+
<xs:element name="name" type="xs:string"/>
|
19
|
+
<xs:element name="address" type="xs:string"/>
|
20
|
+
<xs:element name="city" type="xs:string"/>
|
21
|
+
<xs:element name="country" type="xs:string"/>
|
22
|
+
</xs:sequence>
|
23
|
+
</xs:complexType>
|
24
|
+
</xs:element>
|
25
|
+
<xs:element name="item" maxOccurs="unbounded">
|
26
|
+
<xs:complexType>
|
27
|
+
<xs:seq>
|
28
|
+
<xs:element name="title" type="xs:string"/>
|
29
|
+
<xs:element name="note" type="xs:string" minOccurs="0"/>
|
30
|
+
<xs:element name="quantity" type="xs:positiveInteger"/>
|
31
|
+
<xs:element name="price" type="xs:decimal"/>
|
32
|
+
</xs:seq>
|
33
|
+
</xs:complexType>
|
34
|
+
</xs:element>
|
35
|
+
</xs:sequence>
|
36
|
+
<xs:attribute name="orderid" type="xs:string" use="required"/>
|
37
|
+
<xs:attribute name="foo" default="1" type="xs:integer" use="optional"/>
|
38
|
+
<xs:attribute name="bar" use="prohibited"/>
|
39
|
+
</xs:complexType>
|
40
|
+
</xs:schema>
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1" ?>
|
2
|
+
<xs:schema xmlns="http://xml4r.org/libxml-ruby/test/shiporder"
|
3
|
+
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
4
|
+
targetNamespace="http://xml4r.org/libxml-ruby/test/shiporder">
|
5
|
+
|
6
|
+
<xs:element name="shiporder" type="shiporderFooType"/>
|
7
|
+
<xs:complexType name="shiporderFooType">
|
8
|
+
<xs:annotation>
|
9
|
+
<xs:documentation>Shiporder type documentation for Testing of imported schema</xs:documentation>
|
10
|
+
</xs:annotation>
|
11
|
+
<xs:sequence>
|
12
|
+
<xs:element name="orderperson" type="xs:string">
|
13
|
+
<xs:annotation>
|
14
|
+
<xs:documentation>orderperson element documentation</xs:documentation>
|
15
|
+
</xs:annotation>
|
16
|
+
</xs:element>
|
17
|
+
<xs:element name="shipto">
|
18
|
+
<xs:complexType>
|
19
|
+
<xs:sequence>
|
20
|
+
<xs:element name="name" type="xs:string"/>
|
21
|
+
<xs:element name="address" type="xs:string"/>
|
22
|
+
<xs:element name="city" type="xs:string"/>
|
23
|
+
<xs:element name="country" type="xs:string"/>
|
24
|
+
<xs:element name="phone" type="xs:string"/>
|
25
|
+
</xs:sequence>
|
26
|
+
</xs:complexType>
|
27
|
+
</xs:element>
|
28
|
+
<xs:element name="item" maxOccurs="unbounded">
|
29
|
+
<xs:complexType>
|
30
|
+
<xs:sequence>
|
31
|
+
<xs:element name="title" type="xs:string"/>
|
32
|
+
<xs:element name="note" type="xs:string" minOccurs="0"/>
|
33
|
+
<xs:element name="quantity" type="xs:positiveInteger"/>
|
34
|
+
<xs:element name="price" type="xs:decimal"/>
|
35
|
+
<xs:element name="discount" type="xs:decimal"/>
|
36
|
+
</xs:sequence>
|
37
|
+
</xs:complexType>
|
38
|
+
</xs:element>
|
39
|
+
</xs:sequence>
|
40
|
+
<xs:attribute name="orderid" type="xs:string" use="required"/>
|
41
|
+
<xs:attribute name="foo" default="1" type="xs:integer" use="optional"/>
|
42
|
+
<xs:attribute name="bar" type="xs:string" use="optional"/>
|
43
|
+
<xs:attribute name="xyzzy" type="xs:string" use="prohibited"/>
|
44
|
+
</xs:complexType>
|
45
|
+
</xs:schema>
|
data/test/test_document.rb
CHANGED
@@ -126,6 +126,7 @@ class TestDocument < Minitest::Test
|
|
126
126
|
def test_nonet
|
127
127
|
xml_string = '<ruby_array uga="booga" foo="bar"><fixnum>one</fixnum><fixnum>two</fixnum></ruby_array>'
|
128
128
|
xml = LibXML::XML::Document.string(xml_string, options: LibXML::XML::Parser::Options::NONET)
|
129
|
-
|
129
|
+
file = File.join(File.dirname(__FILE__), 'model/atom.xml')
|
130
|
+
schema_document = LibXML::XML::Document.file(file, options: LibXML::XML::Parser::Options::NONET)
|
130
131
|
end
|
131
132
|
end
|
data/test/test_dtd.rb
CHANGED
@@ -84,7 +84,8 @@ class TestDtd < Minitest::Test
|
|
84
84
|
assert_nil(error.file)
|
85
85
|
assert_nil(error.line)
|
86
86
|
assert_equal('invalid', error.str1)
|
87
|
-
|
87
|
+
# Different answers across operating systems
|
88
|
+
# assert_nil(error.str2)
|
88
89
|
assert_nil(error.str3)
|
89
90
|
assert_equal(0, error.int1)
|
90
91
|
assert_equal(0, error.int2)
|
data/test/test_helper.rb
CHANGED
data/test/test_parser.rb
CHANGED
data/test/test_parser_context.rb
CHANGED
@@ -127,12 +127,6 @@ class TestParserContext < Minitest::Test
|
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
|
-
if ENV['NOTWORKING']
|
131
|
-
def test_num_chars
|
132
|
-
assert_equal(17, context.num_chars)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
130
|
def test_replace_entities
|
137
131
|
context = LibXML::XML::Parser::Context.new
|
138
132
|
assert(!context.replace_entities?)
|
@@ -185,7 +179,7 @@ class TestParserContext < Minitest::Test
|
|
185
179
|
assert_nil(context.name_node)
|
186
180
|
assert_equal(0, context.name_depth)
|
187
181
|
assert_equal(10, context.name_depth_max)
|
188
|
-
|
182
|
+
assert([0, 17].include?(context.num_chars))
|
189
183
|
assert_equal(false, context.replace_entities?)
|
190
184
|
assert_equal(1, context.space_depth)
|
191
185
|
assert_equal(10, context.space_depth_max)
|
data/test/test_reader.rb
CHANGED
@@ -249,9 +249,10 @@ class TestReader < Minitest::Test
|
|
249
249
|
end
|
250
250
|
|
251
251
|
def test_bytes_consumed
|
252
|
+
ending_are_rn = File.binread(XML_FILE).include? "\r\n"
|
252
253
|
reader = LibXML::XML::Reader.file(XML_FILE)
|
253
254
|
reader.read
|
254
|
-
assert_equal(428, reader.byte_consumed)
|
255
|
+
assert_equal(ending_are_rn ? 428 : 416, reader.byte_consumed)
|
255
256
|
end
|
256
257
|
|
257
258
|
def test_node
|
data/test/test_sax_parser.rb
CHANGED
@@ -181,7 +181,7 @@ class TestSaxParser < Minitest::Test
|
|
181
181
|
xml = File.read(saxtest_file)
|
182
182
|
io = StringIO.new(xml)
|
183
183
|
parser = LibXML::XML::SaxParser.io(io)
|
184
|
-
|
184
|
+
|
185
185
|
parser.callbacks = TestCaseCallbacks.new
|
186
186
|
parser.parse
|
187
187
|
verify(parser)
|
@@ -250,25 +250,32 @@ EOS
|
|
250
250
|
result = parser.callbacks.result
|
251
251
|
|
252
252
|
i = -1
|
253
|
+
|
254
|
+
base_err_msg = "Fatal error: (Premature end of data in tag Results line 1|EndTag: '<\\/' not found) at :2\\."
|
255
|
+
re_err_msg1 = /\A(error: )#{base_err_msg}\z/
|
256
|
+
re_err_msg2 = /\A#{base_err_msg}\z/
|
257
|
+
|
253
258
|
assert_equal("startdoc", result[i+=1])
|
254
259
|
assert_equal("start_element: Results, attr: {}", result[i+=1])
|
255
260
|
assert_equal("start_element_ns: Results, attr: {}, prefix: , uri: , ns: {}", result[i+=1])
|
256
261
|
assert_equal("characters: \n", result[i+=1])
|
257
|
-
|
262
|
+
assert_match(re_err_msg1, result[i+=1])
|
258
263
|
assert_equal("end_document", result[i+=1])
|
259
264
|
|
260
265
|
refute_nil(error)
|
261
266
|
assert_kind_of(LibXML::XML::Error, error)
|
262
|
-
|
267
|
+
assert_match(re_err_msg2, error.message)
|
263
268
|
assert_equal(LibXML::XML::Error::PARSER, error.domain)
|
264
|
-
|
269
|
+
|
270
|
+
assert([LibXML::XML::Error::TAG_NOT_FINISHED, LibXML::XML::Error::LTSLASH_REQUIRED].include?(error.code))
|
265
271
|
assert_equal(LibXML::XML::Error::FATAL, error.level)
|
266
272
|
assert_nil(error.file)
|
267
273
|
assert_equal(2, error.line)
|
268
|
-
|
274
|
+
# Sometimes this is nil and sometimes its not depending on OS and libxlm version
|
275
|
+
# assert_nil(error.str1)
|
269
276
|
assert_nil(error.str2)
|
270
277
|
assert_nil(error.str3)
|
271
|
-
|
278
|
+
assert([0, 1].include?(error.int1))
|
272
279
|
assert_equal(1, error.int2)
|
273
280
|
assert_nil(error.node)
|
274
281
|
end
|
data/test/test_schema.rb
CHANGED
@@ -3,18 +3,19 @@
|
|
3
3
|
require_relative './test_helper'
|
4
4
|
|
5
5
|
class TestSchema < Minitest::Test
|
6
|
+
Import_NS = 'http://xml4r.org/libxml-ruby/test/shiporder'.freeze
|
7
|
+
|
6
8
|
def setup
|
7
9
|
file = File.join(File.dirname(__FILE__), 'model/shiporder.xml')
|
8
10
|
@doc = LibXML::XML::Document.file(file)
|
11
|
+
schema_file = File.join(File.dirname(__FILE__), 'model/shiporder.xsd')
|
12
|
+
schema_doc = LibXML::XML::Document.file(schema_file)
|
13
|
+
@schema = LibXML::XML::Schema.document(schema_doc)
|
9
14
|
end
|
10
15
|
|
11
16
|
def teardown
|
12
17
|
@doc = nil
|
13
|
-
|
14
|
-
|
15
|
-
def schema
|
16
|
-
document = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.xsd'))
|
17
|
-
LibXML::XML::Schema.document(document)
|
18
|
+
@schema = nil
|
18
19
|
end
|
19
20
|
|
20
21
|
def check_error(error)
|
@@ -33,11 +34,50 @@ class TestSchema < Minitest::Test
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def test_load_from_doc
|
36
|
-
assert_instance_of(LibXML::XML::Schema, schema)
|
37
|
+
assert_instance_of(LibXML::XML::Schema, @schema)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_schema_load_from_uri
|
41
|
+
xlink_schema = LibXML::XML::Schema.new('http://www.w3.org/1999/xlink.xsd')
|
42
|
+
assert_instance_of(LibXML::XML::Schema, xlink_schema)
|
43
|
+
assert_instance_of(LibXML::XML::Schema::Element, xlink_schema.elements['title'])
|
44
|
+
assert_instance_of(LibXML::XML::Schema::Type, xlink_schema.types['titleEltType'])
|
45
|
+
assert_equal('http://www.w3.org/1999/xlink', xlink_schema.target_namespace)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_schema_from_string
|
49
|
+
schema_file = File.join(File.dirname(__FILE__), 'model/shiporder.xsd')
|
50
|
+
schema_from_str = LibXML::XML::Schema.from_string(File.read(schema_file))
|
51
|
+
assert_instance_of(LibXML::XML::Schema, schema_from_str)
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_invalid_schema_doc
|
55
|
+
bad_schema_file = File.join(File.dirname(__FILE__), 'model/shiporder_bad.xsd')
|
56
|
+
bad_schema_doc = LibXML::XML::Document.file(bad_schema_file)
|
57
|
+
bad_schema = nil
|
58
|
+
## Note: this type of error throws
|
59
|
+
begin
|
60
|
+
bad_schema = LibXML::XML::Schema.document(bad_schema_doc)
|
61
|
+
rescue LibXML::XML::Error => error
|
62
|
+
bad_schema = error
|
63
|
+
assert(error.message.match(/Error: Element '.*': The content is not valid. Expected is \(/))
|
64
|
+
assert_kind_of(LibXML::XML::Error, error)
|
65
|
+
assert_equal(LibXML::XML::Error::SCHEMASP, error.domain)
|
66
|
+
assert_equal(LibXML::XML::Error::SCHEMAP_S4S_ELEM_NOT_ALLOWED, error.code)
|
67
|
+
assert_equal(LibXML::XML::Error::ERROR, error.level)
|
68
|
+
assert(error.file.match(/shiporder_bad.xsd/))
|
69
|
+
assert_equal("Element '{http://www.w3.org/2001/XMLSchema}complexType'", error.str1)
|
70
|
+
refute_nil(error.str2)
|
71
|
+
assert_nil(error.str3)
|
72
|
+
assert_equal(0, error.int1)
|
73
|
+
assert_equal(0, error.int2)
|
74
|
+
end
|
75
|
+
## Last but not least, make sure we threw an error
|
76
|
+
assert_instance_of(LibXML::XML::Error, bad_schema)
|
37
77
|
end
|
38
78
|
|
39
79
|
def test_doc_valid
|
40
|
-
assert(@doc.validate_schema(schema))
|
80
|
+
assert(@doc.validate_schema(@schema))
|
41
81
|
end
|
42
82
|
|
43
83
|
def test_doc_invalid
|
@@ -45,7 +85,7 @@ class TestSchema < Minitest::Test
|
|
45
85
|
@doc.root << new_node
|
46
86
|
|
47
87
|
error = assert_raises(LibXML::XML::Error) do
|
48
|
-
@doc.validate_schema(schema)
|
88
|
+
@doc.validate_schema(@schema)
|
49
89
|
end
|
50
90
|
|
51
91
|
check_error(error)
|
@@ -56,7 +96,7 @@ class TestSchema < Minitest::Test
|
|
56
96
|
|
57
97
|
def test_reader_valid
|
58
98
|
reader = LibXML::XML::Reader.string(@doc.to_s)
|
59
|
-
assert(reader.schema_validate(schema))
|
99
|
+
assert(reader.schema_validate(@schema))
|
60
100
|
|
61
101
|
while reader.read
|
62
102
|
end
|
@@ -74,7 +114,7 @@ class TestSchema < Minitest::Test
|
|
74
114
|
reader = LibXML::XML::Reader.string(@doc.to_s)
|
75
115
|
|
76
116
|
# Set a schema
|
77
|
-
assert(reader.schema_validate(schema))
|
117
|
+
assert(reader.schema_validate(@schema))
|
78
118
|
|
79
119
|
while reader.read
|
80
120
|
end
|
@@ -91,32 +131,55 @@ class TestSchema < Minitest::Test
|
|
91
131
|
|
92
132
|
# Schema meta-data tests
|
93
133
|
def test_elements
|
94
|
-
assert_instance_of(Hash, schema.elements)
|
95
|
-
assert_equal(1, schema.elements.length)
|
96
|
-
assert_instance_of(LibXML::XML::Schema::Element, schema.elements['shiporder'])
|
134
|
+
assert_instance_of(Hash, @schema.elements)
|
135
|
+
assert_equal(1, @schema.elements.length)
|
136
|
+
assert_instance_of(LibXML::XML::Schema::Element, @schema.elements['shiporder'])
|
97
137
|
end
|
98
138
|
|
99
139
|
def test_types
|
100
|
-
assert_instance_of(Hash, schema.types)
|
101
|
-
assert_equal(1, schema.types.length)
|
102
|
-
assert_instance_of(LibXML::XML::Schema::Type, schema.types['
|
140
|
+
assert_instance_of(Hash, @schema.types)
|
141
|
+
assert_equal(1, @schema.types.length)
|
142
|
+
assert_instance_of(LibXML::XML::Schema::Type, @schema.types['shiporderType'])
|
103
143
|
end
|
104
144
|
|
105
145
|
def test_imported_types
|
106
|
-
assert_instance_of(Hash, schema.imported_types)
|
107
|
-
assert_equal(
|
108
|
-
assert_instance_of(LibXML::XML::Schema::Type, schema.
|
146
|
+
assert_instance_of(Hash, @schema.imported_types)
|
147
|
+
assert_equal(2, @schema.imported_types.length)
|
148
|
+
assert_instance_of(LibXML::XML::Schema::Type, @schema.imported_types['shiporderType'])
|
149
|
+
assert_instance_of(LibXML::XML::Schema::Type, @schema.imported_types['shiporderFooType'])
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_imported_ns_types
|
153
|
+
assert_instance_of(Hash, @schema.imported_ns_types)
|
154
|
+
assert_equal(2, @schema.imported_ns_types.length)
|
155
|
+
assert_equal(1, @schema.imported_ns_types[nil].length)
|
156
|
+
assert_equal(1, @schema.imported_ns_types[Import_NS].length)
|
157
|
+
assert_instance_of(LibXML::XML::Schema::Type, @schema.imported_ns_types[nil]['shiporderType'])
|
158
|
+
assert_instance_of(LibXML::XML::Schema::Type, @schema.imported_ns_types[Import_NS]['shiporderFooType'])
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_imported_ns_elements
|
162
|
+
assert_instance_of(Hash, @schema.imported_ns_elements)
|
163
|
+
assert_equal(2, @schema.imported_ns_elements.length)
|
164
|
+
assert_equal(1, @schema.imported_ns_elements[nil].length)
|
165
|
+
assert_equal(1, @schema.imported_ns_elements[Import_NS].length)
|
166
|
+
assert_instance_of(LibXML::XML::Schema::Element, @schema.imported_ns_elements[nil]['shiporder'])
|
167
|
+
assert_instance_of(LibXML::XML::Schema::Element, @schema.imported_ns_elements[Import_NS]['shiporder'])
|
168
|
+
assert_equal('shiporderType', @schema.imported_ns_elements[nil]['shiporder'].type.name)
|
169
|
+
assert_equal('shiporderFooType', @schema.imported_ns_elements[Import_NS]['shiporder'].type.name)
|
109
170
|
end
|
110
171
|
|
111
172
|
def test_namespaces
|
112
|
-
assert_instance_of(Array, schema.namespaces)
|
113
|
-
|
173
|
+
assert_instance_of(Array, @schema.namespaces)
|
174
|
+
## For some reason, when importing another schema we end up with two xs->http://www.w3.org/2001/XMLSchema namespaces.
|
175
|
+
## So, we expect 3 here (one for Import_NS and then two for the schema namespace.
|
176
|
+
assert_equal(3, @schema.namespaces.length)
|
114
177
|
end
|
115
178
|
|
116
179
|
def test_schema_type
|
117
|
-
type = schema.types['
|
180
|
+
type = @schema.types['shiporderType']
|
118
181
|
|
119
|
-
assert_equal('
|
182
|
+
assert_equal('shiporderType', type.name)
|
120
183
|
assert_nil(type.namespace)
|
121
184
|
assert_equal("Shiporder type documentation", type.annotation)
|
122
185
|
assert_instance_of(LibXML::XML::Node, type.node)
|
@@ -130,22 +193,22 @@ class TestSchema < Minitest::Test
|
|
130
193
|
end
|
131
194
|
|
132
195
|
def test_schema_element
|
133
|
-
element = schema.types['
|
196
|
+
element = @schema.types['shiporderType'].elements['orderperson']
|
134
197
|
|
135
198
|
assert_equal('orderperson', element.name)
|
136
199
|
assert_nil(element.namespace)
|
137
200
|
assert_equal("orderperson element documentation", element.annotation)
|
138
201
|
|
139
|
-
element = schema.types['
|
202
|
+
element = @schema.types['shiporderType'].elements['item']
|
140
203
|
assert_equal('item', element.name)
|
141
204
|
|
142
|
-
element = schema.types['
|
205
|
+
element = @schema.types['shiporderType'].elements['item'].type.elements['note']
|
143
206
|
assert_equal('note', element.name)
|
144
207
|
assert_equal('string', element.type.name)
|
145
208
|
end
|
146
209
|
|
147
210
|
def test_schema_attributes
|
148
|
-
type = schema.types['
|
211
|
+
type = @schema.types['shiporderType']
|
149
212
|
|
150
213
|
assert_instance_of(Array, type.attributes)
|
151
214
|
assert_equal(2, type.attributes.length)
|
@@ -153,14 +216,14 @@ class TestSchema < Minitest::Test
|
|
153
216
|
end
|
154
217
|
|
155
218
|
def test_schema_attribute
|
156
|
-
attribute = schema.types['
|
219
|
+
attribute = @schema.types['shiporderType'].attributes.first
|
157
220
|
|
158
221
|
assert_equal("orderid", attribute.name)
|
159
222
|
assert_nil(attribute.namespace)
|
160
223
|
assert_equal(1, attribute.occurs)
|
161
224
|
assert_equal('string', attribute.type.name)
|
162
225
|
|
163
|
-
attribute = schema.types['
|
226
|
+
attribute = @schema.types['shiporderType'].attributes[1]
|
164
227
|
assert_equal(2, attribute.occurs)
|
165
228
|
assert_equal('1', attribute.default)
|
166
229
|
assert_equal('integer', attribute.type.name)
|
data/test/test_xml.rb
CHANGED
@@ -167,11 +167,19 @@ class TestXml < Minitest::Test
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def test_enabled_docbook
|
170
|
-
|
170
|
+
if windows?
|
171
|
+
refute(LibXML::XML.enabled_docbook?)
|
172
|
+
else
|
173
|
+
assert(LibXML::XML.enabled_docbook?)
|
174
|
+
end
|
171
175
|
end
|
172
176
|
|
173
177
|
def test_enabled_ftp
|
174
|
-
|
178
|
+
if windows?
|
179
|
+
refute(LibXML::XML.enabled_ftp?)
|
180
|
+
else
|
181
|
+
assert(LibXML::XML.enabled_ftp?)
|
182
|
+
end
|
175
183
|
end
|
176
184
|
|
177
185
|
def test_enabled_http
|
@@ -183,7 +191,8 @@ class TestXml < Minitest::Test
|
|
183
191
|
end
|
184
192
|
|
185
193
|
def test_enabled_iconv
|
186
|
-
|
194
|
+
iconv_enabled = RUBY_PLATFORM !~ /darwin/
|
195
|
+
assert_equal(iconv_enabled, LibXML::XML.enabled_iconv?)
|
187
196
|
end
|
188
197
|
|
189
198
|
def test_enabled_memory_debug
|
@@ -241,7 +250,11 @@ class TestXml < Minitest::Test
|
|
241
250
|
end
|
242
251
|
|
243
252
|
def test_libxml_parser_features
|
244
|
-
|
253
|
+
if windows?
|
254
|
+
assert_nil(LibXML::XML.features)
|
255
|
+
else
|
256
|
+
assert_instance_of(Array, LibXML::XML.features)
|
257
|
+
end
|
245
258
|
end
|
246
259
|
|
247
260
|
def test_default_options
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: libxml-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Bamform
|
@@ -11,10 +11,10 @@ authors:
|
|
11
11
|
- Anurag Priyam
|
12
12
|
- Charlie Savage
|
13
13
|
- Ryan Johnson
|
14
|
-
autorequire:
|
14
|
+
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date:
|
17
|
+
date: 2022-10-29 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: rake-compiler
|
@@ -50,7 +50,7 @@ description: |2
|
|
50
50
|
Libxml-ruby's primary advantage over REXML is performance - if speed
|
51
51
|
is your need, these are good libraries to consider, as demonstrated
|
52
52
|
by the informal benchmark below.
|
53
|
-
email:
|
53
|
+
email:
|
54
54
|
executables: []
|
55
55
|
extensions:
|
56
56
|
- ext/libxml/extconf.rb
|
@@ -216,9 +216,10 @@ files:
|
|
216
216
|
- test/model/shiporder.rng
|
217
217
|
- test/model/shiporder.xml
|
218
218
|
- test/model/shiporder.xsd
|
219
|
+
- test/model/shiporder_bad.xsd
|
220
|
+
- test/model/shiporder_import.xsd
|
219
221
|
- test/model/soap.xml
|
220
222
|
- test/model/xinclude.xml
|
221
|
-
- test/test.xml
|
222
223
|
- test/test_attr.rb
|
223
224
|
- test/test_attr_decl.rb
|
224
225
|
- test/test_attributes.rb
|
@@ -260,11 +261,11 @@ files:
|
|
260
261
|
- test/test_xpath_context.rb
|
261
262
|
- test/test_xpath_expression.rb
|
262
263
|
- test/test_xpointer.rb
|
263
|
-
homepage:
|
264
|
+
homepage: https://xml4r.github.io/libxml-ruby/
|
264
265
|
licenses:
|
265
266
|
- MIT
|
266
267
|
metadata: {}
|
267
|
-
post_install_message:
|
268
|
+
post_install_message:
|
268
269
|
rdoc_options: []
|
269
270
|
require_paths:
|
270
271
|
- lib
|
@@ -279,14 +280,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
280
|
- !ruby/object:Gem::Version
|
280
281
|
version: '0'
|
281
282
|
requirements: []
|
282
|
-
rubygems_version: 3.
|
283
|
-
signing_key:
|
283
|
+
rubygems_version: 3.3.14
|
284
|
+
signing_key:
|
284
285
|
specification_version: 4
|
285
286
|
summary: Ruby Bindings for LibXML2
|
286
287
|
test_files:
|
287
288
|
- test/test_attr.rb
|
288
|
-
- test/test_attributes.rb
|
289
289
|
- test/test_attr_decl.rb
|
290
|
+
- test/test_attributes.rb
|
290
291
|
- test/test_canonicalize.rb
|
291
292
|
- test/test_deprecated_require.rb
|
292
293
|
- test/test_document.rb
|
data/test/test.xml
DELETED