libxml-ruby 3.0.0-x64-mingw32 → 3.1.0-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY +18 -0
  3. data/MANIFEST +34 -34
  4. data/README.rdoc +14 -1
  5. data/Rakefile +18 -8
  6. data/ext/libxml/ruby_xml_error.c +1 -1
  7. data/ext/libxml/ruby_xml_error.h +1 -1
  8. data/ext/libxml/ruby_xml_node.c +15 -16
  9. data/ext/libxml/ruby_xml_reader.c +7 -2
  10. data/ext/libxml/ruby_xml_schema.c +44 -66
  11. data/ext/libxml/ruby_xml_schema_element.c +15 -14
  12. data/ext/libxml/ruby_xml_schema_type.c +66 -93
  13. data/ext/libxml/ruby_xml_version.h +3 -3
  14. data/lib/libxml/schema.rb +0 -19
  15. data/lib/libxml/schema/element.rb +0 -8
  16. data/lib/libxml/schema/type.rb +0 -8
  17. data/libxml-ruby.gemspec +3 -2
  18. data/setup.rb +0 -1
  19. data/test/model/cwm_1_0.xml +11336 -0
  20. data/test/{tc_attr.rb → test_attr.rb} +1 -1
  21. data/test/{tc_attr_decl.rb → test_attr_decl.rb} +1 -1
  22. data/test/{tc_attributes.rb → test_attributes.rb} +1 -1
  23. data/test/{tc_canonicalize.rb → test_canonicalize.rb} +32 -28
  24. data/test/{tc_deprecated_require.rb → test_deprecated_require.rb} +0 -0
  25. data/test/{tc_document.rb → test_document.rb} +3 -3
  26. data/test/{tc_document_write.rb → test_document_write.rb} +1 -1
  27. data/test/{tc_dtd.rb → test_dtd.rb} +6 -6
  28. data/test/{tc_encoding.rb → test_encoding.rb} +6 -3
  29. data/test/{tc_encoding_sax.rb → test_encoding_sax.rb} +1 -1
  30. data/test/{tc_error.rb → test_error.rb} +1 -1
  31. data/test/test_helper.rb +0 -2
  32. data/test/{tc_html_parser.rb → test_html_parser.rb} +3 -2
  33. data/test/{tc_html_parser_context.rb → test_html_parser_context.rb} +1 -1
  34. data/test/{tc_namespace.rb → test_namespace.rb} +3 -4
  35. data/test/{tc_namespaces.rb → test_namespaces.rb} +5 -14
  36. data/test/{tc_node.rb → test_node.rb} +2 -2
  37. data/test/{tc_node_cdata.rb → test_node_cdata.rb} +1 -1
  38. data/test/{tc_node_comment.rb → test_node_comment.rb} +1 -1
  39. data/test/{tc_node_copy.rb → test_node_copy.rb} +2 -3
  40. data/test/{tc_node_edit.rb → test_node_edit.rb} +5 -6
  41. data/test/{tc_node_pi.rb → test_node_pi.rb} +2 -4
  42. data/test/{tc_node_text.rb → test_node_text.rb} +4 -5
  43. data/test/{tc_node_write.rb → test_node_write.rb} +1 -1
  44. data/test/{tc_node_xlink.rb → test_node_xlink.rb} +1 -1
  45. data/test/{tc_parser.rb → test_parser.rb} +7 -6
  46. data/test/{tc_parser_context.rb → test_parser_context.rb} +8 -8
  47. data/test/{tc_properties.rb → test_properties.rb} +1 -1
  48. data/test/{tc_reader.rb → test_reader.rb} +30 -20
  49. data/test/{tc_relaxng.rb → test_relaxng.rb} +2 -2
  50. data/test/{tc_sax_parser.rb → test_sax_parser.rb} +3 -3
  51. data/test/{tc_schema.rb → test_schema.rb} +18 -11
  52. data/test/test_suite.rb +38 -38
  53. data/test/{tc_traversal.rb → test_traversal.rb} +1 -1
  54. data/test/{tc_writer.rb → test_writer.rb} +1 -1
  55. data/test/{tc_xinclude.rb → test_xinclude.rb} +1 -1
  56. data/test/{tc_xml.rb → test_xml.rb} +61 -36
  57. data/test/{tc_xpath.rb → test_xpath.rb} +4 -4
  58. data/test/{tc_xpath_context.rb → test_xpath_context.rb} +1 -1
  59. data/test/{tc_xpath_expression.rb → test_xpath_expression.rb} +2 -2
  60. data/test/{tc_xpointer.rb → test_xpointer.rb} +1 -1
  61. metadata +84 -99
  62. data/lib/2.4/libxml_ruby.so +0 -0
  63. data/lib/libs/libiconv-2.dll +0 -0
  64. data/lib/libs/libxml2-2.dll +0 -0
  65. data/lib/libs/zlib1.dll +0 -0
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
 
5
5
 
6
6
  class NodeCommentTest < Minitest::Test
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
 
5
5
  # see mailing list archive
6
6
  # [libxml-devel] Segmentation fault when add the cloned/copied node
@@ -37,5 +37,4 @@ class TestNodeCopy < Minitest::Test
37
37
  end
38
38
  assert @div1.to_s =~ /foo/
39
39
  end
40
-
41
- end # TC_XML_Node_Copy
40
+ end
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
 
5
5
  class TestNodeEdit < Minitest::Test
6
6
  def setup
@@ -69,8 +69,7 @@ class TestNodeEdit < Minitest::Test
69
69
  def test_remove_node_gc
70
70
  xp = XML::Parser.string('<test><num>one</num><num>two</num><num>three</num></test>')
71
71
  doc = xp.parse
72
- node = doc.root.child.remove!
73
- node = nil
72
+ doc.root.child.remove!
74
73
  GC.start
75
74
  refute_nil(doc)
76
75
  end
@@ -132,7 +131,8 @@ class TestNodeEdit < Minitest::Test
132
131
  end
133
132
 
134
133
  master_doc = documents.shift
135
- documents.inject(master_doc) do |master_doc, child_doc|
134
+
135
+ documents.each do |child_doc|
136
136
  master_body = master_doc.find("//body").first
137
137
  child_body = child_doc.find("//body").first
138
138
 
@@ -141,7 +141,6 @@ class TestNodeEdit < Minitest::Test
141
141
  end
142
142
 
143
143
  master_body << child_element.copy(true)
144
- master_doc
145
144
  end
146
145
  end
147
146
 
@@ -156,4 +155,4 @@ class TestNodeEdit < Minitest::Test
156
155
  assert_equal("<test xml:base=\"http://www.rubynet.org/\">\n <num>one</num>\n <num>two</num>\n <num>three</num>\n</test>",
157
156
  @doc.root.to_s)
158
157
  end
159
- end
158
+ end
@@ -1,9 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
 
5
-
6
- class NodeCommentTest < Minitest::Test
5
+ class NodePiTest < Minitest::Test
7
6
  def setup
8
7
  xp = XML::Parser.string('<root></root>')
9
8
  @doc = xp.parse
@@ -35,5 +34,4 @@ class NodeCommentTest < Minitest::Test
35
34
  assert_equal '<root><?mypi mycontent?></root>',
36
35
  @root.to_s.gsub(/\n\s*/,'')
37
36
  end
38
-
39
37
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
 
5
5
  class TestTextNode < Minitest::Test
6
6
  def test_content
@@ -11,7 +11,7 @@ class TestTextNode < Minitest::Test
11
11
 
12
12
  def test_invalid_content
13
13
  error = assert_raises(TypeError) do
14
- node = XML::Node.new_text(nil)
14
+ XML::Node.new_text(nil)
15
15
  end
16
16
  assert_equal('wrong argument type nil (expected String)', error.to_s)
17
17
  end
@@ -23,7 +23,7 @@ class TestTextNode < Minitest::Test
23
23
  # in CDATA nodes. Or if you are sanitizing existing HTML documents and want
24
24
  # to preserve the content of any of the text nodes.
25
25
  #
26
- def test_output_escaping
26
+ def test_output_escaping
27
27
  textnoenc = 'if (a < b || c > d) return "e";'
28
28
  text = "if (a &lt; b || c &gt; d) return \"e\";"
29
29
 
@@ -45,7 +45,7 @@ class TestTextNode < Minitest::Test
45
45
  end
46
46
 
47
47
  # Just a sanity check for output escaping.
48
- def test_output_escaping_sanity
48
+ def test_output_escaping_sanity
49
49
  node = XML::Node.new_text('testdata')
50
50
  assert_equal 'text', node.name
51
51
  assert node.output_escaping?
@@ -66,5 +66,4 @@ class TestTextNode < Minitest::Test
66
66
  assert_equal 'text', node.name
67
67
  assert node.output_escaping?
68
68
  end
69
-
70
69
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
 
5
5
  class TestNodeWrite < Minitest::Test
6
6
  def setup
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  # $Id$
4
- require './test_helper'
4
+ require File.expand_path('../test_helper', __FILE__)
5
5
 
6
6
 
7
7
  class TC_XML_Node_XLink < Minitest::Test
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
  require 'stringio'
5
5
 
6
6
  class TestParser < Minitest::Test
@@ -60,7 +60,7 @@ class TestParser < Minitest::Test
60
60
  parser = XML::Parser.file(file, :encoding => XML::Encoding::ISO_8859_1)
61
61
 
62
62
  error = assert_raises(XML::Error) do
63
- doc = parser.parse
63
+ parser.parse
64
64
  end
65
65
 
66
66
  assert(error.to_s.match(/Fatal error: Extra content at the end of the document/))
@@ -210,7 +210,7 @@ class TestParser < Minitest::Test
210
210
  parser = XML::Parser.string(xml, :encoding => XML::Encoding::UTF_8)
211
211
 
212
212
  error = assert_raises(XML::Error) do
213
- doc = parser.parse
213
+ parser.parse
214
214
  end
215
215
 
216
216
  assert_equal("Fatal error: Input is not proper UTF-8, indicate encoding !\nBytes: 0xF6 0x74 0x6C 0x65 at :2.",
@@ -237,7 +237,7 @@ class TestParser < Minitest::Test
237
237
  # otherwise an exception will be thrown.
238
238
  XML::Error.set_handler {|error|}
239
239
 
240
- max_fd = if RUBY_PLATFORM.match(/mswin32|mingw/i)
240
+ max_fd = if RUBY_PLATFORM.match(/mswin32|mswin64|mingw/i)
241
241
  500
242
242
  else
243
243
  Process.getrlimit(Process::RLIMIT_NOFILE)[0] + 1
@@ -251,8 +251,9 @@ class TestParser < Minitest::Test
251
251
  end
252
252
 
253
253
  def test_open_many_files
254
+ file = File.expand_path(File.join(File.dirname(__FILE__), 'model/atom.xml'))
254
255
  1000.times do
255
- doc = XML::Parser.file('model/atom.xml').parse
256
+ XML::Parser.file(file).parse
256
257
  end
257
258
  end
258
259
 
@@ -296,7 +297,7 @@ class TestParser < Minitest::Test
296
297
  assert_nil(error.str2)
297
298
  assert_nil(error.str3)
298
299
  assert_equal(0, error.int1)
299
- assert_equal(34, error.int2)
300
+ assert_equal(20, error.int2)
300
301
  assert_nil(error.node)
301
302
  end
302
303
 
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
 
5
5
 
6
6
  class TestParserContext < Minitest::Test
@@ -100,7 +100,7 @@ class TestParserContext < Minitest::Test
100
100
 
101
101
  def test_depth
102
102
  context = XML::Parser::Context.new
103
- assert_instance_of(Fixnum, context.depth)
103
+ assert_instance_of(Integer, context.depth)
104
104
  end
105
105
 
106
106
  def test_disable_sax
@@ -171,7 +171,7 @@ class TestParserContext < Minitest::Test
171
171
 
172
172
  # Now check context
173
173
  context = xp.context
174
- assert_equal(nil, context.data_directory)
174
+ assert_nil(context.data_directory)
175
175
  assert_equal(0, context.depth)
176
176
  assert_equal(true, context.disable_sax?)
177
177
  assert_equal(false, context.docbook?)
@@ -182,7 +182,7 @@ class TestParserContext < Minitest::Test
182
182
  assert_equal(1, context.io_num_streams)
183
183
  assert_equal(true, context.keep_blanks?)
184
184
  assert_equal(1, context.io_num_streams)
185
- assert_equal(nil, context.name_node)
185
+ assert_nil(context.name_node)
186
186
  assert_equal(0, context.name_depth)
187
187
  assert_equal(10, context.name_depth_max)
188
188
  assert_equal(17, context.num_chars)
@@ -190,10 +190,10 @@ class TestParserContext < Minitest::Test
190
190
  assert_equal(1, context.space_depth)
191
191
  assert_equal(10, context.space_depth_max)
192
192
  assert_equal(false, context.subset_external?)
193
- assert_equal(nil, context.subset_external_system_id)
194
- assert_equal(nil, context.subset_external_uri)
193
+ assert_nil(context.subset_external_system_id)
194
+ assert_nil(context.subset_external_uri)
195
195
  assert_equal(false, context.subset_internal?)
196
- assert_equal(nil, context.subset_internal_name)
196
+ assert_nil(context.subset_internal_name)
197
197
  assert_equal(false, context.stats?)
198
198
  assert_equal(true, context.standalone?)
199
199
  assert_equal(false, context.valid)
@@ -201,4 +201,4 @@ class TestParserContext < Minitest::Test
201
201
  assert_equal('1.0', context.version)
202
202
  assert_equal(false, context.well_formed?)
203
203
  end
204
- end
204
+ end
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
 
5
5
 
6
6
  # attributes is deprecated - use attributes instead.
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
  require 'stringio'
5
5
 
6
6
  class TestReader < Minitest::Test
@@ -142,16 +142,16 @@ class TestReader < Minitest::Test
142
142
  assert_equal(reader.get_attribute_ns('id', 'http://www.w3.org/XML/1998/namespace'), 'abc')
143
143
  assert_equal(reader.get_attribute('bar'), 'jkl')
144
144
 
145
- assert_equal(reader.get_attribute_no(12), nil)
146
- assert_equal(reader.get_attribute('baz'), nil)
147
- assert_equal(reader.get_attribute_ns('baz', 'http://ruby/namespace'), nil)
145
+ assert_nil(reader.get_attribute_no(12))
146
+ assert_nil(reader.get_attribute('baz'))
147
+ assert_nil(reader.get_attribute_ns('baz', 'http://ruby/namespace'))
148
148
  end
149
149
 
150
150
  def test_value
151
151
  parser = XML::Reader.string("<foo><bar>1</bar><bar>2</bar><bar>3</bar></foo>")
152
152
  assert(parser.read)
153
153
  assert_equal('foo', parser.name)
154
- assert_equal(nil, parser.value)
154
+ assert_nil(parser.value)
155
155
  3.times do |i|
156
156
  assert(parser.read)
157
157
  assert_equal(XML::Reader::TYPE_ELEMENT, parser.node_type)
@@ -171,22 +171,11 @@ class TestReader < Minitest::Test
171
171
 
172
172
  # Read a node
173
173
  node = reader.expand
174
+ refute_nil(node.doc)
174
175
  assert_equal('feed', node.name)
175
176
  assert_equal(::Encoding::UTF_8, node.name.encoding) if defined?(::Encoding)
176
177
  end
177
178
 
178
- def test_expand_doc
179
- reader = XML::Reader.file(XML_FILE)
180
- reader.read.to_s
181
- reader.read
182
-
183
- # Read a node
184
- node = reader.expand
185
-
186
- # Try to access the document
187
- refute_nil(node.doc)
188
- end
189
-
190
179
  def test_expand_find
191
180
  reader = XML::Reader.file(XML_FILE)
192
181
  reader.read.to_s
@@ -231,6 +220,27 @@ class TestReader < Minitest::Test
231
220
  assert_equal('feed', node.name)
232
221
  end
233
222
 
223
+ def test_expand_incorrectly_use_returned_node
224
+ file = File.join(File.dirname(__FILE__), 'model/cwm_1_0.xml')
225
+ reader = XML::Reader.file(file)
226
+
227
+ nodes = Array.new
228
+ while reader.read
229
+ node = reader.expand
230
+ refute_nil(node)
231
+ refute_nil(node.doc)
232
+
233
+ # NOTE - DO NOT do this in real code, these nodes are invalid after the next read. This *will* cause
234
+ # a segmentation fault next time the garbage collector runs. The reason is the parent node will be
235
+ # called in the mark phase, but its underlying xml node will be gone. Same goes for calling children,
236
+ # attributes, etc. You must let go of the expanded node *before* calling xml reader again and
237
+ # call the garbage collector to be safe.
238
+ #refute_nil(node.parent)
239
+ nodes << node
240
+ end
241
+ assert(true)
242
+ end
243
+
234
244
  def test_mode
235
245
  reader = XML::Reader.string('<xml/>')
236
246
  assert_equal(XML::Reader::MODE_INITIAL, reader.read_state)
@@ -241,7 +251,7 @@ class TestReader < Minitest::Test
241
251
  def test_bytes_consumed
242
252
  reader = XML::Reader.file(XML_FILE)
243
253
  reader.read
244
- assert_equal(428, reader.byte_consumed)
254
+ assert_equal(416, reader.byte_consumed)
245
255
  end
246
256
 
247
257
  def test_node
@@ -329,7 +339,7 @@ class TestReader < Minitest::Test
329
339
 
330
340
  reader = XML::Reader.string(xml)
331
341
  error = assert_raises(XML::Error) do
332
- node = reader.read
342
+ reader.read
333
343
  end
334
344
 
335
345
  assert_equal("Fatal error: Input is not proper UTF-8, indicate encoding !\nBytes: 0xF6 0x74 0x6C 0x65 at :2.",
@@ -355,4 +365,4 @@ class TestReader < Minitest::Test
355
365
  # Encoding is always null for strings, very annoying!
356
366
  assert_equal(reader.encoding, XML::Encoding::NONE)
357
367
  end
358
- end
368
+ end
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
 
5
5
 
6
6
  class TestRelaxNG < Minitest::Test
@@ -15,7 +15,7 @@ class TestRelaxNG < Minitest::Test
15
15
 
16
16
  def relaxng
17
17
  document = XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.rng'))
18
- relaxng = XML::RelaxNG.document(document)
18
+ XML::RelaxNG.document(document)
19
19
  end
20
20
 
21
21
  def test_from_doc
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
  require 'stringio'
5
5
 
6
6
  class DocTypeCallback
@@ -243,7 +243,7 @@ EOS
243
243
  parser.callbacks = TestCaseCallbacks.new
244
244
 
245
245
  error = assert_raises(XML::Error) do
246
- doc = parser.parse
246
+ parser.parse
247
247
  end
248
248
 
249
249
  # Check callbacks
@@ -314,6 +314,6 @@ EOS
314
314
  assert_equal("Fatal error: xmlParseEntityRef: no name at :5.", error.to_s)
315
315
 
316
316
  # Check callbacks
317
- result = parser.callbacks.result
317
+ parser.callbacks.result
318
318
  end
319
319
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
3
+ require File.expand_path('../test_helper', __FILE__)
4
4
 
5
5
  class TestSchema < Minitest::Test
6
6
  def setup
@@ -90,7 +90,6 @@ class TestSchema < Minitest::Test
90
90
 
91
91
 
92
92
  # Schema meta-data tests
93
-
94
93
  def test_elements
95
94
  assert_instance_of(Hash, schema.elements)
96
95
  assert_equal(1, schema.elements.length)
@@ -103,11 +102,22 @@ class TestSchema < Minitest::Test
103
102
  assert_instance_of(XML::Schema::Type, schema.types['shiporder'])
104
103
  end
105
104
 
105
+ def test_imported_types
106
+ assert_instance_of(Hash, schema.imported_types)
107
+ assert_equal(1, schema.imported_types.length)
108
+ assert_instance_of(XML::Schema::Type, schema.types['shiporder'])
109
+ end
110
+
111
+ def test_namespaces
112
+ assert_instance_of(Array, schema.namespaces)
113
+ assert_equal(1, schema.namespaces.length)
114
+ end
115
+
106
116
  def test_schema_type
107
117
  type = schema.types['shiporder']
108
118
 
109
119
  assert_equal('shiporder', type.name)
110
- assert_equal(nil, type.namespace)
120
+ assert_nil(type.namespace)
111
121
  assert_equal("Shiporder type documentation", type.annotation)
112
122
  assert_instance_of(XML::Node, type.node)
113
123
  assert_equal(XML::Schema::Types::XML_SCHEMA_TYPE_COMPLEX, type.kind)
@@ -123,17 +133,14 @@ class TestSchema < Minitest::Test
123
133
  element = schema.types['shiporder'].elements['orderperson']
124
134
 
125
135
  assert_equal('orderperson', element.name)
126
- assert_equal(nil, element.namespace)
136
+ assert_nil(element.namespace)
127
137
  assert_equal("orderperson element documentation", element.annotation)
128
- assert_equal(1, element.min_occurs)
129
- assert_equal(1, element.max_occurs)
130
-
131
138
 
132
139
  element = schema.types['shiporder'].elements['item']
133
- assert_equal(Float::INFINITY, element.max_occurs)
140
+ assert_equal('item', element.name)
134
141
 
135
142
  element = schema.types['shiporder'].elements['item'].type.elements['note']
136
- assert_equal(0, element.min_occurs)
143
+ assert_equal('note', element.name)
137
144
  assert_equal('string', element.type.name)
138
145
  end
139
146
 
@@ -149,7 +156,7 @@ class TestSchema < Minitest::Test
149
156
  attribute = schema.types['shiporder'].attributes.first
150
157
 
151
158
  assert_equal("orderid", attribute.name)
152
- assert_equal(nil, attribute.namespace)
159
+ assert_nil(attribute.namespace)
153
160
  assert_equal(1, attribute.occurs)
154
161
  assert_equal('string', attribute.type.name)
155
162
 
@@ -158,4 +165,4 @@ class TestSchema < Minitest::Test
158
165
  assert_equal('1', attribute.default)
159
166
  assert_equal('integer', attribute.type.name)
160
167
  end
161
- end
168
+ end