libxml-ruby 2.9.0 → 3.0.0

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 (139) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +811 -790
  3. data/LICENSE +20 -20
  4. data/MANIFEST +166 -166
  5. data/README.rdoc +188 -184
  6. data/Rakefile +1 -1
  7. data/ext/libxml/libxml.c +80 -80
  8. data/ext/libxml/ruby_libxml.h +75 -75
  9. data/ext/libxml/ruby_xml.c +0 -84
  10. data/ext/libxml/ruby_xml.h +0 -10
  11. data/ext/libxml/ruby_xml_attr.h +12 -12
  12. data/ext/libxml/ruby_xml_attr_decl.c +153 -153
  13. data/ext/libxml/ruby_xml_attr_decl.h +11 -11
  14. data/ext/libxml/ruby_xml_attributes.c +275 -275
  15. data/ext/libxml/ruby_xml_attributes.h +15 -15
  16. data/ext/libxml/ruby_xml_document.c +21 -27
  17. data/ext/libxml/ruby_xml_document.h +11 -11
  18. data/ext/libxml/ruby_xml_dtd.c +2 -13
  19. data/ext/libxml/ruby_xml_dtd.h +9 -9
  20. data/ext/libxml/ruby_xml_error.c +996 -996
  21. data/ext/libxml/ruby_xml_error.h +12 -12
  22. data/ext/libxml/ruby_xml_html_parser.c +89 -92
  23. data/ext/libxml/ruby_xml_html_parser.h +10 -10
  24. data/ext/libxml/ruby_xml_html_parser_context.h +10 -10
  25. data/ext/libxml/ruby_xml_html_parser_options.c +46 -46
  26. data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
  27. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  28. data/ext/libxml/ruby_xml_io.c +0 -1
  29. data/ext/libxml/ruby_xml_io.h +10 -10
  30. data/ext/libxml/ruby_xml_namespace.c +153 -153
  31. data/ext/libxml/ruby_xml_namespace.h +10 -10
  32. data/ext/libxml/ruby_xml_namespaces.c +293 -293
  33. data/ext/libxml/ruby_xml_namespaces.h +9 -9
  34. data/ext/libxml/ruby_xml_node.c +100 -143
  35. data/ext/libxml/ruby_xml_node.h +13 -11
  36. data/ext/libxml/ruby_xml_parser.c +91 -94
  37. data/ext/libxml/ruby_xml_parser.h +12 -12
  38. data/ext/libxml/ruby_xml_parser_context.h +10 -10
  39. data/ext/libxml/ruby_xml_parser_options.c +66 -66
  40. data/ext/libxml/ruby_xml_parser_options.h +12 -12
  41. data/ext/libxml/ruby_xml_reader.c +45 -37
  42. data/ext/libxml/ruby_xml_reader.h +17 -17
  43. data/ext/libxml/ruby_xml_relaxng.h +10 -10
  44. data/ext/libxml/ruby_xml_sax2_handler.c +3 -3
  45. data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
  46. data/ext/libxml/ruby_xml_sax_parser.c +116 -120
  47. data/ext/libxml/ruby_xml_sax_parser.h +10 -10
  48. data/ext/libxml/ruby_xml_schema.h +809 -809
  49. data/ext/libxml/ruby_xml_schema_attribute.c +109 -109
  50. data/ext/libxml/ruby_xml_schema_attribute.h +15 -15
  51. data/ext/libxml/ruby_xml_schema_element.c +94 -94
  52. data/ext/libxml/ruby_xml_schema_element.h +14 -14
  53. data/ext/libxml/ruby_xml_schema_facet.c +52 -52
  54. data/ext/libxml/ruby_xml_schema_facet.h +13 -13
  55. data/ext/libxml/ruby_xml_schema_type.c +259 -259
  56. data/ext/libxml/ruby_xml_schema_type.h +9 -9
  57. data/ext/libxml/ruby_xml_version.h +9 -9
  58. data/ext/libxml/ruby_xml_writer.c +1136 -1136
  59. data/ext/libxml/ruby_xml_writer.h +10 -10
  60. data/ext/libxml/ruby_xml_xinclude.c +16 -16
  61. data/ext/libxml/ruby_xml_xinclude.h +11 -11
  62. data/ext/libxml/ruby_xml_xpath.c +42 -36
  63. data/ext/libxml/ruby_xml_xpath.h +13 -13
  64. data/ext/libxml/ruby_xml_xpath_context.c +1 -1
  65. data/ext/libxml/ruby_xml_xpath_context.h +9 -9
  66. data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
  67. data/ext/libxml/ruby_xml_xpath_expression.h +10 -10
  68. data/ext/libxml/ruby_xml_xpath_object.c +5 -2
  69. data/ext/libxml/ruby_xml_xpath_object.h +17 -17
  70. data/ext/libxml/ruby_xml_xpointer.c +99 -99
  71. data/ext/libxml/ruby_xml_xpointer.h +11 -11
  72. data/ext/vc/libxml_ruby.sln +17 -15
  73. data/lib/libxml.rb +1 -6
  74. data/lib/libxml/node.rb +2 -78
  75. data/lib/libxml/parser.rb +0 -266
  76. data/lib/libxml/sax_parser.rb +0 -17
  77. data/lib/libxml/schema.rb +66 -66
  78. data/lib/libxml/schema/attribute.rb +19 -19
  79. data/lib/libxml/schema/element.rb +27 -27
  80. data/lib/libxml/schema/type.rb +29 -29
  81. data/script/benchmark/depixelate +634 -634
  82. data/script/benchmark/hamlet.xml +9054 -9054
  83. data/script/benchmark/parsecount +170 -170
  84. data/script/benchmark/throughput +41 -41
  85. data/script/test +6 -6
  86. data/test/c14n/given/example-1.xml +14 -14
  87. data/test/c14n/given/example-2.xml +11 -11
  88. data/test/c14n/given/example-3.xml +18 -18
  89. data/test/c14n/given/example-4.xml +9 -9
  90. data/test/c14n/given/example-5.xml +12 -12
  91. data/test/c14n/given/example-6.xml +2 -2
  92. data/test/c14n/given/example-7.xml +11 -11
  93. data/test/c14n/given/example-8.xml +11 -11
  94. data/test/c14n/given/example-8.xpath +9 -9
  95. data/test/c14n/result/1-1-without-comments/example-1 +3 -3
  96. data/test/c14n/result/1-1-without-comments/example-2 +10 -10
  97. data/test/c14n/result/1-1-without-comments/example-3 +13 -13
  98. data/test/c14n/result/1-1-without-comments/example-4 +8 -8
  99. data/test/c14n/result/1-1-without-comments/example-5 +2 -2
  100. data/test/c14n/result/with-comments/example-1 +5 -5
  101. data/test/c14n/result/with-comments/example-2 +10 -10
  102. data/test/c14n/result/with-comments/example-3 +13 -13
  103. data/test/c14n/result/with-comments/example-4 +8 -8
  104. data/test/c14n/result/with-comments/example-5 +3 -3
  105. data/test/c14n/result/without-comments/example-1 +3 -3
  106. data/test/c14n/result/without-comments/example-2 +10 -10
  107. data/test/c14n/result/without-comments/example-3 +13 -13
  108. data/test/c14n/result/without-comments/example-4 +8 -8
  109. data/test/c14n/result/without-comments/example-5 +2 -2
  110. data/test/model/atom.xml +12 -12
  111. data/test/model/bands.iso-8859-1.xml +4 -4
  112. data/test/model/bands.utf-8.xml +4 -4
  113. data/test/model/bands.xml +4 -4
  114. data/test/model/books.xml +153 -153
  115. data/test/model/merge_bug_data.xml +58 -58
  116. data/test/model/ruby-lang.html +238 -238
  117. data/test/model/rubynet.xml +79 -79
  118. data/test/model/shiporder.rnc +28 -28
  119. data/test/model/shiporder.rng +86 -86
  120. data/test/model/shiporder.xml +22 -22
  121. data/test/model/shiporder.xsd +39 -39
  122. data/test/model/soap.xml +27 -27
  123. data/test/model/xinclude.xml +4 -4
  124. data/test/tc_attributes.rb +0 -6
  125. data/test/tc_error.rb +157 -158
  126. data/test/tc_node.rb +33 -17
  127. data/test/tc_node_edit.rb +0 -15
  128. data/test/tc_node_pi.rb +39 -39
  129. data/test/tc_parser.rb +0 -48
  130. data/test/tc_reader.rb +12 -53
  131. data/test/tc_writer.rb +447 -447
  132. data/test/tc_xpath.rb +1 -1
  133. data/test/test_helper.rb +2 -2
  134. metadata +3 -8
  135. data/ext/libxml/extconf.h +0 -4
  136. data/lib/libxml/ns.rb +0 -22
  137. data/lib/libxml/properties.rb +0 -23
  138. data/lib/libxml/reader.rb +0 -29
  139. data/lib/libxml/xpath_object.rb +0 -16
@@ -1,27 +1,27 @@
1
- <?xml version="1.0" encoding="utf-8"?>
2
- <soap:Envelope
3
- xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
4
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
5
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
- soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
7
- <soap:Body>
8
- <getManufacturerNamesResponse name="widgestRus" xmlns="http://services.somewhere.com">
9
- <IDAndNameList xmlns="http://services.somewhere.com">
10
- <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
11
- <id xmlns="http://domain.somewhere.com">1</id>
12
- <name xmlns="http://domain.somewhere.com">man1</name>
13
-
14
- </ns1:IdAndName>
15
- <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
16
- <id xmlns="http://domain.somewhere.com">2</id>
17
- <name xmlns="http://domain.somewhere.com">man2</name>
18
-
19
- </ns1:IdAndName>
20
- <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
21
- <id xmlns="http://domain.somewhere.com">3</id>
22
- <name xmlns="http://domain.somewhere.com">man3</name>
23
- </ns1:IdAndName>
24
- </IDAndNameList>
25
- </getManufacturerNamesResponse>
26
- </soap:Body>
27
- </soap:Envelope>
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <soap:Envelope
3
+ xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
4
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
5
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
+ soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
7
+ <soap:Body>
8
+ <getManufacturerNamesResponse name="widgestRus" xmlns="http://services.somewhere.com">
9
+ <IDAndNameList xmlns="http://services.somewhere.com">
10
+ <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
11
+ <id xmlns="http://domain.somewhere.com">1</id>
12
+ <name xmlns="http://domain.somewhere.com">man1</name>
13
+
14
+ </ns1:IdAndName>
15
+ <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
16
+ <id xmlns="http://domain.somewhere.com">2</id>
17
+ <name xmlns="http://domain.somewhere.com">man2</name>
18
+
19
+ </ns1:IdAndName>
20
+ <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com">
21
+ <id xmlns="http://domain.somewhere.com">3</id>
22
+ <name xmlns="http://domain.somewhere.com">man3</name>
23
+ </ns1:IdAndName>
24
+ </IDAndNameList>
25
+ </getManufacturerNamesResponse>
26
+ </soap:Body>
27
+ </soap:Envelope>
@@ -1,5 +1,5 @@
1
- <?xml version="1.0"?>
2
- <document xmlns:xi="http://www.w3.org/2001/XInclude">
3
- <p>This libxml2 binding has the following project information:
4
- <code><xi:include href="rubynet_project" parse="text"/></code></p>
1
+ <?xml version="1.0"?>
2
+ <document xmlns:xi="http://www.w3.org/2001/XInclude">
3
+ <p>This libxml2 binding has the following project information:
4
+ <code><xi:include href="rubynet_project" parse="text"/></code></p>
5
5
  </document>
@@ -74,12 +74,6 @@ class AttributesTest < Minitest::Test
74
74
  assert_nil(attr)
75
75
  end
76
76
 
77
- def test_property
78
- attr = city_member.property('name')
79
- assert_instance_of(String, attr)
80
- assert_equal('Cambridge', attr)
81
- end
82
-
83
77
  def test_get_values
84
78
  assert_equal('Cambridge', city_member[:name])
85
79
  assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', city_member[:href])
@@ -4,133 +4,133 @@ require './test_helper'
4
4
  require 'stringio'
5
5
 
6
6
  class TestError < Minitest::Test
7
- def test_error_codes
8
- assert_equal(4, XML::Error::DTD)
9
- assert_equal(4, XML::Error.const_get('DTD'))
10
-
11
- assert_equal(4, XML::Error::DOCUMENT_EMPTY)
12
- assert_equal(4, XML::Error.const_get('DOCUMENT_EMPTY'))
13
- end
14
-
15
- def test_invalid_handler
16
- assert_raises(RuntimeError) do
17
- XML::Error.set_handler
18
- end
19
- end
20
-
21
- def test_handler
22
- exception = nil
23
- XML::Error.set_handler do |error|
24
- exception = error
25
- end
26
-
27
- # Raise the error
28
- error = assert_raises(XML::Error) do
29
- XML::Reader.string('<foo').read
30
- end
31
- assert_equal(exception, error)
32
-
33
- # Check the handler worked
34
- refute_nil(exception)
35
- assert_kind_of(XML::Error, exception)
36
- assert_equal("Fatal error: Couldn't find end of Start Tag foo at :1.", exception.message)
37
- assert_equal(XML::Error::PARSER, exception.domain)
38
- assert_equal(XML::Error::GT_REQUIRED, exception.code)
39
- assert_equal(XML::Error::FATAL, exception.level)
40
- assert_nil(exception.file)
41
- assert_equal(1, exception.line)
42
- assert_equal('foo', exception.str1)
43
- assert_nil(exception.str2)
44
- assert_nil(exception.str3)
45
- assert_equal(0, exception.int1)
46
- assert_equal(5, exception.int2)
47
- assert_nil(exception.node)
48
- end
49
-
50
- def test_reset_handler
51
- exception = nil
52
- XML::Error.set_handler do |error|
53
- exception = error
54
- end
55
-
56
- XML::Error.reset_handler
57
- XML::Reader.string('<foo')
58
- assert_nil(exception)
59
- end
60
-
61
- def test_get_handler
62
- assert_respond_to(XML::Error, :get_handler)
63
- assert_equal(0, XML::Error.method(:get_handler).arity)
64
-
65
- saved_handler = XML::Error.get_handler
66
- XML::Error.set_handler{ puts "New handler" }
67
- refute_equal(XML::Error.get_handler, saved_handler)
68
-
69
- XML::Error.set_handler(&saved_handler)
70
- assert_equal(XML::Error.get_handler, saved_handler)
71
- end
72
-
73
- def test_verbose_handler
74
- XML::Error.set_handler(&XML::Error::VERBOSE_HANDLER)
75
- output = StringIO.new
76
- original_stderr = Object::STDERR
77
-
78
- Object.const_set(:STDERR, output)
79
- begin
80
- assert_raises(XML::Error) do
81
- XML::Parser.string('<foo><bar/></foz>').parse
82
- end
83
- ensure
84
- Object.const_set(:STDERR, original_stderr)
85
- end
86
- assert_equal("Fatal error: Opening and ending tag mismatch: foo line 1 and foz at :1.\n", output.string)
87
- end
88
-
89
- def test_no_hanlder
90
- XML::Error.reset_handler
91
- output = StringIO.new
92
- original_stderr = Object::STDERR
93
-
94
- Object.const_set(:STDERR, output)
95
- begin
96
- assert_raises(XML::Error) do
97
- XML::Parser.string('<foo><bar/></foz>').parse
98
- end
99
- ensure
100
- Object.const_set(:STDERR, original_stderr)
101
- end
102
- assert_equal('', output.string)
103
- end
104
-
105
- def test_parse_error
106
- exception = assert_raises(XML::Error) do
107
- XML::Parser.string('<foo><bar/></foz>').parse
108
- end
109
-
110
- assert_instance_of(XML::Error, exception)
111
- assert_equal("Fatal error: Opening and ending tag mismatch: foo line 1 and foz at :1.", exception.message)
112
- assert_equal(XML::Error::PARSER, exception.domain)
113
- assert_equal(XML::Error::TAG_NAME_MISMATCH, exception.code)
114
- assert_equal(XML::Error::FATAL, exception.level)
115
- assert_nil(exception.file)
116
- assert_equal(1, exception.line)
117
- end
118
-
119
- def test_xpath_error
120
- doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
121
-
122
- exception = assert_raises(XML::Error) do
123
- doc.find('/foo[bar=test')
124
- end
125
-
126
- assert_instance_of(XML::Error, exception)
127
- assert_equal("Error: Invalid predicate.", exception.message)
128
- assert_equal(XML::Error::XPATH, exception.domain)
129
- assert_equal(XML::Error::XPATH_INVALID_PREDICATE_ERROR, exception.code)
130
- assert_equal(XML::Error::ERROR, exception.level)
131
- assert_nil(exception.file)
132
- assert_nil(nil)
133
- end
7
+ # def test_error_codes
8
+ # assert_equal(4, XML::Error::DTD)
9
+ # assert_equal(4, XML::Error.const_get('DTD'))
10
+ #
11
+ # assert_equal(4, XML::Error::DOCUMENT_EMPTY)
12
+ # assert_equal(4, XML::Error.const_get('DOCUMENT_EMPTY'))
13
+ # end
14
+ #
15
+ # def test_invalid_handler
16
+ # assert_raises(RuntimeError) do
17
+ # XML::Error.set_handler
18
+ # end
19
+ # end
20
+ #
21
+ # def test_handler
22
+ # exception = nil
23
+ # XML::Error.set_handler do |error|
24
+ # exception = error
25
+ # end
26
+ #
27
+ # # Raise the error
28
+ # error = assert_raises(XML::Error) do
29
+ # XML::Reader.string('<foo').read
30
+ # end
31
+ # assert_equal(exception, error)
32
+ #
33
+ # # Check the handler worked
34
+ # refute_nil(exception)
35
+ # assert_kind_of(XML::Error, exception)
36
+ # assert_equal("Fatal error: Couldn't find end of Start Tag foo at :1.", exception.message)
37
+ # assert_equal(XML::Error::PARSER, exception.domain)
38
+ # assert_equal(XML::Error::GT_REQUIRED, exception.code)
39
+ # assert_equal(XML::Error::FATAL, exception.level)
40
+ # assert_nil(exception.file)
41
+ # assert_equal(1, exception.line)
42
+ # assert_equal('foo', exception.str1)
43
+ # assert_nil(exception.str2)
44
+ # assert_nil(exception.str3)
45
+ # assert_equal(0, exception.int1)
46
+ # assert_equal(5, exception.int2)
47
+ # assert_nil(exception.node)
48
+ # end
49
+ #
50
+ # def test_reset_handler
51
+ # exception = nil
52
+ # XML::Error.set_handler do |error|
53
+ # exception = error
54
+ # end
55
+ #
56
+ # XML::Error.reset_handler
57
+ # XML::Reader.string('<foo')
58
+ # assert_nil(exception)
59
+ # end
60
+ #
61
+ # def test_get_handler
62
+ # assert_respond_to(XML::Error, :get_handler)
63
+ # assert_equal(0, XML::Error.method(:get_handler).arity)
64
+ #
65
+ # saved_handler = XML::Error.get_handler
66
+ # XML::Error.set_handler{ puts "New handler" }
67
+ # refute_equal(XML::Error.get_handler, saved_handler)
68
+ #
69
+ # XML::Error.set_handler(&saved_handler)
70
+ # assert_equal(XML::Error.get_handler, saved_handler)
71
+ # end
72
+ #
73
+ # def test_verbose_handler
74
+ # XML::Error.set_handler(&XML::Error::VERBOSE_HANDLER)
75
+ # output = StringIO.new
76
+ # original_stderr = Object::STDERR
77
+ #
78
+ # Object.const_set(:STDERR, output)
79
+ # begin
80
+ # assert_raises(XML::Error) do
81
+ # XML::Parser.string('<foo><bar/></foz>').parse
82
+ # end
83
+ # ensure
84
+ # Object.const_set(:STDERR, original_stderr)
85
+ # end
86
+ # assert_equal("Fatal error: Opening and ending tag mismatch: foo line 1 and foz at :1.\n", output.string)
87
+ # end
88
+ #
89
+ # def test_no_hanlder
90
+ # XML::Error.reset_handler
91
+ # output = StringIO.new
92
+ # original_stderr = Object::STDERR
93
+ #
94
+ # Object.const_set(:STDERR, output)
95
+ # begin
96
+ # assert_raises(XML::Error) do
97
+ # XML::Parser.string('<foo><bar/></foz>').parse
98
+ # end
99
+ # ensure
100
+ # Object.const_set(:STDERR, original_stderr)
101
+ # end
102
+ # assert_equal('', output.string)
103
+ # end
104
+ #
105
+ # def test_parse_error
106
+ # exception = assert_raises(XML::Error) do
107
+ # XML::Parser.string('<foo><bar/></foz>').parse
108
+ # end
109
+ #
110
+ # assert_instance_of(XML::Error, exception)
111
+ # assert_equal("Fatal error: Opening and ending tag mismatch: foo line 1 and foz at :1.", exception.message)
112
+ # assert_equal(XML::Error::PARSER, exception.domain)
113
+ # assert_equal(XML::Error::TAG_NAME_MISMATCH, exception.code)
114
+ # assert_equal(XML::Error::FATAL, exception.level)
115
+ # assert_nil(exception.file)
116
+ # assert_equal(1, exception.line)
117
+ # end
118
+ #
119
+ # def test_xpath_error
120
+ # doc = XML::Document.file(File.join(File.dirname(__FILE__), 'model/soap.xml'))
121
+ #
122
+ # exception = assert_raises(XML::Error) do
123
+ # doc.find('/foo[bar=test')
124
+ # end
125
+ #
126
+ # assert_instance_of(XML::Error, exception)
127
+ # assert_equal("Error: Invalid predicate.", exception.message)
128
+ # assert_equal(XML::Error::XPATH, exception.domain)
129
+ # assert_equal(XML::Error::XPATH_INVALID_PREDICATE_ERROR, exception.code)
130
+ # assert_equal(XML::Error::ERROR, exception.level)
131
+ # assert_nil(exception.file)
132
+ # assert_nil(nil)
133
+ # end
134
134
 
135
135
  def test_double_parse
136
136
  XML::Parser.register_error_handler(lambda {|msg| nil })
@@ -145,35 +145,34 @@ class TestError < Minitest::Test
145
145
  assert_equal(" LibXML::XML::Error.", error.to_s)
146
146
  end
147
147
 
148
- def test_libxml_parser_empty_string
149
- xp = XML::Parser.new
150
-
151
- error = assert_raises(TypeError) do
152
- xp.string = nil
153
- end
154
- assert_equal('wrong argument type nil (expected String)', error.to_s)
155
-
156
- error = assert_raises(ArgumentError) do
157
- xp.string = ''
158
- end
159
- assert_equal('Must specify a string with one or more characters', error.to_s)
160
- end
161
-
162
- def test_error_domain_to_s
163
- exception = assert_raises(XML::Error) do
164
- XML::Parser.string('<foo href="http://example.org/cgi?k1=v1&k2=v2"></foo>').parse
165
- end
166
-
167
- assert_equal(XML::Error::PARSER, exception.domain)
168
- assert_equal("PARSER",exception.domain_to_s)
169
- end
170
-
171
- def test_error_code_to_s
172
- exception = assert_raises(XML::Error) do
173
- XML::Parser.string('<foo href="http://example.org/cgi?k1=v1&k2=v2"></foo>').parse
174
- end
175
- assert_equal(XML::Error::ENTITYREF_SEMICOL_MISSING, exception.code)
176
- assert_equal("ENTITYREF_SEMICOL_MISSING",exception.code_to_s)
177
- end
178
-
148
+ # def test_libxml_parser_empty_string
149
+ # xp = XML::Parser.new
150
+ #
151
+ # error = assert_raises(TypeError) do
152
+ # xp.string = nil
153
+ # end
154
+ # assert_equal('wrong argument type nil (expected String)', error.to_s)
155
+ #
156
+ # error = assert_raises(ArgumentError) do
157
+ # xp.string = ''
158
+ # end
159
+ # assert_equal('Must specify a string with one or more characters', error.to_s)
160
+ # end
161
+ #
162
+ # def test_error_domain_to_s
163
+ # exception = assert_raises(XML::Error) do
164
+ # XML::Parser.string('<foo href="http://example.org/cgi?k1=v1&k2=v2"></foo>').parse
165
+ # end
166
+ #
167
+ # assert_equal(XML::Error::PARSER, exception.domain)
168
+ # assert_equal("PARSER",exception.domain_to_s)
169
+ # end
170
+ #
171
+ # def test_error_code_to_s
172
+ # exception = assert_raises(XML::Error) do
173
+ # XML::Parser.string('<foo href="http://example.org/cgi?k1=v1&k2=v2"></foo>').parse
174
+ # end
175
+ # assert_equal(XML::Error::ENTITYREF_SEMICOL_MISSING, exception.code)
176
+ # assert_equal("ENTITYREF_SEMICOL_MISSING",exception.code_to_s)
177
+ # end
179
178
  end
@@ -71,7 +71,7 @@ class TestNode < Minitest::Test
71
71
  assert_instance_of(XML::Document, n.doc) if n.document?
72
72
  end
73
73
  end
74
-
74
+
75
75
  def test_name
76
76
  node = @doc.root.children.last
77
77
  assert_equal("iron_maiden", node.name)
@@ -84,23 +84,39 @@ class TestNode < Minitest::Test
84
84
  end
85
85
  end
86
86
 
87
- def test_equality
87
+ def test_equality
88
88
  node_a = @doc.find_first('*[@country]')
89
89
  node_b = @doc.root.child
90
90
 
91
+ # On the ruby side these are different objects
92
+ refute(node_a.equal?(node_b))
93
+
94
+ # But they are the same underlying libxml node so specify they are equal
91
95
  assert(node_a == node_b)
92
96
  assert(node_a.eql?(node_b))
93
- assert(node_a.equal?(node_b))
94
97
 
95
98
  file = File.join(File.dirname(__FILE__), @file_name)
96
99
  doc2 = XML::Document.file(file)
97
100
 
98
101
  node_a2 = doc2.find_first('*[@country]')
99
102
 
103
+ refute(node_a == node_a2)
104
+ refute(node_a.eql?(node_a2))
100
105
  assert_equal(node_a.to_s, node_a2.to_s)
101
- assert_equal(node_a, node_a2)
102
- assert(node_a.eql?(node_a2))
103
- assert(!node_a.equal?(node_a2))
106
+ refute(node_a.equal?(node_a2))
107
+ end
108
+
109
+ def test_equality_2
110
+ parent = XML::Node.new('parent')
111
+ child = XML::Node.new('child')
112
+ parent << child
113
+
114
+ node_a = child.parent
115
+ node_b = child.parent
116
+ # In this case the nodes are equal - the parent being the root
117
+ assert(node_a.equal?(node_b))
118
+ assert(node_a == node_b)
119
+ assert(node_a.eql?(node_b))
104
120
  end
105
121
 
106
122
  def test_equality_nil
@@ -127,14 +143,14 @@ class TestNode < Minitest::Test
127
143
  assert_nil(doc.root.base_uri)
128
144
  end
129
145
 
130
- # We use the same facility that libXSLT does here to disable output escaping.
131
- # This lets you specify that the node's content should be rendered unaltered
132
- # whenever it is being output. This is useful for things like <script> and
133
- # <style> nodes in HTML documents if you don't want to be forced to wrap them
134
- # in CDATA nodes. Or if you are sanitizing existing HTML documents and want
135
- # to preserve the content of any of the text nodes.
136
- #
137
- def test_output_escaping
146
+ # We use the same facility that libXSLT does here to disable output escaping.
147
+ # This lets you specify that the node's content should be rendered unaltered
148
+ # whenever it is being output. This is useful for things like <script> and
149
+ # <style> nodes in HTML documents if you don't want to be forced to wrap them
150
+ # in CDATA nodes. Or if you are sanitizing existing HTML documents and want
151
+ # to preserve the content of any of the text nodes.
152
+ #
153
+ def test_output_escaping
138
154
  text = '<bad-script>if (a &lt; b || b &gt; c) { return "text"; }<stop/>return "&gt;&gt;&gt;snip&lt;&lt;&lt;";</bad-script>'
139
155
  node = XML::Parser.string(text).parse.root
140
156
  assert_equal text, node.to_s
@@ -153,8 +169,8 @@ class TestNode < Minitest::Test
153
169
  assert_equal text, node.to_s
154
170
  end
155
171
 
156
- # Just a sanity check for output escaping.
157
- def test_output_escaping_sanity
172
+ # Just a sanity check for output escaping.
173
+ def test_output_escaping_sanity
158
174
  text = '<bad-script>if (a &lt; b || b &gt; c) { return "text"; }<stop/>return "&gt;&gt;&gt;snip&lt;&lt;&lt;";</bad-script>'
159
175
  node = XML::Parser.string(text).parse.root
160
176
  affected = node.find('//text()')
@@ -201,7 +217,7 @@ class TestNode < Minitest::Test
201
217
 
202
218
  node = doc.root
203
219
  assert(!node.empty?)
204
-
220
+
205
221
  text_node = node.first
206
222
  assert(text_node.empty?)
207
223
  end