libxml-ruby 0.6.0-x86-mswin32-60 → 0.7.0-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. data/CHANGES +42 -0
  2. data/README +123 -117
  3. data/doc/classes/XML.html +226 -0
  4. data/doc/classes/XML/Attr.html +969 -0
  5. data/doc/classes/XML/Attributes.html +487 -0
  6. data/doc/classes/XML/Document.html +1423 -0
  7. data/doc/classes/XML/Dtd.html +159 -0
  8. data/doc/classes/XML/Error.html +111 -0
  9. data/doc/classes/XML/HTMLParser.html +330 -0
  10. data/doc/classes/XML/InputCallbacks.html +154 -0
  11. data/doc/classes/XML/NS.html +366 -0
  12. data/doc/classes/XML/Node.html +3292 -0
  13. data/doc/classes/XML/Node/FailedModify.html +111 -0
  14. data/doc/classes/XML/Node/Set.html +435 -0
  15. data/doc/classes/XML/Node/SetNamespace.html +111 -0
  16. data/doc/classes/XML/Node/UnknownType.html +111 -0
  17. data/doc/classes/XML/Parser.html +2178 -0
  18. data/doc/classes/XML/Parser/Context.html +1233 -0
  19. data/doc/classes/XML/Parser/ParseError.html +111 -0
  20. data/doc/classes/XML/Reader.html +2173 -0
  21. data/doc/classes/XML/SaxParser.html +396 -0
  22. data/doc/classes/XML/SiblingEnum.html +142 -0
  23. data/doc/classes/XML/State.html +118 -0
  24. data/doc/classes/XML/Tree.html +224 -0
  25. data/doc/classes/XML/XInclude.html +117 -0
  26. data/doc/classes/XML/XInclude/Error.html +111 -0
  27. data/doc/classes/XML/XMLParserOptions.html +198 -0
  28. data/doc/classes/XML/XPath.html +269 -0
  29. data/doc/classes/XML/XPath/Context.html +193 -0
  30. data/doc/classes/XML/XPath/InvalidPath.html +111 -0
  31. data/doc/classes/XML/XPath/Object.html +439 -0
  32. data/doc/classes/XML/XPointer.html +164 -0
  33. data/doc/classes/XML/XPointer/Context.html +117 -0
  34. data/doc/classes/XML/XPointer/Context/InvalidPath.html +111 -0
  35. data/doc/classes/XML/XPointer/InvalidExpression.html +111 -0
  36. data/doc/classes/singleton.html +114 -0
  37. data/doc/created.rid +1 -0
  38. data/doc/files/CHANGES.html +375 -0
  39. data/doc/files/LICENSE.html +133 -0
  40. data/doc/files/README.html +279 -0
  41. data/doc/files/VERSION.html +107 -0
  42. data/doc/files/ext/libxml/cbg_c.html +101 -0
  43. data/doc/files/ext/libxml/libxml_c.html +101 -0
  44. data/doc/files/ext/libxml/ruby_xml_attr_c.html +101 -0
  45. data/doc/files/ext/libxml/ruby_xml_attributes_c.html +101 -0
  46. data/doc/files/ext/libxml/ruby_xml_document_c.html +101 -0
  47. data/doc/files/ext/libxml/ruby_xml_dtd_c.html +101 -0
  48. data/doc/files/ext/libxml/ruby_xml_html_parser_c.html +101 -0
  49. data/doc/files/ext/libxml/ruby_xml_input_cbg_c.html +101 -0
  50. data/doc/files/ext/libxml/ruby_xml_node_c.html +101 -0
  51. data/doc/files/ext/libxml/ruby_xml_node_set_c.html +101 -0
  52. data/doc/files/ext/libxml/ruby_xml_ns_c.html +101 -0
  53. data/doc/files/ext/libxml/ruby_xml_parser_c.html +101 -0
  54. data/doc/files/ext/libxml/ruby_xml_parser_context_c.html +101 -0
  55. data/doc/files/ext/libxml/ruby_xml_reader_c.html +101 -0
  56. data/doc/files/ext/libxml/ruby_xml_sax_parser_c.html +101 -0
  57. data/doc/files/ext/libxml/ruby_xml_schema_c.html +101 -0
  58. data/doc/files/ext/libxml/ruby_xml_state_c.html +101 -0
  59. data/doc/files/ext/libxml/ruby_xml_tree_c.html +101 -0
  60. data/doc/files/ext/libxml/ruby_xml_xinclude_c.html +101 -0
  61. data/doc/files/ext/libxml/ruby_xml_xpath_c.html +101 -0
  62. data/doc/files/ext/libxml/ruby_xml_xpath_context_c.html +101 -0
  63. data/doc/files/ext/libxml/ruby_xml_xpath_object_c.html +101 -0
  64. data/doc/files/ext/libxml/ruby_xml_xpointer_c.html +101 -0
  65. data/doc/files/ext/libxml/ruby_xml_xpointer_context_c.html +101 -0
  66. data/doc/files/lib/libxml_rb.html +115 -0
  67. data/doc/files/lib/xml/libxml_rb.html +114 -0
  68. data/doc/fr_class_index.html +60 -0
  69. data/doc/fr_file_index.html +56 -0
  70. data/doc/fr_method_index.html +373 -0
  71. data/doc/index.html +24 -0
  72. data/doc/rdoc-style.css +208 -0
  73. data/ext/libxml/cbg.c +76 -76
  74. data/ext/libxml/extconf.rb +308 -308
  75. data/ext/libxml/libxml.c +58 -62
  76. data/ext/libxml/ruby_libxml.h +1 -0
  77. data/ext/libxml/ruby_xml_attr.c +201 -113
  78. data/ext/libxml/ruby_xml_attr.h +6 -9
  79. data/ext/libxml/ruby_xml_attributes.c +268 -0
  80. data/ext/libxml/ruby_xml_attributes.h +17 -0
  81. data/ext/libxml/ruby_xml_document.c +80 -66
  82. data/ext/libxml/ruby_xml_dtd.c +2 -2
  83. data/ext/libxml/ruby_xml_dtd.h +17 -17
  84. data/ext/libxml/ruby_xml_html_parser.c +18 -19
  85. data/ext/libxml/ruby_xml_html_parser.h +29 -29
  86. data/ext/libxml/ruby_xml_input_cbg.c +6 -0
  87. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  88. data/ext/libxml/ruby_xml_node.c +438 -536
  89. data/ext/libxml/ruby_xml_node.h +17 -27
  90. data/ext/libxml/ruby_xml_node_set.c +10 -9
  91. data/ext/libxml/ruby_xml_node_set.h +20 -20
  92. data/ext/libxml/ruby_xml_ns.c +60 -69
  93. data/ext/libxml/ruby_xml_ns.h +12 -21
  94. data/ext/libxml/ruby_xml_parser.c +54 -53
  95. data/ext/libxml/ruby_xml_parser.h +31 -31
  96. data/ext/libxml/ruby_xml_parser_context.c +37 -91
  97. data/ext/libxml/ruby_xml_parser_context.h +20 -22
  98. data/ext/libxml/ruby_xml_reader.h +14 -14
  99. data/ext/libxml/ruby_xml_sax_parser.c +55 -55
  100. data/ext/libxml/ruby_xml_sax_parser.h +56 -56
  101. data/ext/libxml/ruby_xml_schema.c +44 -51
  102. data/ext/libxml/ruby_xml_schema.h +16 -16
  103. data/ext/libxml/ruby_xml_state.c +35 -96
  104. data/ext/libxml/ruby_xml_state.h +2 -3
  105. data/ext/libxml/ruby_xml_tree.h +12 -12
  106. data/ext/libxml/ruby_xml_xinclude.h +13 -13
  107. data/ext/libxml/ruby_xml_xpath.c +57 -18
  108. data/ext/libxml/ruby_xml_xpath.h +23 -23
  109. data/ext/libxml/ruby_xml_xpath_context.c +11 -7
  110. data/ext/libxml/ruby_xml_xpath_context.h +20 -20
  111. data/ext/libxml/ruby_xml_xpath_object.c +9 -16
  112. data/ext/libxml/ruby_xml_xpath_object.h +4 -10
  113. data/ext/libxml/ruby_xml_xpointer.c +11 -11
  114. data/ext/libxml/ruby_xml_xpointer.h +27 -27
  115. data/ext/libxml/ruby_xml_xpointer_context.h +18 -18
  116. data/ext/libxml/version.h +2 -2
  117. data/lib/libxml.rb +134 -125
  118. data/lib/libxml_ruby.so +0 -0
  119. data/mingw/libiconv-2.dll +0 -0
  120. data/mingw/libxml2-2.dll +0 -0
  121. data/mingw/libxml_ruby.so +0 -0
  122. data/test/ets_copy_bug.rb +1 -1
  123. data/test/ets_copy_bug2.rb +16 -27
  124. data/test/ets_doc_to_s.rb +1 -1
  125. data/test/ets_gpx.rb +1 -1
  126. data/test/ets_node_gc.rb +1 -1
  127. data/test/ets_tsr.rb +1 -1
  128. data/test/tc_well_formed.rb +1 -1
  129. data/test/tc_xml_attributes.rb +106 -0
  130. data/test/tc_xml_document.rb +10 -10
  131. data/test/tc_xml_document_write3.rb +1 -1
  132. data/test/tc_xml_dtd.rb +49 -0
  133. data/test/tc_xml_html_parser.rb +3 -3
  134. data/test/tc_xml_node.rb +69 -33
  135. data/test/tc_xml_node_attr.rb +170 -0
  136. data/test/{tc_xml_node8.rb → tc_xml_node_cdata.rb} +2 -2
  137. data/test/{tc_xml_node9.rb → tc_xml_node_comment.rb} +3 -3
  138. data/test/tc_xml_node_edit.rb +91 -0
  139. data/test/tc_xml_parser.rb +97 -50
  140. data/test/tc_xml_parser_context.rb +61 -23
  141. data/test/tc_xml_schema.rb +39 -0
  142. data/test/tc_xml_xinclude.rb +5 -6
  143. data/test/tc_xml_xpath.rb +51 -27
  144. data/test/test_suite.rb +27 -0
  145. data/vc/{libxml.sln → libxml_ruby.sln} +5 -5
  146. data/vc/{libxml.vcproj → libxml_ruby.vcproj} +9 -1
  147. metadata +106 -54
  148. data/mingw/mingw.rake +0 -36
  149. data/test/dtd-test.rb +0 -24
  150. data/test/merge_bug.rb +0 -55
  151. data/test/schema-test.rb +0 -74
  152. data/test/tc_xml_node2.rb +0 -25
  153. data/test/tc_xml_node3.rb +0 -27
  154. data/test/tc_xml_node4.rb +0 -86
  155. data/test/tc_xml_node5.rb +0 -52
  156. data/test/tc_xml_node6.rb +0 -27
  157. data/test/tc_xml_node7.rb +0 -35
  158. data/test/tc_xml_parser2.rb +0 -16
  159. data/test/tc_xml_parser3.rb +0 -23
  160. data/test/tc_xml_parser4.rb +0 -33
  161. data/test/tc_xml_parser5.rb +0 -27
  162. data/test/tc_xml_parser6.rb +0 -23
  163. data/test/tc_xml_parser7.rb +0 -28
  164. data/test/tc_xml_parser8.rb +0 -32
  165. data/test/tc_xml_parser9.rb +0 -11
  166. data/test/tc_xml_xpath2.rb +0 -14
  167. data/work/vc/debug/libxml.exp +0 -0
  168. data/work/vc/debug/libxml.ilk +0 -0
  169. data/work/vc/debug/libxml.lib +0 -0
  170. data/work/vc/debug/libxml.pdb +0 -0
  171. data/work/vc/debug/libxml.so +0 -0
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_attr.h 282 2008-07-01 06:44:30Z cfis $ */
1
+ /* $Id: ruby_xml_attr.h 351 2008-07-09 19:55:21Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -7,13 +7,10 @@
7
7
 
8
8
  extern VALUE cXMLAttr;
9
9
 
10
- typedef struct ruby_xml_attr {
11
- xmlAttrPtr attr;
12
- } ruby_xml_attr_t;
13
-
14
- VALUE ruby_xml_attr_new(VALUE class, xmlAttrPtr xnode);
15
- void ruby_xml_attr_free(ruby_xml_attr_t *rxn);
16
- VALUE ruby_xml_attr_wrap(VALUE class, xmlAttrPtr xnode);
17
10
  void ruby_init_xml_attr(void);
18
- VALUE ruby_xml_attr_name_get(VALUE self);
11
+ VALUE ruby_xml_attr_new(xmlAttrPtr xattr);
12
+ VALUE ruby_xml_attr_value_get(VALUE self);
13
+ VALUE ruby_xml_attr_value_set(VALUE self, VALUE val);
14
+ void ruby_xml_attr_free(xmlAttrPtr xattr);
15
+ VALUE ruby_xml_attr_wrap(xmlAttrPtr xattr);
19
16
  #endif
@@ -0,0 +1,268 @@
1
+ /* $Id: ruby_xml_attributes.c 300 2008-07-01 19:14:15Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ /*
6
+ * Document-class: XML::Attributes
7
+ *
8
+ * Provides access to an elements attributes (XML::Attr).
9
+ *
10
+ * Basic Usage:
11
+ * require 'libxml'
12
+ *
13
+ * doc = XML::Document.new(<some_file>)
14
+ * attributes = doc.root.attributes
15
+ *
16
+ * attributes.each do |attribute|
17
+ * ..
18
+ * end
19
+ *
20
+ * attributes['foo'] = 'bar'
21
+ * attribute = attributes.get_attribute['foo']
22
+ * attribute.value == 'foo'
23
+ *
24
+ * To access a namespaced attribute:
25
+ *
26
+ * XLINK_URI = 'http://www.w3.org/1999/xlink'
27
+ *
28
+ * attribute = attributes.get_attribute_ns(XLINK_URI, 'title')
29
+ * attribute.value = 'My title'
30
+ */
31
+
32
+ #include "ruby_libxml.h"
33
+ #include "ruby_xml_attributes.h"
34
+
35
+ VALUE cXMLAttributes;
36
+
37
+ void
38
+ ruby_xml_attributes_mark(xmlNodePtr xnode) {
39
+ ruby_xml_node_mark_common(xnode);
40
+ }
41
+
42
+ /*
43
+ * Creates a new attributes instance. Not exposed to ruby.
44
+ */
45
+ VALUE
46
+ ruby_xml_attributes_new(xmlNodePtr xnode)
47
+ {
48
+ return Data_Wrap_Struct(cXMLAttributes,
49
+ ruby_xml_attributes_mark, NULL,
50
+ xnode);
51
+ }
52
+
53
+ /*
54
+ * call-seq:
55
+ * attributes.node -> XML::Node
56
+ *
57
+ * Return the node that owns this attributes list.
58
+ *
59
+ * doc.root.attributes.node == doc.root
60
+ */
61
+ VALUE
62
+ ruby_xml_attributes_node_get(VALUE self) {
63
+ xmlNodePtr xnode;
64
+ Data_Get_Struct(self, xmlNode, xnode);
65
+ return(ruby_xml_node2_wrap(cXMLNode, xnode));
66
+ }
67
+
68
+
69
+ /*
70
+ * call-seq:
71
+ * attributes.get_attribute("name") -> XML::Attr
72
+ *
73
+ * Returns the specified attribute.
74
+ *
75
+ * name: The name of the attribute, not including a namespace.
76
+ *
77
+ * doc.root.attributes.get_attribute("foo")
78
+ */
79
+ VALUE
80
+ ruby_xml_attributes_get_attribute(VALUE self, VALUE name) {
81
+ xmlNodePtr xnode;
82
+ xmlAttrPtr xattr;
83
+
84
+ name = check_string_or_symbol(name);
85
+
86
+ Data_Get_Struct(self, xmlNode, xnode);
87
+
88
+ xattr = xmlHasProp(xnode, (xmlChar*)StringValuePtr(name));
89
+
90
+ if (xattr)
91
+ return(ruby_xml_attr_wrap(xattr));
92
+ else
93
+ return(Qnil);
94
+ }
95
+
96
+ /*
97
+ * call-seq:
98
+ * attributes.get_attribute_ns("namespace", "name") -> XML::Attr
99
+ *
100
+ * Returns the specified attribute.
101
+ *
102
+ * namespace: The URI of the attribute's namespace.
103
+ * name: The name of the attribute, not including a namespace.
104
+ *
105
+ * doc.root.attributes.get_attribute_ns('http://www.w3.org/1999/xlink', 'href')
106
+ */
107
+ VALUE
108
+ ruby_xml_attributes_get_attribute_ns(VALUE self, VALUE namespace, VALUE name) {
109
+ xmlNodePtr xnode;
110
+ xmlAttrPtr xattr;
111
+
112
+ name = check_string_or_symbol(name);
113
+
114
+ Data_Get_Struct(self, xmlNode, xnode);
115
+
116
+ xattr = xmlHasNsProp(xnode, (xmlChar*)StringValuePtr(name), (xmlChar*)StringValuePtr(namespace));
117
+
118
+ if (xattr)
119
+ return(ruby_xml_attr_wrap(xattr));
120
+ else
121
+ return(Qnil);
122
+ }
123
+
124
+ /*
125
+ * call-seq:
126
+ * attributes["name"] -> String
127
+ *
128
+ * Fetches an attribute value. If you want to access the underlying
129
+ * Attribute itself use get_attribute.
130
+ *
131
+ * name: The name of the attribute, not including any namespaces.
132
+ *
133
+ * doc.root.attributes['att'] -> 'some value'
134
+ */
135
+ VALUE
136
+ ruby_xml_attributes_attribute_get(VALUE self, VALUE name) {
137
+ VALUE xattr = ruby_xml_attributes_get_attribute(self, name);
138
+ if NIL_P(xattr)
139
+ return(Qnil);
140
+ else
141
+ return ruby_xml_attr_value_get(xattr);
142
+ }
143
+
144
+ /*
145
+ * call-seq:
146
+ * attributes["name"] = "value"
147
+ *
148
+ * Sets an attribute value. If you want to get the Attribute itself,
149
+ * use get_attribute.
150
+ *
151
+ * name: The name of the attribute, not including any namespaces.
152
+ * value: The new value of the namespace.
153
+ *
154
+ * doc.root.attributes['att'] = 'some value'
155
+ */
156
+ VALUE
157
+ ruby_xml_attributes_attribute_set(VALUE self, VALUE name, VALUE value) {
158
+ VALUE xattr = ruby_xml_attributes_get_attribute(self, name);
159
+ if NIL_P(xattr)
160
+ {
161
+ VALUE args[3];
162
+
163
+ args[0] = ruby_xml_attributes_node_get(self);
164
+ args[1] = name;
165
+ args[2] = value;
166
+
167
+ return rb_class_new_instance(sizeof(args)/sizeof(VALUE), args, cXMLAttr);
168
+ }
169
+ else
170
+ {
171
+ return ruby_xml_attr_value_set(xattr, value);
172
+ }
173
+ }
174
+
175
+
176
+ /*
177
+ * call-seq:
178
+ * attributes.each {block} -> XML::Attr
179
+ *
180
+ * Iterates over each attribute.
181
+ *
182
+ * doc.root.attributes.each {|attribute| puts attribute.name}
183
+ */
184
+ VALUE
185
+ ruby_xml_attributes_each(VALUE self) {
186
+ xmlNodePtr xnode;
187
+ xmlAttrPtr xattr;
188
+ Data_Get_Struct(self, xmlNode, xnode);
189
+
190
+ xattr = xnode->properties;
191
+
192
+ while (xattr)
193
+ {
194
+ VALUE attr = ruby_xml_attr_wrap(xattr);
195
+ rb_yield(attr);
196
+ xattr = xattr->next;
197
+ }
198
+
199
+ return self;
200
+ }
201
+
202
+ /*
203
+ * call-seq:
204
+ * attributes.length -> Integer
205
+ *
206
+ * Returns the number of attributes.
207
+ *
208
+ * doc.root.attributes.length
209
+ */
210
+ VALUE
211
+ ruby_xml_attributes_length(VALUE self) {
212
+ int length = 0;
213
+ xmlNodePtr xnode;
214
+ xmlAttrPtr xattr;
215
+ Data_Get_Struct(self, xmlNode, xnode);
216
+
217
+ xattr = xnode->properties;
218
+
219
+ while (xattr)
220
+ {
221
+ length++;
222
+ xattr = xattr->next;
223
+ }
224
+
225
+ return INT2NUM(length);
226
+ }
227
+
228
+ /*
229
+ * call-seq:
230
+ * attributes.first -> XML::Attr
231
+ *
232
+ * Returns the first attribute.
233
+ *
234
+ * doc.root.attributes.first
235
+ */
236
+ VALUE
237
+ ruby_xml_attributes_first(VALUE self) {
238
+ xmlNodePtr xnode;
239
+ Data_Get_Struct(self, xmlNode, xnode);
240
+
241
+ if (xnode->type == XML_ELEMENT_NODE) {
242
+ xmlAttrPtr xattr = xnode->properties;
243
+
244
+ if (xattr) {
245
+ return(ruby_xml_attr_wrap(xattr));
246
+ }
247
+ }
248
+ return(Qnil);
249
+ }
250
+
251
+ // Rdoc needs to know
252
+ #ifdef RDOC_NEVER_DEFINED
253
+ mXML = rb_define_module("XML");
254
+ #endif
255
+
256
+ void
257
+ ruby_init_xml_attributes(void) {
258
+ cXMLAttributes = rb_define_class_under(mXML, "Attributes", rb_cObject);
259
+ rb_include_module(cXMLAttributes, rb_const_get(rb_cObject, rb_intern("Enumerable")));
260
+ rb_define_method(cXMLAttributes, "node", ruby_xml_attributes_node_get, 0);
261
+ rb_define_method(cXMLAttributes, "get_attribute", ruby_xml_attributes_get_attribute, 1);
262
+ rb_define_method(cXMLAttributes, "get_attribute_ns", ruby_xml_attributes_get_attribute_ns, 2);
263
+ rb_define_method(cXMLAttributes, "[]", ruby_xml_attributes_attribute_get, 1);
264
+ rb_define_method(cXMLAttributes, "[]=", ruby_xml_attributes_attribute_set, 2);
265
+ rb_define_method(cXMLAttributes, "each", ruby_xml_attributes_each, 0);
266
+ rb_define_method(cXMLAttributes, "length", ruby_xml_attributes_length, 0);
267
+ rb_define_method(cXMLAttributes, "first", ruby_xml_attributes_first, 0);
268
+ }
@@ -0,0 +1,17 @@
1
+ /* $Id: ruby_xml_attributes.h 282 2008-07-01 06:44:30Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RUBY_XML_ATTRIBUTES__
6
+ #define __RUBY_XML_ATTRIBUTES__
7
+
8
+ extern VALUE cXMLAttributesibutes;
9
+
10
+ void ruby_init_xml_attributes(void);
11
+ VALUE ruby_xml_attributes_new(xmlNodePtr xnode);
12
+
13
+ VALUE ruby_xml_attributes_attribute_get(VALUE self, VALUE name);
14
+ VALUE ruby_xml_attributes_attribute_set(VALUE self, VALUE name, VALUE value);
15
+
16
+
17
+ #endif
@@ -1,16 +1,36 @@
1
- /* $Id: ruby_xml_document.c 300 2008-07-01 19:14:15Z cfis $ */
1
+ /* $Id: ruby_xml_document.c 359 2008-07-09 20:24:21Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
5
+ /*
6
+ * Document-class: XML::Document
7
+ *
8
+ * Reads or writes an XML document:
9
+ *
10
+ * Reading:
11
+ * require 'libxml'
12
+ *
13
+ * doc = XML::Document.new()
14
+ * doc.root = XML::Node.new('root_node')
15
+ * doc.root << XML::Node.new('elem1')
16
+ * doc.save('output.xml', format)
17
+ *
18
+ * Writing:
19
+ * require 'libxml'
20
+ * doc = XML::Document.file('output.xml')
21
+ * root = doc.root
22
+ */
23
+
5
24
  #include <stdarg.h>
6
25
  #include "ruby_libxml.h"
7
26
  #include "ruby_xml_document.h"
8
27
 
28
+
9
29
  VALUE cXMLDocument;
10
30
 
11
31
  /*
12
32
  * call-seq:
13
- * document.compression => num
33
+ * document.compression -> num
14
34
  *
15
35
  * Obtain this document's compression mode identifier.
16
36
  */
@@ -67,7 +87,7 @@ ruby_xml_document_compression_set(VALUE self, VALUE num) {
67
87
 
68
88
  /*
69
89
  * call-seq:
70
- * document.compression? => (true|false)
90
+ * document.compression? -> (true|false)
71
91
  *
72
92
  * Determine whether this document is compressed.
73
93
  */
@@ -90,7 +110,7 @@ ruby_xml_document_compression_q(VALUE self) {
90
110
 
91
111
  /*
92
112
  * call-seq:
93
- * document.child => node
113
+ * document.child -> node
94
114
  *
95
115
  * Get this document's child node.
96
116
  */
@@ -109,7 +129,7 @@ ruby_xml_document_child_get(VALUE self) {
109
129
 
110
130
  /*
111
131
  * call-seq:
112
- * document.child? => (true|false)
132
+ * document.child? -> (true|false)
113
133
  *
114
134
  * Determine whether this document has a child node.
115
135
  */
@@ -127,7 +147,7 @@ ruby_xml_document_child_q(VALUE self) {
127
147
 
128
148
  /*
129
149
  * call-seq:
130
- * document.dump([stream]) => true
150
+ * document.dump([stream]) -> true
131
151
  *
132
152
  * Dump this document's XML to the specified IO stream.
133
153
  * If no stream is specified, stdout is used.
@@ -166,7 +186,7 @@ ruby_xml_document_dump(int argc, VALUE *argv, VALUE self) {
166
186
 
167
187
  /*
168
188
  * call-seq:
169
- * document.debug_dump([stream]) => true
189
+ * document.debug_dump([stream]) -> true
170
190
  *
171
191
  * Debug version of dump.
172
192
  */
@@ -209,7 +229,7 @@ ruby_xml_document_debug_dump(int argc, VALUE *argv, VALUE self) {
209
229
 
210
230
  /*
211
231
  * call-seq:
212
- * document.debug_dump_head([stream]) => true
232
+ * document.debug_dump_head([stream]) -> true
213
233
  *
214
234
  * Debug-dump this document's header to the specified IO stream.
215
235
  * If no stream is specified, stdout is used.
@@ -253,7 +273,7 @@ ruby_xml_document_debug_dump_head(int argc, VALUE *argv, VALUE self) {
253
273
 
254
274
  /*
255
275
  * call-seq:
256
- * document.format_dump([stream], [spacing]) => true
276
+ * document.format_dump([stream], [spacing]) -> true
257
277
  *
258
278
  * Dump this document's formatted XML to the specified IO stream.
259
279
  * If no stream is specified, stdout is used. If spacing is
@@ -310,7 +330,7 @@ ruby_xml_document_format_dump(int argc, VALUE *argv, VALUE self) {
310
330
 
311
331
  /*
312
332
  * call-seq:
313
- * document.debug_format_dump([stream]) => true
333
+ * document.debug_format_dump([stream]) -> true
314
334
  *
315
335
  * *Deprecated* in favour of format_dump.
316
336
  */
@@ -323,7 +343,7 @@ ruby_xml_document_debug_format_dump(int argc, VALUE *argv, VALUE self) {
323
343
 
324
344
  /*
325
345
  * call-seq:
326
- * document.encoding => "encoding"
346
+ * document.encoding -> "encoding"
327
347
  *
328
348
  * Obtain the encoding specified by this document.
329
349
  */
@@ -357,7 +377,7 @@ ruby_xml_document_encoding_set(VALUE self, VALUE encoding) {
357
377
 
358
378
  /*
359
379
  * call-seq:
360
- * document.filename => "filename"
380
+ * document.filename -> "filename"
361
381
  *
362
382
  * Obtain the filename this document was read from.
363
383
  */
@@ -386,10 +406,31 @@ ruby_xml_document_filename_get(VALUE self) {
386
406
 
387
407
  /*
388
408
  * call-seq:
389
- * document.find(xpath_expr, [namespace]) => nodeset
409
+ * document.find(xpath_expr, [namespace]) -> XML::Node::Set
390
410
  *
391
411
  * Find nodes matching the specified xpath expression, optionally
392
- * using the specified namespace. Returns an XML::Node::Set.
412
+ * using the specified namespace. Returns an XML::Node::Set. For
413
+ * more information about working with namespaces, please refer
414
+ * to the XML::XPath documentation.
415
+ *
416
+ * IMPORTANT - The returned XML::Node::Set must be freed before
417
+ * its associated document. In a running Ruby program this will
418
+ * happen automatically via Ruby's mark and sweep garbage collector.
419
+ * However, if the program exits, Ruby does not guarantee the order
420
+ * in which objects are freed
421
+ * (see http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17700).
422
+ * As a result, the associated document may be freed before the node
423
+ * list, which will cause a segmentation fault.
424
+ *
425
+ * To avoid this, use the following (non-ruby like) coding style:
426
+ *
427
+ * nodes = doc.find('/header')
428
+ * nodes.each do |node|
429
+ * ... do stuff ...
430
+ * end
431
+ *
432
+ * nodes = nil
433
+ * GC.start
393
434
  */
394
435
  VALUE
395
436
  ruby_xml_document_find(int argc, VALUE *argv, VALUE self) {
@@ -438,12 +479,12 @@ void
438
479
  ruby_xml_document_mark(ruby_xml_document_t *rxd) {
439
480
  // will mark parsers and source types
440
481
  // I do not thing doc->parent has anything useful in it.
441
- ruby_xml_state_marker();
482
+ rb_gc_mark(LIBXML_STATE);
442
483
  }
443
484
 
444
485
  /*
445
486
  * call-seq:
446
- * XML::Document.new(xml_version = 1.0) => document
487
+ * XML::Document.new(xml_version = 1.0) -> document
447
488
  *
448
489
  * Create a new XML::Document, optionally specifying the
449
490
  * XML version.
@@ -470,7 +511,7 @@ ruby_xml_document_new(int argc, VALUE *argv, VALUE class) {
470
511
 
471
512
  /*
472
513
  * call-seq:
473
- * document.last => node
514
+ * document.last -> node
474
515
  *
475
516
  * Obtain the last node.
476
517
  */
@@ -489,7 +530,7 @@ ruby_xml_document_last_get(VALUE self) {
489
530
 
490
531
  /*
491
532
  * call-seq:
492
- * document.last? => (true|false)
533
+ * document.last? -> (true|false)
493
534
  *
494
535
  * Determine whether there is a last node.
495
536
  */
@@ -541,7 +582,7 @@ ruby_xml_document_new_native(VALUE class, VALUE xmlver) {
541
582
 
542
583
  /*
543
584
  * call-seq:
544
- * XML::Document.file(filename) => document
585
+ * XML::Document.file(filename) -> document
545
586
  *
546
587
  * Create a new XML::Document by parsing the specified
547
588
  * file.
@@ -558,7 +599,7 @@ ruby_xml_document_new_file(VALUE class, VALUE filename) {
558
599
 
559
600
  /*
560
601
  * call-seq:
561
- * document.next => node
602
+ * document.next -> node
562
603
  *
563
604
  * Obtain the next node.
564
605
  */
@@ -577,7 +618,7 @@ ruby_xml_document_next_get(VALUE self) {
577
618
 
578
619
  /*
579
620
  * call-seq:
580
- * document.next? => (true|false)
621
+ * document.next? -> (true|false)
581
622
  *
582
623
  * Determine whether there is a next node.
583
624
  */
@@ -595,7 +636,7 @@ ruby_xml_document_next_q(VALUE self) {
595
636
 
596
637
  /*
597
638
  * call-seq:
598
- * document.parent => node
639
+ * document.parent -> node
599
640
  *
600
641
  * Obtain the parent node.
601
642
  */
@@ -614,7 +655,7 @@ ruby_xml_document_parent_get(VALUE self) {
614
655
 
615
656
  /*
616
657
  * call-seq:
617
- * document.parent? => (true|false)
658
+ * document.parent? -> (true|false)
618
659
  *
619
660
  * Determine whether there is a parent node.
620
661
  */
@@ -632,7 +673,7 @@ ruby_xml_document_parent_q(VALUE self) {
632
673
 
633
674
  /*
634
675
  * call-seq:
635
- * document.prev => node
676
+ * document.prev -> node
636
677
  *
637
678
  * Obtain the previous node.
638
679
  */
@@ -651,7 +692,7 @@ ruby_xml_document_prev_get(VALUE self) {
651
692
 
652
693
  /*
653
694
  * call-seq:
654
- * document.prev? => (true|false)
695
+ * document.prev? -> (true|false)
655
696
  *
656
697
  * Determine whether there is a previous node.
657
698
  */
@@ -669,31 +710,7 @@ ruby_xml_document_prev_q(VALUE self) {
669
710
 
670
711
  /*
671
712
  * call-seq:
672
- * document["key"] => "value"
673
- *
674
- * Obtain the named property.
675
- */
676
- VALUE
677
- ruby_xml_document_property_get(VALUE self, VALUE key) {
678
- return(ruby_xml_node_property_get(ruby_xml_document_root_get(self), key));
679
- }
680
-
681
-
682
- /*
683
- * call-seq:
684
- * document["key"] = "value"
685
- *
686
- * Set the named property.
687
- */
688
- VALUE
689
- ruby_xml_document_property_set(VALUE self, VALUE key, VALUE val) {
690
- return(ruby_xml_node_property_set(ruby_xml_document_root_get(self), key, val));
691
- }
692
-
693
-
694
- /*
695
- * call-seq:
696
- * document.root => node
713
+ * document.root -> node
697
714
  *
698
715
  * Obtain the root node.
699
716
  */
@@ -721,19 +738,18 @@ ruby_xml_document_root_get(VALUE self) {
721
738
  VALUE
722
739
  ruby_xml_document_root_set(VALUE self, VALUE node) {
723
740
  ruby_xml_document_t *rxd;
724
- ruby_xml_node *rxn;
725
- xmlNodePtr root;
741
+ xmlNodePtr xroot, xnode;
726
742
 
727
743
  if (rb_obj_is_kind_of(node, cXMLNode) == Qfalse)
728
744
  rb_raise(rb_eTypeError, "must pass an XML::Node type object");
729
745
 
730
746
  Data_Get_Struct(self, ruby_xml_document_t, rxd);
731
- Data_Get_Struct(node, ruby_xml_node, rxn);
732
- root = xmlDocSetRootElement(rxd->doc, rxn->node);
733
- if (root == NULL)
747
+ Data_Get_Struct(node, xmlNode, xnode);
748
+ xroot = xmlDocSetRootElement(rxd->doc, xnode);
749
+ if (xroot == NULL)
734
750
  return(Qnil);
735
751
 
736
- return ruby_xml_node2_wrap(cXMLNode, root);
752
+ return ruby_xml_node2_wrap(cXMLNode, xroot);
737
753
  }
738
754
 
739
755
 
@@ -780,7 +796,7 @@ ruby_xml_document_save(int argc, VALUE *argv, VALUE self) {
780
796
 
781
797
  /*
782
798
  * call-seq:
783
- * document.standalone? => (true|false)
799
+ * document.standalone? -> (true|false)
784
800
  *
785
801
  * Determine whether this is a standalone document.
786
802
  */
@@ -797,7 +813,7 @@ ruby_xml_document_standalone_q(VALUE self) {
797
813
 
798
814
  /*
799
815
  * call-seq:
800
- * document.to_s({format=true,encoding) => "xml"
816
+ * document.to_s({format=true,encoding) -> "xml"
801
817
  *
802
818
  * Coerce this document to a string representation
803
819
  * of it's XML. The default is to pretty format, but this
@@ -858,7 +874,7 @@ ruby_xml_document_to_s(int argc, VALUE *argv, VALUE self) {
858
874
 
859
875
  /*
860
876
  * call-seq:
861
- * document.url => "url"
877
+ * document.url -> "url"
862
878
  *
863
879
  * Obtain this document's source URL, if any.
864
880
  */
@@ -875,7 +891,7 @@ ruby_xml_document_url_get(VALUE self) {
875
891
 
876
892
  /*
877
893
  * call-seq:
878
- * document.version => "version"
894
+ * document.version -> "version"
879
895
  *
880
896
  * Obtain the XML version specified by this document.
881
897
  */
@@ -892,7 +908,7 @@ ruby_xml_document_version_get(VALUE self) {
892
908
 
893
909
  /*
894
910
  * call-seq:
895
- * document.xinclude => num
911
+ * document.xinclude -> num
896
912
  *
897
913
  * Process xinclude directives in this document.
898
914
  */
@@ -942,7 +958,7 @@ LibXML_validity_warning(void * ctxt, const char * msg, va_list ap)
942
958
 
943
959
  /*
944
960
  * call-seq:
945
- * document.validate(schema) => (true|false)
961
+ * document.validate_schema(schema) -> (true|false)
946
962
  *
947
963
  * Validate this document against the specified XML::Schema.
948
964
  */
@@ -973,7 +989,7 @@ ruby_xml_document_validate_schema(VALUE self, VALUE schema) {
973
989
 
974
990
  /*
975
991
  * call-seq:
976
- * document.validate(schema) => (true|false)
992
+ * document.validate(dtd) -> (true|false)
977
993
  *
978
994
  * Validate this document against the specified XML::DTD.
979
995
  */
@@ -1048,7 +1064,7 @@ validate(self, ...)
1048
1064
 
1049
1065
  /*
1050
1066
  * call-seq:
1051
- * document.reader => reader
1067
+ * document.reader -> reader
1052
1068
  *
1053
1069
  * Create a XML::Reader from the document. This is a shortcut to
1054
1070
  * XML::Reader.walker().
@@ -1073,8 +1089,6 @@ ruby_init_xml_document(void) {
1073
1089
  //rb_raise(eXMLNodeFailedModify, "unable to add a child to the document");
1074
1090
  //eDTDValidityWarning = rb_define_class_under(cXMLNode, "ValidityWarning", eXMLError);
1075
1091
  //eDTDValidityError = rb_define_class_under(cXMLNode, "ValidityWarning", eXMLError);
1076
- rb_define_method(cXMLDocument, "[]", ruby_xml_document_property_get, 1);
1077
- rb_define_method(cXMLDocument, "[]=", ruby_xml_document_property_set, 2);
1078
1092
  rb_define_method(cXMLDocument, "child", ruby_xml_document_child_get, 0);
1079
1093
  rb_define_method(cXMLDocument, "child?", ruby_xml_document_child_q, 0);
1080
1094
  rb_define_method(cXMLDocument, "compression", ruby_xml_document_compression_get, 0);