libxml-ruby 0.8.3 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. data/CHANGES +18 -0
  2. data/RAKEFILE +15 -39
  3. data/README +48 -47
  4. data/ext/libxml/libxml.c +847 -22
  5. data/ext/libxml/ruby_libxml.h +71 -95
  6. data/ext/libxml/ruby_xml_attr.c +500 -500
  7. data/ext/libxml/ruby_xml_attributes.c +1 -1
  8. data/ext/libxml/ruby_xml_document.c +1144 -1135
  9. data/ext/libxml/ruby_xml_document.h +4 -11
  10. data/ext/libxml/ruby_xml_dtd.c +27 -0
  11. data/ext/libxml/ruby_xml_encoding.c +164 -0
  12. data/ext/libxml/ruby_xml_encoding.h +13 -0
  13. data/ext/libxml/ruby_xml_error.c +941 -0
  14. data/ext/libxml/ruby_xml_error.h +13 -0
  15. data/ext/libxml/ruby_xml_html_parser.c +71 -387
  16. data/ext/libxml/ruby_xml_html_parser.h +1 -17
  17. data/ext/libxml/ruby_xml_input.c +179 -0
  18. data/ext/libxml/ruby_xml_input.h +18 -0
  19. data/ext/libxml/ruby_xml_input_cbg.c +17 -3
  20. data/ext/libxml/ruby_xml_node.c +1566 -1582
  21. data/ext/libxml/ruby_xml_node.h +1 -4
  22. data/ext/libxml/ruby_xml_ns.c +14 -3
  23. data/ext/libxml/ruby_xml_parser.c +164 -1398
  24. data/ext/libxml/ruby_xml_parser.h +5 -17
  25. data/ext/libxml/ruby_xml_parser_context.c +131 -169
  26. data/ext/libxml/ruby_xml_parser_context.h +2 -9
  27. data/ext/libxml/ruby_xml_reader.c +910 -945
  28. data/ext/libxml/ruby_xml_relaxng.c +32 -3
  29. data/ext/libxml/ruby_xml_sax_parser.c +106 -364
  30. data/ext/libxml/ruby_xml_sax_parser.h +1 -37
  31. data/ext/libxml/ruby_xml_schema.c +174 -145
  32. data/ext/libxml/ruby_xml_xinclude.c +9 -5
  33. data/ext/libxml/ruby_xml_xpath.c +25 -6
  34. data/ext/libxml/ruby_xml_xpath.h +1 -2
  35. data/ext/libxml/ruby_xml_xpath_context.c +17 -19
  36. data/ext/libxml/ruby_xml_xpath_object.c +60 -56
  37. data/ext/libxml/ruby_xml_xpointer.c +11 -5
  38. data/ext/libxml/sax_parser_callbacks.inc +42 -37
  39. data/ext/libxml/version.h +3 -3
  40. data/ext/mingw/Rakefile +20 -27
  41. data/ext/mingw/build.rake +41 -0
  42. data/ext/vc/libxml_ruby.vcproj +23 -15
  43. data/lib/libxml.rb +8 -2
  44. data/lib/libxml/document.rb +16 -4
  45. data/lib/libxml/error.rb +84 -0
  46. data/lib/libxml/hpricot.rb +76 -0
  47. data/lib/libxml/html_parser.rb +61 -0
  48. data/lib/libxml/node.rb +36 -25
  49. data/lib/libxml/parser.rb +312 -33
  50. data/lib/libxml/parser_context.rb +17 -0
  51. data/lib/libxml/properties.rb +15 -2
  52. data/lib/libxml/reader.rb +15 -0
  53. data/lib/libxml/sax_callbacks.rb +179 -0
  54. data/lib/libxml/sax_parser.rb +42 -0
  55. data/lib/libxml/tree.rb +1 -2
  56. data/lib/libxml/xpath_object.rb +12 -0
  57. data/test/model/atom.xml +4 -0
  58. data/test/tc_attributes.rb +43 -19
  59. data/test/tc_document.rb +1 -1
  60. data/test/tc_document_write.rb +15 -8
  61. data/test/tc_dtd.rb +36 -20
  62. data/test/tc_encoding.rb +13 -0
  63. data/test/tc_error.rb +136 -0
  64. data/test/tc_node.rb +2 -3
  65. data/test/tc_node_copy.rb +1 -1
  66. data/test/tc_node_edit.rb +6 -0
  67. data/test/tc_ns.rb +18 -0
  68. data/test/tc_parser.rb +113 -228
  69. data/test/tc_parser_context.rb +1 -2
  70. data/test/tc_reader.rb +24 -14
  71. data/test/tc_relaxng.rb +18 -6
  72. data/test/tc_sax_parser.rb +48 -13
  73. data/test/tc_schema.rb +20 -8
  74. data/test/tc_well_formed.rb +2 -1
  75. data/test/tc_xml.rb +212 -0
  76. data/test/tc_xpath.rb +60 -46
  77. data/test/tc_xpointer.rb +7 -11
  78. data/test/test_suite.rb +4 -3
  79. metadata +26 -109
  80. data/doc/rdoc/classes/LibXML.html +0 -241
  81. data/doc/rdoc/classes/LibXML/XML.html +0 -185
  82. data/doc/rdoc/classes/LibXML/XML/Attr.html +0 -1010
  83. data/doc/rdoc/classes/LibXML/XML/Attributes.html +0 -526
  84. data/doc/rdoc/classes/LibXML/XML/Document.html +0 -1489
  85. data/doc/rdoc/classes/LibXML/XML/Dtd.html +0 -213
  86. data/doc/rdoc/classes/LibXML/XML/Error.html +0 -117
  87. data/doc/rdoc/classes/LibXML/XML/HTMLParser.html +0 -348
  88. data/doc/rdoc/classes/LibXML/XML/InputCallbacks.html +0 -160
  89. data/doc/rdoc/classes/LibXML/XML/NS.html +0 -381
  90. data/doc/rdoc/classes/LibXML/XML/Node.html +0 -3396
  91. data/doc/rdoc/classes/LibXML/XML/Node/FailedModify.html +0 -123
  92. data/doc/rdoc/classes/LibXML/XML/Node/Set.html +0 -440
  93. data/doc/rdoc/classes/LibXML/XML/Node/SetNamespace.html +0 -123
  94. data/doc/rdoc/classes/LibXML/XML/Node/UnknownType.html +0 -123
  95. data/doc/rdoc/classes/LibXML/XML/Parser.html +0 -2239
  96. data/doc/rdoc/classes/LibXML/XML/Parser/Context.html +0 -1255
  97. data/doc/rdoc/classes/LibXML/XML/Parser/ParseError.html +0 -123
  98. data/doc/rdoc/classes/LibXML/XML/Reader.html +0 -2264
  99. data/doc/rdoc/classes/LibXML/XML/RelaxNG.html +0 -237
  100. data/doc/rdoc/classes/LibXML/XML/SaxParser.html +0 -415
  101. data/doc/rdoc/classes/LibXML/XML/Schema.html +0 -308
  102. data/doc/rdoc/classes/LibXML/XML/State.html +0 -124
  103. data/doc/rdoc/classes/LibXML/XML/Tree.html +0 -111
  104. data/doc/rdoc/classes/LibXML/XML/XInclude.html +0 -123
  105. data/doc/rdoc/classes/LibXML/XML/XInclude/Error.html +0 -117
  106. data/doc/rdoc/classes/LibXML/XML/XMLParserOptions.html +0 -198
  107. data/doc/rdoc/classes/LibXML/XML/XPath.html +0 -184
  108. data/doc/rdoc/classes/LibXML/XML/XPath/Context.html +0 -404
  109. data/doc/rdoc/classes/LibXML/XML/XPath/InvalidPath.html +0 -172
  110. data/doc/rdoc/classes/LibXML/XML/XPath/Object.html +0 -627
  111. data/doc/rdoc/classes/LibXML/XML/XPointer.html +0 -170
  112. data/doc/rdoc/classes/LibXML/XML/XPointer/Context.html +0 -123
  113. data/doc/rdoc/classes/LibXML/XML/XPointer/Context/InvalidPath.html +0 -117
  114. data/doc/rdoc/classes/LibXML/XML/XPointer/InvalidExpression.html +0 -124
  115. data/doc/rdoc/classes/singleton.html +0 -114
  116. data/doc/rdoc/created.rid +0 -1
  117. data/doc/rdoc/files/CHANGES.html +0 -442
  118. data/doc/rdoc/files/LICENSE.html +0 -133
  119. data/doc/rdoc/files/README.html +0 -388
  120. data/doc/rdoc/files/VERSION.html +0 -107
  121. data/doc/rdoc/files/ext/libxml/cbg_c.html +0 -101
  122. data/doc/rdoc/files/ext/libxml/libxml_c.html +0 -101
  123. data/doc/rdoc/files/ext/libxml/ruby_xml_attr_c.html +0 -101
  124. data/doc/rdoc/files/ext/libxml/ruby_xml_attributes_c.html +0 -101
  125. data/doc/rdoc/files/ext/libxml/ruby_xml_document_c.html +0 -101
  126. data/doc/rdoc/files/ext/libxml/ruby_xml_dtd_c.html +0 -101
  127. data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_c.html +0 -101
  128. data/doc/rdoc/files/ext/libxml/ruby_xml_input_cbg_c.html +0 -101
  129. data/doc/rdoc/files/ext/libxml/ruby_xml_node_c.html +0 -101
  130. data/doc/rdoc/files/ext/libxml/ruby_xml_node_set_c.html +0 -101
  131. data/doc/rdoc/files/ext/libxml/ruby_xml_ns_c.html +0 -101
  132. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_c.html +0 -101
  133. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_context_c.html +0 -101
  134. data/doc/rdoc/files/ext/libxml/ruby_xml_reader_c.html +0 -101
  135. data/doc/rdoc/files/ext/libxml/ruby_xml_relaxng_c.html +0 -101
  136. data/doc/rdoc/files/ext/libxml/ruby_xml_sax_parser_c.html +0 -101
  137. data/doc/rdoc/files/ext/libxml/ruby_xml_schema_c.html +0 -101
  138. data/doc/rdoc/files/ext/libxml/ruby_xml_state_c.html +0 -101
  139. data/doc/rdoc/files/ext/libxml/ruby_xml_xinclude_c.html +0 -101
  140. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_c.html +0 -101
  141. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_context_c.html +0 -101
  142. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_object_c.html +0 -101
  143. data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_c.html +0 -101
  144. data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_context_c.html +0 -101
  145. data/doc/rdoc/files/lib/libxml/attr_rb.html +0 -108
  146. data/doc/rdoc/files/lib/libxml/attributes_rb.html +0 -108
  147. data/doc/rdoc/files/lib/libxml/document_rb.html +0 -108
  148. data/doc/rdoc/files/lib/libxml/node_rb.html +0 -108
  149. data/doc/rdoc/files/lib/libxml/node_set_rb.html +0 -108
  150. data/doc/rdoc/files/lib/libxml/parser_options_rb.html +0 -107
  151. data/doc/rdoc/files/lib/libxml/parser_rb.html +0 -101
  152. data/doc/rdoc/files/lib/libxml/properties_rb.html +0 -108
  153. data/doc/rdoc/files/lib/libxml/tree_rb.html +0 -107
  154. data/doc/rdoc/files/lib/libxml_rb.html +0 -124
  155. data/doc/rdoc/files/lib/xml/libxml_rb.html +0 -124
  156. data/doc/rdoc/files/lib/xml_rb.html +0 -134
  157. data/doc/rdoc/fr_class_index.html +0 -62
  158. data/doc/rdoc/fr_file_index.html +0 -66
  159. data/doc/rdoc/fr_method_index.html +0 -392
  160. data/doc/rdoc/index.html +0 -24
  161. data/doc/rdoc/rdoc-style.css +0 -208
  162. data/ext/libxml/ruby_xml_node_set.c +0 -172
  163. data/ext/libxml/ruby_xml_node_set.h +0 -20
  164. data/ext/libxml/ruby_xml_xpointer_context.c +0 -22
  165. data/ext/libxml/ruby_xml_xpointer_context.h +0 -18
  166. data/lib/libxml/node_set.rb +0 -27
  167. data/test/tc_node_set.rb +0 -24
  168. data/test/tc_node_set2.rb +0 -37
@@ -0,0 +1,17 @@
1
+ # $Id: libxml.rb 374 2008-07-11 04:51:41Z cfis $
2
+
3
+ module LibXML
4
+ module XML
5
+ class Parser
6
+ class Context
7
+ def options
8
+ warn("ParserContext#options has been removed from the bindings")
9
+ end
10
+
11
+ def options=(value)
12
+ warn("ParserContext#options has been removed from the bindings")
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -6,8 +6,21 @@
6
6
  module LibXML
7
7
  module XML
8
8
  class Node
9
- alias :properties :attributes
10
- alias :properties? :attributes?
9
+ def property(name)
10
+ warn('Node#properties is deprecated. Use Node#[] instead.')
11
+ self[name]
12
+ end
13
+
14
+ def properties
15
+ warn('Node#properties is deprecated. Use Node#attributes instead.')
16
+ self.attributes
17
+ end
18
+
19
+ def properties?
20
+ warn('Node#properties? is deprecated. Use Node#attributes? instead.')
21
+ self.attributes?
22
+ end
11
23
  end
24
+
12
25
  end
13
26
  end
@@ -0,0 +1,15 @@
1
+ module LibXML
2
+ module XML
3
+ class Reader
4
+ def reset_error_handler
5
+ warn('reset_error_handler is deprecated. Use Error.reset_handler instead')
6
+ Error.reset_handler
7
+ end
8
+
9
+ def set_error_handler(&block)
10
+ warn('set_error_handler is deprecated. Use Error.set_handler instead')
11
+ Error.set_handler(&block)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,179 @@
1
+ module LibXML
2
+ module XML
3
+ class SaxParser
4
+ module Callbacks
5
+ # Called for an internal subset event.
6
+ def on_internal_subset(name, external_id, system_id)
7
+ end
8
+
9
+ # Called for 'is standalone' event.
10
+ def on_is_standalone
11
+ end
12
+
13
+ # Called for an internal subset notification event.
14
+ def on_has_internal_subset
15
+ end
16
+
17
+ # Called for an external subset notification event.
18
+ def on_has_external_subset
19
+ end
20
+
21
+ # Called for a start document event.
22
+ def on_start_document
23
+ end
24
+
25
+ # Called for a end document event.
26
+ def on_end_document
27
+ end
28
+
29
+ # Called for a start element event.
30
+ def on_start_element(name, attributes_hash)
31
+ end
32
+
33
+ # Called for a end element event.
34
+ def on_end_element(name)
35
+ end
36
+
37
+ # Called for a reference event.
38
+ def on_reference(name)
39
+ end
40
+
41
+ # Called for a characters event.
42
+ def on_characters(chars)
43
+ end
44
+
45
+ # Called for an processing instruction event.
46
+ def on_processing_instruction(target, data)
47
+ end
48
+
49
+ # Called for a comment event.
50
+ def on_comment(msg)
51
+ end
52
+
53
+ # Called for parser warnings.
54
+ def on_parser_warning(msg)
55
+ end
56
+
57
+ # Called for parser errors.
58
+ def on_parser_error(msg)
59
+ end
60
+
61
+ # Called for fatal parser errors.
62
+ def on_parser_fatal_error(msg)
63
+ end
64
+
65
+ # Called for a CDATA block event.
66
+ def on_cdata_block(cdata)
67
+ end
68
+
69
+ # Called for an external subset event.
70
+ def on_external_subset(name, external_id, system_id)
71
+ end
72
+ end
73
+
74
+ module VerboseCallbacks
75
+ # Called for an internal subset event.
76
+ def on_internal_subset(name, external_id, system_id)
77
+ STDOUT << "on_internal_subset(" << name << ", " << external_id << ", " << system_id << ")\n"
78
+ STDOUT.flush
79
+ end
80
+
81
+ # Called for 'is standalone' event.
82
+ def on_is_standalone
83
+ STDOUT << "on_is_standalone\n"
84
+ STDOUT.flush
85
+ end
86
+
87
+ # Called for an internal subset notification event.
88
+ def on_has_internal_subset
89
+ STDOUT << "on_has_internal_subset\n"
90
+ STDOUT.flush
91
+ end
92
+
93
+ # Called for an external subset notification event.
94
+ def on_has_external_subset
95
+ STDOUT << "on_has_internal_subset\n"
96
+ STDOUT.flush
97
+ end
98
+
99
+ # Called for a start document event.
100
+ def on_start_document
101
+ STDOUT << "on_start_document\n"
102
+ STDOUT.flush
103
+ end
104
+
105
+ # Called for a end document event.
106
+ def on_end_document
107
+ STDOUT << "on_end_document\n"
108
+ STDOUT.flush
109
+ end
110
+
111
+ # Called for a start element event.
112
+ def on_start_element(name, attributes_hash)
113
+ STDOUT << "on_start_element(" << name << ", " << attributes_hash << ")\n"
114
+ STDOUT.flush
115
+ end
116
+
117
+ # Called for a end element event.
118
+ def on_end_element(name)
119
+ STDOUT << "on_end_element(" << name << ")\n"
120
+ STDOUT.flush
121
+ end
122
+
123
+ # Called for a reference event.
124
+ def on_reference(name)
125
+ STDOUT << "on_reference(" << name << ")\n"
126
+ STDOUT.flush
127
+ end
128
+
129
+ # Called for a characters event.
130
+ def on_characters(chars)
131
+ STDOUT << "on_characters(" << chars << ")\n"
132
+ STDOUT.flush
133
+ end
134
+
135
+ # Called for an processing instruction event.
136
+ def on_processing_instruction(target, data)
137
+ STDOUT << "on_characters(" << target << ", " << data << ")\n"
138
+ STDOUT.flush
139
+ end
140
+
141
+ # Called for a comment event.
142
+ def on_comment(msg)
143
+ STDOUT << "on_comment(" << msg << ")\n"
144
+ STDOUT.flush
145
+ end
146
+
147
+ # Called for parser warnings.
148
+ def on_parser_warning(msg)
149
+ STDOUT << "on_parser_warning(" << msg << ")\n"
150
+ STDOUT.flush
151
+ end
152
+
153
+ # Called for parser errors.
154
+ def on_parser_error(msg)
155
+ STDOUT << "on_parser_error(" << msg << ")\n"
156
+ STDOUT.flush
157
+ end
158
+
159
+ # Called for fatal parser errors.
160
+ def on_parser_fatal_error(msg)
161
+ STDOUT << "on_parser_fatal_error(" << msg << ")\n"
162
+ STDOUT.flush
163
+ end
164
+
165
+ # Called for a CDATA block event.
166
+ def on_cdata_block(cdata)
167
+ STDOUT << "on_cdata_block(" << cdata << ")\n"
168
+ STDOUT.flush
169
+ end
170
+
171
+ # Called for an external subset event.
172
+ def on_external_subset(name, external_id, system_id)
173
+ STDOUT << "on_external_subset(" << name << ", " << external_id << ", " << system_id << ")\n"
174
+ STDOUT.flush
175
+ end
176
+ end
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,42 @@
1
+ module LibXML
2
+ module XML
3
+ class SaxParser
4
+ def filename=(value)
5
+ warn("SaxParser.filename is deprecated. Use SaxParser#file instead.")
6
+ self.file = value
7
+ end
8
+
9
+ def file
10
+ input.file
11
+ end
12
+
13
+ def file=(value)
14
+ input.file = value
15
+ end
16
+
17
+ def string
18
+ input.string
19
+ end
20
+
21
+ def string=(value)
22
+ input.string = value
23
+ end
24
+
25
+ def document
26
+ input.document
27
+ end
28
+
29
+ def document=(value)
30
+ input.document = value
31
+ end
32
+
33
+ def io
34
+ input.io
35
+ end
36
+
37
+ def io=(value)
38
+ input.io = value
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,8 +1,7 @@
1
1
  # This is for backwards compatibility and is DEPRECATED
2
2
  module LibXML
3
3
  module XML
4
- class Tree
5
- # :enddoc:
4
+ class Tree # :nodoc:
6
5
  ELEMENT_NODE = Node::ELEMENT_NODE
7
6
  ATTRIBUTE_NODE = Node::ATTRIBUTE_NODE
8
7
  TEXT_NODE = Node::TEXT_NODE
@@ -0,0 +1,12 @@
1
+ module LibXML
2
+ module XML
3
+ module XPath
4
+ class Object
5
+ def set
6
+ warn("XPath::Object#set is deprecated. Simply use the XPath::Object API instead")
7
+ self
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <feed xmlns="http://www.w3.org/2005/Atom">
3
+ <title type="text">Phil Bogle's Contacts</title>
4
+ </feed>
@@ -2,7 +2,7 @@ require 'xml'
2
2
  require 'test/unit'
3
3
 
4
4
  class AttributesTest < Test::Unit::TestCase
5
- def setup()
5
+ def setup
6
6
  xp = XML::Parser.string(<<-EOS)
7
7
  <CityModel
8
8
  xmlns="http://www.opengis.net/examples"
@@ -22,7 +22,7 @@ class AttributesTest < Test::Unit::TestCase
22
22
  @doc = xp.parse
23
23
  end
24
24
 
25
- def teardown()
25
+ def teardown
26
26
  @doc = nil
27
27
  end
28
28
 
@@ -35,7 +35,7 @@ class AttributesTest < Test::Unit::TestCase
35
35
  assert_instance_of(XML::Attributes, attributes)
36
36
  assert_equal(5, attributes.length)
37
37
  end
38
-
38
+
39
39
  def test_each
40
40
  attributes = city_member.attributes
41
41
  length = attributes.inject(0) do |result, attr|
@@ -47,60 +47,84 @@ class AttributesTest < Test::Unit::TestCase
47
47
 
48
48
  def test_get_attribute
49
49
  attributes = city_member.attributes
50
-
50
+
51
51
  attr = attributes.get_attribute('name')
52
52
  assert_instance_of(XML::Attr, attr)
53
-
53
+
54
54
  attr = attributes.get_attribute('does_not_exist')
55
55
  assert_nil(attr)
56
-
56
+
57
57
  attr = attributes.get_attribute('name')
58
58
  assert_instance_of(XML::Attr, attr)
59
-
59
+
60
60
  attr = attributes.get_attribute('href')
61
61
  assert_instance_of(XML::Attr, attr)
62
62
  assert_instance_of(XML::NS, attr.ns)
63
63
  assert_equal('xlink', attr.ns.prefix)
64
64
  assert_equal('http://www.w3.org/1999/xlink', attr.ns.href)
65
-
65
+
66
66
  attr = attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
67
67
  assert_instance_of(XML::Attr, attr)
68
-
68
+
69
69
  attr = attributes.get_attribute_ns('http://www.opengis.net/gml', 'remoteSchema')
70
70
  assert_instance_of(XML::Attr, attr)
71
-
71
+
72
72
  attr = attributes.get_attribute_ns('http://i.dont.exist', 'nor do i')
73
73
  assert_nil(attr)
74
74
  end
75
-
75
+
76
+ def test_property
77
+ attr = city_member.property('name')
78
+ assert_instance_of(String, attr)
79
+ assert_equal('Cambridge', attr)
80
+ end
81
+
76
82
  def test_get_values
77
83
  assert_equal('Cambridge', city_member[:name])
78
84
  assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', city_member[:href])
79
-
85
+
80
86
  attributes = city_member.attributes
81
87
  assert_equal('Cambridge', attributes[:name])
82
88
  assert_equal('http://www.foo.net/cgi-bin/wfs?FeatureID=C10239', attributes[:href])
83
89
  end
84
-
90
+
85
91
  def test_set_values
86
92
  city_member[:name] = 'London'
87
93
  assert_equal('London', city_member[:name])
88
-
94
+
89
95
  city_member[:href] = 'foo'
90
96
  assert_equal('foo', city_member[:href])
91
-
97
+
92
98
  attributes = city_member.attributes
93
-
99
+
94
100
  attributes[:name] = 'London'
95
101
  assert_equal('London', attributes[:name])
96
-
102
+
97
103
  attributes[:href] = 'foo'
98
104
  assert_equal('foo', attributes[:href])
99
105
  end
100
-
106
+
101
107
  def test_str_sym()
102
108
  attributes = city_member.attributes
103
109
  assert_equal('Cambridge', attributes[:name])
104
110
  assert_equal('Cambridge', attributes['name'])
105
111
  end
106
- end
112
+
113
+ def test_remove_first
114
+ attributes = @doc.find_first('/city:CityModel/city:cityMember').attributes
115
+ assert_equal(5, attributes.length)
116
+ attr = attributes.first
117
+ attr.remove!
118
+ assert_equal(4, attributes.length)
119
+ end
120
+
121
+ def test_remove_all
122
+ node = @doc.find_first('/city:CityModel/city:cityMember')
123
+ assert_equal(5, node.attributes.length)
124
+
125
+ node.attributes.entries.each do |attr|
126
+ attr.remove!
127
+ end
128
+ assert_equal(0, node.attributes.length)
129
+ end
130
+ end
@@ -25,7 +25,7 @@ class TC_XML_Document < Test::Unit::TestCase
25
25
  end
26
26
 
27
27
  def test_ruby_xml_document_compression
28
- if XML::Parser::enabled_zlib?
28
+ if XML.enabled_zlib?
29
29
  0.upto(9) do |i|
30
30
  assert_equal(i, @doc.compression = i)
31
31
  assert_equal(i, @doc.compression)