libxml-ruby 3.2.2-x64-mingw-ucrt → 3.2.4-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +16 -0
  3. data/ext/libxml/extconf.h +3 -0
  4. data/ext/libxml/ruby_libxml.h +0 -22
  5. data/ext/libxml/ruby_xml.c +6 -0
  6. data/ext/libxml/ruby_xml_document.c +6 -0
  7. data/ext/libxml/ruby_xml_encoding.h +2 -0
  8. data/ext/libxml/ruby_xml_error.h +2 -0
  9. data/ext/libxml/ruby_xml_html_parser.c +2 -0
  10. data/ext/libxml/ruby_xml_html_parser_context.c +1 -0
  11. data/ext/libxml/ruby_xml_html_parser_options.c +2 -0
  12. data/ext/libxml/ruby_xml_namespace.c +1 -0
  13. data/ext/libxml/ruby_xml_node.c +12 -4
  14. data/ext/libxml/ruby_xml_parser_context.c +2 -0
  15. data/ext/libxml/ruby_xml_reader.c +3 -0
  16. data/ext/libxml/ruby_xml_reader.h +0 -3
  17. data/ext/libxml/ruby_xml_relaxng.c +2 -0
  18. data/ext/libxml/ruby_xml_relaxng.h +0 -2
  19. data/ext/libxml/ruby_xml_schema.c +223 -81
  20. data/ext/libxml/ruby_xml_schema.h +4 -788
  21. data/ext/libxml/ruby_xml_schema_attribute.c +69 -71
  22. data/ext/libxml/ruby_xml_schema_attribute.h +25 -3
  23. data/ext/libxml/ruby_xml_schema_element.c +28 -54
  24. data/ext/libxml/ruby_xml_schema_element.h +0 -3
  25. data/ext/libxml/ruby_xml_schema_facet.c +19 -21
  26. data/ext/libxml/ruby_xml_schema_facet.h +0 -4
  27. data/ext/libxml/ruby_xml_schema_type.c +56 -37
  28. data/ext/libxml/ruby_xml_version.h +3 -3
  29. data/ext/libxml/ruby_xml_writer.c +4 -0
  30. data/ext/libxml/ruby_xml_writer.h +0 -4
  31. data/ext/libxml/ruby_xml_xinclude.c +4 -0
  32. data/ext/libxml/ruby_xml_xpath.c +1 -0
  33. data/ext/libxml/ruby_xml_xpath.h +2 -0
  34. data/ext/libxml/ruby_xml_xpath_context.c +2 -0
  35. data/ext/libxml/ruby_xml_xpath_object.c +1 -0
  36. data/ext/libxml/ruby_xml_xpointer.c +5 -1
  37. data/lib/3.1/libxml_ruby.so +0 -0
  38. data/lib/libxml-ruby.rb +1 -1
  39. data/test/model/shiporder.rnc +2 -2
  40. data/test/model/shiporder.rng +2 -2
  41. data/test/model/shiporder.xsd +7 -3
  42. data/test/model/shiporder_bad.xsd +40 -0
  43. data/test/model/shiporder_import.xsd +45 -0
  44. data/test/test_helper.rb +4 -0
  45. data/test/test_schema.rb +92 -29
  46. data/test/test_xml.rb +15 -3
  47. metadata +6 -3
@@ -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="shiporder"/>
10
+ <ref name="shiporderType"/>
11
11
  </start>
12
- <define name="shiporder">
12
+ <define name="shiporderType">
13
13
  <element name="shiporder">
14
14
  <attribute name="orderid"/>
15
15
  <attribute name="xsi:noNamespaceSchemaLocation"/>
@@ -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:complexType name="shiporder">
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_helper.rb CHANGED
@@ -6,4 +6,8 @@ require 'bundler/setup'
6
6
  require 'minitest/autorun'
7
7
  require 'libxml-ruby'
8
8
 
9
+ def windows?
10
+ !(RbConfig::CONFIG['host_os'] =~ /mswin|mingw/).nil?
11
+ end
12
+
9
13
  STDOUT.write "\nlibxml2: #{LibXML::XML::LIBXML_VERSION}\n#{RUBY_DESCRIPTION}\n\n"
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
- end
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['shiporder'])
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(1, schema.imported_types.length)
108
- assert_instance_of(LibXML::XML::Schema::Type, schema.types['shiporder'])
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
- assert_equal(1, schema.namespaces.length)
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['shiporder']
180
+ type = @schema.types['shiporderType']
118
181
 
119
- assert_equal('shiporder', type.name)
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['shiporder'].elements['orderperson']
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['shiporder'].elements['item']
202
+ element = @schema.types['shiporderType'].elements['item']
140
203
  assert_equal('item', element.name)
141
204
 
142
- element = schema.types['shiporder'].elements['item'].type.elements['note']
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['shiporder']
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['shiporder'].attributes.first
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['shiporder'].attributes[1]
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
- assert(LibXML::XML.enabled_docbook?)
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
- assert(LibXML::XML.enabled_ftp?)
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
@@ -242,7 +250,11 @@ class TestXml < Minitest::Test
242
250
  end
243
251
 
244
252
  def test_libxml_parser_features
245
- assert_instance_of(Array, LibXML::XML.features)
253
+ if windows?
254
+ assert_nil(LibXML::XML.features)
255
+ else
256
+ assert_instance_of(Array, LibXML::XML.features)
257
+ end
246
258
  end
247
259
 
248
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.2
4
+ version: 3.2.4
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - Ross Bamform
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2022-01-16 00:00:00.000000000 Z
17
+ date: 2022-10-29 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: rake-compiler
@@ -60,6 +60,7 @@ files:
60
60
  - MANIFEST
61
61
  - README.rdoc
62
62
  - Rakefile
63
+ - ext/libxml/extconf.h
63
64
  - ext/libxml/extconf.rb
64
65
  - ext/libxml/libxml.c
65
66
  - ext/libxml/libxml_ruby.def
@@ -215,6 +216,8 @@ files:
215
216
  - test/model/shiporder.rng
216
217
  - test/model/shiporder.xml
217
218
  - test/model/shiporder.xsd
219
+ - test/model/shiporder_bad.xsd
220
+ - test/model/shiporder_import.xsd
218
221
  - test/model/soap.xml
219
222
  - test/model/xinclude.xml
220
223
  - test/test_attr.rb
@@ -277,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
277
280
  - !ruby/object:Gem::Version
278
281
  version: '0'
279
282
  requirements: []
280
- rubygems_version: 3.3.4
283
+ rubygems_version: 3.3.14
281
284
  signing_key:
282
285
  specification_version: 4
283
286
  summary: Ruby Bindings for LibXML2