libxml-ruby 3.2.1 → 4.1.1

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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +37 -0
  3. data/Rakefile +24 -16
  4. data/ext/libxml/libxml.c +0 -1
  5. data/ext/libxml/libxml_ruby.def +0 -1
  6. data/ext/libxml/ruby_libxml.h +0 -23
  7. data/ext/libxml/ruby_xml.c +3 -37
  8. data/ext/libxml/ruby_xml.h +1 -1
  9. data/ext/libxml/ruby_xml_cbg.c +1 -1
  10. data/ext/libxml/ruby_xml_document.c +6 -0
  11. data/ext/libxml/ruby_xml_dtd.c +1 -1
  12. data/ext/libxml/ruby_xml_encoding.c +2 -2
  13. data/ext/libxml/ruby_xml_encoding.h +2 -0
  14. data/ext/libxml/ruby_xml_error.c +3 -3
  15. data/ext/libxml/ruby_xml_error.h +3 -1
  16. data/ext/libxml/ruby_xml_html_parser.c +2 -0
  17. data/ext/libxml/ruby_xml_html_parser_context.c +1 -1
  18. data/ext/libxml/ruby_xml_html_parser_options.c +2 -0
  19. data/ext/libxml/ruby_xml_input_cbg.c +4 -7
  20. data/ext/libxml/ruby_xml_io.c +1 -1
  21. data/ext/libxml/ruby_xml_namespace.c +1 -0
  22. data/ext/libxml/ruby_xml_node.c +11 -15
  23. data/ext/libxml/ruby_xml_parser.h +0 -2
  24. data/ext/libxml/ruby_xml_parser_context.c +2 -0
  25. data/ext/libxml/ruby_xml_parser_options.h +0 -2
  26. data/ext/libxml/ruby_xml_reader.c +3 -0
  27. data/ext/libxml/ruby_xml_reader.h +0 -3
  28. data/ext/libxml/ruby_xml_relaxng.c +2 -0
  29. data/ext/libxml/ruby_xml_relaxng.h +0 -2
  30. data/ext/libxml/ruby_xml_schema.c +223 -81
  31. data/ext/libxml/ruby_xml_schema.h +4 -788
  32. data/ext/libxml/ruby_xml_schema_attribute.c +69 -71
  33. data/ext/libxml/ruby_xml_schema_attribute.h +25 -3
  34. data/ext/libxml/ruby_xml_schema_element.c +28 -54
  35. data/ext/libxml/ruby_xml_schema_element.h +0 -3
  36. data/ext/libxml/ruby_xml_schema_facet.c +19 -21
  37. data/ext/libxml/ruby_xml_schema_facet.h +0 -4
  38. data/ext/libxml/ruby_xml_schema_type.c +56 -37
  39. data/ext/libxml/ruby_xml_version.h +4 -4
  40. data/ext/libxml/ruby_xml_writer.c +4 -0
  41. data/ext/libxml/ruby_xml_writer.h +0 -4
  42. data/ext/libxml/ruby_xml_xinclude.c +4 -0
  43. data/ext/libxml/ruby_xml_xpath.c +1 -0
  44. data/ext/libxml/ruby_xml_xpath.h +2 -0
  45. data/ext/libxml/ruby_xml_xpath_context.c +2 -0
  46. data/ext/libxml/ruby_xml_xpath_object.c +1 -0
  47. data/lib/libxml/error.rb +7 -7
  48. data/libxml-ruby.gemspec +1 -1
  49. data/test/model/shiporder.rnc +2 -2
  50. data/test/model/shiporder.rng +2 -2
  51. data/test/model/shiporder.xsd +7 -3
  52. data/test/model/shiporder_bad.xsd +40 -0
  53. data/test/model/shiporder_import.xsd +45 -0
  54. data/test/test_document.rb +2 -1
  55. data/test/test_dtd.rb +2 -1
  56. data/test/test_error.rb +173 -157
  57. data/test/test_helper.rb +6 -0
  58. data/test/test_parser.rb +1 -1
  59. data/test/test_parser_context.rb +1 -7
  60. data/test/test_reader.rb +2 -1
  61. data/test/test_sax_parser.rb +13 -6
  62. data/test/test_schema.rb +92 -29
  63. data/test/test_xml.rb +12 -7
  64. metadata +11 -18
  65. data/MANIFEST +0 -166
  66. data/ext/libxml/ruby_xml_xpointer.c +0 -99
  67. data/ext/libxml/ruby_xml_xpointer.h +0 -11
  68. data/setup.rb +0 -1584
  69. data/test/test.xml +0 -2
  70. data/test/test_suite.rb +0 -48
  71. data/test/test_xpointer.rb +0 -72
@@ -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
- assert_equal("error: Fatal error: EndTag: '</' not found at :2.", result[i+=1])
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
- assert_equal("Fatal error: EndTag: '</' not found at :2.", error.message)
267
+ assert_match(re_err_msg2, error.message)
263
268
  assert_equal(LibXML::XML::Error::PARSER, error.domain)
264
- assert_equal(LibXML::XML::Error::LTSLASH_REQUIRED, error.code)
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
- assert_nil(error.str1)
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
- assert_equal(0, error.int1)
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
- 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
@@ -183,7 +191,8 @@ class TestXml < Minitest::Test
183
191
  end
184
192
 
185
193
  def test_enabled_iconv
186
- assert(LibXML::XML.enabled_iconv?)
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
@@ -240,10 +249,6 @@ class TestXml < Minitest::Test
240
249
  assert_instance_of(Integer, LibXML::XML::VERNUM)
241
250
  end
242
251
 
243
- def test_libxml_parser_features
244
- assert_instance_of(Array, LibXML::XML.features)
245
- end
246
-
247
252
  def test_default_options
248
253
  assert_equal(0, LibXML::XML.default_options)
249
254
  end
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.1
4
+ version: 4.1.1
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: 2020-11-05 00:00:00.000000000 Z
17
+ date: 2023-05-02 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
@@ -58,7 +58,6 @@ extra_rdoc_files: []
58
58
  files:
59
59
  - HISTORY
60
60
  - LICENSE
61
- - MANIFEST
62
61
  - README.rdoc
63
62
  - Rakefile
64
63
  - ext/libxml/extconf.h
@@ -136,8 +135,6 @@ files:
136
135
  - ext/libxml/ruby_xml_xpath_expression.h
137
136
  - ext/libxml/ruby_xml_xpath_object.c
138
137
  - ext/libxml/ruby_xml_xpath_object.h
139
- - ext/libxml/ruby_xml_xpointer.c
140
- - ext/libxml/ruby_xml_xpointer.h
141
138
  - ext/vc/libxml_ruby.sln
142
139
  - lib/libxml-ruby.rb
143
140
  - lib/libxml.rb
@@ -168,7 +165,6 @@ files:
168
165
  - script/benchmark/sock_entries.xml
169
166
  - script/benchmark/throughput
170
167
  - script/test
171
- - setup.rb
172
168
  - test/c14n/given/doc.dtd
173
169
  - test/c14n/given/example-1.xml
174
170
  - test/c14n/given/example-2.xml
@@ -216,9 +212,10 @@ files:
216
212
  - test/model/shiporder.rng
217
213
  - test/model/shiporder.xml
218
214
  - test/model/shiporder.xsd
215
+ - test/model/shiporder_bad.xsd
216
+ - test/model/shiporder_import.xsd
219
217
  - test/model/soap.xml
220
218
  - test/model/xinclude.xml
221
- - test/test.xml
222
219
  - test/test_attr.rb
223
220
  - test/test_attr_decl.rb
224
221
  - test/test_attributes.rb
@@ -251,7 +248,6 @@ files:
251
248
  - test/test_relaxng.rb
252
249
  - test/test_sax_parser.rb
253
250
  - test/test_schema.rb
254
- - test/test_suite.rb
255
251
  - test/test_traversal.rb
256
252
  - test/test_writer.rb
257
253
  - test/test_xinclude.rb
@@ -259,12 +255,11 @@ files:
259
255
  - test/test_xpath.rb
260
256
  - test/test_xpath_context.rb
261
257
  - test/test_xpath_expression.rb
262
- - test/test_xpointer.rb
263
- homepage: http://xml4r.github.com/libxml-ruby
258
+ homepage: https://xml4r.github.io/libxml-ruby/
264
259
  licenses:
265
260
  - MIT
266
261
  metadata: {}
267
- post_install_message:
262
+ post_install_message:
268
263
  rdoc_options: []
269
264
  require_paths:
270
265
  - lib
@@ -279,14 +274,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
279
274
  - !ruby/object:Gem::Version
280
275
  version: '0'
281
276
  requirements: []
282
- rubygems_version: 3.1.4
283
- signing_key:
277
+ rubygems_version: 3.3.26
278
+ signing_key:
284
279
  specification_version: 4
285
280
  summary: Ruby Bindings for LibXML2
286
281
  test_files:
287
282
  - test/test_attr.rb
288
- - test/test_attributes.rb
289
283
  - test/test_attr_decl.rb
284
+ - test/test_attributes.rb
290
285
  - test/test_canonicalize.rb
291
286
  - test/test_deprecated_require.rb
292
287
  - test/test_document.rb
@@ -316,7 +311,6 @@ test_files:
316
311
  - test/test_relaxng.rb
317
312
  - test/test_sax_parser.rb
318
313
  - test/test_schema.rb
319
- - test/test_suite.rb
320
314
  - test/test_traversal.rb
321
315
  - test/test_writer.rb
322
316
  - test/test_xinclude.rb
@@ -324,4 +318,3 @@ test_files:
324
318
  - test/test_xpath.rb
325
319
  - test/test_xpath_context.rb
326
320
  - test/test_xpath_expression.rb
327
- - test/test_xpointer.rb
data/MANIFEST DELETED
@@ -1,166 +0,0 @@
1
- #!mast -x doc/libxml-ruby/rdoc -i .gitignore ext doc lib script test [A-Z]*
2
- ext/libxml/extconf.rb
3
- ext/libxml/libxml.c
4
- ext/libxml/ruby_libxml.h
5
- ext/libxml/ruby_xml.c
6
- ext/libxml/ruby_xml.h
7
- ext/libxml/ruby_xml_attr.c
8
- ext/libxml/ruby_xml_attr.h
9
- ext/libxml/ruby_xml_attr_decl.c
10
- ext/libxml/ruby_xml_attr_decl.h
11
- ext/libxml/ruby_xml_attributes.c
12
- ext/libxml/ruby_xml_attributes.h
13
- ext/libxml/ruby_xml_cbg.c
14
- ext/libxml/ruby_xml_document.c
15
- ext/libxml/ruby_xml_document.h
16
- ext/libxml/ruby_xml_dtd.c
17
- ext/libxml/ruby_xml_dtd.h
18
- ext/libxml/ruby_xml_encoding.c
19
- ext/libxml/ruby_xml_encoding.h
20
- ext/libxml/ruby_xml_error.c
21
- ext/libxml/ruby_xml_error.h
22
- ext/libxml/ruby_xml_html_parser.c
23
- ext/libxml/ruby_xml_html_parser.h
24
- ext/libxml/ruby_xml_html_parser_context.c
25
- ext/libxml/ruby_xml_html_parser_context.h
26
- ext/libxml/ruby_xml_html_parser_options.c
27
- ext/libxml/ruby_xml_html_parser_options.h
28
- ext/libxml/ruby_xml_input_cbg.c
29
- ext/libxml/ruby_xml_input_cbg.h
30
- ext/libxml/ruby_xml_io.c
31
- ext/libxml/ruby_xml_io.h
32
- ext/libxml/ruby_xml_namespace.c
33
- ext/libxml/ruby_xml_namespace.h
34
- ext/libxml/ruby_xml_namespaces.c
35
- ext/libxml/ruby_xml_namespaces.h
36
- ext/libxml/ruby_xml_node.c
37
- ext/libxml/ruby_xml_node.h
38
- ext/libxml/ruby_xml_parser.c
39
- ext/libxml/ruby_xml_parser.h
40
- ext/libxml/ruby_xml_parser_context.c
41
- ext/libxml/ruby_xml_parser_context.h
42
- ext/libxml/ruby_xml_parser_options.c
43
- ext/libxml/ruby_xml_parser_options.h
44
- ext/libxml/ruby_xml_reader.c
45
- ext/libxml/ruby_xml_reader.h
46
- ext/libxml/ruby_xml_relaxng.c
47
- ext/libxml/ruby_xml_relaxng.h
48
- ext/libxml/ruby_xml_sax2_handler.c
49
- ext/libxml/ruby_xml_sax2_handler.h
50
- ext/libxml/ruby_xml_sax_parser.c
51
- ext/libxml/ruby_xml_sax_parser.h
52
- ext/libxml/ruby_xml_schema.c
53
- ext/libxml/ruby_xml_schema.h
54
- ext/libxml/ruby_xml_version.h
55
- ext/libxml/ruby_xml_xinclude.c
56
- ext/libxml/ruby_xml_xinclude.h
57
- ext/libxml/ruby_xml_xpath.c
58
- ext/libxml/ruby_xml_xpath.h
59
- ext/libxml/ruby_xml_xpath_context.c
60
- ext/libxml/ruby_xml_xpath_context.h
61
- ext/libxml/ruby_xml_xpath_expression.c
62
- ext/libxml/ruby_xml_xpath_expression.h
63
- ext/libxml/ruby_xml_xpath_object.c
64
- ext/libxml/ruby_xml_xpath_object.h
65
- ext/libxml/ruby_xml_xpointer.c
66
- ext/libxml/ruby_xml_xpointer.h
67
- ext/mingw/Rakefile
68
- ext/mingw/build.rake
69
- ext/mingw/libiconv-2.dll
70
- ext/mingw/libxml2-2.dll
71
- ext/mingw/libxml_ruby.dll.a
72
- ext/mingw/libxml_ruby.so
73
- ext/vc/libxml_ruby.sln
74
- ext/vc/libxml_ruby_18/libxml_ruby.vcproj
75
- ext/vc/libxml_ruby_19/libxml_ruby_19.vcproj
76
- doc/.htaccess
77
- doc/.rsync-filter
78
- lib/libxml/attr.rb
79
- lib/libxml/attr_decl.rb
80
- lib/libxml/attributes.rb
81
- lib/libxml/document.rb
82
- lib/libxml/error.rb
83
- lib/libxml/hpricot.rb
84
- lib/libxml/html_parser.rb
85
- lib/libxml/namespace.rb
86
- lib/libxml/namespaces.rb
87
- lib/libxml/node.rb
88
- lib/libxml/ns.rb
89
- lib/libxml/parser.rb
90
- lib/libxml/properties.rb
91
- lib/libxml/reader.rb
92
- lib/libxml/sax_callbacks.rb
93
- lib/libxml/sax_parser.rb
94
- lib/libxml/tree.rb
95
- lib/libxml/xpath_object.rb
96
- lib/libxml.rb
97
- lib/xml/libxml.rb
98
- lib/xml.rb
99
- script/benchmark/depixelate
100
- script/benchmark/hamlet.xml
101
- script/benchmark/parsecount
102
- script/benchmark/sock_entries.xml
103
- script/benchmark/throughput
104
- script/test
105
- test/etc_doc_to_s.rb
106
- test/ets_doc_file.rb
107
- test/ets_doc_to_s.rb
108
- test/ets_gpx.rb
109
- test/ets_node_gc.rb
110
- test/ets_test.xml
111
- test/ets_tsr.rb
112
- test/model/atom.xml
113
- test/model/bands.xml
114
- test/model/books.xml
115
- test/model/merge_bug_data.xml
116
- test/model/ruby-lang.html
117
- test/model/rubynet.xml
118
- test/model/rubynet_project
119
- test/model/shiporder.rnc
120
- test/model/shiporder.rng
121
- test/model/shiporder.xml
122
- test/model/shiporder.xsd
123
- test/model/soap.xml
124
- test/model/xinclude.xml
125
- test/test_attr.rb
126
- test/test_attr_decl.rb
127
- test/test_attributes.rb
128
- test/test_deprecated_require.rb
129
- test/test_document.rb
130
- test/test_document_write.rb
131
- test/test_dtd.rb
132
- test/test_error.rb
133
- test/test_html_parser.rb
134
- test/test_namespace.rb
135
- test/test_namespaces.rb
136
- test/test_node.rb
137
- test/test_node_cdata.rb
138
- test/test_node_comment.rb
139
- test/test_node_copy.rb
140
- test/test_node_edit.rb
141
- test/test_node_pi.rb
142
- test/test_node_text.rb
143
- test/test_node_write.rb
144
- test/test_node_xlink.rb
145
- test/test_parser.rb
146
- test/test_parser_context.rb
147
- test/test_properties.rb
148
- test/test_reader.rb
149
- test/test_relaxng.rb
150
- test/test_sax_parser.rb
151
- test/test_schema.rb
152
- test/test_traversal.rb
153
- test/test_xinclude.rb
154
- test/test_xml.rb
155
- test/test_xpath.rb
156
- test/test_xpath_context.rb
157
- test/test_xpath_expression.rb
158
- test/test_xpointer.rb
159
- test/test_suite.rb
160
- Rakefile
161
- HISTORY.rdoc
162
- PROFILE
163
- TODO
164
- LICENSE
165
- README.rdoc
166
- VERSION
@@ -1,99 +0,0 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #include "ruby_libxml.h"
4
- #include "ruby_xml_xpointer.h"
5
-
6
- VALUE cXMLXPointer;
7
-
8
- /*
9
- * Document-class: LibXML::XML::XPointer
10
- *
11
- * The XML::Pointer class provides a standards based API for searching an xml document.
12
- * XPointer is based on the XML Path Language (XML::XPath) and is documented
13
- * at http://www.w3.org/TR/WD-xptr.
14
- */
15
-
16
- static VALUE rxml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str)
17
- {
18
- #ifdef LIBXML_XPTR_ENABLED
19
- xmlNodePtr xnode;
20
- xmlXPathContextPtr xctxt;
21
- xmlXPathObjectPtr xpop;
22
-
23
- VALUE context;
24
- VALUE result;
25
- VALUE argv[1];
26
-
27
- Check_Type(xptr_str, T_STRING);
28
- if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
29
- rb_raise(rb_eTypeError, "require an XML::Node object");
30
-
31
- Data_Get_Struct(rnode, xmlNode, xnode);
32
-
33
- argv[0] = rb_funcall(rnode, rb_intern("doc"), 0);
34
- context = rb_class_new_instance(1, argv, cXMLXPathContext);
35
- Data_Get_Struct(context, xmlXPathContext, xctxt);
36
-
37
- xpop = xmlXPtrEval((xmlChar*)StringValuePtr(xptr_str), xctxt);
38
- if (!xpop)
39
- rxml_raise(&xmlLastError);
40
-
41
- result = rxml_xpath_object_wrap(xnode->doc, xpop);
42
- rb_iv_set(result, "@context", context);
43
-
44
- return(result);
45
- #else
46
- rb_warn("libxml was compiled without XPointer support");
47
- return (Qfalse);
48
- #endif
49
- }
50
-
51
- VALUE rxml_xpointer_point2(VALUE node, VALUE xptr_str)
52
- {
53
- return (rxml_xpointer_point(cXMLXPointer, node, xptr_str));
54
- }
55
-
56
- /*
57
- * call-seq:
58
- * XML::XPointer.range(start_node, end_node) -> xpath
59
- *
60
- * Create an xpath representing the range between the supplied
61
- * start and end node.
62
- */
63
- static VALUE rxml_xpointer_range(VALUE class, VALUE rstart, VALUE rend)
64
- {
65
- #ifdef LIBXML_XPTR_ENABLED
66
- xmlNodePtr start, end;
67
- VALUE rxxp;
68
- xmlXPathObjectPtr xpath;
69
-
70
- if (rb_obj_is_kind_of(rstart, cXMLNode) == Qfalse)
71
- rb_raise(rb_eTypeError, "require an XML::Node object as a starting point");
72
- if (rb_obj_is_kind_of(rend, cXMLNode) == Qfalse)
73
- rb_raise(rb_eTypeError, "require an XML::Node object as an ending point");
74
-
75
- Data_Get_Struct(rstart, xmlNode, start);
76
- if (start == NULL)
77
- return(Qnil);
78
-
79
- Data_Get_Struct(rend, xmlNode, end);
80
- if (end == NULL)
81
- return(Qnil);
82
-
83
- xpath = xmlXPtrNewRangeNodes(start, end);
84
- if (xpath == NULL)
85
- rb_fatal("You shouldn't be able to have this happen");
86
-
87
- rxxp = rxml_xpath_object_wrap(start->doc, xpath);
88
- return(rxxp);
89
- #else
90
- rb_warn("libxml was compiled without XPointer support");
91
- return (Qfalse);
92
- #endif
93
- }
94
-
95
- void rxml_init_xpointer(void)
96
- {
97
- cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
98
- rb_define_singleton_method(cXMLXPointer, "range", rxml_xpointer_range, 2);
99
- }