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
@@ -22,8 +22,8 @@ ruby_xml_dtd_mark(ruby_xml_dtd *rxdtd) {
22
22
 
23
23
  /*
24
24
  * call-seq:
25
- * XML::Dtd.new("public system") => dtd
26
- * XML::Dtd.new("public", "system") => dtd
25
+ * XML::Dtd.new("public system") -> dtd
26
+ * XML::Dtd.new("public", "system") -> dtd
27
27
  *
28
28
  * Create a new Dtd from the specified public and system
29
29
  * identifiers.
@@ -1,17 +1,17 @@
1
- #ifndef __RUBY_XML_DTD__
2
- #define __RUBY_XML_DTD__
3
-
4
- extern VALUE cXMLDtd;
5
-
6
- typedef struct rxp_dtd {
7
- xmlDtdPtr dtd; /* DTD interface */
8
- //int data_type; /* The data type referenced by *data */
9
- //void *data; /* Pointer to an external structure of options */
10
- //int is_ptr; /* Determines if this object owns its data or points to it someplace else */
11
- //VALUE xmlver; /* T_STRING with the xml version */
12
- } ruby_xml_dtd;
13
-
14
- void ruby_init_xml_dtd(void);
15
- void ruby_dtd_free(ruby_xml_dtd *rxdtd);
16
-
17
- #endif
1
+ #ifndef __RUBY_XML_DTD__
2
+ #define __RUBY_XML_DTD__
3
+
4
+ extern VALUE cXMLDtd;
5
+
6
+ typedef struct rxp_dtd {
7
+ xmlDtdPtr dtd; /* DTD interface */
8
+ //int data_type; /* The data type referenced by *data */
9
+ //void *data; /* Pointer to an external structure of options */
10
+ //int is_ptr; /* Determines if this object owns its data or points to it someplace else */
11
+ //VALUE xmlver; /* T_STRING with the xml version */
12
+ } ruby_xml_dtd;
13
+
14
+ void ruby_init_xml_dtd(void);
15
+ void ruby_dtd_free(ruby_xml_dtd *rxdtd);
16
+
17
+ #endif
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_html_parser.c 300 2008-07-01 19:14:15Z cfis $ */
1
+ /* $Id: ruby_xml_html_parser.c 339 2008-07-09 08:36:26Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -14,7 +14,7 @@ VALUE cXMLHTMLParser;
14
14
 
15
15
  /*
16
16
  * call-seq:
17
- * parser.filename => "filename"
17
+ * parser.filename -> "filename"
18
18
  *
19
19
  * Obtain the filename this parser will read from.
20
20
  */
@@ -63,7 +63,7 @@ ruby_xml_html_parser_filename_set(VALUE self, VALUE filename) {
63
63
  return(Qnil);
64
64
  }
65
65
 
66
- rxp->ctxt = ruby_xml_parser_context_new3();
66
+ rxp->ctxt = ruby_xml_parser_context_new();
67
67
  data = (rx_file_data *)rxp->data;
68
68
  data->filename = filename;
69
69
 
@@ -105,7 +105,7 @@ ruby_xml_html_parser_free(ruby_xml_html_parser *rxp) {
105
105
 
106
106
  /*
107
107
  * call-seq:
108
- * parser.io => IO
108
+ * parser.io -> IO
109
109
  *
110
110
  * Obtain the IO instance this parser works with.
111
111
  */
@@ -159,7 +159,7 @@ ruby_xml_html_parser_io_set(VALUE self, VALUE io) {
159
159
  return(Qnil);
160
160
  }
161
161
 
162
- rxp->ctxt = ruby_xml_parser_context_new3();
162
+ rxp->ctxt = ruby_xml_parser_context_new();
163
163
  data = (rx_io_data *)rxp->data;
164
164
  data->io = io;
165
165
 
@@ -181,9 +181,10 @@ ruby_xml_html_parser_io_set(VALUE self, VALUE io) {
181
181
  void
182
182
  ruby_xml_html_parser_mark(ruby_xml_html_parser *rxp) {
183
183
  if (rxp == NULL) return;
184
- if (!NIL_P(rxp->ctxt)) rb_gc_mark(rxp->ctxt);
184
+ if (!NIL_P(rxp->ctxt))
185
+ rb_gc_mark(rxp->ctxt);
185
186
 
186
- ruby_xml_state_marker();
187
+ rb_gc_mark(LIBXML_STATE);
187
188
 
188
189
  switch(rxp->data_type) {
189
190
  case RUBY_LIBXML_SRC_TYPE_NULL:
@@ -208,7 +209,7 @@ ruby_xml_html_parser_mark(ruby_xml_html_parser *rxp) {
208
209
 
209
210
  /*
210
211
  * call-seq:
211
- * XML::HTMLParser.new => parser
212
+ * XML::HTMLParser.new -> parser
212
213
  *
213
214
  * Create a new parser instance with no pre-determined source.
214
215
  */
@@ -229,7 +230,7 @@ ruby_xml_html_parser_new(VALUE class) {
229
230
 
230
231
  /*
231
232
  * call-seq:
232
- * XML::HTMLParser.file => parser
233
+ * XML::HTMLParser.file -> parser
233
234
  *
234
235
  * Create a new parser instance that will read the specified file.
235
236
  */
@@ -255,7 +256,7 @@ ruby_xml_html_parser_new_file(VALUE class, VALUE filename) {
255
256
 
256
257
  /*
257
258
  * call-seq:
258
- * XML::HTMLParser.io => parser
259
+ * XML::HTMLParser.io -> parser
259
260
  *
260
261
  * Create a new parser instance that will read from the
261
262
  * specified IO object.
@@ -282,7 +283,7 @@ ruby_xml_html_parser_new_io(VALUE class, VALUE io) {
282
283
 
283
284
  /*
284
285
  * call-seq:
285
- * XML::HTMLParser.string => parser
286
+ * XML::HTMLParser.string -> parser
286
287
  *
287
288
  * Create a new parser instance that will parse the given
288
289
  * string.
@@ -308,7 +309,7 @@ ruby_xml_html_parser_new_string(VALUE class, VALUE str) {
308
309
 
309
310
  /*
310
311
  * call-seq:
311
- * parser.parse => document
312
+ * parser.parse -> document
312
313
  *
313
314
  * Parse the input XML and create an XML::Document with
314
315
  * it's content. If an error occurs, XML::Parser::ParseError
@@ -350,7 +351,7 @@ ruby_xml_html_parser_parse(VALUE self) {
350
351
 
351
352
  /*
352
353
  * call-seq:
353
- * parser.context => context
354
+ * parser.context -> context
354
355
  *
355
356
  * Obtain the XML::Parser::Context associated with this
356
357
  * parser.
@@ -369,7 +370,7 @@ ruby_xml_html_parser_context_get(VALUE self) {
369
370
 
370
371
  /*
371
372
  * call-seq:
372
- * parser.string => "string"
373
+ * parser.string -> "string"
373
374
  *
374
375
  * Obtain the string this parser works with.
375
376
  */
@@ -410,7 +411,7 @@ ruby_xml_html_parser_str_set(VALUE self, VALUE str) {
410
411
  return(Qnil);
411
412
  }
412
413
 
413
- rxp->ctxt = ruby_xml_parser_context_new3();
414
+ rxp->ctxt = ruby_xml_parser_context_new();
414
415
  data = (rx_string_data *)rxp->data;
415
416
  data->str = str;
416
417
 
@@ -430,13 +431,11 @@ void
430
431
  ruby_init_html_parser(void) {
431
432
  cXMLHTMLParser = rb_define_class_under(mXML, "HTMLParser", rb_cObject);
432
433
 
434
+ rb_define_singleton_method(cXMLHTMLParser, "new", ruby_xml_html_parser_new, 0);
435
+ rb_define_singleton_method(cXMLHTMLParser, "string", ruby_xml_html_parser_new_string, 1);
433
436
  /*
434
437
  rb_define_singleton_method(cXMLHTMLParser, "file", ruby_xml_html_parser_new_file, 1);
435
438
  rb_define_singleton_method(cXMLHTMLParser, "io", ruby_xml_html_parser_new_io, 1);
436
- */
437
- rb_define_singleton_method(cXMLHTMLParser, "new", ruby_xml_html_parser_new, 0);
438
- rb_define_singleton_method(cXMLHTMLParser, "string", ruby_xml_html_parser_new_string, 1);
439
- /*
440
439
  rb_define_method(cXMLHTMLParser, "filename", ruby_xml_html_parser_filename_get, 0);
441
440
  rb_define_method(cXMLHTMLParser, "filename=", ruby_xml_html_parser_filename_set, 1);
442
441
  rb_define_method(cXMLHTMLParser, "io", ruby_xml_html_parser_io_get, 0);
@@ -1,29 +1,29 @@
1
- /* $Id: ruby_xml_html_parser.h 111 2006-11-20 01:39:14Z roscopeco $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
4
-
5
- #ifndef __RUBY_XML_HTML_PARSER__
6
- #define __RUBY_XML_HTML_PARSER__
7
-
8
- extern int ruby_xml_html_parser_count;
9
- extern VALUE cXMLHTMLParser;
10
-
11
- typedef struct ruby_xml_html_parser {
12
- VALUE ctxt;
13
- int parsed;
14
- void *data;
15
- int data_type;
16
- } ruby_xml_html_parser;
17
-
18
- /*
19
- * VALUE ruby_xml_html_parser_filename_get(VALUE self);
20
- VALUE ruby_xml_html_parser_filename_set(VALUE self, VALUE filename);
21
- VALUE ruby_xml_html_parser_new(VALUE class);
22
- */
23
- VALUE ruby_xml_html_parser_parse(VALUE self);
24
- VALUE ruby_xml_html_parser_str_get(VALUE self);
25
- VALUE ruby_xml_html_parser_str_set(VALUE self, VALUE str);
26
-
27
- void ruby_init_html_parser(void);
28
-
29
- #endif
1
+ /* $Id: ruby_xml_html_parser.h 111 2006-11-20 01:39:14Z roscopeco $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RUBY_XML_HTML_PARSER__
6
+ #define __RUBY_XML_HTML_PARSER__
7
+
8
+ extern int ruby_xml_html_parser_count;
9
+ extern VALUE cXMLHTMLParser;
10
+
11
+ typedef struct ruby_xml_html_parser {
12
+ VALUE ctxt;
13
+ int parsed;
14
+ void *data;
15
+ int data_type;
16
+ } ruby_xml_html_parser;
17
+
18
+ /*
19
+ * VALUE ruby_xml_html_parser_filename_get(VALUE self);
20
+ VALUE ruby_xml_html_parser_filename_set(VALUE self, VALUE filename);
21
+ VALUE ruby_xml_html_parser_new(VALUE class);
22
+ */
23
+ VALUE ruby_xml_html_parser_parse(VALUE self);
24
+ VALUE ruby_xml_html_parser_str_get(VALUE self);
25
+ VALUE ruby_xml_html_parser_str_set(VALUE self, VALUE str);
26
+
27
+ void ruby_init_html_parser(void);
28
+
29
+ #endif
@@ -71,6 +71,12 @@ int ic_close (void *context) {
71
71
  return 1;
72
72
  }
73
73
 
74
+ /*
75
+ * call-seq:
76
+ * register
77
+ *
78
+ * Register a new set of I/O callback for handling parser input.
79
+ */
74
80
  VALUE input_callbacks_register_input_callbacks() {
75
81
  xmlRegisterInputCallbacks( ic_match, ic_open, ic_read, ic_close );
76
82
  return(Qtrue);
@@ -1,20 +1,20 @@
1
- #ifndef _INPUT_CBG_
2
- #define _INPUT_CBG_
3
-
4
- void ruby_init_input_callbacks(void);
5
-
6
- typedef struct ic_doc_context {
7
- char *buffer;
8
- char *bpos;
9
- int remaining;
10
- } ic_doc_context;
11
-
12
- typedef struct ic_scheme {
13
- char *scheme_name;
14
- VALUE class;
15
- int name_len;
16
-
17
- struct ic_scheme *next_scheme;
18
- } ic_scheme;
19
-
20
- #endif
1
+ #ifndef _INPUT_CBG_
2
+ #define _INPUT_CBG_
3
+
4
+ void ruby_init_input_callbacks(void);
5
+
6
+ typedef struct ic_doc_context {
7
+ char *buffer;
8
+ char *bpos;
9
+ int remaining;
10
+ } ic_doc_context;
11
+
12
+ typedef struct ic_scheme {
13
+ char *scheme_name;
14
+ VALUE class;
15
+ int name_len;
16
+
17
+ struct ic_scheme *next_scheme;
18
+ } ic_scheme;
19
+
20
+ #endif
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_node.c 300 2008-07-01 19:14:15Z cfis $ */
1
+ /* $Id: ruby_xml_node.c 351 2008-07-09 19:55:21Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -10,7 +10,7 @@ VALUE eXMLNodeSetNamespace;
10
10
  VALUE eXMLNodeFailedModify;
11
11
  VALUE eXMLNodeUnknownType;
12
12
 
13
- static VALUE
13
+ VALUE
14
14
  check_string_or_symbol( VALUE val ) {
15
15
  if( TYPE(val) != T_STRING && TYPE(val) != T_SYMBOL ) {
16
16
  rb_raise(rb_eTypeError, "wrong argument type %s (expected String or Symbol)",
@@ -21,15 +21,15 @@ check_string_or_symbol( VALUE val ) {
21
21
 
22
22
  /*
23
23
  * call-seq:
24
- * node.attribute? => (true|false)
24
+ * node.attribute? -> (true|false)
25
25
  *
26
26
  * Determine whether this is an attribute node,
27
27
  */
28
28
  VALUE
29
29
  ruby_xml_node_attribute_q(VALUE self) {
30
- ruby_xml_node *rxn;
31
- Data_Get_Struct(self, ruby_xml_node, rxn);
32
- if (rxn->node->type == XML_ATTRIBUTE_NODE)
30
+ xmlNodePtr xnode;
31
+ Data_Get_Struct(self, xmlNode, xnode);
32
+ if (xnode->type == XML_ATTRIBUTE_NODE)
33
33
  return(Qtrue);
34
34
  else
35
35
  return(Qfalse);
@@ -38,15 +38,15 @@ ruby_xml_node_attribute_q(VALUE self) {
38
38
 
39
39
  /*
40
40
  * call-seq:
41
- * node.attribute_decl? => (true|false)
41
+ * node.attribute_decl? -> (true|false)
42
42
  *
43
43
  * Determine whether this is an attribute declaration node,
44
44
  */
45
45
  VALUE
46
46
  ruby_xml_node_attribute_decl_q(VALUE self) {
47
- ruby_xml_node *rxn;
48
- Data_Get_Struct(self, ruby_xml_node, rxn);
49
- if (rxn->node->type == XML_ATTRIBUTE_DECL)
47
+ xmlNodePtr xnode;
48
+ Data_Get_Struct(self, xmlNode, xnode);
49
+ if (xnode->type == XML_ATTRIBUTE_DECL)
50
50
  return(Qtrue);
51
51
  else
52
52
  return(Qfalse);
@@ -55,22 +55,22 @@ ruby_xml_node_attribute_decl_q(VALUE self) {
55
55
 
56
56
  /*
57
57
  * call-seq:
58
- * node.base => "uri"
58
+ * node.base -> "uri"
59
59
  *
60
60
  * Obtain this node's base URI.
61
61
  */
62
62
  VALUE
63
63
  ruby_xml_node_base_get(VALUE self) {
64
- ruby_xml_node *rxn;
64
+ xmlNodePtr xnode;
65
65
  xmlChar* base_uri;
66
66
  VALUE result = Qnil;
67
67
 
68
- Data_Get_Struct(self, ruby_xml_node, rxn);
68
+ Data_Get_Struct(self, xmlNode, xnode);
69
69
 
70
- if (rxn->node->doc == NULL)
70
+ if (xnode->doc == NULL)
71
71
  return(result);
72
72
 
73
- base_uri = xmlNodeGetBase(rxn->node->doc, rxn->node);
73
+ base_uri = xmlNodeGetBase(xnode->doc, xnode);
74
74
  if (base_uri) {
75
75
  result = rb_str_new2((const char*)base_uri);
76
76
  xmlFree(base_uri);
@@ -90,29 +90,29 @@ ruby_xml_node_base_get(VALUE self) {
90
90
  */
91
91
  VALUE
92
92
  ruby_xml_node_base_set(VALUE self, VALUE uri) {
93
- ruby_xml_node *node;
93
+ xmlNodePtr xnode;
94
94
 
95
95
  Check_Type(uri, T_STRING);
96
- Data_Get_Struct(self, ruby_xml_node, node);
97
- if (node->node->doc == NULL)
96
+ Data_Get_Struct(self, xmlNode, xnode);
97
+ if (xnode->doc == NULL)
98
98
  return(Qnil);
99
99
 
100
- xmlNodeSetBase(node->node, (xmlChar*)StringValuePtr(uri));
100
+ xmlNodeSetBase(xnode, (xmlChar*)StringValuePtr(uri));
101
101
  return(Qtrue);
102
102
  }
103
103
 
104
104
 
105
105
  /*
106
106
  * call-seq:
107
- * node.cdata? => (true|false)
107
+ * node.cdata? -> (true|false)
108
108
  *
109
109
  * Determine whether this is a #CDATA node
110
110
  */
111
111
  VALUE
112
112
  ruby_xml_node_cdata_q(VALUE self) {
113
- ruby_xml_node *rxn;
114
- Data_Get_Struct(self, ruby_xml_node, rxn);
115
- if (rxn->node->type == XML_CDATA_SECTION_NODE)
113
+ xmlNodePtr xnode;
114
+ Data_Get_Struct(self, xmlNode, xnode);
115
+ if (xnode->type == XML_CDATA_SECTION_NODE)
116
116
  return(Qtrue);
117
117
  else
118
118
  return(Qfalse);
@@ -121,15 +121,15 @@ ruby_xml_node_cdata_q(VALUE self) {
121
121
 
122
122
  /*
123
123
  * call-seq:
124
- * node.comment? => (true|false)
124
+ * node.comment? -> (true|false)
125
125
  *
126
126
  * Determine whether this is a comment node
127
127
  */
128
128
  VALUE
129
129
  ruby_xml_node_comment_q(VALUE self) {
130
- ruby_xml_node *rxn;
131
- Data_Get_Struct(self, ruby_xml_node, rxn);
132
- if (rxn->node->type == XML_COMMENT_NODE)
130
+ xmlNodePtr xnode;
131
+ Data_Get_Struct(self, xmlNode, xnode);
132
+ if (xnode->type == XML_COMMENT_NODE)
133
133
  return(Qtrue);
134
134
  else
135
135
  return(Qfalse);
@@ -138,52 +138,18 @@ ruby_xml_node_comment_q(VALUE self) {
138
138
 
139
139
  /*
140
140
  * call-seq:
141
- * node << ("string" | node) => node
142
- *
143
- * Add the specified string or XML::Node to this node's
144
- * content.
145
- */
146
- VALUE
147
- ruby_xml_node_content_add(VALUE self, VALUE obj) {
148
- ruby_xml_node *node;
149
- VALUE str;
150
-
151
- Data_Get_Struct(self, ruby_xml_node, node);
152
- /* XXX This should only be legal for a CDATA type node, I think,
153
- * resulting in a merge of content, as if a string were passed
154
- * danj 070827
155
- */
156
- if (rb_obj_is_kind_of(obj, cXMLNode)) {
157
- ruby_xml_node_child_set(self, obj);
158
- return(self);
159
- } else if (TYPE(obj) == T_STRING) {
160
- xmlNodeAddContent(node->node, (xmlChar*)StringValuePtr(obj));
161
- return(self);
162
- } else {
163
- str = rb_obj_as_string(obj);
164
- if (NIL_P(str) || TYPE(str) != T_STRING)
165
- rb_raise(rb_eTypeError, "invalid argument: must be string or XML::Node");
166
-
167
- xmlNodeAddContent(node->node, (xmlChar*)StringValuePtr(str));
168
- return(self);
169
- }
170
- }
171
-
172
-
173
- /*
174
- * call-seq:
175
- * node.content => "string"
141
+ * node.content -> "string"
176
142
  *
177
143
  * Obtain this node's content as a string.
178
144
  */
179
145
  VALUE
180
146
  ruby_xml_node_content_get(VALUE self) {
181
- ruby_xml_node *rxn;
147
+ xmlNodePtr xnode;
182
148
  xmlChar *content;
183
- VALUE result;
149
+ VALUE result = Qnil;
184
150
 
185
- Data_Get_Struct(self, ruby_xml_node, rxn);
186
- content = xmlNodeGetContent(rxn->node);
151
+ Data_Get_Struct(self, xmlNode, xnode);
152
+ content = xmlNodeGetContent(xnode);
187
153
  if (content) {
188
154
  result = rb_str_new2((const char *) content);
189
155
  xmlFree(content);
@@ -200,19 +166,19 @@ ruby_xml_node_content_get(VALUE self) {
200
166
  */
201
167
  VALUE
202
168
  ruby_xml_node_content_set(VALUE self, VALUE content) {
203
- ruby_xml_node *node;
169
+ xmlNodePtr xnode;
204
170
 
205
171
  Check_Type(content, T_STRING);
206
- Data_Get_Struct(self, ruby_xml_node, node);
172
+ Data_Get_Struct(self, xmlNode, xnode);
207
173
  // XXX docs indicate need for escaping entites, need to be done? danj
208
- xmlNodeSetContent(node->node, (xmlChar*)StringValuePtr(content));
174
+ xmlNodeSetContent(xnode, (xmlChar*)StringValuePtr(content));
209
175
  return(Qtrue);
210
176
  }
211
177
 
212
178
 
213
179
  /*
214
180
  * call-seq:
215
- * node.content_stripped => "string"
181
+ * node.content_stripped -> "string"
216
182
  *
217
183
  * Obtain this node's stripped content.
218
184
  *
@@ -221,16 +187,16 @@ ruby_xml_node_content_set(VALUE self, VALUE content) {
221
187
  */
222
188
  VALUE
223
189
  ruby_xml_node_content_stripped_get(VALUE self) {
224
- ruby_xml_node *rxn;
190
+ xmlNodePtr xnode;
225
191
  xmlChar* content;
226
192
  VALUE result = Qnil;
227
193
 
228
- Data_Get_Struct(self, ruby_xml_node, rxn);
194
+ Data_Get_Struct(self, xmlNode, xnode);
229
195
 
230
- if (!rxn->node->content)
196
+ if (!xnode->content)
231
197
  return result;
232
198
 
233
- content = xmlNodeGetContent(rxn->node);
199
+ content = xmlNodeGetContent(xnode);
234
200
  if (content) {
235
201
  result = rb_str_new2((const char*)content);
236
202
  xmlFree(content);
@@ -240,18 +206,18 @@ ruby_xml_node_content_stripped_get(VALUE self) {
240
206
 
241
207
  /*
242
208
  * call-seq:
243
- * node.child => node
209
+ * node.child -> node
244
210
  *
245
211
  * Obtain this node's first child node, if any.
246
212
  */
247
213
  VALUE
248
214
  ruby_xml_node_child_get(VALUE self) {
249
- ruby_xml_node *node;
215
+ xmlNodePtr xnode;
250
216
  xmlNodePtr tmp;
251
217
 
252
- Data_Get_Struct(self, ruby_xml_node, node);
218
+ Data_Get_Struct(self, xmlNode, xnode);
253
219
 
254
- switch (node->node->type) {
220
+ switch (xnode->type) {
255
221
  case XML_ELEMENT_NODE:
256
222
  case XML_ENTITY_REF_NODE:
257
223
  case XML_ENTITY_NODE:
@@ -263,11 +229,11 @@ ruby_xml_node_child_get(VALUE self) {
263
229
  #endif
264
230
  case XML_HTML_DOCUMENT_NODE:
265
231
  case XML_DTD_NODE:
266
- tmp = node->node->children;
232
+ tmp = xnode->children;
267
233
  break;
268
234
  case XML_ATTRIBUTE_NODE:
269
235
  {
270
- xmlAttrPtr attr = (xmlAttrPtr) node->node;
236
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
271
237
  tmp = attr->children;
272
238
  break;
273
239
  }
@@ -285,18 +251,18 @@ ruby_xml_node_child_get(VALUE self) {
285
251
 
286
252
  /*
287
253
  * call-seq:
288
- * node.child? => (true|false)
254
+ * node.child? -> (true|false)
289
255
  *
290
256
  * Determine whether this node has at least one child.
291
257
  */
292
258
  VALUE
293
259
  ruby_xml_node_child_q(VALUE self) {
294
- ruby_xml_node *rxn;
260
+ xmlNodePtr xnode;
295
261
  xmlNodePtr node;
296
- Data_Get_Struct(self, ruby_xml_node, rxn);
262
+ Data_Get_Struct(self, xmlNode, xnode);
297
263
 
298
264
  node = NULL;
299
- switch (rxn->node->type) {
265
+ switch (xnode->type) {
300
266
  case XML_ELEMENT_NODE:
301
267
  case XML_ENTITY_REF_NODE:
302
268
  case XML_ENTITY_NODE:
@@ -308,11 +274,11 @@ ruby_xml_node_child_q(VALUE self) {
308
274
  #endif
309
275
  case XML_HTML_DOCUMENT_NODE:
310
276
  case XML_DTD_NODE:
311
- node = rxn->node->children;
277
+ node = xnode->children;
312
278
  break;
313
279
  case XML_ATTRIBUTE_NODE:
314
280
  {
315
- xmlAttrPtr attr = (xmlAttrPtr) rxn->node;
281
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
316
282
  node = attr->children;
317
283
  break;
318
284
  }
@@ -331,38 +297,20 @@ ruby_xml_node_child_q(VALUE self) {
331
297
  * former raises on implicit copy, latter does not.
332
298
  */
333
299
  VALUE
334
- ruby_xml_node_child_set_aux(VALUE self, VALUE rnode, int do_raise) {
335
- ruby_xml_node *cnode, *pnode;
336
- xmlNodePtr chld, ret;
337
- int copied=0;
300
+ ruby_xml_node_child_set_aux(VALUE self, VALUE rnode) {
301
+ xmlNodePtr pnode, chld, ret;
338
302
 
339
303
  if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
340
304
  rb_raise(rb_eTypeError, "Must pass an XML::Node object");
341
305
 
342
- Data_Get_Struct(self, ruby_xml_node, pnode);
343
- Data_Get_Struct(rnode, ruby_xml_node, cnode);
306
+ Data_Get_Struct(self, xmlNode, pnode);
307
+ Data_Get_Struct(rnode, xmlNode, chld);
344
308
 
345
- chld = cnode->node;
346
- /* Since an add operation may destroy a textnode by merging, we need to work
347
- * with a copy, so that the ruby instance is not left with a dangling reference
348
- */
349
- if ( chld->type == XML_TEXT_NODE ) {
350
- chld = xmlCopyNode(chld,1);
351
- copied=1;
352
- }
353
-
354
- if ( chld->parent != NULL || chld->doc != NULL ) {
355
- /* raise before copying if applicable */
356
- if ( do_raise == 1 )
357
- rb_raise(rb_eRuntimeError, "implicit copy not legal for child= or <<");
358
- chld=xmlCopyNode(chld,1);
359
- copied=1;
360
- }
309
+ if ( chld->parent != NULL || chld->doc != NULL )
310
+ rb_raise(rb_eRuntimeError, "Cannot move a node from one document to another with child= or <<. First copy the node before moving it.");
361
311
 
362
- ret = xmlAddChild(pnode->node, chld);
312
+ ret = xmlAddChild(pnode, chld);
363
313
  if (ret == NULL) {
364
- if ( copied == 1 )
365
- xmlFreeNode(chld);
366
314
  rb_raise(eXMLNodeFailedModify, "unable to add a child to the document");
367
315
  } else if ( ret==chld ) {
368
316
  /* child was added whole to parent and we need to return it as a new object */
@@ -381,7 +329,41 @@ ruby_xml_node_child_set_aux(VALUE self, VALUE rnode, int do_raise) {
381
329
  */
382
330
  VALUE
383
331
  ruby_xml_node_child_set(VALUE self, VALUE rnode) {
384
- return ruby_xml_node_child_set_aux(self,rnode,1);
332
+ return ruby_xml_node_child_set_aux(self, rnode);
333
+ }
334
+
335
+
336
+ /*
337
+ * call-seq:
338
+ * node << ("string" | node) -> node
339
+ *
340
+ * Add the specified string or XML::Node to this node's
341
+ * content.
342
+ */
343
+ VALUE
344
+ ruby_xml_node_content_add(VALUE self, VALUE obj) {
345
+ xmlNodePtr xnode;
346
+ VALUE str;
347
+
348
+ Data_Get_Struct(self, xmlNode, xnode);
349
+ /* XXX This should only be legal for a CDATA type node, I think,
350
+ * resulting in a merge of content, as if a string were passed
351
+ * danj 070827
352
+ */
353
+ if (rb_obj_is_kind_of(obj, cXMLNode)) {
354
+ ruby_xml_node_child_set(self, obj);
355
+ return(self);
356
+ } else if (TYPE(obj) == T_STRING) {
357
+ xmlNodeAddContent(xnode, (xmlChar*)StringValuePtr(obj));
358
+ return(self);
359
+ } else {
360
+ str = rb_obj_as_string(obj);
361
+ if (NIL_P(str) || TYPE(str) != T_STRING)
362
+ rb_raise(rb_eTypeError, "invalid argument: must be string or XML::Node");
363
+
364
+ xmlNodeAddContent(xnode, (xmlChar*)StringValuePtr(str));
365
+ return(self);
366
+ }
385
367
  }
386
368
 
387
369
  /*
@@ -392,23 +374,23 @@ ruby_xml_node_child_set(VALUE self, VALUE rnode) {
392
374
  */
393
375
  VALUE
394
376
  ruby_xml_node_child_add(VALUE self, VALUE rnode) {
395
- return ruby_xml_node_child_set_aux(self,rnode,0);
377
+ return ruby_xml_node_child_set_aux(self, rnode);
396
378
  }
397
379
 
398
380
  /*
399
381
  * call-seq:
400
- * node.doc => document
382
+ * node.doc -> document
401
383
  *
402
384
  * Obtain the XML::Document this node belongs to.
403
385
  */
404
386
  VALUE
405
387
  ruby_xml_node_doc(VALUE self) {
406
- ruby_xml_node *rxn;
388
+ xmlNodePtr xnode;
407
389
  xmlDocPtr doc=NULL;
408
390
 
409
- Data_Get_Struct(self, ruby_xml_node, rxn);
391
+ Data_Get_Struct(self, xmlNode, xnode);
410
392
 
411
- switch (rxn->node->type) {
393
+ switch (xnode->type) {
412
394
  case XML_DOCUMENT_NODE:
413
395
  #ifdef LIBXML_DOCB_ENABLED
414
396
  case XML_DOCB_DOCUMENT_NODE:
@@ -418,7 +400,7 @@ ruby_xml_node_doc(VALUE self) {
418
400
  break;
419
401
  case XML_ATTRIBUTE_NODE:
420
402
  {
421
- xmlAttrPtr attr = (xmlAttrPtr) rxn->node;
403
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
422
404
  doc = attr->doc;
423
405
  break;
424
406
  }
@@ -426,7 +408,7 @@ ruby_xml_node_doc(VALUE self) {
426
408
  doc = NULL;
427
409
  break;
428
410
  default:
429
- doc = rxn->node->doc;
411
+ doc = xnode->doc;
430
412
  break;
431
413
  }
432
414
 
@@ -442,16 +424,16 @@ ruby_xml_node_doc(VALUE self) {
442
424
 
443
425
  /*
444
426
  * call-seq:
445
- * node.docbook? => (true|false)
427
+ * node.docbook? -> (true|false)
446
428
  *
447
429
  * Determine whether this is a docbook node.
448
430
  */
449
431
  VALUE
450
432
  ruby_xml_node_docbook_doc_q(VALUE self) {
451
433
  #ifdef LIBXML_DOCB_ENABLED
452
- ruby_xml_node *rxn;
453
- Data_Get_Struct(self, ruby_xml_node, rxn);
454
- if (rxn->node->type == XML_DOCB_DOCUMENT_NODE)
434
+ xmlNodePtr xnode;
435
+ Data_Get_Struct(self, xmlNode, xnode);
436
+ if (xnode->type == XML_DOCB_DOCUMENT_NODE)
455
437
  return(Qtrue);
456
438
  else
457
439
  return(Qfalse);
@@ -464,15 +446,15 @@ ruby_xml_node_docbook_doc_q(VALUE self) {
464
446
 
465
447
  /*
466
448
  * call-seq:
467
- * node.doctype? => (true|false)
449
+ * node.doctype? -> (true|false)
468
450
  *
469
451
  * Determine whether this is a DOCTYPE node.
470
452
  */
471
453
  VALUE
472
454
  ruby_xml_node_doctype_q(VALUE self) {
473
- ruby_xml_node *rxn;
474
- Data_Get_Struct(self, ruby_xml_node, rxn);
475
- if (rxn->node->type == XML_DOCUMENT_TYPE_NODE)
455
+ xmlNodePtr xnode;
456
+ Data_Get_Struct(self, xmlNode, xnode);
457
+ if (xnode->type == XML_DOCUMENT_TYPE_NODE)
476
458
  return(Qtrue);
477
459
  else
478
460
  return(Qfalse);
@@ -481,15 +463,15 @@ ruby_xml_node_doctype_q(VALUE self) {
481
463
 
482
464
  /*
483
465
  * call-seq:
484
- * node.document? => (true|false)
466
+ * node.document? -> (true|false)
485
467
  *
486
468
  * Determine whether this is a document node.
487
469
  */
488
470
  VALUE
489
471
  ruby_xml_node_document_q(VALUE self) {
490
- ruby_xml_node *rxn;
491
- Data_Get_Struct(self, ruby_xml_node, rxn);
492
- if (rxn->node->type == XML_DOCUMENT_NODE)
472
+ xmlNodePtr xnode;
473
+ Data_Get_Struct(self, xmlNode, xnode);
474
+ if (xnode->type == XML_DOCUMENT_NODE)
493
475
  return(Qtrue);
494
476
  else
495
477
  return(Qfalse);
@@ -498,15 +480,15 @@ ruby_xml_node_document_q(VALUE self) {
498
480
 
499
481
  /*
500
482
  * call-seq:
501
- * node.dtd? => (true|false)
483
+ * node.dtd? -> (true|false)
502
484
  *
503
485
  * Determine whether this is a DTD node.
504
486
  */
505
487
  VALUE
506
488
  ruby_xml_node_dtd_q(VALUE self) {
507
- ruby_xml_node *rxn;
508
- Data_Get_Struct(self, ruby_xml_node, rxn);
509
- if (rxn->node->type == XML_DTD_NODE)
489
+ xmlNodePtr xnode;
490
+ Data_Get_Struct(self, xmlNode, xnode);
491
+ if (xnode->type == XML_DTD_NODE)
510
492
  return(Qtrue);
511
493
  else
512
494
  return(Qfalse);
@@ -515,22 +497,22 @@ ruby_xml_node_dtd_q(VALUE self) {
515
497
 
516
498
  /*
517
499
  * call-seq:
518
- * node.dump => (true|nil)
500
+ * node.dump -> (true|nil)
519
501
  *
520
502
  * Dump this node to stdout.
521
503
  */
522
504
  VALUE
523
505
  ruby_xml_node_dump(VALUE self) {
524
- ruby_xml_node *rxn;
506
+ xmlNodePtr xnode;
525
507
  xmlBufferPtr buf;
526
508
 
527
- Data_Get_Struct(self, ruby_xml_node, rxn);
509
+ Data_Get_Struct(self, xmlNode, xnode);
528
510
 
529
- if (rxn->node->doc == NULL)
511
+ if (xnode->doc == NULL)
530
512
  return(Qnil);
531
513
 
532
514
  buf = xmlBufferCreate();
533
- xmlNodeDump(buf, rxn->node->doc, rxn->node, 0, 1);
515
+ xmlNodeDump(buf, xnode->doc, xnode, 0, 1);
534
516
  xmlBufferDump(stdout, buf);
535
517
  xmlBufferFree(buf);
536
518
  return(Qtrue);
@@ -539,35 +521,35 @@ ruby_xml_node_dump(VALUE self) {
539
521
 
540
522
  /*
541
523
  * call-seq:
542
- * node.debug_dump => (true|nil)
524
+ * node.debug_dump -> (true|nil)
543
525
  *
544
526
  * Dump this node to stdout, including any debugging
545
527
  * information.
546
528
  */
547
529
  VALUE
548
530
  ruby_xml_node_debug_dump(VALUE self) {
549
- ruby_xml_node *rxn;
550
- Data_Get_Struct(self, ruby_xml_node, rxn);
531
+ xmlNodePtr xnode;
532
+ Data_Get_Struct(self, xmlNode, xnode);
551
533
 
552
- if (rxn->node->doc == NULL)
534
+ if (xnode->doc == NULL)
553
535
  return(Qnil);
554
536
 
555
- xmlElemDump(stdout, rxn->node->doc, rxn->node);
537
+ xmlElemDump(stdout, xnode->doc, xnode);
556
538
  return(Qtrue);
557
539
  }
558
540
 
559
541
 
560
542
  /*
561
543
  * call-seq:
562
- * node.element? => (true|false)
544
+ * node.element? -> (true|false)
563
545
  *
564
546
  * Determine whether this is an element node.
565
547
  */
566
548
  VALUE
567
549
  ruby_xml_node_element_q(VALUE self) {
568
- ruby_xml_node *rxn;
569
- Data_Get_Struct(self, ruby_xml_node, rxn);
570
- if (rxn->node->type == XML_ELEMENT_NODE)
550
+ xmlNodePtr xnode;
551
+ Data_Get_Struct(self, xmlNode, xnode);
552
+ if (xnode->type == XML_ELEMENT_NODE)
571
553
  return(Qtrue);
572
554
  else
573
555
  return(Qfalse);
@@ -576,15 +558,15 @@ ruby_xml_node_element_q(VALUE self) {
576
558
 
577
559
  /*
578
560
  * call-seq:
579
- * node.element_decl? => (true|false)
561
+ * node.element_decl? -> (true|false)
580
562
  *
581
563
  * Determine whether this is an element declaration node.
582
564
  */
583
565
  VALUE
584
566
  ruby_xml_node_element_decl_q(VALUE self) {
585
- ruby_xml_node *rxn;
586
- Data_Get_Struct(self, ruby_xml_node, rxn);
587
- if (rxn->node->type == XML_ELEMENT_DECL)
567
+ xmlNodePtr xnode;
568
+ Data_Get_Struct(self, xmlNode, xnode);
569
+ if (xnode->type == XML_ELEMENT_DECL)
588
570
  return(Qtrue);
589
571
  else
590
572
  return(Qfalse);
@@ -593,32 +575,32 @@ ruby_xml_node_element_decl_q(VALUE self) {
593
575
 
594
576
  /*
595
577
  * call-seq:
596
- * node.empty? => (true|false)
578
+ * node.empty? -> (true|false)
597
579
  *
598
580
  * Determine whether this node is empty.
599
581
  */
600
582
  VALUE
601
583
  ruby_xml_node_empty_q(VALUE self) {
602
- ruby_xml_node *rxn;
603
- Data_Get_Struct(self, ruby_xml_node, rxn);
604
- if (rxn->node == NULL)
584
+ xmlNodePtr xnode;
585
+ Data_Get_Struct(self, xmlNode, xnode);
586
+ if (xnode == NULL)
605
587
  return(Qnil);
606
588
 
607
- return((xmlIsBlankNode(rxn->node) == 1) ? Qtrue : Qfalse);
589
+ return((xmlIsBlankNode(xnode) == 1) ? Qtrue : Qfalse);
608
590
  }
609
591
 
610
592
 
611
593
  /*
612
594
  * call-seq:
613
- * node.entity? => (true|false)
595
+ * node.entity? -> (true|false)
614
596
  *
615
597
  * Determine whether this is an entity node.
616
598
  */
617
599
  VALUE
618
600
  ruby_xml_node_entity_q(VALUE self) {
619
- ruby_xml_node *rxn;
620
- Data_Get_Struct(self, ruby_xml_node, rxn);
621
- if (rxn->node->type == XML_ENTITY_NODE)
601
+ xmlNodePtr xnode;
602
+ Data_Get_Struct(self, xmlNode, xnode);
603
+ if (xnode->type == XML_ENTITY_NODE)
622
604
  return(Qtrue);
623
605
  else
624
606
  return(Qfalse);
@@ -627,15 +609,15 @@ ruby_xml_node_entity_q(VALUE self) {
627
609
 
628
610
  /*
629
611
  * call-seq:
630
- * node.entity_ref? => (true|false)
612
+ * node.entity_ref? -> (true|false)
631
613
  *
632
614
  * Determine whether this is an entity reference node.
633
615
  */
634
616
  VALUE
635
617
  ruby_xml_node_entity_ref_q(VALUE self) {
636
- ruby_xml_node *rxn;
637
- Data_Get_Struct(self, ruby_xml_node, rxn);
638
- if (rxn->node->type == XML_ENTITY_REF_NODE)
618
+ xmlNodePtr xnode;
619
+ Data_Get_Struct(self, xmlNode, xnode);
620
+ if (xnode->type == XML_ENTITY_REF_NODE)
639
621
  return(Qtrue);
640
622
  else
641
623
  return(Qfalse);
@@ -647,26 +629,26 @@ VALUE ruby_xml_node_to_s(VALUE self);
647
629
  * call-seq:
648
630
  * node.eql?(other_node) => (true|false)
649
631
  *
650
- * Test equality between the two nodes. Equality is determined based
651
- * on the XML representation of the nodes.
652
- */
632
+ * Test equality between the two nodes. Two nodes are equal
633
+ * if they are the same node or have the same XML representation.*/
653
634
  VALUE
654
635
  ruby_xml_node_eql_q(VALUE self, VALUE other) {
655
- // TODO this isn't the best way to handle this
656
- ruby_xml_node *rxn, *orxn;
657
- VALUE thisxml, otherxml;
658
- Data_Get_Struct(self, ruby_xml_node, rxn);
659
- Data_Get_Struct(other, ruby_xml_node, orxn);
660
- thisxml = ruby_xml_node_to_s(self);
661
- otherxml = ruby_xml_node_to_s(other);
662
-
663
- return(rb_funcall(thisxml, rb_intern("=="), 1, otherxml));
636
+ if (self == other)
637
+ {
638
+ return Qtrue;
639
+ }
640
+ else
641
+ {
642
+ VALUE self_xml = ruby_xml_node_to_s(self);
643
+ VALUE other_xml = ruby_xml_node_to_s(other);
644
+ return(rb_funcall(self_xml, rb_intern("=="), 1, other_xml));
645
+ }
664
646
  }
665
647
 
666
648
 
667
649
  /*
668
650
  * call-seq:
669
- * node.find(xpath_expr, namespace = [any]) => nodeset
651
+ * node.find(xpath_expr, namespace = [any]) -> nodeset
670
652
  *
671
653
  * Find nodes matching the specified xpath expression, optionally
672
654
  * using the specified namespaces. Returns an XML::Node::Set.
@@ -681,7 +663,7 @@ ruby_xml_node_find(int argc, VALUE *argv, VALUE self) {
681
663
 
682
664
  /*
683
665
  * call-seq:
684
- * node.find_first(xpath_expr, namespace = [any]) => nodeset
666
+ * node.find_first(xpath_expr, namespace = [any]) -> nodeset
685
667
  *
686
668
  * Find the first node matching the specified xpath expression, optionally
687
669
  * using the specified namespaces. Returns an XML::Node.
@@ -694,49 +676,32 @@ ruby_xml_node_find_first(int argc, VALUE *argv, VALUE self) {
694
676
 
695
677
  /*
696
678
  * call-seq:
697
- * node.fragment? => (true|false)
679
+ * node.fragment? -> (true|false)
698
680
  *
699
681
  * Determine whether this node is a fragment.
700
682
  */
701
683
  VALUE
702
684
  ruby_xml_node_fragment_q(VALUE self) {
703
- ruby_xml_node *rxn;
704
- Data_Get_Struct(self, ruby_xml_node, rxn);
705
- if (rxn->node->type == XML_DOCUMENT_FRAG_NODE)
685
+ xmlNodePtr xnode;
686
+ Data_Get_Struct(self, xmlNode, xnode);
687
+ if (xnode->type == XML_DOCUMENT_FRAG_NODE)
706
688
  return(Qtrue);
707
689
  else
708
690
  return(Qfalse);
709
691
  }
710
692
 
711
- /*
712
- * call-seq:
713
- * node.hash => fixnum
714
- *
715
- * Returns the hash-code for this node. This is the hash of the XML
716
- * representation in order to be consistent with eql.
717
- */
718
- VALUE
719
- ruby_xml_node_hash(VALUE self) {
720
- ruby_xml_node *rxn;
721
- VALUE thisxml;
722
- Data_Get_Struct(self, ruby_xml_node, rxn);
723
- thisxml = ruby_xml_node_to_s(self);
724
-
725
- return(rb_funcall(thisxml, rb_intern("hash"), 0));
726
- }
727
-
728
693
 
729
694
  /*
730
695
  * call-seq:
731
- * node.html_doc? => (true|false)
696
+ * node.html_doc? -> (true|false)
732
697
  *
733
698
  * Determine whether this node is an html document node.
734
699
  */
735
700
  VALUE
736
701
  ruby_xml_node_html_doc_q(VALUE self) {
737
- ruby_xml_node *rxn;
738
- Data_Get_Struct(self, ruby_xml_node, rxn);
739
- if (rxn->node->type == XML_HTML_DOCUMENT_NODE)
702
+ xmlNodePtr xnode;
703
+ Data_Get_Struct(self, xmlNode, xnode);
704
+ if (xnode->type == XML_HTML_DOCUMENT_NODE)
740
705
  return(Qtrue);
741
706
  else
742
707
  return(Qfalse);
@@ -744,7 +709,7 @@ ruby_xml_node_html_doc_q(VALUE self) {
744
709
 
745
710
  /*
746
711
  * call-seq:
747
- * XML::Node.new_cdata(content = nil) => node
712
+ * XML::Node.new_cdata(content = nil) -> node
748
713
  *
749
714
  * Create a new #CDATA node, optionally setting
750
715
  * the node's content.
@@ -780,7 +745,7 @@ ruby_xml_node_new_cdata(int argc, VALUE *argv, VALUE class) {
780
745
 
781
746
  /*
782
747
  * call-seq:
783
- * XML::Node.new_comment(content = nil) => node
748
+ * XML::Node.new_comment(content = nil) -> node
784
749
  *
785
750
  * Create a new comment node, optionally setting
786
751
  * the node's content.
@@ -818,19 +783,19 @@ ruby_xml_node_new_comment(int argc, VALUE *argv, VALUE class) {
818
783
 
819
784
  /*
820
785
  * call-seq:
821
- * node.lang => "string"
786
+ * node.lang -> "string"
822
787
  *
823
788
  * Obtain the language set for this node, if any.
824
789
  * This is set in XML via the xml:lang attribute.
825
790
  */
826
791
  VALUE
827
792
  ruby_xml_node_lang_get(VALUE self) {
828
- ruby_xml_node *rxn;
793
+ xmlNodePtr xnode;
829
794
  xmlChar *lang;
830
795
  VALUE result = Qnil;
831
796
 
832
- Data_Get_Struct(self, ruby_xml_node, rxn);
833
- lang = xmlNodeGetLang(rxn->node);
797
+ Data_Get_Struct(self, xmlNode, xnode);
798
+ lang = xmlNodeGetLang(xnode);
834
799
 
835
800
  if (lang) {
836
801
  result = rb_str_new2((const char*)lang);
@@ -852,11 +817,11 @@ ruby_xml_node_lang_get(VALUE self) {
852
817
  */
853
818
  VALUE
854
819
  ruby_xml_node_lang_set(VALUE self, VALUE lang) {
855
- ruby_xml_node *node;
820
+ xmlNodePtr xnode;
856
821
 
857
822
  Check_Type(lang, T_STRING);
858
- Data_Get_Struct(self, ruby_xml_node, node);
859
- xmlNodeSetLang(node->node, (xmlChar*)StringValuePtr(lang));
823
+ Data_Get_Struct(self, xmlNode, xnode);
824
+ xmlNodeSetLang(xnode, (xmlChar*)StringValuePtr(lang));
860
825
 
861
826
  return(Qtrue);
862
827
  }
@@ -864,18 +829,18 @@ ruby_xml_node_lang_set(VALUE self, VALUE lang) {
864
829
 
865
830
  /*
866
831
  * call-seq:
867
- * node.last => node
832
+ * node.last -> node
868
833
  *
869
834
  * Obtain the last child node of this node, if any.
870
835
  */
871
836
  VALUE
872
837
  ruby_xml_node_last_get(VALUE self) {
873
- ruby_xml_node *rxn;
838
+ xmlNodePtr xnode;
874
839
  xmlNodePtr node;
875
840
 
876
- Data_Get_Struct(self, ruby_xml_node, rxn);
841
+ Data_Get_Struct(self, xmlNode, xnode);
877
842
 
878
- switch (rxn->node->type) {
843
+ switch (xnode->type) {
879
844
  case XML_ELEMENT_NODE:
880
845
  case XML_ENTITY_REF_NODE:
881
846
  case XML_ENTITY_NODE:
@@ -887,11 +852,11 @@ ruby_xml_node_last_get(VALUE self) {
887
852
  #endif
888
853
  case XML_HTML_DOCUMENT_NODE:
889
854
  case XML_DTD_NODE:
890
- node = rxn->node->last;
855
+ node = xnode->last;
891
856
  break;
892
857
  case XML_ATTRIBUTE_NODE:
893
858
  {
894
- xmlAttrPtr attr = (xmlAttrPtr) rxn->node;
859
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
895
860
  node = attr->last;
896
861
  }
897
862
  default:
@@ -908,18 +873,18 @@ ruby_xml_node_last_get(VALUE self) {
908
873
 
909
874
  /*
910
875
  * call-seq:
911
- * node.last? => (true|false)
876
+ * node.last? -> (true|false)
912
877
  *
913
878
  * Determine whether this node has a last child node.
914
879
  */
915
880
  VALUE
916
881
  ruby_xml_node_last_q(VALUE self) {
917
- ruby_xml_node *rxn;
882
+ xmlNodePtr xnode;
918
883
  xmlNodePtr node;
919
884
 
920
- Data_Get_Struct(self, ruby_xml_node, rxn);
885
+ Data_Get_Struct(self, xmlNode, xnode);
921
886
 
922
- switch (rxn->node->type) {
887
+ switch (xnode->type) {
923
888
  case XML_ELEMENT_NODE:
924
889
  case XML_ENTITY_REF_NODE:
925
890
  case XML_ENTITY_NODE:
@@ -931,11 +896,11 @@ ruby_xml_node_last_q(VALUE self) {
931
896
  #endif
932
897
  case XML_HTML_DOCUMENT_NODE:
933
898
  case XML_DTD_NODE:
934
- node = rxn->node->last;
899
+ node = xnode->last;
935
900
  break;
936
901
  case XML_ATTRIBUTE_NODE:
937
902
  {
938
- xmlAttrPtr attr = (xmlAttrPtr) rxn->node;
903
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
939
904
  node = attr->last;
940
905
  }
941
906
  default:
@@ -952,7 +917,7 @@ ruby_xml_node_last_q(VALUE self) {
952
917
 
953
918
  /*
954
919
  * call-seq:
955
- * node.line_num => num
920
+ * node.line_num -> num
956
921
  *
957
922
  * Obtain the line number (in the XML document) that this
958
923
  * node was read from. If +default_line_numbers+ is set
@@ -960,14 +925,14 @@ ruby_xml_node_last_q(VALUE self) {
960
925
  */
961
926
  VALUE
962
927
  ruby_xml_node_line_num(VALUE self) {
963
- ruby_xml_node *rxn;
928
+ xmlNodePtr xnode;
964
929
  long line_num;
965
- Data_Get_Struct(self, ruby_xml_node, rxn);
930
+ Data_Get_Struct(self, xmlNode, xnode);
966
931
 
967
932
  if (!xmlLineNumbersDefaultValue)
968
933
  rb_warn("Line numbers were not retained: use XML::Parser::default_line_numbers=true");
969
934
 
970
- line_num = xmlGetLineNo(rxn->node);
935
+ line_num = xmlGetLineNo(xnode);
971
936
  if (line_num == -1)
972
937
  return(Qnil);
973
938
  else
@@ -977,17 +942,17 @@ ruby_xml_node_line_num(VALUE self) {
977
942
 
978
943
  /*
979
944
  * call-seq:
980
- * node.xlink? => (true|false)
945
+ * node.xlink? -> (true|false)
981
946
  *
982
947
  * Determine whether this node is an xlink node.
983
948
  */
984
949
  VALUE
985
950
  ruby_xml_node_xlink_q(VALUE self) {
986
- ruby_xml_node *node;
951
+ xmlNodePtr xnode;
987
952
  xlinkType xlt;
988
953
 
989
- Data_Get_Struct(self, ruby_xml_node, node);
990
- xlt = xlinkIsLink(node->node->doc, node->node);
954
+ Data_Get_Struct(self, xmlNode, xnode);
955
+ xlt = xlinkIsLink(xnode->doc, xnode);
991
956
 
992
957
  if (xlt == XLINK_TYPE_NONE)
993
958
  return(Qfalse);
@@ -998,7 +963,7 @@ ruby_xml_node_xlink_q(VALUE self) {
998
963
 
999
964
  /*
1000
965
  * call-seq:
1001
- * node.xlink_type => num
966
+ * node.xlink_type -> num
1002
967
  *
1003
968
  * Obtain the type identifier for this xlink, if applicable.
1004
969
  * If this is not an xlink node (see +xlink?+), will return
@@ -1006,11 +971,11 @@ ruby_xml_node_xlink_q(VALUE self) {
1006
971
  */
1007
972
  VALUE
1008
973
  ruby_xml_node_xlink_type(VALUE self) {
1009
- ruby_xml_node *node;
974
+ xmlNodePtr xnode;
1010
975
  xlinkType xlt;
1011
976
 
1012
- Data_Get_Struct(self, ruby_xml_node, node);
1013
- xlt = xlinkIsLink(node->node->doc, node->node);
977
+ Data_Get_Struct(self, xmlNode, xnode);
978
+ xlt = xlinkIsLink(xnode->doc, xnode);
1014
979
 
1015
980
  if (xlt == XLINK_TYPE_NONE)
1016
981
  return(Qnil);
@@ -1021,7 +986,7 @@ ruby_xml_node_xlink_type(VALUE self) {
1021
986
 
1022
987
  /*
1023
988
  * call-seq:
1024
- * node.xlink_type_name => "string"
989
+ * node.xlink_type_name -> "string"
1025
990
  *
1026
991
  * Obtain the type name for this xlink, if applicable.
1027
992
  * If this is not an xlink node (see +xlink?+), will return
@@ -1029,11 +994,11 @@ ruby_xml_node_xlink_type(VALUE self) {
1029
994
  */
1030
995
  VALUE
1031
996
  ruby_xml_node_xlink_type_name(VALUE self) {
1032
- ruby_xml_node *node;
997
+ xmlNodePtr xnode;
1033
998
  xlinkType xlt;
1034
999
 
1035
- Data_Get_Struct(self, ruby_xml_node, node);
1036
- xlt = xlinkIsLink(node->node->doc, node->node);
1000
+ Data_Get_Struct(self, xmlNode, xnode);
1001
+ xlt = xlinkIsLink(xnode->doc, xnode);
1037
1002
 
1038
1003
  switch(xlt) {
1039
1004
  case XLINK_TYPE_NONE:
@@ -1051,46 +1016,46 @@ ruby_xml_node_xlink_type_name(VALUE self) {
1051
1016
 
1052
1017
  /*
1053
1018
  * call-seq:
1054
- * node.name => "string"
1019
+ * node.name -> "string"
1055
1020
  *
1056
1021
  * Obtain this node's name.
1057
1022
  */
1058
1023
  VALUE
1059
1024
  ruby_xml_node_name_get(VALUE self) {
1060
- ruby_xml_node *rxn;
1025
+ xmlNodePtr xnode;
1061
1026
  const xmlChar *name;
1062
1027
 
1063
- Data_Get_Struct(self, ruby_xml_node, rxn);
1028
+ Data_Get_Struct(self, xmlNode, xnode);
1064
1029
 
1065
- switch (rxn->node->type) {
1030
+ switch (xnode->type) {
1066
1031
  case XML_DOCUMENT_NODE:
1067
1032
  #ifdef LIBXML_DOCB_ENABLED
1068
1033
  case XML_DOCB_DOCUMENT_NODE:
1069
1034
  #endif
1070
1035
  case XML_HTML_DOCUMENT_NODE:
1071
1036
  {
1072
- xmlDocPtr doc = (xmlDocPtr) rxn->node;
1037
+ xmlDocPtr doc = (xmlDocPtr) xnode;
1073
1038
  name = doc->URL;
1074
1039
  break;
1075
1040
  }
1076
1041
  case XML_ATTRIBUTE_NODE:
1077
1042
  {
1078
- xmlAttrPtr attr = (xmlAttrPtr) rxn->node;
1043
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
1079
1044
  name = attr->name;
1080
1045
  break;
1081
1046
  }
1082
1047
  case XML_NAMESPACE_DECL:
1083
1048
  {
1084
- xmlNsPtr ns = (xmlNsPtr) rxn->node;
1049
+ xmlNsPtr ns = (xmlNsPtr) xnode;
1085
1050
  name = ns->prefix;
1086
1051
  break;
1087
1052
  }
1088
1053
  default:
1089
- name = rxn->node->name;
1054
+ name = xnode->name;
1090
1055
  break;
1091
1056
  }
1092
1057
 
1093
- if (rxn->node->name == NULL)
1058
+ if (xnode->name == NULL)
1094
1059
  return(Qnil);
1095
1060
  else
1096
1061
  return(rb_str_new2((const char*)name));
@@ -1105,40 +1070,40 @@ ruby_xml_node_name_get(VALUE self) {
1105
1070
  */
1106
1071
  VALUE
1107
1072
  ruby_xml_node_name_set(VALUE self, VALUE name) {
1108
- ruby_xml_node *node;
1073
+ xmlNodePtr xnode;
1109
1074
 
1110
1075
  Check_Type(name, T_STRING);
1111
- Data_Get_Struct(self, ruby_xml_node, node);
1112
- xmlNodeSetName(node->node, (xmlChar*)StringValuePtr(name));
1076
+ Data_Get_Struct(self, xmlNode, xnode);
1077
+ xmlNodeSetName(xnode, (xmlChar*)StringValuePtr(name));
1113
1078
  return(Qtrue);
1114
1079
  }
1115
1080
 
1116
1081
 
1117
1082
  /*
1118
1083
  * call-seq:
1119
- * node.namespace => [namespace, ..., namespace]
1084
+ * node.namespace -> [namespace, ..., namespace]
1120
1085
  *
1121
1086
  * Obtain an array of +XML::NS+ objects representing
1122
1087
  * this node's xmlns attributes
1123
1088
  */
1124
1089
  VALUE
1125
1090
  ruby_xml_node_namespace_get(VALUE self) {
1126
- ruby_xml_node *node;
1091
+ xmlNodePtr xnode;
1127
1092
  xmlNsPtr *nsList, *cur;
1128
1093
  VALUE arr, ns;
1129
1094
 
1130
- Data_Get_Struct(self, ruby_xml_node, node);
1131
- if (node->node == NULL)
1095
+ Data_Get_Struct(self, xmlNode, xnode);
1096
+ if (xnode == NULL)
1132
1097
  return(Qnil);
1133
1098
 
1134
- nsList = xmlGetNsList(node->node->doc, node->node);
1099
+ nsList = xmlGetNsList(xnode->doc, xnode);
1135
1100
 
1136
1101
  if (nsList == NULL)
1137
1102
  return(Qnil);
1138
1103
 
1139
1104
  arr = rb_ary_new();
1140
1105
  for (cur = nsList; *cur != NULL; cur++) {
1141
- ns = ruby_xml_ns_new2(cXMLNS, ruby_xml_document_wrap(node->node->doc), *cur);
1106
+ ns = ruby_xml_ns_wrap(*cur);
1142
1107
  if (ns == Qnil)
1143
1108
  continue;
1144
1109
  else
@@ -1152,21 +1117,19 @@ ruby_xml_node_namespace_get(VALUE self) {
1152
1117
 
1153
1118
  /*
1154
1119
  * call-seq:
1155
- * node.namespace_node => namespace.
1120
+ * node.namespace_node -> namespace.
1156
1121
  *
1157
1122
  * Obtain this node's namespace node.
1158
1123
  */
1159
1124
  VALUE
1160
1125
  ruby_xml_node_namespace_get_node(VALUE self) {
1161
- ruby_xml_node *node;
1126
+ xmlNodePtr xnode;
1162
1127
 
1163
- Data_Get_Struct(self, ruby_xml_node, node);
1164
- if (node->node->ns == NULL)
1128
+ Data_Get_Struct(self, xmlNode, xnode);
1129
+ if (xnode->ns == NULL)
1165
1130
  return(Qnil);
1166
1131
  else
1167
- return ruby_xml_ns_new2(cXMLNS,
1168
- ruby_xml_document_wrap(node->node->doc),
1169
- node->node->ns);
1132
+ return ruby_xml_ns_wrap(xnode->ns);
1170
1133
  }
1171
1134
 
1172
1135
  // TODO namespace_set can take varargs (in fact, must if used
@@ -1185,12 +1148,11 @@ ruby_xml_node_namespace_get_node(VALUE self) {
1185
1148
  VALUE
1186
1149
  ruby_xml_node_namespace_set(int argc, VALUE *argv, VALUE self) {
1187
1150
  VALUE rns, rprefix;
1188
- ruby_xml_node *rxn;
1189
- ruby_xml_ns *rxns;
1190
- xmlNsPtr ns;
1151
+ xmlNodePtr xnode;
1152
+ xmlNsPtr xns;
1191
1153
  char *cp, *href;
1192
1154
 
1193
- Data_Get_Struct(self, ruby_xml_node, rxn);
1155
+ Data_Get_Struct(self, xmlNode, xnode);
1194
1156
  switch (argc) {
1195
1157
  case 1:
1196
1158
  rns = argv[0];
@@ -1204,8 +1166,8 @@ ruby_xml_node_namespace_set(int argc, VALUE *argv, VALUE self) {
1204
1166
  href = &cp[1]; /* skip the : */
1205
1167
  }
1206
1168
  } else if (rb_obj_is_kind_of(rns, cXMLNS) == Qtrue) {
1207
- Data_Get_Struct(self, ruby_xml_ns, rxns);
1208
- xmlSetNs(rxn->node, rxns->ns);
1169
+ Data_Get_Struct(self, xmlNs, xns);
1170
+ xmlSetNs(xnode, xns);
1209
1171
  return(rns);
1210
1172
  } else
1211
1173
  rb_raise(rb_eTypeError, "must pass a string or an XML::Ns object");
@@ -1220,11 +1182,11 @@ ruby_xml_node_namespace_set(int argc, VALUE *argv, VALUE self) {
1220
1182
  href = StringValuePtr(argv[1]);
1221
1183
  }
1222
1184
 
1223
- ns = xmlNewNs(rxn->node, (xmlChar*)href, (xmlChar*)StringValuePtr(rprefix));
1224
- if (ns == NULL)
1185
+ xns = xmlNewNs(xnode, (xmlChar*)href, (xmlChar*)StringValuePtr(rprefix));
1186
+ if (xns == NULL)
1225
1187
  rb_raise(eXMLNodeSetNamespace, "unable to set the namespace");
1226
1188
  else
1227
- return ruby_xml_ns_new2(cXMLNS, ruby_xml_document_wrap(rxn->node->doc), ns);
1189
+ return ruby_xml_ns_wrap(xns);
1228
1190
  break;
1229
1191
 
1230
1192
  default:
@@ -1238,16 +1200,16 @@ ruby_xml_node_namespace_set(int argc, VALUE *argv, VALUE self) {
1238
1200
 
1239
1201
  /*
1240
1202
  * call-seq:
1241
- * node.namespace? => (true|false)
1203
+ * node.namespace? -> (true|false)
1242
1204
  *
1243
1205
  * Determine whether this node *is* (not has) a namespace
1244
1206
  * node.
1245
1207
  */
1246
1208
  VALUE
1247
1209
  ruby_xml_node_namespace_q(VALUE self) {
1248
- ruby_xml_node *rxn;
1249
- Data_Get_Struct(self, ruby_xml_node, rxn);
1250
- if (rxn->node->type == XML_NAMESPACE_DECL)
1210
+ xmlNodePtr xnode;
1211
+ Data_Get_Struct(self, xmlNode, xnode);
1212
+ if (xnode->type == XML_NAMESPACE_DECL)
1251
1213
  return(Qtrue);
1252
1214
  else
1253
1215
  return(Qfalse);
@@ -1265,71 +1227,64 @@ ruby_xml_node_namespace_q(VALUE self) {
1265
1227
  * If the xmlNode has no parent or document, then call xmlFree.
1266
1228
  */
1267
1229
  void
1268
- ruby_xml_node2_free(ruby_xml_node *rxn) {
1269
-
1270
- if (rxn == NULL ) return;
1230
+ ruby_xml_node2_free(xmlNodePtr xnode) {
1271
1231
 
1272
- if (rxn->node != NULL ) {
1273
- rxn->node->_private=NULL;
1232
+ if (xnode != NULL) {
1233
+ xnode->_private=NULL;
1274
1234
 
1275
- if ( rxn->node->doc==NULL || rxn->node->parent==NULL ) {
1235
+ if (xnode->doc==NULL && xnode->parent==NULL) {
1276
1236
  #ifdef NODE_DEBUG
1277
- fprintf(stderr,"ruby_xml_node2_free ruby_xfree rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)rxn->node,(long)rxn->node->_private);
1237
+ fprintf(stderr,"ruby_xml_node2_free ruby_xfree rxn=0x%x xn=0x%x o=0x%x\n",(long)rxn,(long)xnode,(long)xnode->_private);
1278
1238
  #endif
1279
- xmlFreeNode(rxn->node);
1239
+ xmlFreeNode(xnode);
1280
1240
  }
1281
-
1282
- rxn->node=NULL;
1283
1241
  }
1284
-
1285
- ruby_xfree(rxn);
1286
1242
  }
1287
1243
 
1288
1244
  void
1289
- ruby_xml_node_mark_common(xmlNodePtr node) {
1290
- if (node->parent == NULL ) {
1245
+ ruby_xml_node_mark_common(xmlNodePtr xnode) {
1246
+ if (xnode->parent == NULL ) {
1291
1247
  #ifdef NODE_DEBUG
1292
1248
  fprintf(stderr,"mark no parent r=0x%x *n=0x%x\n",rxn,node);
1293
1249
  #endif
1294
- } else if ( node->doc != NULL ) {
1295
- if (node->doc->_private == NULL) {
1250
+ } else if (xnode->doc != NULL ) {
1251
+ if (xnode->doc->_private == NULL) {
1296
1252
  rb_bug("XmlNode Doc is not bound! (%s:%d)",
1297
1253
  __FILE__,__LINE__);
1298
1254
  }
1299
- rb_gc_mark((VALUE)node->doc->_private);
1255
+ rb_gc_mark((VALUE)xnode->doc->_private);
1300
1256
  } else {
1301
- while (node->parent != NULL )
1302
- node=node->parent;
1303
- if (node->_private == NULL )
1257
+ while (xnode->parent != NULL )
1258
+ xnode = xnode->parent;
1259
+ if (xnode->_private == NULL )
1304
1260
  rb_warning("XmlNode Root Parent is not bound! (%s:%d)",
1305
1261
  __FILE__,__LINE__);
1306
1262
  else {
1307
1263
  #ifdef NODE_DEBUG
1308
1264
  fprintf(stderr,"mark rxn=0x%x xn=0x%x o=0x%x doc=0x%x\n",(long)rxn,(long)node,(long)node->_private,node->doc);
1309
1265
  #endif
1310
- rb_gc_mark((VALUE)node->_private);
1266
+ rb_gc_mark((VALUE)xnode->_private);
1311
1267
  }
1312
1268
  }
1313
1269
  }
1314
1270
 
1315
1271
  void
1316
- ruby_xml_node2_mark(ruby_xml_node *rxn) {
1317
- if (rxn->node == NULL ) return;
1272
+ ruby_xml_node2_mark(xmlNodePtr xnode) {
1273
+ if (xnode == NULL ) return;
1318
1274
 
1319
- if (rxn->node->_private == NULL ) {
1275
+ if (xnode->_private == NULL ) {
1320
1276
  rb_warning("XmlNode is not bound! (%s:%d)",
1321
1277
  __FILE__,__LINE__);
1322
1278
  return;
1323
1279
  }
1324
1280
 
1325
- ruby_xml_node_mark_common(rxn->node);
1281
+ ruby_xml_node_mark_common(xnode);
1326
1282
  }
1327
1283
 
1328
1284
  VALUE
1329
1285
  ruby_xml_node2_wrap(VALUE class, xmlNodePtr xnode)
1330
1286
  {
1331
1287
  VALUE obj;
1332
- ruby_xml_node *rxn;
1333
1288
 
1334
1289
  // This node is already wrapped
1335
1290
  if (xnode->_private != NULL) {
@@ -1340,10 +1295,10 @@ ruby_xml_node2_wrap(VALUE class, xmlNodePtr xnode)
1340
1295
  return (VALUE)xnode->_private;
1341
1296
  }
1342
1297
 
1343
- obj=Data_Make_Struct(class,ruby_xml_node,ruby_xml_node2_mark,
1344
- ruby_xml_node2_free,rxn);
1298
+ obj=Data_Wrap_Struct(class,
1299
+ ruby_xml_node2_mark, ruby_xml_node2_free,
1300
+ xnode);
1345
1301
 
1346
- rxn->node=xnode;
1347
1302
  xnode->_private=(void*)obj;
1348
1303
  #ifdef NODE_DEBUG
1349
1304
  fprintf(stderr,"wrap rn=0x%x n*=0x%x d*=0x%x\n",
@@ -1365,8 +1320,7 @@ ruby_xml_node2_new_native(VALUE class, VALUE ns, VALUE name)
1365
1320
  xnode=xmlNewNode(xns,(xmlChar*)StringValuePtr(name));
1366
1321
  xnode->_private=NULL;
1367
1322
 
1368
- obj=
1369
- ruby_xml_node2_wrap(class,xnode);
1323
+ obj= ruby_xml_node2_wrap(class,xnode);
1370
1324
 
1371
1325
  rb_obj_call_init(obj,0,NULL);
1372
1326
  return obj;
@@ -1386,8 +1340,8 @@ ruby_xml_node2_new_string(VALUE class, VALUE ns, VALUE name, VALUE val)
1386
1340
  }
1387
1341
  /*
1388
1342
  * call-seq:
1389
- * XML::Node.new(name, content = nil) => node
1390
- * XML::Node.new_element(name, content = nil) => node
1343
+ * XML::Node.new(name, content = nil) -> node
1344
+ * XML::Node.new_element(name, content = nil) -> node
1391
1345
  *
1392
1346
  * Create a new element node with the specified name, optionally setting
1393
1347
  * the node's content.
@@ -1415,17 +1369,17 @@ ruby_xml_node2_new_string_bc(int argc, VALUE *argv, VALUE class)
1415
1369
 
1416
1370
  /*
1417
1371
  * call-seq:
1418
- * node.next => node
1372
+ * node.next -> node
1419
1373
  *
1420
1374
  * Obtain the next sibling node, if any.
1421
1375
  */
1422
1376
  VALUE
1423
1377
  ruby_xml_node_next_get(VALUE self) {
1424
- ruby_xml_node *rxn;
1378
+ xmlNodePtr xnode;
1425
1379
  xmlNodePtr node;
1426
- Data_Get_Struct(self, ruby_xml_node, rxn);
1380
+ Data_Get_Struct(self, xmlNode, xnode);
1427
1381
 
1428
- switch (rxn->node->type) {
1382
+ switch (xnode->type) {
1429
1383
  case XML_DOCUMENT_NODE:
1430
1384
  #ifdef LIBXML_DOCB_ENABLED
1431
1385
  case XML_DOCB_DOCUMENT_NODE:
@@ -1435,18 +1389,18 @@ ruby_xml_node_next_get(VALUE self) {
1435
1389
  break;
1436
1390
  case XML_ATTRIBUTE_NODE:
1437
1391
  {
1438
- xmlAttrPtr attr = (xmlAttrPtr) rxn->node;
1392
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
1439
1393
  node = (xmlNodePtr) attr->next;
1440
1394
  break;
1441
1395
  }
1442
1396
  case XML_NAMESPACE_DECL:
1443
1397
  {
1444
- xmlNsPtr ns = (xmlNsPtr) rxn->node;
1398
+ xmlNsPtr ns = (xmlNsPtr) xnode;
1445
1399
  node = (xmlNodePtr) ns->next;
1446
1400
  break;
1447
1401
  }
1448
1402
  default:
1449
- node = rxn->node->next;
1403
+ node = xnode->next;
1450
1404
  break;
1451
1405
  }
1452
1406
 
@@ -1460,17 +1414,17 @@ ruby_xml_node_next_get(VALUE self) {
1460
1414
 
1461
1415
  /*
1462
1416
  * call-seq:
1463
- * node.next? => (true|false)
1417
+ * node.next? -> (true|false)
1464
1418
  *
1465
1419
  * Determine whether this node has a next sibling.
1466
1420
  */
1467
1421
  VALUE
1468
1422
  ruby_xml_node_next_q(VALUE self) {
1469
- ruby_xml_node *rxn;
1423
+ xmlNodePtr xnode;
1470
1424
  xmlNodePtr node;
1471
- Data_Get_Struct(self, ruby_xml_node, rxn);
1425
+ Data_Get_Struct(self, xmlNode, xnode);
1472
1426
 
1473
- switch (rxn->node->type) {
1427
+ switch (xnode->type) {
1474
1428
  case XML_DOCUMENT_NODE:
1475
1429
  #ifdef LIBXML_DOCB_ENABLED
1476
1430
  case XML_DOCB_DOCUMENT_NODE:
@@ -1480,18 +1434,18 @@ ruby_xml_node_next_q(VALUE self) {
1480
1434
  break;
1481
1435
  case XML_ATTRIBUTE_NODE:
1482
1436
  {
1483
- xmlAttrPtr attr = (xmlAttrPtr) rxn->node;
1437
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
1484
1438
  node = (xmlNodePtr) attr->next;
1485
1439
  break;
1486
1440
  }
1487
1441
  case XML_NAMESPACE_DECL:
1488
1442
  {
1489
- xmlNsPtr ns = (xmlNsPtr) rxn->node;
1443
+ xmlNsPtr ns = (xmlNsPtr) xnode;
1490
1444
  node = (xmlNodePtr) ns->next;
1491
1445
  break;
1492
1446
  }
1493
1447
  default:
1494
- node = rxn->node->next;
1448
+ node = xnode->next;
1495
1449
  break;
1496
1450
  }
1497
1451
 
@@ -1510,16 +1464,15 @@ ruby_xml_node_next_q(VALUE self) {
1510
1464
  */
1511
1465
  VALUE
1512
1466
  ruby_xml_node_next_set(VALUE self, VALUE rnode) {
1513
- ruby_xml_node *cnode, *pnode;
1514
- xmlNodePtr ret;
1467
+ xmlNodePtr cnode, pnode, ret;
1515
1468
 
1516
1469
  if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
1517
1470
  rb_raise(rb_eTypeError, "Must pass an XML::Node object");
1518
1471
 
1519
- Data_Get_Struct(self, ruby_xml_node, pnode);
1520
- Data_Get_Struct(rnode, ruby_xml_node, cnode);
1472
+ Data_Get_Struct(self, xmlNode, pnode);
1473
+ Data_Get_Struct(rnode, xmlNode, cnode);
1521
1474
 
1522
- ret = xmlAddNextSibling(pnode->node, cnode->node);
1475
+ ret = xmlAddNextSibling(pnode, cnode);
1523
1476
  if (ret == NULL)
1524
1477
  rb_raise(eXMLNodeFailedModify, "unable to add a sibling to the document");
1525
1478
 
@@ -1529,15 +1482,15 @@ ruby_xml_node_next_set(VALUE self, VALUE rnode) {
1529
1482
 
1530
1483
  /*
1531
1484
  * call-seq:
1532
- * node.notation? => (true|false)
1485
+ * node.notation? -> (true|false)
1533
1486
  *
1534
1487
  * Determine whether this is a notation node
1535
1488
  */
1536
1489
  VALUE
1537
1490
  ruby_xml_node_notation_q(VALUE self) {
1538
- ruby_xml_node *rxn;
1539
- Data_Get_Struct(self, ruby_xml_node, rxn);
1540
- if (rxn->node->type == XML_NOTATION_NODE)
1491
+ xmlNodePtr xnode;
1492
+ Data_Get_Struct(self, xmlNode, xnode);
1493
+ if (xnode->type == XML_NOTATION_NODE)
1541
1494
  return(Qtrue);
1542
1495
  else
1543
1496
  return(Qfalse);
@@ -1546,15 +1499,15 @@ ruby_xml_node_notation_q(VALUE self) {
1546
1499
 
1547
1500
  /*
1548
1501
  * call-seq:
1549
- * node.ns? => (true|false)
1502
+ * node.ns? -> (true|false)
1550
1503
  *
1551
1504
  * Determine whether this node is a namespace node.
1552
1505
  */
1553
1506
  VALUE
1554
1507
  ruby_xml_node_ns_q(VALUE self) {
1555
- ruby_xml_node *rxn;
1556
- Data_Get_Struct(self, ruby_xml_node, rxn);
1557
- if (rxn->node->ns == NULL)
1508
+ xmlNodePtr xnode;
1509
+ Data_Get_Struct(self, xmlNode, xnode);
1510
+ if (xnode->ns == NULL)
1558
1511
  return(Qfalse);
1559
1512
  else
1560
1513
  return(Qtrue);
@@ -1563,33 +1516,33 @@ ruby_xml_node_ns_q(VALUE self) {
1563
1516
 
1564
1517
  /*
1565
1518
  * call-seq:
1566
- * node.ns_def => namespace
1519
+ * node.ns_def -> namespace
1567
1520
  *
1568
1521
  * Obtain this node's default namespace.
1569
1522
  */
1570
1523
  VALUE
1571
1524
  ruby_xml_node_ns_def_get(VALUE self) {
1572
- ruby_xml_node *rxn;
1573
- Data_Get_Struct(self, ruby_xml_node, rxn);
1574
- if (rxn->node->nsDef == NULL)
1525
+ xmlNodePtr xnode;
1526
+ Data_Get_Struct(self, xmlNode, xnode);
1527
+ if (xnode->nsDef == NULL)
1575
1528
  return(Qnil);
1576
1529
  else
1577
- return(ruby_xml_ns_new2(cXMLNS, ruby_xml_document_wrap(rxn->node->doc), rxn->node->nsDef));
1530
+ return(ruby_xml_ns_wrap(xnode->nsDef));
1578
1531
  }
1579
1532
 
1580
1533
 
1581
1534
  /*
1582
1535
  * call-seq:
1583
- * node.ns_def? => (true|false)
1536
+ * node.ns_def? -> (true|false)
1584
1537
  *
1585
1538
  * Obtain an array of +XML::NS+ objects representing
1586
1539
  * this node's xmlns attributes
1587
1540
  */
1588
1541
  VALUE
1589
1542
  ruby_xml_node_ns_def_q(VALUE self) {
1590
- ruby_xml_node *rxn;
1591
- Data_Get_Struct(self, ruby_xml_node, rxn);
1592
- if (rxn->node->nsDef == NULL)
1543
+ xmlNodePtr xnode;
1544
+ Data_Get_Struct(self, xmlNode, xnode);
1545
+ if (xnode->nsDef == NULL)
1593
1546
  return(Qfalse);
1594
1547
  else
1595
1548
  return(Qtrue);
@@ -1598,18 +1551,18 @@ ruby_xml_node_ns_def_q(VALUE self) {
1598
1551
 
1599
1552
  /*
1600
1553
  * call-seq:
1601
- * node.parent => node
1554
+ * node.parent -> node
1602
1555
  *
1603
1556
  * Obtain this node's parent node, if any.
1604
1557
  */
1605
1558
  VALUE
1606
1559
  ruby_xml_node_parent_get(VALUE self) {
1607
- ruby_xml_node *rxn;
1560
+ xmlNodePtr xnode;
1608
1561
  xmlNodePtr node;
1609
1562
 
1610
- Data_Get_Struct(self, ruby_xml_node, rxn);
1563
+ Data_Get_Struct(self, xmlNode, xnode);
1611
1564
 
1612
- switch (rxn->node->type) {
1565
+ switch (xnode->type) {
1613
1566
  case XML_DOCUMENT_NODE:
1614
1567
  case XML_HTML_DOCUMENT_NODE:
1615
1568
  #ifdef LIBXML_DOCB_ENABLED
@@ -1619,7 +1572,7 @@ ruby_xml_node_parent_get(VALUE self) {
1619
1572
  break;
1620
1573
  case XML_ATTRIBUTE_NODE:
1621
1574
  {
1622
- xmlAttrPtr attr = (xmlAttrPtr) rxn->node;
1575
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
1623
1576
  node = attr->parent;
1624
1577
  }
1625
1578
  case XML_ENTITY_DECL:
@@ -1629,7 +1582,7 @@ ruby_xml_node_parent_get(VALUE self) {
1629
1582
  node = NULL;
1630
1583
  break;
1631
1584
  default:
1632
- node = rxn->node->parent;
1585
+ node = xnode->parent;
1633
1586
  break;
1634
1587
  }
1635
1588
 
@@ -1642,18 +1595,18 @@ ruby_xml_node_parent_get(VALUE self) {
1642
1595
 
1643
1596
  /*
1644
1597
  * call-seq:
1645
- * node.parent? => (true|false)
1598
+ * node.parent? -> (true|false)
1646
1599
  *
1647
1600
  * Determine whether this node has a parent node.
1648
1601
  */
1649
1602
  VALUE
1650
1603
  ruby_xml_node_parent_q(VALUE self) {
1651
- ruby_xml_node *rxn;
1604
+ xmlNodePtr xnode;
1652
1605
  xmlNodePtr node;
1653
1606
 
1654
- Data_Get_Struct(self, ruby_xml_node, rxn);
1607
+ Data_Get_Struct(self, xmlNode, xnode);
1655
1608
 
1656
- switch (rxn->node->type) {
1609
+ switch (xnode->type) {
1657
1610
  case XML_DOCUMENT_NODE:
1658
1611
  case XML_HTML_DOCUMENT_NODE:
1659
1612
  #ifdef LIBXML_DOCB_ENABLED
@@ -1663,7 +1616,7 @@ ruby_xml_node_parent_q(VALUE self) {
1663
1616
  break;
1664
1617
  case XML_ATTRIBUTE_NODE:
1665
1618
  {
1666
- xmlAttrPtr attr = (xmlAttrPtr) rxn->node;
1619
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
1667
1620
  node = attr->parent;
1668
1621
  }
1669
1622
  case XML_ENTITY_DECL:
@@ -1673,7 +1626,7 @@ ruby_xml_node_parent_q(VALUE self) {
1673
1626
  node = NULL;
1674
1627
  break;
1675
1628
  default:
1676
- node = rxn->node->parent;
1629
+ node = xnode->parent;
1677
1630
  break;
1678
1631
  }
1679
1632
 
@@ -1686,17 +1639,17 @@ ruby_xml_node_parent_q(VALUE self) {
1686
1639
 
1687
1640
  /*
1688
1641
  * call-seq:
1689
- * node.path => path
1642
+ * node.path -> path
1690
1643
  *
1691
1644
  * Obtain this node's path.
1692
1645
  */
1693
1646
  VALUE
1694
1647
  ruby_xml_node_path(VALUE self) {
1695
- ruby_xml_node *rxn;
1648
+ xmlNodePtr xnode;
1696
1649
  xmlChar *path;
1697
1650
 
1698
- Data_Get_Struct(self, ruby_xml_node, rxn);
1699
- path = xmlGetNodePath(rxn->node);
1651
+ Data_Get_Struct(self, xmlNode, xnode);
1652
+ path = xmlGetNodePath(xnode);
1700
1653
 
1701
1654
  if (path == NULL)
1702
1655
  return(Qnil);
@@ -1707,15 +1660,15 @@ ruby_xml_node_path(VALUE self) {
1707
1660
 
1708
1661
  /*
1709
1662
  * call-seq:
1710
- * node.pi? => (true|false)
1663
+ * node.pi? -> (true|false)
1711
1664
  *
1712
1665
  * Determine whether this is a processing instruction node.
1713
1666
  */
1714
1667
  VALUE
1715
1668
  ruby_xml_node_pi_q(VALUE self) {
1716
- ruby_xml_node *rxn;
1717
- Data_Get_Struct(self, ruby_xml_node, rxn);
1718
- if (rxn->node->type == XML_PI_NODE)
1669
+ xmlNodePtr xnode;
1670
+ Data_Get_Struct(self, xmlNode, xnode);
1671
+ if (xnode->type == XML_PI_NODE)
1719
1672
  return(Qtrue);
1720
1673
  else
1721
1674
  return(Qfalse);
@@ -1724,7 +1677,7 @@ ruby_xml_node_pi_q(VALUE self) {
1724
1677
 
1725
1678
  /*
1726
1679
  * call-seq:
1727
- * node.pointer => node_set
1680
+ * node.pointer -> node_set
1728
1681
  *
1729
1682
  * Evaluates an XPointer expression relative to this node.
1730
1683
  */
@@ -1736,17 +1689,17 @@ ruby_xml_node_pointer(VALUE self, VALUE xptr_str) {
1736
1689
 
1737
1690
  /*
1738
1691
  * call-seq:
1739
- * node.prev => node
1692
+ * node.prev -> node
1740
1693
  *
1741
1694
  * Obtain the previous sibling, if any.
1742
1695
  */
1743
1696
  VALUE
1744
1697
  ruby_xml_node_prev_get(VALUE self) {
1745
- ruby_xml_node *rxn;
1698
+ xmlNodePtr xnode;
1746
1699
  xmlNodePtr node;
1747
- Data_Get_Struct(self, ruby_xml_node, rxn);
1700
+ Data_Get_Struct(self, xmlNode, xnode);
1748
1701
 
1749
- switch (rxn->node->type) {
1702
+ switch (xnode->type) {
1750
1703
  case XML_DOCUMENT_NODE:
1751
1704
  #ifdef LIBXML_DOCB_ENABLED
1752
1705
  case XML_DOCB_DOCUMENT_NODE:
@@ -1757,12 +1710,12 @@ ruby_xml_node_prev_get(VALUE self) {
1757
1710
  break;
1758
1711
  case XML_ATTRIBUTE_NODE:
1759
1712
  {
1760
- xmlAttrPtr attr = (xmlAttrPtr) rxn->node;
1713
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
1761
1714
  node = (xmlNodePtr) attr->prev;
1762
1715
  }
1763
1716
  break;
1764
1717
  default:
1765
- node = rxn->node->prev;
1718
+ node = xnode->prev;
1766
1719
  break;
1767
1720
  }
1768
1721
 
@@ -1775,18 +1728,18 @@ ruby_xml_node_prev_get(VALUE self) {
1775
1728
 
1776
1729
  /*
1777
1730
  * call-seq:
1778
- * node.prev? => (true|false)
1731
+ * node.prev? -> (true|false)
1779
1732
  *
1780
1733
  * Determines whether this node has a previous sibling node.
1781
1734
  */
1782
1735
  VALUE
1783
1736
  ruby_xml_node_prev_q(VALUE self) {
1784
- ruby_xml_node *rxn;
1737
+ xmlNodePtr xnode;
1785
1738
  xmlNodePtr node;
1786
1739
 
1787
- Data_Get_Struct(self, ruby_xml_node, rxn);
1740
+ Data_Get_Struct(self, xmlNode, xnode);
1788
1741
 
1789
- switch (rxn->node->type) {
1742
+ switch (xnode->type) {
1790
1743
  case XML_DOCUMENT_NODE:
1791
1744
  #ifdef LIBXML_DOCB_ENABLED
1792
1745
  case XML_DOCB_DOCUMENT_NODE:
@@ -1797,12 +1750,12 @@ ruby_xml_node_prev_q(VALUE self) {
1797
1750
  break;
1798
1751
  case XML_ATTRIBUTE_NODE:
1799
1752
  {
1800
- xmlAttrPtr attr = (xmlAttrPtr) rxn->node;
1753
+ xmlAttrPtr attr = (xmlAttrPtr) xnode;
1801
1754
  node = (xmlNodePtr) attr->prev;
1802
1755
  }
1803
1756
  break;
1804
1757
  default:
1805
- node = rxn->node->prev;
1758
+ node = xnode->prev;
1806
1759
  break;
1807
1760
  }
1808
1761
 
@@ -1821,16 +1774,15 @@ ruby_xml_node_prev_q(VALUE self) {
1821
1774
  */
1822
1775
  VALUE
1823
1776
  ruby_xml_node_prev_set(VALUE self, VALUE rnode) {
1824
- ruby_xml_node *cnode, *pnode;
1825
- xmlNodePtr ret;
1777
+ xmlNodePtr cnode, pnode, ret;
1826
1778
 
1827
1779
  if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
1828
1780
  rb_raise(rb_eTypeError, "Must pass an XML::Node object");
1829
1781
 
1830
- Data_Get_Struct(self, ruby_xml_node, pnode);
1831
- Data_Get_Struct(rnode, ruby_xml_node, cnode);
1782
+ Data_Get_Struct(self, xmlNode, pnode);
1783
+ Data_Get_Struct(rnode, xmlNode, cnode);
1832
1784
 
1833
- ret = xmlAddPrevSibling(pnode->node, cnode->node);
1785
+ ret = xmlAddPrevSibling(pnode, cnode);
1834
1786
  if (ret == NULL)
1835
1787
  rb_raise(eXMLNodeFailedModify, "unable to add a sibling to the document");
1836
1788
 
@@ -1840,105 +1792,61 @@ ruby_xml_node_prev_set(VALUE self, VALUE rnode) {
1840
1792
 
1841
1793
  /*
1842
1794
  * call-seq:
1843
- * node.property("name") => "string"
1844
- * node["name"] => "string"
1795
+ * node.attributes -> attributes
1845
1796
  *
1846
- * Obtain the named property.
1797
+ * Returns the XML::Attributes for this node.
1847
1798
  */
1848
1799
  VALUE
1849
- ruby_xml_node_property_get(VALUE self, VALUE prop) {
1850
- ruby_xml_node *rxn;
1851
- xmlChar *p;
1852
- VALUE result = Qnil;
1853
-
1854
- prop = check_string_or_symbol( prop );
1855
-
1856
- Data_Get_Struct(self, ruby_xml_node, rxn);
1857
- p = xmlGetProp(rxn->node, (xmlChar*)StringValuePtr(prop));
1800
+ ruby_xml_node_attributes_get(VALUE self) {
1801
+ xmlNodePtr xnode;
1858
1802
 
1859
- if (p) {
1860
- result = rb_str_new2((const char*)p);
1861
- xmlFree(p);
1803
+ Data_Get_Struct(self, xmlNode, xnode);
1804
+
1805
+ if (xnode->type == XML_ELEMENT_NODE) {
1806
+ return ruby_xml_attributes_new(xnode);
1807
+ } else {
1808
+ return(Qnil);
1862
1809
  }
1863
-
1864
- return result;
1865
1810
  }
1866
1811
 
1867
-
1868
1812
  /*
1869
1813
  * call-seq:
1870
- * node["name"] = "string"
1814
+ * node.property("name") -> "string"
1815
+ * node["name"] -> "string"
1871
1816
  *
1872
- * Set the named property.
1817
+ * Obtain the named property.
1873
1818
  */
1874
1819
  VALUE
1875
- ruby_xml_node_property_set(VALUE self, VALUE key, VALUE val) {
1876
- ruby_xml_node *node;
1877
- xmlAttrPtr attr;
1878
-
1879
- key = check_string_or_symbol( key );
1880
- Data_Get_Struct(self, ruby_xml_node, node);
1881
-
1882
- if( val == Qnil ) {
1883
- attr = xmlSetProp(node->node, (xmlChar*)StringValuePtr(key), NULL);
1884
- if (attr->_private == NULL)
1885
- xmlRemoveProp( attr );
1886
- else
1887
- xmlUnlinkNode( attr );
1888
- return Qnil;
1889
- } else {
1890
- Check_Type(val, T_STRING);
1891
- }
1892
-
1893
- attr = xmlSetProp(node->node, (xmlChar*)StringValuePtr(key), (xmlChar*)StringValuePtr(val));
1894
- if (attr == NULL) {
1895
- attr = xmlNewProp(node->node, (xmlChar*)StringValuePtr(key), (xmlChar*)StringValuePtr(val));
1896
- if (attr == NULL)
1897
- return(Qnil);
1898
- }
1899
- return(ruby_xml_attr_new(cXMLAttr, attr));
1820
+ ruby_xml_node_property_get(VALUE self, VALUE name) {
1821
+ VALUE attributes = ruby_xml_node_attributes_get(self);
1822
+ return ruby_xml_attributes_attribute_get(attributes, name);
1900
1823
  }
1901
1824
 
1902
-
1903
1825
  /*
1904
1826
  * call-seq:
1905
- * node.properties => attributes
1827
+ * node["name"] = "string"
1906
1828
  *
1907
- * Returns the +XML::Attr+ for this node.
1829
+ * Set the named property.
1908
1830
  */
1909
1831
  VALUE
1910
- ruby_xml_node_properties_get(VALUE self) {
1911
- ruby_xml_node *node;
1912
- xmlAttrPtr attr;
1913
-
1914
- Data_Get_Struct(self, ruby_xml_node, node);
1915
-
1916
- if (node->node->type == XML_ELEMENT_NODE) {
1917
- attr = node->node->properties;
1918
-
1919
- if (attr == NULL) {
1920
- return(Qnil);
1921
- } else {
1922
- return(ruby_xml_attr_wrap(cXMLAttr, attr));
1923
- }
1924
- } else {
1925
- return(Qnil);
1926
- }
1832
+ ruby_xml_node_property_set(VALUE self, VALUE name, VALUE value) {
1833
+ VALUE attributes = ruby_xml_node_attributes_get(self);
1834
+ return ruby_xml_attributes_attribute_set(attributes, name, value);
1927
1835
  }
1928
1836
 
1929
1837
 
1930
1838
  /*
1931
1839
  * call-seq:
1932
- * node.properties? => (true|false)
1840
+ * node.attributes? -> (true|false)
1933
1841
  *
1934
1842
  * Determine whether this node has properties
1935
1843
  * (attributes).
1936
1844
  */
1937
1845
  VALUE
1938
- ruby_xml_node_properties_q(VALUE self) {
1939
- ruby_xml_node *rxn;
1940
- Data_Get_Struct(self, ruby_xml_node, rxn);
1941
- if (rxn->node->type == XML_ELEMENT_NODE && rxn->node->properties != NULL)
1846
+ ruby_xml_node_attributes_q(VALUE self) {
1847
+ xmlNodePtr xnode;
1848
+ Data_Get_Struct(self, xmlNode, xnode);
1849
+ if (xnode->type == XML_ELEMENT_NODE && xnode->properties != NULL)
1942
1850
  return(Qtrue);
1943
1851
  else
1944
1852
  return(Qfalse);
@@ -1947,75 +1855,71 @@ ruby_xml_node_properties_q(VALUE self) {
1947
1855
 
1948
1856
  /*
1949
1857
  * call-seq:
1950
- * node.remove! => nil
1858
+ * node.remove! -> nil
1951
1859
  *
1952
1860
  * Removes this node from it's parent.
1953
1861
  */
1954
1862
  VALUE
1955
1863
  ruby_xml_node_remove_ex(VALUE self) {
1956
- ruby_xml_node *rxn;
1957
- Data_Get_Struct(self, ruby_xml_node, rxn);
1958
- xmlUnlinkNode(rxn->node);
1864
+ xmlNodePtr xnode;
1865
+ Data_Get_Struct(self, xmlNode, xnode);
1866
+ xmlUnlinkNode(xnode);
1959
1867
  return(Qnil);
1960
1868
  }
1961
1869
 
1962
1870
 
1963
1871
  /*
1964
1872
  * call-seq:
1965
- * node.search_href => namespace
1873
+ * node.search_href -> namespace
1966
1874
  *
1967
1875
  * Search for a namespace by href.
1968
1876
  */
1969
1877
  VALUE
1970
1878
  ruby_xml_node_search_href(VALUE self, VALUE href) {
1971
- ruby_xml_node *node;
1879
+ xmlNodePtr xnode;
1972
1880
 
1973
1881
  Check_Type(href, T_STRING);
1974
- Data_Get_Struct(self, ruby_xml_node, node);
1975
- return(ruby_xml_ns_new2(cXMLNS, ruby_xml_document_wrap(node->node->doc),
1976
- xmlSearchNsByHref(node->node->doc, node->node,
1882
+ Data_Get_Struct(self, xmlNode, xnode);
1883
+ return(ruby_xml_ns_wrap(xmlSearchNsByHref(xnode->doc, xnode,
1977
1884
  (xmlChar*)StringValuePtr(href))));
1978
1885
  }
1979
1886
 
1980
1887
 
1981
1888
  /*
1982
1889
  * call-seq:
1983
- * node.search_ns => namespace
1890
+ * node.search_ns -> namespace
1984
1891
  *
1985
1892
  * Search for a namespace by namespace.
1986
1893
  */
1987
1894
  VALUE
1988
1895
  ruby_xml_node_search_ns(VALUE self, VALUE ns) {
1989
- ruby_xml_node *node;
1896
+ xmlNodePtr xnode;
1990
1897
 
1991
1898
  Check_Type(ns, T_STRING);
1992
- Data_Get_Struct(self, ruby_xml_node, node);
1993
- return(ruby_xml_ns_new2(cXMLNS,
1994
- ruby_xml_document_wrap(node->node->doc),
1995
- xmlSearchNs(node->node->doc, node->node,
1996
- (xmlChar*)StringValuePtr(ns))));
1899
+ Data_Get_Struct(self, xmlNode, xnode);
1900
+ return(ruby_xml_ns_wrap(xmlSearchNs(xnode->doc, xnode,
1901
+ (xmlChar*)StringValuePtr(ns))));
1997
1902
  }
1998
1903
 
1999
1904
 
2000
1905
  /*
2001
1906
  * call-seq:
2002
- * node.sibling(node) => node
1907
+ * node.sibling(node) -> node
2003
1908
  *
2004
1909
  * Add the specified node as a sibling of this node.
2005
1910
  */
2006
1911
  VALUE
2007
1912
  ruby_xml_node_sibling_set(VALUE self, VALUE rnode) {
2008
- ruby_xml_node *cnode, *pnode;
2009
- xmlNodePtr ret;
1913
+ xmlNodePtr cnode, pnode, ret;
2010
1914
  VALUE obj;
2011
1915
 
2012
1916
  if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
2013
1917
  rb_raise(rb_eTypeError, "Must pass an XML::Node object");
2014
1918
 
2015
- Data_Get_Struct(self, ruby_xml_node, pnode);
2016
- Data_Get_Struct(rnode, ruby_xml_node, cnode);
1919
+ Data_Get_Struct(self, xmlNode, pnode);
1920
+ Data_Get_Struct(rnode, xmlNode, cnode);
2017
1921
 
2018
- ret = xmlAddSibling(pnode->node, cnode->node);
1922
+ ret = xmlAddSibling(pnode, cnode);
2019
1923
  if (ret == NULL)
2020
1924
  rb_raise(eXMLNodeFailedModify, "unable to add a sibling to the document");
2021
1925
  if (ret->_private==NULL)
@@ -2029,16 +1933,16 @@ ruby_xml_node_sibling_set(VALUE self, VALUE rnode) {
2029
1933
 
2030
1934
  /*
2031
1935
  * call-seq:
2032
- * node.space_preserve => (true|false)
1936
+ * node.space_preserve -> (true|false)
2033
1937
  *
2034
1938
  * Determine whether this node preserves whitespace.
2035
1939
  */
2036
1940
  VALUE
2037
1941
  ruby_xml_node_space_preserve_get(VALUE self) {
2038
- ruby_xml_node *rxn;
1942
+ xmlNodePtr xnode;
2039
1943
 
2040
- Data_Get_Struct(self, ruby_xml_node, rxn);
2041
- return(INT2NUM(xmlNodeGetSpacePreserve(rxn->node)));
1944
+ Data_Get_Struct(self, xmlNode, xnode);
1945
+ return(INT2NUM(xmlNodeGetSpacePreserve(xnode)));
2042
1946
  }
2043
1947
 
2044
1948
 
@@ -2050,13 +1954,13 @@ ruby_xml_node_space_preserve_get(VALUE self) {
2050
1954
  */
2051
1955
  VALUE
2052
1956
  ruby_xml_node_space_preserve_set(VALUE self, VALUE bool) {
2053
- ruby_xml_node *rxn;
2054
- Data_Get_Struct(self, ruby_xml_node, rxn);
1957
+ xmlNodePtr xnode;
1958
+ Data_Get_Struct(self, xmlNode, xnode);
2055
1959
 
2056
1960
  if (TYPE(bool) == T_FALSE)
2057
- xmlNodeSetSpacePreserve(rxn->node, 1);
1961
+ xmlNodeSetSpacePreserve(xnode, 1);
2058
1962
  else
2059
- xmlNodeSetSpacePreserve(rxn->node, 0);
1963
+ xmlNodeSetSpacePreserve(xnode, 0);
2060
1964
 
2061
1965
  return(Qnil);
2062
1966
  }
@@ -2064,37 +1968,37 @@ ruby_xml_node_space_preserve_set(VALUE self, VALUE bool) {
2064
1968
 
2065
1969
  /*
2066
1970
  * call-seq:
2067
- * node.text? => (true|false)
1971
+ * node.text? -> (true|false)
2068
1972
  *
2069
1973
  * Determine whether this node has text.
2070
1974
  */
2071
1975
  VALUE
2072
1976
  ruby_xml_node_text_q(VALUE self) {
2073
- ruby_xml_node *rxn;
2074
- Data_Get_Struct(self, ruby_xml_node, rxn);
2075
- if (rxn->node == NULL)
1977
+ xmlNodePtr xnode;
1978
+ Data_Get_Struct(self, xmlNode, xnode);
1979
+ if (xnode == NULL)
2076
1980
  return(Qnil);
2077
1981
 
2078
- return((xmlNodeIsText(rxn->node) == 1) ? Qtrue : Qfalse);
1982
+ return((xmlNodeIsText(xnode) == 1) ? Qtrue : Qfalse);
2079
1983
  }
2080
1984
 
2081
1985
 
2082
1986
  /*
2083
1987
  * call-seq:
2084
- * node.to_s => "string"
1988
+ * node.to_s -> "string"
2085
1989
  *
2086
1990
  * Coerce this node to a string representation of
2087
1991
  * it's XML.
2088
1992
  */
2089
1993
  VALUE
2090
1994
  ruby_xml_node_to_s(VALUE self) {
2091
- ruby_xml_node *rxn;
1995
+ xmlNodePtr xnode;
2092
1996
  xmlBufferPtr buf;
2093
1997
  VALUE result;
2094
1998
 
2095
- Data_Get_Struct(self, ruby_xml_node, rxn);
1999
+ Data_Get_Struct(self, xmlNode, xnode);
2096
2000
  buf = xmlBufferCreate();
2097
- xmlNodeDump(buf, rxn->node->doc, rxn->node, 0, 1);
2001
+ xmlNodeDump(buf, xnode->doc, xnode, 0, 1);
2098
2002
  result = rb_str_new2((const char*)buf->content);
2099
2003
 
2100
2004
  xmlBufferFree(buf);
@@ -2104,30 +2008,30 @@ ruby_xml_node_to_s(VALUE self) {
2104
2008
 
2105
2009
  /*
2106
2010
  * call-seq:
2107
- * node.type => num
2011
+ * node.type -> num
2108
2012
  *
2109
2013
  * Obtain this node's type identifier.
2110
2014
  */
2111
2015
  VALUE
2112
2016
  ruby_xml_node_type(VALUE self) {
2113
- ruby_xml_node *rxn;
2114
- Data_Get_Struct(self, ruby_xml_node, rxn);
2115
- return(INT2NUM(rxn->node->type));
2017
+ xmlNodePtr xnode;
2018
+ Data_Get_Struct(self, xmlNode, xnode);
2019
+ return(INT2NUM(xnode->type));
2116
2020
  }
2117
2021
 
2118
2022
 
2119
2023
  /*
2120
2024
  * call-seq:
2121
- * node.type_name => num
2025
+ * node.type_name -> num
2122
2026
  *
2123
2027
  * Obtain this node's type name.
2124
2028
  */
2125
2029
  VALUE
2126
2030
  ruby_xml_node_type_name(VALUE self) {
2127
- ruby_xml_node *rxn;
2128
- Data_Get_Struct(self, ruby_xml_node, rxn);
2031
+ xmlNodePtr xnode;
2032
+ Data_Get_Struct(self, xmlNode, xnode);
2129
2033
 
2130
- switch(rxn->node->type) {
2034
+ switch(xnode->type) {
2131
2035
  case XML_ELEMENT_NODE:
2132
2036
  return(rb_str_new2("element"));
2133
2037
  case XML_ATTRIBUTE_NODE:
@@ -2173,7 +2077,7 @@ ruby_xml_node_type_name(VALUE self) {
2173
2077
  return(rb_str_new2("document_docbook"));
2174
2078
  #endif
2175
2079
  default:
2176
- rb_raise(eXMLNodeUnknownType, "Unknown node type: %n", rxn->node->type);
2080
+ rb_raise(eXMLNodeUnknownType, "Unknown node type: %n", xnode->type);
2177
2081
  return(Qfalse);
2178
2082
  }
2179
2083
  }
@@ -2181,15 +2085,15 @@ ruby_xml_node_type_name(VALUE self) {
2181
2085
 
2182
2086
  /*
2183
2087
  * call-seq:
2184
- * node.xinclude_end? => num
2088
+ * node.xinclude_end? -> num
2185
2089
  *
2186
2090
  * Determine whether this node is an xinclude end node.
2187
2091
  */
2188
2092
  VALUE
2189
2093
  ruby_xml_node_xinclude_end_q(VALUE self) {
2190
- ruby_xml_node *rxn;
2191
- Data_Get_Struct(self, ruby_xml_node, rxn);
2192
- if (rxn->node->type == XML_XINCLUDE_END)
2094
+ xmlNodePtr xnode;
2095
+ Data_Get_Struct(self, xmlNode, xnode);
2096
+ if (xnode->type == XML_XINCLUDE_END)
2193
2097
  return(Qtrue);
2194
2098
  else
2195
2099
  return(Qfalse);
@@ -2198,15 +2102,15 @@ ruby_xml_node_xinclude_end_q(VALUE self) {
2198
2102
 
2199
2103
  /*
2200
2104
  * call-seq:
2201
- * node.xinclude_start? => num
2105
+ * node.xinclude_start? -> num
2202
2106
  *
2203
2107
  * Determine whether this node is an xinclude start node.
2204
2108
  */
2205
2109
  VALUE
2206
2110
  ruby_xml_node_xinclude_start_q(VALUE self) {
2207
- ruby_xml_node *rxn;
2208
- Data_Get_Struct(self, ruby_xml_node, rxn);
2209
- if (rxn->node->type == XML_XINCLUDE_START)
2111
+ xmlNodePtr xnode;
2112
+ Data_Get_Struct(self, xmlNode, xnode);
2113
+ if (xnode->type == XML_XINCLUDE_START)
2210
2114
  return(Qtrue);
2211
2115
  else
2212
2116
  return(Qfalse);
@@ -2215,30 +2119,28 @@ ruby_xml_node_xinclude_start_q(VALUE self) {
2215
2119
 
2216
2120
  /*
2217
2121
  * call-seq:
2218
- * node.copy => node
2122
+ * node.copy -> node
2219
2123
  *
2220
2124
  * Create a copy of this node.
2221
2125
  */
2222
2126
  VALUE
2223
2127
  ruby_xml_node_copy(VALUE self, VALUE deep) {
2224
- ruby_xml_node *rxn;
2225
- xmlNode *copy;
2226
- VALUE obj;
2227
-
2228
- Data_Get_Struct(self, ruby_xml_node, rxn);
2229
- copy = xmlCopyNode( rxn->node, ((deep==Qnil)||(deep==Qfalse))?0:1 );
2128
+ xmlNodePtr xnode;
2129
+ xmlNodePtr xcopy;
2130
+ int recursive = (deep==Qnil || deep==Qfalse) ? 0 : 1;
2131
+ Data_Get_Struct(self, xmlNode, xnode);
2132
+
2133
+ xcopy = xmlCopyNode(xnode, recursive);
2230
2134
 
2231
- if (copy == NULL)
2135
+ if (xcopy)
2136
+ return ruby_xml_node2_wrap(cXMLNode, xcopy);
2137
+ else
2232
2138
  return Qnil;
2233
-
2234
- obj=ruby_xml_node2_wrap(cXMLNode,copy);
2235
- copy->_private = (void*) obj;
2236
- return obj;
2237
2139
  }
2238
2140
 
2239
2141
  /*
2240
2142
  * call-seq:
2241
- * XML::Node.new_text(content = nil) => node
2143
+ * XML::Node.new_text(content = nil) -> node
2242
2144
  *
2243
2145
  * Create a new text node, optionally setting
2244
2146
  * the node's content.
@@ -2272,12 +2174,13 @@ ruby_xml_node_registerNode(xmlNodePtr node)
2272
2174
  }
2273
2175
 
2274
2176
  void
2275
- ruby_xml_node_deregisterNode(xmlNodePtr node)
2177
+ ruby_xml_node_deregisterNode(xmlNodePtr xnode)
2276
2178
  {
2277
- ruby_xml_node *rxn;
2278
- if ( node->_private==NULL ) return;
2279
- Data_Get_Struct(node->_private, ruby_xml_node, rxn);
2280
- rxn->node=NULL;
2179
+ VALUE node;
2180
+
2181
+ if (xnode->_private==NULL ) return;
2182
+ node = (VALUE)xnode->_private;
2183
+ DATA_PTR(node) = NULL;
2281
2184
  }
2282
2185
 
2283
2186
  // Rdoc needs to know
@@ -2327,6 +2230,8 @@ ruby_init_xml_node(void) {
2327
2230
  rb_define_method(cXMLNode, "[]=", ruby_xml_node_property_set, 2);
2328
2231
  rb_define_method(cXMLNode, "attribute?", ruby_xml_node_attribute_q, 0);
2329
2232
  rb_define_method(cXMLNode, "attribute_decl?", ruby_xml_node_attribute_decl_q, 0);
2233
+ rb_define_method(cXMLNode, "attributes", ruby_xml_node_attributes_get, 0);
2234
+ rb_define_method(cXMLNode, "attributes?", ruby_xml_node_attributes_q, 0);
2330
2235
  rb_define_method(cXMLNode, "base", ruby_xml_node_base_get, 0);
2331
2236
  rb_define_method(cXMLNode, "base=", ruby_xml_node_base_set, 1);
2332
2237
  rb_define_method(cXMLNode, "blank?", ruby_xml_node_empty_q, 0);
@@ -2358,7 +2263,6 @@ ruby_init_xml_node(void) {
2358
2263
  rb_define_method(cXMLNode, "find", ruby_xml_node_find, -1);
2359
2264
  rb_define_method(cXMLNode, "find_first", ruby_xml_node_find_first, -1);
2360
2265
  rb_define_method(cXMLNode, "fragment?", ruby_xml_node_fragment_q, 0);
2361
- rb_define_method(cXMLNode, "hash", ruby_xml_node_hash, 0);
2362
2266
  rb_define_method(cXMLNode, "html_doc?", ruby_xml_node_html_doc_q, 0);
2363
2267
  rb_define_method(cXMLNode, "lang", ruby_xml_node_lang_get, 0);
2364
2268
  rb_define_method(cXMLNode, "lang=", ruby_xml_node_lang_set, 1);
@@ -2389,9 +2293,6 @@ ruby_init_xml_node(void) {
2389
2293
  rb_define_method(cXMLNode, "prev", ruby_xml_node_prev_get, 0);
2390
2294
  rb_define_method(cXMLNode, "prev?", ruby_xml_node_prev_q, 0);
2391
2295
  rb_define_method(cXMLNode, "prev=", ruby_xml_node_prev_set, 1);
2392
- rb_define_method(cXMLNode, "property", ruby_xml_node_property_get, 1);
2393
- rb_define_method(cXMLNode, "properties", ruby_xml_node_properties_get, 0);
2394
- rb_define_method(cXMLNode, "properties?", ruby_xml_node_properties_q, 0);
2395
2296
  rb_define_method(cXMLNode, "remove!", ruby_xml_node_remove_ex, 0);
2396
2297
  rb_define_method(cXMLNode, "search_ns", ruby_xml_node_search_ns, 1);
2397
2298
  rb_define_method(cXMLNode, "search_href", ruby_xml_node_search_href, 1);
@@ -2405,6 +2306,7 @@ ruby_init_xml_node(void) {
2405
2306
  rb_define_method(cXMLNode, "xlink?", ruby_xml_node_xlink_q, 0);
2406
2307
  rb_define_method(cXMLNode, "xlink_type", ruby_xml_node_xlink_type, 0);
2407
2308
  rb_define_method(cXMLNode, "xlink_type_name", ruby_xml_node_xlink_type_name, 0);
2408
-
2309
+
2409
2310
  rb_define_alias(cXMLNode, "==", "eql?");
2311
+ rb_define_alias(cXMLNode, "properties?", "attributes?");
2410
2312
  }