libxml-ruby 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +8 -0
  3. data/ext/libxml/extconf.h +3 -0
  4. data/ext/libxml/extconf.rb +30 -26
  5. data/ext/libxml/ruby_libxml.h +0 -8
  6. data/ext/libxml/ruby_xml.c +40 -0
  7. data/ext/libxml/ruby_xml_document.c +1 -1
  8. data/ext/libxml/ruby_xml_dtd.c +6 -8
  9. data/ext/libxml/ruby_xml_node.c +1 -1
  10. data/ext/libxml/ruby_xml_parser_context.c +1 -1
  11. data/ext/libxml/ruby_xml_version.h +3 -3
  12. data/lib/libxml-ruby.rb +30 -0
  13. data/lib/libxml.rb +3 -28
  14. data/libxml-ruby.gemspec +2 -2
  15. data/test/test_attr.rb +18 -18
  16. data/test/test_attr_decl.rb +8 -8
  17. data/test/test_attributes.rb +10 -10
  18. data/test/test_canonicalize.rb +16 -24
  19. data/test/test_deprecated_require.rb +3 -3
  20. data/test/test_document.rb +118 -112
  21. data/test/test_document_write.rb +39 -88
  22. data/test/test_dtd.rb +23 -23
  23. data/test/test_encoding.rb +15 -15
  24. data/test/test_encoding_sax.rb +3 -3
  25. data/test/test_error.rb +51 -51
  26. data/test/test_helper.rb +2 -9
  27. data/test/test_html_parser.rb +30 -30
  28. data/test/test_html_parser_context.rb +6 -6
  29. data/test/test_namespace.rb +16 -16
  30. data/test/test_namespaces.rb +25 -25
  31. data/test/test_node.rb +36 -30
  32. data/test/test_node_cdata.rb +10 -10
  33. data/test/test_node_comment.rb +6 -6
  34. data/test/test_node_copy.rb +2 -2
  35. data/test/test_node_edit.rb +16 -16
  36. data/test/test_node_pi.rb +7 -7
  37. data/test/test_node_text.rb +6 -6
  38. data/test/test_node_write.rb +16 -26
  39. data/test/test_node_xlink.rb +6 -6
  40. data/test/test_parser.rb +68 -72
  41. data/test/test_parser_context.rb +28 -28
  42. data/test/test_properties.rb +5 -5
  43. data/test/test_reader.rb +80 -85
  44. data/test/test_relaxng.rb +11 -11
  45. data/test/test_sax_parser.rb +28 -28
  46. data/test/test_schema.rb +24 -24
  47. data/test/test_suite.rb +3 -4
  48. data/test/test_traversal.rb +4 -4
  49. data/test/test_writer.rb +50 -52
  50. data/test/test_xinclude.rb +3 -3
  51. data/test/test_xml.rb +114 -102
  52. data/test/test_xpath.rb +22 -22
  53. data/test/test_xpath_context.rb +5 -5
  54. data/test/test_xpath_expression.rb +6 -6
  55. data/test/test_xpointer.rb +15 -15
  56. metadata +6 -5
@@ -1,12 +1,12 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
 
6
6
  class TestRelaxNG < Minitest::Test
7
7
  def setup
8
8
  file = File.join(File.dirname(__FILE__), 'model/shiporder.xml')
9
- @doc = XML::Document.file(file)
9
+ @doc = LibXML::XML::Document.file(file)
10
10
  end
11
11
 
12
12
  def teardown
@@ -14,12 +14,12 @@ class TestRelaxNG < Minitest::Test
14
14
  end
15
15
 
16
16
  def relaxng
17
- document = XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.rng'))
18
- XML::RelaxNG.document(document)
17
+ document = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.rng'))
18
+ LibXML::XML::RelaxNG.document(document)
19
19
  end
20
20
 
21
21
  def test_from_doc
22
- assert_instance_of(XML::RelaxNG, relaxng)
22
+ assert_instance_of(LibXML::XML::RelaxNG, relaxng)
23
23
  end
24
24
 
25
25
  def test_valid
@@ -27,19 +27,19 @@ class TestRelaxNG < Minitest::Test
27
27
  end
28
28
 
29
29
  def test_invalid
30
- new_node = XML::Node.new('invalid', 'this will mess up validation')
30
+ new_node = LibXML::XML::Node.new('invalid', 'this will mess up validation')
31
31
  @doc.root << new_node
32
32
 
33
- error = assert_raises(XML::Error) do
33
+ error = assert_raises(LibXML::XML::Error) do
34
34
  @doc.validate_relaxng(relaxng)
35
35
  end
36
36
 
37
37
  refute_nil(error)
38
- assert_kind_of(XML::Error, error)
38
+ assert_kind_of(LibXML::XML::Error, error)
39
39
  assert(error.message.match(/Error: Did not expect element invalid there/))
40
- assert_equal(XML::Error::RELAXNGV, error.domain)
41
- assert_equal(XML::Error::LT_IN_ATTRIBUTE, error.code)
42
- assert_equal(XML::Error::ERROR, error.level)
40
+ assert_equal(LibXML::XML::Error::RELAXNGV, error.domain)
41
+ assert_equal(LibXML::XML::Error::LT_IN_ATTRIBUTE, error.code)
42
+ assert_equal(LibXML::XML::Error::ERROR, error.level)
43
43
  assert(error.file.match(/shiporder\.xml/))
44
44
  assert_nil(error.line)
45
45
  assert_equal('invalid', error.str1)
@@ -1,16 +1,16 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
  require 'stringio'
5
5
 
6
6
  class DocTypeCallback
7
- include XML::SaxParser::Callbacks
7
+ include LibXML::XML::SaxParser::Callbacks
8
8
  def on_start_element(element, attributes)
9
9
  end
10
10
  end
11
11
 
12
12
  class TestCaseCallbacks
13
- include XML::SaxParser::Callbacks
13
+ include LibXML::XML::SaxParser::Callbacks
14
14
 
15
15
  attr_accessor :result
16
16
 
@@ -119,20 +119,20 @@ class TestSaxParser < Minitest::Test
119
119
  end
120
120
 
121
121
  def test_file
122
- parser = XML::SaxParser.file(saxtest_file)
122
+ parser = LibXML::XML::SaxParser.file(saxtest_file)
123
123
  parser.callbacks = TestCaseCallbacks.new
124
124
  parser.parse
125
125
  verify(parser)
126
126
  end
127
127
 
128
128
  def test_file_no_callbacks
129
- parser = XML::SaxParser.file(saxtest_file)
129
+ parser = LibXML::XML::SaxParser.file(saxtest_file)
130
130
  assert_equal true, parser.parse
131
131
  end
132
132
 
133
133
  def test_noexistent_file
134
- error = assert_raises(XML::Error) do
135
- XML::SaxParser.file('i_dont_exist.xml')
134
+ error = assert_raises(LibXML::XML::Error) do
135
+ LibXML::XML::SaxParser.file('i_dont_exist.xml')
136
136
  end
137
137
 
138
138
  assert_equal('Warning: failed to load external entity "i_dont_exist.xml".', error.to_s)
@@ -140,7 +140,7 @@ class TestSaxParser < Minitest::Test
140
140
 
141
141
  def test_nil_file
142
142
  error = assert_raises(TypeError) do
143
- XML::SaxParser.file(nil)
143
+ LibXML::XML::SaxParser.file(nil)
144
144
  end
145
145
 
146
146
  assert_match(/nil into String/, error.to_s)
@@ -148,7 +148,7 @@ class TestSaxParser < Minitest::Test
148
148
 
149
149
  def test_io
150
150
  File.open(saxtest_file) do |file|
151
- parser = XML::SaxParser.io(file)
151
+ parser = LibXML::XML::SaxParser.io(file)
152
152
  parser.callbacks = TestCaseCallbacks.new
153
153
  parser.parse
154
154
  verify(parser)
@@ -157,7 +157,7 @@ class TestSaxParser < Minitest::Test
157
157
 
158
158
  def test_nil_io
159
159
  error = assert_raises(TypeError) do
160
- XML::HTMLParser.io(nil)
160
+ LibXML::XML::HTMLParser.io(nil)
161
161
  end
162
162
 
163
163
  assert_equal("Must pass in an IO object", error.to_s)
@@ -165,13 +165,13 @@ class TestSaxParser < Minitest::Test
165
165
 
166
166
  def test_string_no_callbacks
167
167
  xml = File.read(saxtest_file)
168
- parser = XML::SaxParser.string(xml)
168
+ parser = LibXML::XML::SaxParser.string(xml)
169
169
  assert_equal true, parser.parse
170
170
  end
171
171
 
172
172
  def test_string
173
173
  xml = File.read(saxtest_file)
174
- parser = XML::SaxParser.string(xml)
174
+ parser = LibXML::XML::SaxParser.string(xml)
175
175
  parser.callbacks = TestCaseCallbacks.new
176
176
  parser.parse
177
177
  verify(parser)
@@ -180,7 +180,7 @@ class TestSaxParser < Minitest::Test
180
180
  def test_string_io
181
181
  xml = File.read(saxtest_file)
182
182
  io = StringIO.new(xml)
183
- parser = XML::SaxParser.io(io)
183
+ parser = LibXML::XML::SaxParser.io(io)
184
184
 
185
185
  parser.callbacks = TestCaseCallbacks.new
186
186
  parser.parse
@@ -189,7 +189,7 @@ class TestSaxParser < Minitest::Test
189
189
 
190
190
  def test_nil_string
191
191
  error = assert_raises(TypeError) do
192
- XML::SaxParser.string(nil)
192
+ LibXML::XML::SaxParser.string(nil)
193
193
  end
194
194
 
195
195
  assert_equal("wrong argument type nil (expected String)", error.to_s)
@@ -203,7 +203,7 @@ class TestSaxParser < Minitest::Test
203
203
  <a>a1</a>
204
204
  </Results>
205
205
  EOS
206
- parser = XML::SaxParser.string(xml)
206
+ parser = LibXML::XML::SaxParser.string(xml)
207
207
  parser.callbacks = DocTypeCallback.new
208
208
  doc = parser.parse
209
209
  refute_nil(doc)
@@ -217,7 +217,7 @@ EOS
217
217
  <Test/>
218
218
  EOS
219
219
 
220
- parser = XML::SaxParser.string(xml)
220
+ parser = LibXML::XML::SaxParser.string(xml)
221
221
  parser.callbacks = TestCaseCallbacks.new
222
222
 
223
223
  parser.parse
@@ -239,10 +239,10 @@ EOS
239
239
  xml = <<-EOS
240
240
  <Results>
241
241
  EOS
242
- parser = XML::SaxParser.string(xml)
242
+ parser = LibXML::XML::SaxParser.string(xml)
243
243
  parser.callbacks = TestCaseCallbacks.new
244
244
 
245
- error = assert_raises(XML::Error) do
245
+ error = assert_raises(LibXML::XML::Error) do
246
246
  parser.parse
247
247
  end
248
248
 
@@ -254,21 +254,21 @@ EOS
254
254
  assert_equal("start_element: Results, attr: {}", result[i+=1])
255
255
  assert_equal("start_element_ns: Results, attr: {}, prefix: , uri: , ns: {}", result[i+=1])
256
256
  assert_equal("characters: \n", result[i+=1])
257
- assert_equal("error: Fatal error: Premature end of data in tag Results line 1 at :2.", result[i+=1])
257
+ assert_equal("error: Fatal error: EndTag: '</' not found at :2.", result[i+=1])
258
258
  assert_equal("end_document", result[i+=1])
259
259
 
260
260
  refute_nil(error)
261
- assert_kind_of(XML::Error, error)
262
- assert_equal("Fatal error: Premature end of data in tag Results line 1 at :2.", error.message)
263
- assert_equal(XML::Error::PARSER, error.domain)
264
- assert_equal(XML::Error::TAG_NOT_FINISHED, error.code)
265
- assert_equal(XML::Error::FATAL, error.level)
261
+ assert_kind_of(LibXML::XML::Error, error)
262
+ assert_equal("Fatal error: EndTag: '</' not found at :2.", error.message)
263
+ assert_equal(LibXML::XML::Error::PARSER, error.domain)
264
+ assert_equal(LibXML::XML::Error::LTSLASH_REQUIRED, error.code)
265
+ assert_equal(LibXML::XML::Error::FATAL, error.level)
266
266
  assert_nil(error.file)
267
267
  assert_equal(2, error.line)
268
- assert_equal('Results', error.str1)
268
+ assert_nil(error.str1)
269
269
  assert_nil(error.str2)
270
270
  assert_nil(error.str3)
271
- assert_equal(1, error.int1)
271
+ assert_equal(0, error.int1)
272
272
  assert_equal(1, error.int2)
273
273
  assert_nil(error.node)
274
274
  end
@@ -305,10 +305,10 @@ EOS
305
305
  </Products>
306
306
  EOS
307
307
 
308
- parser = XML::SaxParser.string(xml)
308
+ parser = LibXML::XML::SaxParser.string(xml)
309
309
  parser.callbacks = TestCaseCallbacks.new
310
310
 
311
- error = assert_raises(XML::Error) do
311
+ error = assert_raises(LibXML::XML::Error) do
312
312
  parser.parse
313
313
  end
314
314
  assert_equal("Fatal error: xmlParseEntityRef: no name at :5.", error.to_s)
@@ -1,11 +1,11 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
  class TestSchema < Minitest::Test
6
6
  def setup
7
7
  file = File.join(File.dirname(__FILE__), 'model/shiporder.xml')
8
- @doc = XML::Document.file(file)
8
+ @doc = LibXML::XML::Document.file(file)
9
9
  end
10
10
 
11
11
  def teardown
@@ -13,17 +13,17 @@ class TestSchema < Minitest::Test
13
13
  end
14
14
 
15
15
  def schema
16
- document = XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.xsd'))
17
- XML::Schema.document(document)
16
+ document = LibXML::XML::Document.file(File.join(File.dirname(__FILE__), 'model/shiporder.xsd'))
17
+ LibXML::XML::Schema.document(document)
18
18
  end
19
19
 
20
20
  def check_error(error)
21
21
  refute_nil(error)
22
22
  assert(error.message.match(/Error: Element 'invalid': This element is not expected. Expected is \( item \)/))
23
- assert_kind_of(XML::Error, error)
24
- assert_equal(XML::Error::SCHEMASV, error.domain)
25
- assert_equal(XML::Error::SCHEMAV_ELEMENT_CONTENT, error.code)
26
- assert_equal(XML::Error::ERROR, error.level)
23
+ assert_kind_of(LibXML::XML::Error, error)
24
+ assert_equal(LibXML::XML::Error::SCHEMASV, error.domain)
25
+ assert_equal(LibXML::XML::Error::SCHEMAV_ELEMENT_CONTENT, error.code)
26
+ assert_equal(LibXML::XML::Error::ERROR, error.level)
27
27
  assert(error.file.match(/shiporder.xml/)) if error.file
28
28
  assert_nil(error.str1)
29
29
  assert_nil(error.str2)
@@ -33,7 +33,7 @@ class TestSchema < Minitest::Test
33
33
  end
34
34
 
35
35
  def test_load_from_doc
36
- assert_instance_of(XML::Schema, schema)
36
+ assert_instance_of(LibXML::XML::Schema, schema)
37
37
  end
38
38
 
39
39
  def test_doc_valid
@@ -41,10 +41,10 @@ class TestSchema < Minitest::Test
41
41
  end
42
42
 
43
43
  def test_doc_invalid
44
- new_node = XML::Node.new('invalid', 'this will mess up validation')
44
+ new_node = LibXML::XML::Node.new('invalid', 'this will mess up validation')
45
45
  @doc.root << new_node
46
46
 
47
- error = assert_raises(XML::Error) do
47
+ error = assert_raises(LibXML::XML::Error) do
48
48
  @doc.validate_schema(schema)
49
49
  end
50
50
 
@@ -55,7 +55,7 @@ class TestSchema < Minitest::Test
55
55
  end
56
56
 
57
57
  def test_reader_valid
58
- reader = XML::Reader.string(@doc.to_s)
58
+ reader = LibXML::XML::Reader.string(@doc.to_s)
59
59
  assert(reader.schema_validate(schema))
60
60
 
61
61
  while reader.read
@@ -65,13 +65,13 @@ class TestSchema < Minitest::Test
65
65
  def test_reader_invalid
66
66
  # Set error handler
67
67
  errors = Array.new
68
- XML::Error.set_handler do |error|
68
+ LibXML::XML::Error.set_handler do |error|
69
69
  errors << error
70
70
  end
71
71
 
72
- new_node = XML::Node.new('invalid', 'this will mess up validation')
72
+ new_node = LibXML::XML::Node.new('invalid', 'this will mess up validation')
73
73
  @doc.root << new_node
74
- reader = XML::Reader.string(@doc.to_s)
74
+ reader = LibXML::XML::Reader.string(@doc.to_s)
75
75
 
76
76
  # Set a schema
77
77
  assert(reader.schema_validate(schema))
@@ -85,7 +85,7 @@ class TestSchema < Minitest::Test
85
85
  check_error(error)
86
86
  assert_equal(21, error.line)
87
87
  ensure
88
- XML::Error.set_handler(&LibXML::XML::Error::VERBOSE_HANDLER)
88
+ LibXML::XML::Error.set_handler(&LibXML::XML::Error::VERBOSE_HANDLER)
89
89
  end
90
90
 
91
91
 
@@ -93,19 +93,19 @@ class TestSchema < Minitest::Test
93
93
  def test_elements
94
94
  assert_instance_of(Hash, schema.elements)
95
95
  assert_equal(1, schema.elements.length)
96
- assert_instance_of(XML::Schema::Element, schema.elements['shiporder'])
96
+ assert_instance_of(LibXML::XML::Schema::Element, schema.elements['shiporder'])
97
97
  end
98
98
 
99
99
  def test_types
100
100
  assert_instance_of(Hash, schema.types)
101
101
  assert_equal(1, schema.types.length)
102
- assert_instance_of(XML::Schema::Type, schema.types['shiporder'])
102
+ assert_instance_of(LibXML::XML::Schema::Type, schema.types['shiporder'])
103
103
  end
104
104
 
105
105
  def test_imported_types
106
106
  assert_instance_of(Hash, schema.imported_types)
107
107
  assert_equal(1, schema.imported_types.length)
108
- assert_instance_of(XML::Schema::Type, schema.types['shiporder'])
108
+ assert_instance_of(LibXML::XML::Schema::Type, schema.types['shiporder'])
109
109
  end
110
110
 
111
111
  def test_namespaces
@@ -119,11 +119,11 @@ class TestSchema < Minitest::Test
119
119
  assert_equal('shiporder', type.name)
120
120
  assert_nil(type.namespace)
121
121
  assert_equal("Shiporder type documentation", type.annotation)
122
- assert_instance_of(XML::Node, type.node)
123
- assert_equal(XML::Schema::Types::XML_SCHEMA_TYPE_COMPLEX, type.kind)
124
- assert_instance_of(XML::Schema::Type, type.base)
122
+ assert_instance_of(LibXML::XML::Node, type.node)
123
+ assert_equal(LibXML::XML::Schema::Types::XML_SCHEMA_TYPE_COMPLEX, type.kind)
124
+ assert_instance_of(LibXML::XML::Schema::Type, type.base)
125
125
  assert_equal("anyType", type.base.name)
126
- assert_equal(XML::Schema::Types::XML_SCHEMA_TYPE_BASIC, type.base.kind)
126
+ assert_equal(LibXML::XML::Schema::Types::XML_SCHEMA_TYPE_BASIC, type.base.kind)
127
127
 
128
128
  assert_instance_of(Hash, type.elements)
129
129
  assert_equal(3, type.elements.length)
@@ -149,7 +149,7 @@ class TestSchema < Minitest::Test
149
149
 
150
150
  assert_instance_of(Array, type.attributes)
151
151
  assert_equal(2, type.attributes.length)
152
- assert_instance_of(XML::Schema::Attribute, type.attributes.first)
152
+ assert_instance_of(LibXML::XML::Schema::Attribute, type.attributes.first)
153
153
  end
154
154
 
155
155
  def test_schema_attribute
@@ -40,10 +40,9 @@ require './test_xpath_context'
40
40
  require './test_xpath_expression'
41
41
  require './test_xpointer'
42
42
 
43
- if defined?(Encoding)
44
- require './test_encoding'
45
- require './test_encoding_sax'
46
- end
43
+ require './test_encoding'
44
+ require './test_encoding_sax'
45
+
47
46
  # Compatibility
48
47
  require './test_properties'
49
48
  require './test_deprecated_require'
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
 
5
5
  class TestTranversal < Minitest::Test
6
6
  ROOT_NODES_LENGTH = 27
@@ -8,7 +8,7 @@ class TestTranversal < Minitest::Test
8
8
 
9
9
  def setup
10
10
  filename = File.join(File.dirname(__FILE__), 'model/books.xml')
11
- @doc = XML::Document.file(filename)
11
+ @doc = LibXML::XML::Document.file(filename)
12
12
  end
13
13
 
14
14
  def teardown
@@ -143,10 +143,10 @@ class TestTranversal < Minitest::Test
143
143
  end
144
144
 
145
145
  def test_doc_class
146
- assert_instance_of(XML::Document, @doc)
146
+ assert_instance_of(LibXML::XML::Document, @doc)
147
147
  end
148
148
 
149
149
  def test_root_class
150
- assert_instance_of(XML::Node, @doc.root)
150
+ assert_instance_of(LibXML::XML::Node, @doc.root)
151
151
  end
152
152
  end
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require File.expand_path('../test_helper', __FILE__)
3
+ require_relative './test_helper'
4
4
  require 'stringio'
5
5
 
6
6
  class TestWriter < Minitest::Test
@@ -8,32 +8,32 @@ class TestWriter < Minitest::Test
8
8
  XSL_URI = 'http://www.w3.org/1999/XSL/Transform'
9
9
 
10
10
  def test_generic_failure
11
- writer = XML::Writer.string
11
+ writer = LibXML::XML::Writer.string
12
12
  writer.start_document
13
13
  assert(!writer.end_element)
14
14
  writer.end_document
15
15
  end
16
16
 
17
17
  def test_empty_doc
18
- writer = XML::Writer.string
18
+ writer = LibXML::XML::Writer.string
19
19
  document writer
20
20
  assert_equal(writer.result.strip!, '<?xml version="1.0"?>')
21
21
 
22
- writer = XML::Writer.string
23
- document writer, { :encoding => XML::Encoding::ISO_8859_1 }
22
+ writer = LibXML::XML::Writer.string
23
+ document writer, { :encoding => LibXML::XML::Encoding::ISO_8859_1 }
24
24
  assert_equal(writer.result.strip!, '<?xml version="1.0" encoding="ISO-8859-1"?>')
25
25
 
26
- writer = XML::Writer.string
26
+ writer = LibXML::XML::Writer.string
27
27
  document writer, { :standalone => 1 }
28
28
  assert_equal(writer.result.strip!, '<?xml version="1.0" standalone="yes"?>')
29
29
 
30
- writer = XML::Writer.string
31
- document writer, { :standalone => 1, :encoding => XML::Encoding::ISO_8859_1, :foo => :bar }
30
+ writer = LibXML::XML::Writer.string
31
+ document writer, { :standalone => 1, :encoding => LibXML::XML::Encoding::ISO_8859_1, :foo => :bar }
32
32
  assert_equal(writer.result.strip!, '<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>')
33
33
  end
34
34
 
35
35
  def test_single_root
36
- writer = XML::Writer.string
36
+ writer = LibXML::XML::Writer.string
37
37
  document writer do
38
38
  element writer, 'root'
39
39
  end
@@ -44,7 +44,7 @@ class TestWriter < Minitest::Test
44
44
  def test_pi
45
45
  expected = "<?xml version=\"1.0\"?>\n<?php echo \"foo\";?>"
46
46
 
47
- writer = XML::Writer.string
47
+ writer = LibXML::XML::Writer.string
48
48
  document writer do
49
49
  assert(writer.start_pi('php'))
50
50
  assert(writer.write_string('echo "foo";'))
@@ -52,7 +52,7 @@ class TestWriter < Minitest::Test
52
52
  end
53
53
  assert_equal(writer.result.strip!, expected)
54
54
 
55
- writer = XML::Writer.string
55
+ writer = LibXML::XML::Writer.string
56
56
  document writer do
57
57
  assert(writer.write_pi('php', 'echo "foo";'))
58
58
  end
@@ -62,7 +62,7 @@ class TestWriter < Minitest::Test
62
62
  def test_comment
63
63
  expected = "<?xml version=\"1.0\"?>\n<!--foo-->"
64
64
 
65
- writer = XML::Writer.string
65
+ writer = LibXML::XML::Writer.string
66
66
  document writer do
67
67
  assert(writer.start_comment)
68
68
  assert(writer.write_string 'foo')
@@ -70,7 +70,7 @@ class TestWriter < Minitest::Test
70
70
  end
71
71
  assert_equal(writer.result.strip!, expected)
72
72
 
73
- writer = XML::Writer.string
73
+ writer = LibXML::XML::Writer.string
74
74
  document writer do
75
75
  assert(writer.write_comment 'foo')
76
76
  end
@@ -80,7 +80,7 @@ class TestWriter < Minitest::Test
80
80
  def test_cdata
81
81
  expected = "<?xml version=\"1.0\"?>\n<root><![CDATA[<?php echo $foo; ?>]]></root>"
82
82
 
83
- writer = XML::Writer.string
83
+ writer = LibXML::XML::Writer.string
84
84
  document writer do
85
85
  element writer, 'root' do
86
86
  assert(writer.start_cdata)
@@ -90,7 +90,7 @@ class TestWriter < Minitest::Test
90
90
  end
91
91
  assert_equal(writer.result.strip!, expected)
92
92
 
93
- writer = XML::Writer.string
93
+ writer = LibXML::XML::Writer.string
94
94
  document writer do
95
95
  element writer, 'root' do
96
96
  assert(writer.write_cdata '<?php echo $foo; ?>')
@@ -100,13 +100,13 @@ class TestWriter < Minitest::Test
100
100
  end
101
101
 
102
102
  def test_write_empty_elements
103
- writer = XML::Writer.string
103
+ writer = LibXML::XML::Writer.string
104
104
  document writer do
105
105
  assert(writer.write_element 'foo')
106
106
  end
107
107
  assert_equal(writer.result.strip!, "<?xml version=\"1.0\"?>\n<foo/>")
108
108
 
109
- writer = XML::Writer.string
109
+ writer = LibXML::XML::Writer.string
110
110
  document writer do
111
111
  assert(writer.write_element_ns XSL_PREFIX, 'stylesheet', XSL_URI)
112
112
  end
@@ -116,7 +116,7 @@ class TestWriter < Minitest::Test
116
116
  def test_valued_element
117
117
  expected = "<?xml version=\"1.0\"?>\n<abc>123<def>456<ghi>789</ghi>cueillir des cerises</def>nous irons au bois</abc>"
118
118
 
119
- writer = XML::Writer.string
119
+ writer = LibXML::XML::Writer.string
120
120
  document writer do
121
121
  assert(writer.start_element 'abc')
122
122
  assert(writer.write_string '123')
@@ -132,7 +132,7 @@ class TestWriter < Minitest::Test
132
132
  end
133
133
  assert_equal(writer.result.strip!, expected)
134
134
 
135
- writer = XML::Writer.string
135
+ writer = LibXML::XML::Writer.string
136
136
  document writer do
137
137
  assert(writer.start_element 'abc')
138
138
  assert(writer.write_string '123')
@@ -156,7 +156,7 @@ class TestWriter < Minitest::Test
156
156
  "</xsl:attribute-set>" +
157
157
  "</xsl:stylesheet>"
158
158
 
159
- writer = XML::Writer.string
159
+ writer = LibXML::XML::Writer.string
160
160
  document writer do
161
161
  assert(writer.start_element_ns XSL_PREFIX, 'stylesheet', XSL_URI)
162
162
  assert(writer.start_element_ns XSL_PREFIX, 'attribute-set')
@@ -171,7 +171,7 @@ class TestWriter < Minitest::Test
171
171
  end
172
172
  assert_equal(writer.result.strip!, expected)
173
173
 
174
- writer = XML::Writer.string
174
+ writer = LibXML::XML::Writer.string
175
175
  document writer do
176
176
  assert(writer.start_element_ns XSL_PREFIX, 'stylesheet', XSL_URI)
177
177
  assert(writer.start_element_ns XSL_PREFIX, 'attribute-set')
@@ -184,7 +184,7 @@ class TestWriter < Minitest::Test
184
184
  end
185
185
 
186
186
  def test_attribute
187
- writer = XML::Writer.string
187
+ writer = LibXML::XML::Writer.string
188
188
  document writer do
189
189
  element writer, 'root' do
190
190
  element writer, 'child' do
@@ -196,7 +196,7 @@ class TestWriter < Minitest::Test
196
196
  end
197
197
  assert_equal(writer.result.strip!, "<?xml version=\"1.0\"?>\n<root><child foo=\"bar\"/></root>")
198
198
 
199
- writer = XML::Writer.string
199
+ writer = LibXML::XML::Writer.string
200
200
  document writer do
201
201
  element writer, 'root' do
202
202
  element writer, 'child' do
@@ -211,7 +211,7 @@ class TestWriter < Minitest::Test
211
211
  def test_attribute_ns
212
212
  expected = "<?xml version=\"1.0\"?>\n<root><link xlink:href=\"abc\" xhtml:class=\"def\"/></root>"
213
213
 
214
- writer = XML::Writer.string
214
+ writer = LibXML::XML::Writer.string
215
215
  document writer do
216
216
  element writer, 'root' do
217
217
  element writer, 'link' do
@@ -222,7 +222,7 @@ class TestWriter < Minitest::Test
222
222
  end
223
223
  assert_equal(writer.result.strip!, expected)
224
224
 
225
- writer = XML::Writer.string
225
+ writer = LibXML::XML::Writer.string
226
226
  document writer do
227
227
  element writer, 'root' do
228
228
  element writer, 'link' do
@@ -239,8 +239,8 @@ class TestWriter < Minitest::Test
239
239
  end
240
240
 
241
241
  def test_quote_char
242
- if XML::Writer.method_defined? :set_quote_char
243
- writer = XML::Writer.string
242
+ if LibXML::XML::Writer.method_defined? :set_quote_char
243
+ writer = LibXML::XML::Writer.string
244
244
  writer.set_quote_char "'"
245
245
  document writer do
246
246
  element writer, 'root' do
@@ -254,8 +254,8 @@ class TestWriter < Minitest::Test
254
254
  end
255
255
 
256
256
  def test_indentation_on
257
- if XML::Writer.method_defined? :set_indent
258
- writer = XML::Writer.string
257
+ if LibXML::XML::Writer.method_defined? :set_indent
258
+ writer = LibXML::XML::Writer.string
259
259
  assert(writer.set_indent true)
260
260
  document writer do
261
261
  element writer, 'root' do
@@ -271,8 +271,8 @@ class TestWriter < Minitest::Test
271
271
  end
272
272
 
273
273
  def test_indentation_string
274
- if XML::Writer.method_defined? :set_indent_string
275
- writer = XML::Writer.string
274
+ if LibXML::XML::Writer.method_defined? :set_indent_string
275
+ writer = LibXML::XML::Writer.string
276
276
  assert(writer.set_indent true)
277
277
  assert(writer.set_indent_string ' ' * 4)
278
278
  document writer do
@@ -289,11 +289,11 @@ class TestWriter < Minitest::Test
289
289
  end
290
290
 
291
291
  def test_dtd_declaration
292
- writer = XML::Writer.string
292
+ writer = LibXML::XML::Writer.string
293
293
  dtd writer, 'html'
294
294
  assert_equal(writer.result, '<!DOCTYPE html>')
295
295
 
296
- writer = XML::Writer.string
296
+ writer = LibXML::XML::Writer.string
297
297
  dtd writer, 'html', '-//W3C//DTD XHTML 1.0 Strict//EN', 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
298
298
  assert_equal(writer.result, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">')
299
299
  end
@@ -301,7 +301,7 @@ class TestWriter < Minitest::Test
301
301
  def test_dtd_attlist
302
302
  expected = '<!DOCTYPE http [<!ATTLIST method (get|post) "get">]>'
303
303
 
304
- writer = XML::Writer.string
304
+ writer = LibXML::XML::Writer.string
305
305
  dtd writer, 'http' do
306
306
  assert(writer.start_dtd_attlist 'method')
307
307
  assert(writer.write_string '(get|post) "get"')
@@ -309,7 +309,7 @@ class TestWriter < Minitest::Test
309
309
  end
310
310
  assert_equal(writer.result, expected)
311
311
 
312
- writer = XML::Writer.string
312
+ writer = LibXML::XML::Writer.string
313
313
  dtd writer, 'http' do
314
314
  assert(writer.write_dtd_attlist 'method', '(get|post) "get"')
315
315
  end
@@ -319,7 +319,7 @@ class TestWriter < Minitest::Test
319
319
  def test_dtd_element
320
320
  expected = '<!DOCTYPE html [<!ELEMENT dl (dt|dd)+>]>'
321
321
 
322
- writer = XML::Writer.string
322
+ writer = LibXML::XML::Writer.string
323
323
  dtd writer, 'html' do
324
324
  assert(writer.start_dtd_element 'dl')
325
325
  assert(writer.write_string '(dt|dd)+')
@@ -327,7 +327,7 @@ class TestWriter < Minitest::Test
327
327
  end
328
328
  assert_equal(writer.result, expected)
329
329
 
330
- writer = XML::Writer.string
330
+ writer = LibXML::XML::Writer.string
331
331
  dtd writer, 'html' do
332
332
  assert(writer.write_dtd_element 'dl', '(dt|dd)+')
333
333
  end
@@ -338,7 +338,7 @@ class TestWriter < Minitest::Test
338
338
  # parameterized entity
339
339
  expected = '<!DOCTYPE html [<!ENTITY % special.pre "br | span | bdo | map"><!ENTITY % special "%special.pre; | object | img">]>'
340
340
 
341
- writer = XML::Writer.string
341
+ writer = LibXML::XML::Writer.string
342
342
  dtd writer, 'html' do
343
343
  assert(writer.start_dtd_entity 'special.pre', true)
344
344
  assert(writer.write_string 'br | span | bdo | map')
@@ -349,7 +349,7 @@ class TestWriter < Minitest::Test
349
349
  end
350
350
  assert_equal(writer.result, expected)
351
351
 
352
- writer = XML::Writer.string
352
+ writer = LibXML::XML::Writer.string
353
353
  dtd writer, 'html' do
354
354
  assert(writer.write_dtd_internal_entity 'special.pre', 'br | span | bdo | map', true)
355
355
  assert(writer.write_dtd_internal_entity 'special', '%special.pre; | object | img', true)
@@ -359,7 +359,7 @@ class TestWriter < Minitest::Test
359
359
  # non parameterized entity
360
360
  expected = '<!DOCTYPE html [<!ENTITY Alpha "&#913;">]>'
361
361
 
362
- writer = XML::Writer.string
362
+ writer = LibXML::XML::Writer.string
363
363
  dtd writer, 'html' do
364
364
  assert(writer.start_dtd_entity 'Alpha')
365
365
  assert(writer.write_string '&#913;')
@@ -367,7 +367,7 @@ class TestWriter < Minitest::Test
367
367
  end
368
368
  assert_equal(writer.result, expected)
369
369
 
370
- writer = XML::Writer.string
370
+ writer = LibXML::XML::Writer.string
371
371
  dtd writer, 'html' do
372
372
  assert(writer.start_dtd_entity 'Alpha', false)
373
373
  assert(writer.write_string '&#913;')
@@ -375,7 +375,7 @@ class TestWriter < Minitest::Test
375
375
  end
376
376
  assert_equal(writer.result, expected)
377
377
 
378
- writer = XML::Writer.string
378
+ writer = LibXML::XML::Writer.string
379
379
  dtd writer, 'html' do
380
380
  assert(writer.write_dtd_internal_entity 'Alpha', '&#913;', false)
381
381
  end
@@ -383,7 +383,7 @@ class TestWriter < Minitest::Test
383
383
  end
384
384
 
385
385
  def test_dtd_notation
386
- writer = XML::Writer.string
386
+ writer = LibXML::XML::Writer.string
387
387
  dtd writer, 'pictures' do
388
388
  assert(writer.write_dtd_notation 'GIF89a', '-//Compuserve//NOTATION Graphics Interchange Format 89a//EN', nil)
389
389
  assert(writer.write_dtd_external_entity 'pictures', nil, 'images/plage.gif', 'GIF89a', false)
@@ -392,19 +392,17 @@ class TestWriter < Minitest::Test
392
392
  end
393
393
 
394
394
  def test_encoding
395
- if defined?(Encoding)
396
- iso = 'éloïse'.encode 'ISO-8859-1'
395
+ iso = 'éloïse'.encode 'ISO-8859-1'
397
396
 
398
- writer = XML::Writer.string
399
- document writer do
400
- assert(writer.write_element iso)
401
- end
402
- assert_equal(writer.result.strip!, "<?xml version=\"1.0\"?>\n<éloïse/>")
397
+ writer = LibXML::XML::Writer.string
398
+ document writer do
399
+ assert(writer.write_element iso)
403
400
  end
401
+ assert_equal(writer.result.strip!, "<?xml version=\"1.0\"?>\n<éloïse/>")
404
402
  end
405
403
 
406
404
  def test_flush
407
- writer = XML::Writer.string
405
+ writer = LibXML::XML::Writer.string
408
406
  assert(writer.start_document)
409
407
  assert_equal(writer.flush.strip!, '<?xml version="1.0"?>')
410
408
  assert(writer.start_element 'foo')
@@ -417,7 +415,7 @@ class TestWriter < Minitest::Test
417
415
  def test_nil_pe_issue
418
416
  expected = '<!DOCTYPE html [<!ENTITY special.pre "br | span | bdo | map"><!ENTITY special "%special.pre; | object | img">]>'
419
417
 
420
- writer = XML::Writer.string
418
+ writer = LibXML::XML::Writer.string
421
419
  dtd writer, 'html' do
422
420
  assert(writer.write_dtd_internal_entity 'special.pre', 'br | span | bdo | map', nil)
423
421
  assert(writer.write_dtd_internal_entity 'special', '%special.pre; | object | img', nil)