libxml-ruby 2.8.0 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +5 -5
  2. data/HISTORY +842 -775
  3. data/LICENSE +20 -20
  4. data/MANIFEST +166 -166
  5. data/README.rdoc +217 -184
  6. data/Rakefile +90 -78
  7. data/ext/libxml/extconf.h +3 -0
  8. data/ext/libxml/extconf.rb +61 -116
  9. data/ext/libxml/libxml.c +80 -76
  10. data/ext/libxml/ruby_libxml.h +67 -75
  11. data/ext/libxml/ruby_xml.c +933 -893
  12. data/ext/libxml/ruby_xml.h +10 -10
  13. data/ext/libxml/ruby_xml_attr.c +333 -333
  14. data/ext/libxml/ruby_xml_attr.h +12 -12
  15. data/ext/libxml/ruby_xml_attr_decl.c +153 -153
  16. data/ext/libxml/ruby_xml_attr_decl.h +11 -11
  17. data/ext/libxml/ruby_xml_attributes.c +275 -275
  18. data/ext/libxml/ruby_xml_attributes.h +15 -15
  19. data/ext/libxml/ruby_xml_cbg.c +85 -85
  20. data/ext/libxml/ruby_xml_document.c +1123 -1147
  21. data/ext/libxml/ruby_xml_document.h +11 -11
  22. data/ext/libxml/ruby_xml_dtd.c +248 -268
  23. data/ext/libxml/ruby_xml_dtd.h +9 -9
  24. data/ext/libxml/ruby_xml_encoding.c +250 -260
  25. data/ext/libxml/ruby_xml_encoding.h +16 -19
  26. data/ext/libxml/ruby_xml_error.c +996 -996
  27. data/ext/libxml/ruby_xml_error.h +12 -12
  28. data/ext/libxml/ruby_xml_html_parser.c +89 -92
  29. data/ext/libxml/ruby_xml_html_parser.h +10 -10
  30. data/ext/libxml/ruby_xml_html_parser_context.c +337 -338
  31. data/ext/libxml/ruby_xml_html_parser_context.h +10 -10
  32. data/ext/libxml/ruby_xml_html_parser_options.c +46 -46
  33. data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
  34. data/ext/libxml/ruby_xml_input_cbg.c +191 -191
  35. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  36. data/ext/libxml/ruby_xml_io.c +47 -50
  37. data/ext/libxml/ruby_xml_io.h +10 -10
  38. data/ext/libxml/ruby_xml_namespace.c +153 -153
  39. data/ext/libxml/ruby_xml_namespace.h +10 -10
  40. data/ext/libxml/ruby_xml_namespaces.c +293 -293
  41. data/ext/libxml/ruby_xml_namespaces.h +9 -9
  42. data/ext/libxml/ruby_xml_node.c +1402 -1452
  43. data/ext/libxml/ruby_xml_node.h +13 -11
  44. data/ext/libxml/ruby_xml_parser.c +91 -94
  45. data/ext/libxml/ruby_xml_parser.h +12 -12
  46. data/ext/libxml/ruby_xml_parser_context.c +999 -1001
  47. data/ext/libxml/ruby_xml_parser_context.h +10 -10
  48. data/ext/libxml/ruby_xml_parser_options.c +66 -66
  49. data/ext/libxml/ruby_xml_parser_options.h +12 -12
  50. data/ext/libxml/ruby_xml_reader.c +1239 -1228
  51. data/ext/libxml/ruby_xml_reader.h +17 -17
  52. data/ext/libxml/ruby_xml_relaxng.c +110 -111
  53. data/ext/libxml/ruby_xml_relaxng.h +10 -10
  54. data/ext/libxml/ruby_xml_sax2_handler.c +326 -328
  55. data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
  56. data/ext/libxml/ruby_xml_sax_parser.c +116 -120
  57. data/ext/libxml/ruby_xml_sax_parser.h +10 -10
  58. data/ext/libxml/ruby_xml_schema.c +278 -301
  59. data/ext/libxml/ruby_xml_schema.h +809 -809
  60. data/ext/libxml/ruby_xml_schema_attribute.c +109 -109
  61. data/ext/libxml/ruby_xml_schema_attribute.h +15 -15
  62. data/ext/libxml/ruby_xml_schema_element.c +95 -94
  63. data/ext/libxml/ruby_xml_schema_element.h +14 -14
  64. data/ext/libxml/ruby_xml_schema_facet.c +52 -52
  65. data/ext/libxml/ruby_xml_schema_facet.h +13 -13
  66. data/ext/libxml/ruby_xml_schema_type.c +232 -259
  67. data/ext/libxml/ruby_xml_schema_type.h +9 -9
  68. data/ext/libxml/ruby_xml_version.h +9 -9
  69. data/ext/libxml/ruby_xml_writer.c +1133 -1137
  70. data/ext/libxml/ruby_xml_writer.h +10 -10
  71. data/ext/libxml/ruby_xml_xinclude.c +16 -16
  72. data/ext/libxml/ruby_xml_xinclude.h +11 -11
  73. data/ext/libxml/ruby_xml_xpath.c +194 -188
  74. data/ext/libxml/ruby_xml_xpath.h +13 -13
  75. data/ext/libxml/ruby_xml_xpath_context.c +360 -361
  76. data/ext/libxml/ruby_xml_xpath_context.h +9 -9
  77. data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
  78. data/ext/libxml/ruby_xml_xpath_expression.h +10 -10
  79. data/ext/libxml/ruby_xml_xpath_object.c +338 -335
  80. data/ext/libxml/ruby_xml_xpath_object.h +17 -17
  81. data/ext/libxml/ruby_xml_xpointer.c +99 -99
  82. data/ext/libxml/ruby_xml_xpointer.h +11 -11
  83. data/ext/vc/libxml_ruby.sln +17 -15
  84. data/lib/libxml-ruby.rb +30 -0
  85. data/lib/libxml.rb +3 -33
  86. data/lib/libxml/node.rb +2 -78
  87. data/lib/libxml/parser.rb +0 -266
  88. data/lib/libxml/sax_parser.rb +0 -17
  89. data/lib/libxml/schema.rb +47 -66
  90. data/lib/libxml/schema/attribute.rb +19 -19
  91. data/lib/libxml/schema/element.rb +19 -27
  92. data/lib/libxml/schema/type.rb +21 -29
  93. data/libxml-ruby.gemspec +48 -44
  94. data/script/benchmark/depixelate +634 -634
  95. data/script/benchmark/hamlet.xml +9054 -9054
  96. data/script/benchmark/parsecount +170 -170
  97. data/script/benchmark/throughput +41 -41
  98. data/script/test +6 -6
  99. data/setup.rb +0 -1
  100. data/test/c14n/given/example-1.xml +14 -14
  101. data/test/c14n/given/example-2.xml +11 -11
  102. data/test/c14n/given/example-3.xml +18 -18
  103. data/test/c14n/given/example-4.xml +9 -9
  104. data/test/c14n/given/example-5.xml +12 -12
  105. data/test/c14n/given/example-6.xml +2 -2
  106. data/test/c14n/given/example-7.xml +11 -11
  107. data/test/c14n/given/example-8.xml +11 -11
  108. data/test/c14n/given/example-8.xpath +9 -9
  109. data/test/c14n/result/1-1-without-comments/example-1 +3 -3
  110. data/test/c14n/result/1-1-without-comments/example-2 +10 -10
  111. data/test/c14n/result/1-1-without-comments/example-3 +13 -13
  112. data/test/c14n/result/1-1-without-comments/example-4 +8 -8
  113. data/test/c14n/result/1-1-without-comments/example-5 +2 -2
  114. data/test/c14n/result/with-comments/example-1 +5 -5
  115. data/test/c14n/result/with-comments/example-2 +10 -10
  116. data/test/c14n/result/with-comments/example-3 +13 -13
  117. data/test/c14n/result/with-comments/example-4 +8 -8
  118. data/test/c14n/result/with-comments/example-5 +3 -3
  119. data/test/c14n/result/without-comments/example-1 +3 -3
  120. data/test/c14n/result/without-comments/example-2 +10 -10
  121. data/test/c14n/result/without-comments/example-3 +13 -13
  122. data/test/c14n/result/without-comments/example-4 +8 -8
  123. data/test/c14n/result/without-comments/example-5 +2 -2
  124. data/test/model/atom.xml +12 -12
  125. data/test/model/bands.iso-8859-1.xml +4 -4
  126. data/test/model/bands.utf-8.xml +4 -4
  127. data/test/model/bands.xml +4 -4
  128. data/test/model/books.xml +153 -153
  129. data/test/model/cwm_1_0.xml +11336 -0
  130. data/test/model/merge_bug_data.xml +58 -58
  131. data/test/model/ruby-lang.html +238 -238
  132. data/test/model/rubynet.xml +79 -79
  133. data/test/model/shiporder.rnc +28 -28
  134. data/test/model/shiporder.rng +86 -86
  135. data/test/model/shiporder.xml +22 -22
  136. data/test/model/shiporder.xsd +39 -39
  137. data/test/model/soap.xml +27 -27
  138. data/test/model/xinclude.xml +4 -4
  139. data/test/test.xml +2 -0
  140. data/test/{tc_attr.rb → test_attr.rb} +23 -25
  141. data/test/{tc_attr_decl.rb → test_attr_decl.rb} +13 -14
  142. data/test/{tc_attributes.rb → test_attributes.rb} +11 -18
  143. data/test/{tc_canonicalize.rb → test_canonicalize.rb} +36 -41
  144. data/test/test_deprecated_require.rb +12 -0
  145. data/test/{tc_document.rb → test_document.rb} +32 -27
  146. data/test/test_document_write.rb +146 -0
  147. data/test/{tc_dtd.rb → test_dtd.rb} +28 -29
  148. data/test/{tc_encoding.rb → test_encoding.rb} +129 -126
  149. data/test/{tc_encoding_sax.rb → test_encoding_sax.rb} +7 -6
  150. data/test/test_error.rb +178 -0
  151. data/test/test_helper.rb +3 -10
  152. data/test/test_html_parser.rb +162 -0
  153. data/test/test_html_parser_context.rb +23 -0
  154. data/test/test_namespace.rb +60 -0
  155. data/test/{tc_namespaces.rb → test_namespaces.rb} +34 -44
  156. data/test/{tc_node.rb → test_node.rb} +68 -47
  157. data/test/{tc_node_cdata.rb → test_node_cdata.rb} +12 -13
  158. data/test/{tc_node_comment.rb → test_node_comment.rb} +7 -8
  159. data/test/{tc_node_copy.rb → test_node_copy.rb} +4 -6
  160. data/test/{tc_node_edit.rb → test_node_edit.rb} +23 -41
  161. data/test/{tc_node_pi.rb → test_node_pi.rb} +37 -40
  162. data/test/{tc_node_text.rb → test_node_text.rb} +10 -12
  163. data/test/{tc_node_write.rb → test_node_write.rb} +18 -29
  164. data/test/test_node_xlink.rb +28 -0
  165. data/test/test_parser.rb +324 -0
  166. data/test/{tc_parser_context.rb → test_parser_context.rb} +41 -42
  167. data/test/{tc_properties.rb → test_properties.rb} +6 -7
  168. data/test/test_reader.rb +363 -0
  169. data/test/test_relaxng.rb +53 -0
  170. data/test/{tc_sax_parser.rb → test_sax_parser.rb} +36 -37
  171. data/test/{tc_schema.rb → test_schema.rb} +43 -37
  172. data/test/test_suite.rb +38 -40
  173. data/test/{tc_traversal.rb → test_traversal.rb} +5 -6
  174. data/test/{tc_writer.rb → test_writer.rb} +468 -448
  175. data/test/{tc_xinclude.rb → test_xinclude.rb} +4 -5
  176. data/test/test_xml.rb +262 -0
  177. data/test/{tc_xpath.rb → test_xpath.rb} +31 -32
  178. data/test/{tc_xpath_context.rb → test_xpath_context.rb} +8 -9
  179. data/test/test_xpath_expression.rb +37 -0
  180. data/test/{tc_xpointer.rb → test_xpointer.rb} +16 -18
  181. metadata +117 -95
  182. data/lib/libxml/ns.rb +0 -22
  183. data/lib/libxml/properties.rb +0 -23
  184. data/lib/libxml/reader.rb +0 -29
  185. data/lib/libxml/xpath_object.rb +0 -16
  186. data/test/etc_doc_to_s.rb +0 -21
  187. data/test/ets_doc_file.rb +0 -17
  188. data/test/ets_doc_to_s.rb +0 -23
  189. data/test/ets_gpx.rb +0 -28
  190. data/test/ets_node_gc.rb +0 -23
  191. data/test/ets_test.xml +0 -2
  192. data/test/ets_tsr.rb +0 -11
  193. data/test/tc_deprecated_require.rb +0 -13
  194. data/test/tc_document_write.rb +0 -196
  195. data/test/tc_error.rb +0 -180
  196. data/test/tc_html_parser.rb +0 -153
  197. data/test/tc_html_parser_context.rb +0 -24
  198. data/test/tc_namespace.rb +0 -62
  199. data/test/tc_node_xlink.rb +0 -29
  200. data/test/tc_parser.rb +0 -381
  201. data/test/tc_reader.rb +0 -400
  202. data/test/tc_relaxng.rb +0 -54
  203. data/test/tc_xml.rb +0 -226
  204. data/test/tc_xpath_expression.rb +0 -38
@@ -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>
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Name>François</Name>
@@ -1,11 +1,10 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
4
- require 'test/unit'
3
+ require_relative './test_helper'
5
4
 
6
- class AttrNodeTest < Test::Unit::TestCase
5
+ class AttrNodeTest < Minitest::Test
7
6
  def setup
8
- xp = XML::Parser.string(<<-EOS)
7
+ xp = LibXML::XML::Parser.string(<<-EOS)
9
8
  <CityModel
10
9
  xmlns="http://www.opengis.net/examples"
11
10
  xmlns:city="http://www.opengis.net/examples"
@@ -27,7 +26,6 @@ class AttrNodeTest < Test::Unit::TestCase
27
26
 
28
27
  def teardown
29
28
  @doc = nil
30
- GC.start
31
29
  end
32
30
 
33
31
  def city_member
@@ -35,20 +33,20 @@ class AttrNodeTest < Test::Unit::TestCase
35
33
  end
36
34
 
37
35
  def test_doc
38
- assert_not_nil(@doc)
39
- assert_equal(XML::Encoding::NONE, @doc.encoding)
36
+ refute_nil(@doc)
37
+ assert_equal(LibXML::XML::Encoding::NONE, @doc.encoding)
40
38
  end
41
39
 
42
40
  def test_types
43
41
  attribute = city_member.attributes.get_attribute('name')
44
- assert_instance_of(XML::Attr, attribute)
42
+ assert_instance_of(LibXML::XML::Attr, attribute)
45
43
  assert_equal('attribute', attribute.node_type_name)
46
44
  end
47
45
 
48
46
  def test_name
49
47
  attribute = city_member.attributes.get_attribute('name')
50
48
  assert_equal('name', attribute.name)
51
- assert_equal(Encoding::UTF_8, attribute.name.encoding) if defined?(Encoding)
49
+ assert_equal(Encoding::UTF_8, attribute.name.encoding)
52
50
 
53
51
  attribute = city_member.attributes.get_attribute('href')
54
52
  assert_equal('href', attribute.name)
@@ -64,7 +62,7 @@ class AttrNodeTest < Test::Unit::TestCase
64
62
  def test_value
65
63
  attribute = city_member.attributes.get_attribute('name')
66
64
  assert_equal('Cambridge', attribute.value)
67
- assert_equal(Encoding::UTF_8, attribute.value.encoding) if defined?(Encoding)
65
+ assert_equal(Encoding::UTF_8, attribute.value.encoding)
68
66
 
69
67
  attribute = city_member.attributes.get_attribute('href')
70
68
  assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
@@ -74,17 +72,17 @@ class AttrNodeTest < Test::Unit::TestCase
74
72
  attribute = city_member.attributes.get_attribute('name')
75
73
  attribute.value = 'London'
76
74
  assert_equal('London', attribute.value)
77
- assert_equal(Encoding::UTF_8, attribute.value.encoding) if defined?(Encoding)
75
+ assert_equal(Encoding::UTF_8, attribute.value.encoding)
78
76
 
79
77
  attribute = city_member.attributes.get_attribute('href')
80
78
  attribute.value = 'http://i.have.changed'
81
79
  assert_equal('http://i.have.changed', attribute.value)
82
- assert_equal(Encoding::UTF_8, attribute.value.encoding) if defined?(Encoding)
80
+ assert_equal(Encoding::UTF_8, attribute.value.encoding)
83
81
  end
84
82
 
85
83
  def test_set_nil
86
84
  attribute = city_member.attributes.get_attribute('name')
87
- assert_raise(TypeError) do
85
+ assert_raises(TypeError) do
88
86
  attribute.value = nil
89
87
  end
90
88
  end
@@ -93,8 +91,8 @@ class AttrNodeTest < Test::Unit::TestCase
93
91
  attributes = city_member.attributes
94
92
  assert_equal(5, attributes.length)
95
93
 
96
- attr = XML::Attr.new(city_member, 'size', '50,000')
97
- assert_instance_of(XML::Attr, attr)
94
+ attr = LibXML::XML::Attr.new(city_member, 'size', '50,000')
95
+ assert_instance_of(LibXML::XML::Attr, attr)
98
96
 
99
97
  attributes = city_member.attributes
100
98
  assert_equal(6, attributes.length)
@@ -117,9 +115,9 @@ class AttrNodeTest < Test::Unit::TestCase
117
115
  def test_create_ns
118
116
  assert_equal(5, city_member.attributes.length)
119
117
 
120
- ns = XML::Namespace.new(city_member, 'my_namepace', 'http://www.mynamespace.com')
121
- attr = XML::Attr.new(city_member, 'rating', 'rocks', ns)
122
- assert_instance_of(XML::Attr, attr)
118
+ ns = LibXML::XML::Namespace.new(city_member, 'my_namepace', 'http://www.mynamespace.com')
119
+ attr = LibXML::XML::Attr.new(city_member, 'rating', 'rocks', ns)
120
+ assert_instance_of(LibXML::XML::Attr, attr)
123
121
  assert_equal('rating', attr.name)
124
122
  assert_equal('rocks', attr.value)
125
123
 
@@ -134,7 +132,7 @@ class AttrNodeTest < Test::Unit::TestCase
134
132
  assert_equal(5, attributes.length)
135
133
 
136
134
  attribute = attributes.get_attribute('name')
137
- assert_not_nil(attribute.parent)
135
+ refute_nil(attribute.parent)
138
136
  assert(attribute.parent?)
139
137
 
140
138
  attribute.remove!
@@ -146,27 +144,27 @@ class AttrNodeTest < Test::Unit::TestCase
146
144
 
147
145
  def test_first
148
146
  attribute = city_member.attributes.first
149
- assert_instance_of(XML::Attr, attribute)
147
+ assert_instance_of(LibXML::XML::Attr, attribute)
150
148
  assert_equal('name', attribute.name)
151
149
  assert_equal('Cambridge', attribute.value)
152
150
 
153
151
  attribute = attribute.next
154
- assert_instance_of(XML::Attr, attribute)
152
+ assert_instance_of(LibXML::XML::Attr, attribute)
155
153
  assert_equal('type', attribute.name)
156
154
  assert_equal('simple', attribute.value)
157
155
 
158
156
  attribute = attribute.next
159
- assert_instance_of(XML::Attr, attribute)
157
+ assert_instance_of(LibXML::XML::Attr, attribute)
160
158
  assert_equal('title', attribute.name)
161
159
  assert_equal('Trinity Lane', attribute.value)
162
160
 
163
161
  attribute = attribute.next
164
- assert_instance_of(XML::Attr, attribute)
162
+ assert_instance_of(LibXML::XML::Attr, attribute)
165
163
  assert_equal('href', attribute.name)
166
164
  assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attribute.value)
167
165
 
168
166
  attribute = attribute.next
169
- assert_instance_of(XML::Attr, attribute)
167
+ assert_instance_of(LibXML::XML::Attr, attribute)
170
168
  assert_equal('remoteSchema', attribute.name)
171
169
  assert_equal("city.xsd#xpointer(//complexType[@name='RoadType'])", attribute.value)
172
170
 
@@ -177,7 +175,7 @@ class AttrNodeTest < Test::Unit::TestCase
177
175
  def test_no_attributes
178
176
  element = @doc.find('/city:CityModel/city:type').first
179
177
 
180
- assert_not_nil(element.attributes)
178
+ refute_nil(element.attributes)
181
179
  assert_equal(0, element.attributes.length)
182
180
  end
183
181
  end
@@ -1,11 +1,10 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
4
- require 'test/unit'
3
+ require_relative './test_helper'
5
4
 
6
- class AttrDeclTest < Test::Unit::TestCase
5
+ class AttrDeclTest < Minitest::Test
7
6
  def setup
8
- xp = XML::Parser.string(<<-EOS)
7
+ xp = LibXML::XML::Parser.string(<<-EOS)
9
8
  <!DOCTYPE test [
10
9
  <!ELEMENT root (property*)>
11
10
  <!ELEMENT property EMPTY>
@@ -28,7 +27,7 @@ class AttrDeclTest < Test::Unit::TestCase
28
27
  # Get a element with an access attribute
29
28
  elem = @doc.find_first('/root/property[@name="readonly"]')
30
29
  assert_equal(2, elem.attributes.length)
31
- assert_not_nil(elem['access'])
30
+ refute_nil(elem['access'])
32
31
 
33
32
  # Get a element node without a access attribute
34
33
  elem = @doc.find_first('/root/property[@name="readwrite"]')
@@ -42,8 +41,8 @@ class AttrDeclTest < Test::Unit::TestCase
42
41
 
43
42
  # Get the attr_decl
44
43
  attr = elem.attributes.get_attribute('access')
45
- assert_not_nil(attr)
46
- assert_equal(XML::Node::ATTRIBUTE_NODE, attr.node_type)
44
+ refute_nil(attr)
45
+ assert_equal(LibXML::XML::Node::ATTRIBUTE_NODE, attr.node_type)
47
46
  assert_equal('attribute', attr.node_type_name)
48
47
 
49
48
  # Get its value
@@ -56,8 +55,8 @@ class AttrDeclTest < Test::Unit::TestCase
56
55
 
57
56
  # Get the attr_decl
58
57
  attr_decl = elem.attributes.get_attribute('access')
59
- assert_not_nil(attr_decl)
60
- assert_equal(XML::Node::ATTRIBUTE_DECL, attr_decl.node_type)
58
+ refute_nil(attr_decl)
59
+ assert_equal(LibXML::XML::Node::ATTRIBUTE_DECL, attr_decl.node_type)
61
60
  assert_equal('attribute declaration', attr_decl.node_type_name)
62
61
 
63
62
  # Get its value
@@ -69,8 +68,8 @@ class AttrDeclTest < Test::Unit::TestCase
69
68
  elem = @doc.find_first('/root/property[@name="readwrite"]')
70
69
  attr_decl = elem.attributes.get_attribute('access')
71
70
 
72
- assert_not_nil(attr_decl)
73
- assert_equal(XML::Node::ATTRIBUTE_DECL, attr_decl.node_type)
71
+ refute_nil(attr_decl)
72
+ assert_equal(LibXML::XML::Node::ATTRIBUTE_DECL, attr_decl.node_type)
74
73
  assert_equal('attribute declaration', attr_decl.node_type_name)
75
74
  end
76
75
 
@@ -100,12 +99,12 @@ class AttrDeclTest < Test::Unit::TestCase
100
99
  attr_decl = elem.attributes.get_attribute('access')
101
100
 
102
101
  first_decl = attr_decl.prev
103
- assert_equal(XML::Node::ATTRIBUTE_DECL, first_decl.node_type)
102
+ assert_equal(LibXML::XML::Node::ATTRIBUTE_DECL, first_decl.node_type)
104
103
  assert_equal('name', first_decl.name)
105
104
  assert_nil(first_decl.value)
106
105
 
107
106
  elem_decl = first_decl.prev
108
- assert_equal(XML::Node::ELEMENT_DECL, elem_decl.node_type)
107
+ assert_equal(LibXML::XML::Node::ELEMENT_DECL, elem_decl.node_type)
109
108
  end
110
109
 
111
110
  def test_next
@@ -128,6 +127,6 @@ class AttrDeclTest < Test::Unit::TestCase
128
127
  attr_decl = elem.attributes.get_attribute('access')
129
128
 
130
129
  parent = attr_decl.parent
131
- assert_instance_of(XML::Dtd, parent)
130
+ assert_instance_of(LibXML::XML::Dtd, parent)
132
131
  end
133
132
  end
@@ -1,11 +1,10 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require './test_helper'
4
- require 'test/unit'
3
+ require_relative './test_helper'
5
4
 
6
- class AttributesTest < Test::Unit::TestCase
5
+ class AttributesTest < Minitest::Test
7
6
  def setup
8
- xp = XML::Parser.string(<<-EOS)
7
+ xp = LibXML::XML::Parser.string(<<-EOS)
9
8
  <CityModel name="value"
10
9
  xmlns="http://www.opengis.net/examples"
11
10
  xmlns:city="http://www.opengis.net/examples"
@@ -34,14 +33,14 @@ class AttributesTest < Test::Unit::TestCase
34
33
 
35
34
  def test_attributes
36
35
  attributes = city_member.attributes
37
- assert_instance_of(XML::Attributes, attributes)
36
+ assert_instance_of(LibXML::XML::Attributes, attributes)
38
37
  assert_equal(5, attributes.length)
39
38
  end
40
39
 
41
40
  def test_each
42
41
  attributes = city_member.attributes
43
42
  length = attributes.inject(0) do |result, attr|
44
- assert_instance_of(XML::Attr, attr)
43
+ assert_instance_of(LibXML::XML::Attr, attr)
45
44
  result + 1
46
45
  end
47
46
  assert_equal(5, length)
@@ -51,36 +50,30 @@ class AttributesTest < Test::Unit::TestCase
51
50
  attributes = city_member.attributes
52
51
 
53
52
  attr = attributes.get_attribute('name')
54
- assert_instance_of(XML::Attr, attr)
53
+ assert_instance_of(LibXML::XML::Attr, attr)
55
54
 
56
55
  attr = attributes.get_attribute('does_not_exist')
57
56
  assert_nil(attr)
58
57
 
59
58
  attr = attributes.get_attribute('name')
60
- assert_instance_of(XML::Attr, attr)
59
+ assert_instance_of(LibXML::XML::Attr, attr)
61
60
 
62
61
  attr = attributes.get_attribute('href')
63
- assert_instance_of(XML::Attr, attr)
64
- assert_instance_of(XML::Namespace, attr.ns)
62
+ assert_instance_of(LibXML::XML::Attr, attr)
63
+ assert_instance_of(LibXML::XML::Namespace, attr.ns)
65
64
  assert_equal('xlink', attr.ns.prefix)
66
65
  assert_equal('http://www.w3.org/1999/xlink', attr.ns.href)
67
66
 
68
67
  attr = attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
69
- assert_instance_of(XML::Attr, attr)
68
+ assert_instance_of(LibXML::XML::Attr, attr)
70
69
 
71
70
  attr = attributes.get_attribute_ns('http://www.opengis.net/gml', 'remoteSchema')
72
- assert_instance_of(XML::Attr, attr)
71
+ assert_instance_of(LibXML::XML::Attr, attr)
73
72
 
74
73
  attr = attributes.get_attribute_ns('http://i.dont.exist', 'nor do i')
75
74
  assert_nil(attr)
76
75
  end
77
76
 
78
- def test_property
79
- attr = city_member.property('name')
80
- assert_instance_of(String, attr)
81
- assert_equal('Cambridge', attr)
82
- end
83
-
84
77
  def test_get_values
85
78
  assert_equal('Cambridge', city_member[:name])
86
79
  assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', city_member[:href])
@@ -1,25 +1,28 @@
1
1
  # encoding: UTF-8
2
- require './test_helper'
3
- require 'test/unit'
2
+ require_relative './test_helper'
4
3
 
5
- class TestCanonicalize < Test::Unit::TestCase
4
+ class TestCanonicalize < Minitest::Test
5
+ def path(file)
6
+ File.join(File.dirname(__FILE__), file)
7
+ end
8
+
6
9
  # (www.w3.org) 3.1 PIs, Comments, and Outside of Document Element
7
10
  # http://www.w3.org/TR/xml-c14n#Example-OutsideDoc
8
11
  def test_canonicalize_with_w3c_c14n_3_1
9
- given_doc = XML::Document.file('c14n/given/example-1.xml')
12
+ given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-1.xml'))
10
13
 
11
14
  # With Comments
12
- expected_with_comments = IO.read('c14n/result/with-comments/example-1')
15
+ expected_with_comments = IO.read(self.path('c14n/result/with-comments/example-1'))
13
16
  assert_equal(expected_with_comments, given_doc.canonicalize(:comments => true))
14
17
 
15
18
  # Without Comments
16
- expected_without_comments = IO.read('c14n/result/without-comments/example-1')
19
+ expected_without_comments = IO.read(self.path('c14n/result/without-comments/example-1'))
17
20
  assert_equal(expected_without_comments, given_doc.canonicalize)
18
21
  assert_equal(expected_without_comments, given_doc.canonicalize(:comments => false))
19
22
 
20
23
  # Without Comments (XML_C14N_1_1)
21
- expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-1')
22
- mode = XML::Document::XML_C14N_1_1
24
+ expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-1'))
25
+ mode = LibXML::XML::Document::XML_C14N_1_1
23
26
  assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
24
27
  end#test_canonicalize_with_w3c_c14n_3_1
25
28
 
@@ -27,12 +30,12 @@ class TestCanonicalize < Test::Unit::TestCase
27
30
  # (www.w3.org) 3.2 Whitespace in Document Content
28
31
  # http://www.w3.org/TR/xml-c14n#Example-WhitespaceInContent
29
32
  def test_canonicalize_with_w3c_c14n_3_2
30
- given_doc = XML::Document.file('c14n/given/example-2.xml')
31
- expected = IO.read('c14n/result/without-comments/example-2')
33
+ given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-2.xml'))
34
+ expected = IO.read(self.path('c14n/result/without-comments/example-2'))
32
35
  assert_equal(expected, given_doc.canonicalize)
33
36
 
34
- expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-2')
35
- mode = XML::Document::XML_C14N_1_1
37
+ expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-2'))
38
+ mode = LibXML::XML::Document::XML_C14N_1_1
36
39
  assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
37
40
  end
38
41
 
@@ -42,24 +45,24 @@ class TestCanonicalize < Test::Unit::TestCase
42
45
  # - Embedded DTD not parsed out of XML, therefore default attributes are
43
46
  # not applied to canonicalization.
44
47
  def test_canonicalize_with_w3c_c14n_3_3
45
- given_doc = XML::Document.file('c14n/given/example-3.xml')
46
- expected = IO.read('c14n/result/without-comments/example-3')
48
+ given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-3.xml'))
49
+ expected = IO.read(self.path('c14n/result/without-comments/example-3'))
47
50
  assert_equal(expected, given_doc.canonicalize)
48
51
 
49
- expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-3')
50
- mode = XML::Document::XML_C14N_1_1
52
+ expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-3'))
53
+ mode = LibXML::XML::Document::XML_C14N_1_1
51
54
  assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
52
55
  end
53
56
 
54
57
  # (www.w3.org) 3.4 Character Modifications and Character References
55
58
  # http://www.w3.org/TR/xml-c14n#Example-Chars
56
59
  def test_canonicalize_with_w3c_c14n_3_4
57
- given_doc = XML::Document.file('c14n/given/example-4.xml')
58
- expected = IO.read('c14n/result/without-comments/example-4')
60
+ given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-4.xml'))
61
+ expected = IO.read(self.path('c14n/result/without-comments/example-4'))
59
62
  assert_equal(expected, given_doc.canonicalize)
60
63
 
61
- expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-4')
62
- mode = XML::Document::XML_C14N_1_1
64
+ expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-4'))
65
+ mode = LibXML::XML::Document::XML_C14N_1_1
63
66
  assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
64
67
  end
65
68
 
@@ -68,20 +71,20 @@ class TestCanonicalize < Test::Unit::TestCase
68
71
  # (2012-02-20) Failing likely due to a logic error
69
72
  # - libxml2(c14n.c:1788) XML_ENTITY_REF_NODE is invalid node for parsing.
70
73
  def test_canonicalize_with_w3c_c14n_3_5
71
- given_doc = XML::Document.file('c14n/given/example-5.xml')
74
+ #given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-5.xml'))
72
75
 
73
76
  # With Comments
74
- expected_with_comments = IO.read('c14n/result/with-comments/example-5')
77
+ #expected_with_comments = IO.read(self.path('c14n/result/with-comments/example-5'))
75
78
 
76
79
  # TODO - CANNOT COMPLETE TEST unless libxml2 supports additional node types.
77
80
  #assert_equal(expected_with_comments, given_doc.canonicalize(:comments => true))
78
81
 
79
82
  # Without Comments
80
- expected_without_comments = IO.read('c14n/result/without-comments/example-5')
83
+ #expected_without_comments = IO.read(self.path('c14n/result/without-comments/example-5'))
81
84
  # TODO - CANNOT COMPLETE TEST unless libxml2 supports additional node types.
82
85
  #assert_equal(expected_without_comments, given_doc.canonicalize(:comments => false))
83
- expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-5')
84
- mode = XML::Document::XML_C14N_1_1
86
+ #expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-5'))
87
+ #mode = LibXML::XML::Document::XML_C14N_1_1
85
88
 
86
89
  # TODO - CANNOT COMPLETE TEST unless libxml2 supports additional node types.
87
90
  #assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
@@ -90,20 +93,12 @@ class TestCanonicalize < Test::Unit::TestCase
90
93
  # (www.w3.org) 3.6 UTF-8 Encoding
91
94
  # http://www.w3.org/TR/xml-c14n#Example-UTF8
92
95
  def test_canonicalize_with_w3c_c14n_3_6
93
- given_doc = XML::Document.file('c14n/given/example-6.xml')
94
- if defined?(Encoding)
95
- expected = IO.read('c14n/result/without-comments/example-6', :encoding => Encoding::UTF_8)
96
- else
97
- expected = IO.read('c14n/result/without-comments/example-6')
98
- end
96
+ given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-6.xml'))
97
+ expected = IO.read(self.path('c14n/result/without-comments/example-6'), :encoding => Encoding::UTF_8)
99
98
  assert_equal(expected, given_doc.canonicalize)
100
99
 
101
- if defined?(Encoding)
102
- expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-6', :encoding => Encoding::UTF_8)
103
- else
104
- expected_1_1_without_comments = IO.read('c14n/result/1-1-without-comments/example-6')
105
- end
106
- mode = XML::Document::XML_C14N_1_1
100
+ expected_1_1_without_comments = IO.read(self.path('c14n/result/1-1-without-comments/example-6'), :encoding => Encoding::UTF_8)
101
+ mode = LibXML::XML::Document::XML_C14N_1_1
107
102
  assert_equal(expected_1_1_without_comments, given_doc.canonicalize(:mode => mode))
108
103
  end
109
104
 
@@ -111,13 +106,13 @@ class TestCanonicalize < Test::Unit::TestCase
111
106
  # http://www.w3.org/TR/xml-c14n#Example-DocSubsets
112
107
  def test_canonicalize_with_w3c_c14n_3_7
113
108
  # Non Canonicalized Document
114
- given_doc = XML::Document.file('c14n/given/example-7.xml')
115
- expected = IO.read('c14n/result/without-comments/example-7')
109
+ # given_doc = LibXML::XML::Document.file(self.path('c14n/given/example-7.xml'))
110
+ #expected = IO.read(self.path('c14n/result/without-comments/example-7'))
116
111
 
117
- e1_node = given_doc.find_first('ietf:e1', 'ietf:http://www.ietf.org')
112
+ # e1_node = given_doc.find_first('ietf:e1', 'ietf:http://www.ietf.org')
118
113
 
119
114
  # Select current node, all child nodes, all attributes and namespace nodes
120
- subdoc_nodes = e1_node.find("(.//.|.//@id|namespace::*)")
115
+ #subdoc_nodes = e1_node.find("(.//.|.//@id|namespace::*)")
121
116
 
122
117
  # TODO - This fails because the namespace nodes aren't taken into account
123
118
  # assert_equal(expected, given_doc.canonicalize(:nodes => subdoc_nodes))