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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. data/CHANGES +24 -1
  2. data/README +48 -3
  3. data/benchmark/depixelate.rb +632 -0
  4. data/benchmark/hamlet.xml +9055 -0
  5. data/benchmark/sock_entries.xml +507 -0
  6. data/benchmark/throughput.rb +39 -0
  7. data/benchmark/xml_benchmarks.rb +222 -0
  8. data/doc/classes/LibXML.html +237 -0
  9. data/doc/classes/LibXML/XML.html +178 -0
  10. data/doc/classes/{XML → LibXML/XML}/Attr.html +213 -182
  11. data/doc/classes/{XML → LibXML/XML}/Attributes.html +126 -54
  12. data/doc/classes/{XML → LibXML/XML}/Document.html +299 -297
  13. data/doc/classes/{XML → LibXML/XML}/Dtd.html +10 -10
  14. data/doc/classes/{XML/XInclude → LibXML/XML}/Error.html +4 -4
  15. data/doc/classes/{XML → LibXML/XML}/HTMLParser.html +40 -40
  16. data/doc/classes/{XML → LibXML/XML}/InputCallbacks.html +10 -10
  17. data/doc/classes/{XML → LibXML/XML}/NS.html +46 -46
  18. data/doc/classes/{XML → LibXML/XML}/Node.html +935 -788
  19. data/doc/classes/LibXML/XML/Node/FailedModify.html +111 -0
  20. data/doc/classes/{XML → LibXML/XML}/Node/Set.html +69 -68
  21. data/doc/classes/{XML → LibXML/XML}/Node/SetNamespace.html +4 -4
  22. data/doc/classes/{XML/Node/FailedModify.html → LibXML/XML/Node/UnknownType.html} +4 -4
  23. data/doc/classes/{XML → LibXML/XML}/Parser.html +426 -389
  24. data/doc/classes/{XML → LibXML/XML}/Parser/Context.html +208 -208
  25. data/doc/classes/{XML → LibXML/XML}/Parser/ParseError.html +4 -4
  26. data/doc/classes/{XML → LibXML/XML}/Reader.html +288 -287
  27. data/doc/classes/{XML → LibXML/XML}/SaxParser.html +52 -52
  28. data/doc/classes/{XML/XPath/Context.html → LibXML/XML/Schema.html} +60 -32
  29. data/doc/classes/{XML → LibXML/XML}/State.html +4 -4
  30. data/doc/classes/{XML/Node/UnknownType.html → LibXML/XML/Tree.html} +5 -5
  31. data/doc/classes/{XML → LibXML/XML}/XInclude.html +5 -5
  32. data/doc/classes/{XML → LibXML/XML/XInclude}/Error.html +5 -5
  33. data/doc/classes/{XML → LibXML/XML}/XMLParserOptions.html +5 -5
  34. data/doc/classes/{XML → LibXML/XML}/XPath.html +23 -64
  35. data/doc/classes/LibXML/XML/XPath/Context.html +403 -0
  36. data/doc/classes/{XML/XPointer/Context → LibXML/XML/XPath}/InvalidPath.html +4 -4
  37. data/doc/classes/LibXML/XML/XPath/Object.html +623 -0
  38. data/doc/classes/{XML → LibXML/XML}/XPointer.html +12 -12
  39. data/doc/classes/{XML → LibXML/XML}/XPointer/Context.html +5 -5
  40. data/doc/classes/{XML/XPath → LibXML/XML/XPointer/Context}/InvalidPath.html +5 -5
  41. data/doc/classes/{XML → LibXML/XML}/XPointer/InvalidExpression.html +4 -4
  42. data/doc/classes/XML.html +17 -123
  43. data/doc/created.rid +1 -1
  44. data/doc/files/CHANGES.html +49 -25
  45. data/doc/files/LICENSE.html +1 -1
  46. data/doc/files/README.html +79 -4
  47. data/doc/files/VERSION.html +2 -2
  48. data/doc/files/ext/libxml/cbg_c.html +1 -1
  49. data/doc/files/ext/libxml/libxml_c.html +1 -1
  50. data/doc/files/ext/libxml/ruby_xml_attr_c.html +1 -1
  51. data/doc/files/ext/libxml/ruby_xml_attributes_c.html +1 -1
  52. data/doc/files/ext/libxml/ruby_xml_document_c.html +1 -1
  53. data/doc/files/ext/libxml/ruby_xml_dtd_c.html +1 -1
  54. data/doc/files/ext/libxml/ruby_xml_html_parser_c.html +1 -1
  55. data/doc/files/ext/libxml/ruby_xml_input_cbg_c.html +1 -1
  56. data/doc/files/ext/libxml/ruby_xml_node_c.html +1 -1
  57. data/doc/files/ext/libxml/ruby_xml_node_set_c.html +1 -1
  58. data/doc/files/ext/libxml/ruby_xml_ns_c.html +1 -1
  59. data/doc/files/ext/libxml/ruby_xml_parser_c.html +1 -1
  60. data/doc/files/ext/libxml/ruby_xml_parser_context_c.html +1 -1
  61. data/doc/files/ext/libxml/ruby_xml_reader_c.html +1 -1
  62. data/doc/files/ext/libxml/ruby_xml_sax_parser_c.html +1 -1
  63. data/doc/files/ext/libxml/ruby_xml_schema_c.html +1 -1
  64. data/doc/files/ext/libxml/ruby_xml_state_c.html +1 -1
  65. data/doc/files/ext/libxml/ruby_xml_xinclude_c.html +1 -1
  66. data/doc/files/ext/libxml/ruby_xml_xpath_c.html +1 -1
  67. data/doc/files/ext/libxml/ruby_xml_xpath_context_c.html +1 -1
  68. data/doc/files/ext/libxml/ruby_xml_xpath_object_c.html +1 -1
  69. data/doc/files/ext/libxml/ruby_xml_xpointer_c.html +1 -1
  70. data/doc/files/ext/libxml/ruby_xml_xpointer_context_c.html +1 -1
  71. data/doc/files/lib/libxml/attr_rb.html +108 -0
  72. data/doc/files/lib/libxml/attributes_rb.html +108 -0
  73. data/doc/files/lib/libxml/document_rb.html +108 -0
  74. data/doc/files/lib/libxml/node_rb.html +108 -0
  75. data/doc/files/lib/libxml/node_set_rb.html +108 -0
  76. data/doc/files/lib/libxml/parser_options_rb.html +107 -0
  77. data/doc/files/{ext/libxml/ruby_xml_tree_c.html → lib/libxml/parser_rb.html} +4 -4
  78. data/doc/files/lib/libxml/properties_rb.html +108 -0
  79. data/doc/files/lib/libxml/tree_rb.html +107 -0
  80. data/doc/files/lib/libxml_rb.html +12 -3
  81. data/doc/fr_class_index.html +34 -32
  82. data/doc/fr_file_index.html +9 -1
  83. data/doc/fr_method_index.html +362 -347
  84. data/ext/libxml/cbg.c +76 -76
  85. data/ext/libxml/libxml.c +4 -3
  86. data/ext/libxml/ruby_libxml.h +1 -1
  87. data/ext/libxml/ruby_xml_attr.c +4 -3
  88. data/ext/libxml/ruby_xml_attr.h +16 -16
  89. data/ext/libxml/ruby_xml_attributes.c +267 -266
  90. data/ext/libxml/ruby_xml_attributes.h +17 -17
  91. data/ext/libxml/ruby_xml_document.c +30 -59
  92. data/ext/libxml/ruby_xml_document.h +27 -27
  93. data/ext/libxml/ruby_xml_dtd.c +2 -1
  94. data/ext/libxml/ruby_xml_dtd.h +17 -17
  95. data/ext/libxml/ruby_xml_html_parser.c +3 -2
  96. data/ext/libxml/ruby_xml_html_parser.h +29 -29
  97. data/ext/libxml/ruby_xml_input_cbg.c +2 -1
  98. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  99. data/ext/libxml/ruby_xml_node.c +127 -470
  100. data/ext/libxml/ruby_xml_node.h +17 -17
  101. data/ext/libxml/ruby_xml_node_set.c +5 -4
  102. data/ext/libxml/ruby_xml_node_set.h +20 -20
  103. data/ext/libxml/ruby_xml_ns.c +3 -2
  104. data/ext/libxml/ruby_xml_ns.h +12 -12
  105. data/ext/libxml/ruby_xml_parser.c +20 -48
  106. data/ext/libxml/ruby_xml_parser.h +31 -31
  107. data/ext/libxml/ruby_xml_parser_context.c +3 -2
  108. data/ext/libxml/ruby_xml_parser_context.h +20 -20
  109. data/ext/libxml/ruby_xml_reader.c +2 -1
  110. data/ext/libxml/ruby_xml_sax_parser.c +3 -2
  111. data/ext/libxml/ruby_xml_sax_parser.h +56 -56
  112. data/ext/libxml/ruby_xml_schema.c +6 -0
  113. data/ext/libxml/ruby_xml_schema.h +16 -16
  114. data/ext/libxml/ruby_xml_state.c +13 -12
  115. data/ext/libxml/ruby_xml_state.h +1 -1
  116. data/ext/libxml/ruby_xml_xinclude.c +3 -2
  117. data/ext/libxml/ruby_xml_xinclude.h +13 -13
  118. data/ext/libxml/ruby_xml_xpath.c +35 -228
  119. data/ext/libxml/ruby_xml_xpath.h +22 -23
  120. data/ext/libxml/ruby_xml_xpath_context.c +223 -62
  121. data/ext/libxml/ruby_xml_xpath_context.h +15 -20
  122. data/ext/libxml/ruby_xml_xpath_object.c +63 -19
  123. data/ext/libxml/ruby_xml_xpointer.c +19 -15
  124. data/ext/libxml/ruby_xml_xpointer.h +27 -27
  125. data/ext/libxml/ruby_xml_xpointer_context.c +3 -2
  126. data/ext/libxml/ruby_xml_xpointer_context.h +18 -18
  127. data/ext/libxml/version.h +9 -9
  128. data/lib/libxml.rb +16 -128
  129. data/lib/libxml/attr.rb +45 -0
  130. data/lib/libxml/attributes.rb +15 -0
  131. data/lib/libxml/document.rb +54 -0
  132. data/lib/libxml/node.rb +132 -0
  133. data/lib/libxml/node_set.rb +27 -0
  134. data/lib/libxml/parser.rb +42 -0
  135. data/lib/libxml/parser_options.rb +25 -0
  136. data/lib/libxml/properties.rb +19 -0
  137. data/lib/libxml/tree.rb +29 -0
  138. data/lib/libxml_ruby.so +0 -0
  139. data/mingw/libxml_ruby.so +0 -0
  140. data/{work/task/setup → setup.rb} +1585 -1616
  141. data/test/gc.log +0 -0
  142. data/test/model/books.xml +147 -0
  143. data/{work/test/runner.rb → test/model/default_validation_bug.rb} +0 -0
  144. data/test/model/merge_bug_data.xml +58 -0
  145. data/test/model/rubynet.xml +78 -0
  146. data/test/model/rubynet_project +1 -0
  147. data/test/model/saxtest.xml +5 -0
  148. data/test/model/shiporder.xml +23 -0
  149. data/test/model/shiporder.xsd +31 -0
  150. data/test/model/simple.xml +7 -0
  151. data/test/model/soap.xml +27 -0
  152. data/test/model/xinclude.xml +5 -0
  153. data/test/tc_deprecated_require.rb +13 -0
  154. data/test/tc_xml_document.rb +57 -16
  155. data/test/tc_xml_document_write.rb +125 -10
  156. data/test/tc_xml_dtd.rb +22 -1
  157. data/test/tc_xml_node.rb +13 -0
  158. data/test/tc_xml_node_edit.rb +1 -1
  159. data/test/tc_xml_node_xlink.rb +1 -1
  160. data/test/tc_xml_parser.rb +64 -7
  161. data/test/tc_xml_properties.rb +42 -0
  162. data/test/tc_xml_reader.rb +4 -4
  163. data/test/tc_xml_sax_parser.rb +50 -50
  164. data/test/tc_xml_schema.rb +2 -2
  165. data/test/tc_xml_traversal.rb +220 -0
  166. data/test/tc_xml_xinclude.rb +12 -15
  167. data/test/tc_xml_xpath.rb +74 -6
  168. data/test/tc_xml_xpath_context.rb +72 -0
  169. data/test/test_suite.rb +6 -4
  170. data/vc/libxml_ruby.vcproj +1 -9
  171. metadata +92 -65
  172. data/doc/classes/XML/SiblingEnum.html +0 -142
  173. data/doc/classes/XML/Tree.html +0 -224
  174. data/doc/classes/XML/XPath/Object.html +0 -439
  175. data/ext/libxml/ruby_xml_tree.c +0 -43
  176. data/ext/libxml/ruby_xml_tree.h +0 -12
  177. data/test/ets_copy_bug2.rb +0 -21
  178. data/test/tc_xml_document_write2.rb +0 -54
  179. data/test/tc_xml_document_write3.rb +0 -96
  180. data/test/tc_xml_sax_parser2.rb +0 -51
  181. data/work/Rakefile +0 -247
  182. data/work/task/make +0 -26
  183. data/work/task/memory +0 -37
  184. data/work/task/rdoc +0 -39
  185. data/work/task/test +0 -29
  186. data/work/test/ets_runner.rb +0 -33
  187. data/work/test/libxml_test.rb +0 -3
  188. data/work/test/runner_ets.rb +0 -33
@@ -1,17 +1,17 @@
1
- /* $Id: ruby_xml_attributes.h 282 2008-07-01 06:44:30Z cfis $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
4
-
5
- #ifndef __RUBY_XML_ATTRIBUTES__
6
- #define __RUBY_XML_ATTRIBUTES__
7
-
8
- extern VALUE cXMLAttributesibutes;
9
-
10
- void ruby_init_xml_attributes(void);
11
- VALUE ruby_xml_attributes_new(xmlNodePtr xnode);
12
-
13
- VALUE ruby_xml_attributes_attribute_get(VALUE self, VALUE name);
14
- VALUE ruby_xml_attributes_attribute_set(VALUE self, VALUE name, VALUE value);
15
-
16
-
17
- #endif
1
+ /* $Id: ruby_xml_attributes.h 282 2008-07-01 06:44:30Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RUBY_XML_ATTRIBUTES__
6
+ #define __RUBY_XML_ATTRIBUTES__
7
+
8
+ extern VALUE cXMLAttributesibutes;
9
+
10
+ void ruby_init_xml_attributes(void);
11
+ VALUE ruby_xml_attributes_new(xmlNodePtr xnode);
12
+
13
+ VALUE ruby_xml_attributes_attribute_get(VALUE self, VALUE name);
14
+ VALUE ruby_xml_attributes_attribute_set(VALUE self, VALUE name, VALUE value);
15
+
16
+
17
+ #endif
@@ -1,9 +1,9 @@
1
- /* $Id: ruby_xml_document.c 359 2008-07-09 20:24:21Z cfis $ */
1
+ /* $Id: ruby_xml_document.c 461 2008-07-15 21:35:56Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
5
5
  /*
6
- * Document-class: XML::Document
6
+ * Document-class: LibXML::XML::Document
7
7
  *
8
8
  * Reads or writes an XML document:
9
9
  *
@@ -404,43 +404,6 @@ ruby_xml_document_filename_get(VALUE self) {
404
404
  }
405
405
 
406
406
 
407
- /*
408
- * call-seq:
409
- * document.find(xpath_expr, [namespace]) -> XML::Node::Set
410
- *
411
- * Find nodes matching the specified xpath expression, optionally
412
- * using the specified namespace. Returns an XML::Node::Set. For
413
- * more information about working with namespaces, please refer
414
- * to the XML::XPath documentation.
415
- *
416
- * IMPORTANT - The returned XML::Node::Set must be freed before
417
- * its associated document. In a running Ruby program this will
418
- * happen automatically via Ruby's mark and sweep garbage collector.
419
- * However, if the program exits, Ruby does not guarantee the order
420
- * in which objects are freed
421
- * (see http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/17700).
422
- * As a result, the associated document may be freed before the node
423
- * list, which will cause a segmentation fault.
424
- *
425
- * To avoid this, use the following (non-ruby like) coding style:
426
- *
427
- * nodes = doc.find('/header')
428
- * nodes.each do |node|
429
- * ... do stuff ...
430
- * end
431
- *
432
- * nodes = nil
433
- * GC.start
434
- */
435
- VALUE
436
- ruby_xml_document_find(int argc, VALUE *argv, VALUE self) {
437
- if (argc > 2 || argc < 1)
438
- rb_raise(rb_eArgError, "wrong number of arguments (need 1 or 2)");
439
-
440
- return(ruby_xml_xpath_find2(self,argv[0],(argc==2)?argv[1]:Qnil));
441
- }
442
-
443
-
444
407
  void
445
408
  ruby_xml_document_free(ruby_xml_document_t *rxd) {
446
409
  void *data;
@@ -755,40 +718,48 @@ ruby_xml_document_root_set(VALUE self, VALUE node) {
755
718
 
756
719
  /*
757
720
  * call-seq:
758
- * document.save(format = false)
721
+ * document.save(filename, format = false) -> int
759
722
  *
760
723
  * Save this document to the file given by filename,
761
724
  * optionally formatting the output.
725
+
726
+ * Parameters:
727
+ * filename: The filename or URL of the new document
728
+ * format: Specifies whether formatting spaces should be added.
729
+ * returns: The number of bytes written or -1 in case of error.
762
730
  */
763
731
  VALUE
764
732
  ruby_xml_document_save(int argc, VALUE *argv, VALUE self) {
765
733
  ruby_xml_document_t *rxd;
766
734
  const char *filename;
767
- int format, len;
735
+ int format = 0;
736
+ int len;
768
737
 
769
- format = 0;
770
- switch (argc) {
771
- case 1:
772
- break;
773
- case 2:
774
- if (TYPE(argv[1]) == T_TRUE)
775
- format = 1;
776
- else if (TYPE(argv[1]) == T_FALSE)
777
- format = 0;
778
- else
779
- rb_raise(rb_eTypeError, "wrong type of argument, must be bool");
780
- break;
781
- default:
782
- rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)");
783
- }
738
+ if (argc <1 || argc > 2)
739
+ rb_raise(rb_eArgError, "wrong number of arguments (need 1 or 2)");
784
740
 
785
741
  Check_Type(argv[0], T_STRING);
786
742
  filename = StringValuePtr(argv[0]);
743
+
744
+ if (argc == 2)
745
+ {
746
+ switch (TYPE(argv[1])) {
747
+ case T_TRUE:
748
+ format = 1;
749
+ break;
750
+ case T_FALSE:
751
+ format = 0;
752
+ break;
753
+ default:
754
+ rb_raise(rb_eArgError, "The second parameter (format) must be true or false");
755
+ }
756
+ }
787
757
 
788
758
  Data_Get_Struct(self, ruby_xml_document_t, rxd);
789
759
  len = xmlSaveFormatFileEnc(filename, rxd->doc, (const char*)rxd->doc->encoding, format);
760
+
790
761
  if (len == -1)
791
- rb_fatal("Unable to write out file");
762
+ rb_raise(rb_eIOError, "Could not write document");
792
763
  else
793
764
  return(INT2NUM(len));
794
765
  }
@@ -1077,7 +1048,8 @@ ruby_xml_document_reader(VALUE self)
1077
1048
 
1078
1049
  // Rdoc needs to know
1079
1050
  #ifdef RDOC_NEVER_DEFINED
1080
- mXML = rb_define_module("XML");
1051
+ mLibXML = rb_define_module("LibXML");
1052
+ mXML = rb_define_module_under(mLibXML, "XML");
1081
1053
  #endif
1082
1054
 
1083
1055
  void
@@ -1101,7 +1073,6 @@ ruby_init_xml_document(void) {
1101
1073
  rb_define_method(cXMLDocument, "encoding", ruby_xml_document_encoding_get, 0);
1102
1074
  rb_define_method(cXMLDocument, "encoding=", ruby_xml_document_encoding_set, 1);
1103
1075
  rb_define_method(cXMLDocument, "filename", ruby_xml_document_filename_get, 0);
1104
- rb_define_method(cXMLDocument, "find", ruby_xml_document_find, -1);
1105
1076
  rb_define_method(cXMLDocument, "format_dump", ruby_xml_document_format_dump, -1);
1106
1077
  rb_define_method(cXMLDocument, "last", ruby_xml_document_last_get, 0);
1107
1078
  rb_define_method(cXMLDocument, "last?", ruby_xml_document_last_q, 0);
@@ -1,27 +1,27 @@
1
- /* $Id: ruby_xml_document.h 304 2008-07-02 17:42:41Z cfis $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
4
-
5
- #ifndef __RUBY_XML_DOCUMENT__
6
- #define __RUBY_XML_DOCUMENT__
7
-
8
- extern VALUE cXMLDocument;
9
-
10
- typedef struct rxp_document {
11
- xmlDocPtr doc; /* Tree/DOM interface */
12
- int data_type; /* The data type referenced by *data */
13
- void *data; /* Pointer to an external structure of options */
14
- } ruby_xml_document_t;
15
-
16
- VALUE ruby_xml_document_filename_get(VALUE self);
17
- VALUE ruby_xml_document_new_native(VALUE class, VALUE xmlver);
18
- void ruby_xml_document_free(ruby_xml_document_t *rxd);
19
- VALUE ruby_xml_document_root_get(VALUE self);
20
- void ruby_init_xml_document(void);
21
-
22
- #if defined(_WIN32)
23
- __declspec(dllexport)
24
- #endif
25
- VALUE ruby_xml_document_wrap(xmlDocPtr xnode);
26
-
27
- #endif
1
+ /* $Id: ruby_xml_document.h 304 2008-07-02 17:42:41Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RUBY_XML_DOCUMENT__
6
+ #define __RUBY_XML_DOCUMENT__
7
+
8
+ extern VALUE cXMLDocument;
9
+
10
+ typedef struct rxp_document {
11
+ xmlDocPtr doc; /* Tree/DOM interface */
12
+ int data_type; /* The data type referenced by *data */
13
+ void *data; /* Pointer to an external structure of options */
14
+ } ruby_xml_document_t;
15
+
16
+ VALUE ruby_xml_document_filename_get(VALUE self);
17
+ VALUE ruby_xml_document_new_native(VALUE class, VALUE xmlver);
18
+ void ruby_xml_document_free(ruby_xml_document_t *rxd);
19
+ VALUE ruby_xml_document_root_get(VALUE self);
20
+ void ruby_init_xml_document(void);
21
+
22
+ #if defined(_WIN32)
23
+ __declspec(dllexport)
24
+ #endif
25
+ VALUE ruby_xml_document_wrap(xmlDocPtr xnode);
26
+
27
+ #endif
@@ -156,7 +156,8 @@ SV * parse_string(CLASS, str, ...)
156
156
 
157
157
  // Rdoc needs to know
158
158
  #ifdef RDOC_NEVER_DEFINED
159
- mXML = rb_define_module("XML");
159
+ mLibXML = rb_define_module("LibXML");
160
+ mXML = rb_define_module_under(mLibXML, "XML");
160
161
  #endif
161
162
 
162
163
  void
@@ -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 339 2008-07-09 08:36:26Z cfis $ */
1
+ /* $Id: ruby_xml_html_parser.c 461 2008-07-15 21:35:56Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -424,7 +424,8 @@ ruby_xml_html_parser_str_set(VALUE self, VALUE str) {
424
424
 
425
425
  // Rdoc needs to know
426
426
  #ifdef RDOC_NEVER_DEFINED
427
- mXML = rb_define_module("XML");
427
+ mLibXML = rb_define_module("LibXML");
428
+ mXML = rb_define_module_under(mLibXML, "XML");
428
429
  #endif
429
430
 
430
431
  void
@@ -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
@@ -149,7 +149,8 @@ input_callbacks_remove_scheme (VALUE self, VALUE scheme_name) {
149
149
 
150
150
  // Rdoc needs to know
151
151
  #ifdef RDOC_NEVER_DEFINED
152
- mXML = rb_define_module("XML");
152
+ mLibXML = rb_define_module("LibXML");
153
+ mXML = rb_define_module_under(mLibXML, "XML");
153
154
  #endif
154
155
 
155
156
  void
@@ -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 351 2008-07-09 19:55:21Z cfis $ */
1
+ /* $Id: ruby_xml_node.c 461 2008-07-15 21:35:56Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -35,7 +35,6 @@ ruby_xml_node_attribute_q(VALUE self) {
35
35
  return(Qfalse);
36
36
  }
37
37
 
38
-
39
38
  /*
40
39
  * call-seq:
41
40
  * node.attribute_decl? -> (true|false)
@@ -206,92 +205,23 @@ ruby_xml_node_content_stripped_get(VALUE self) {
206
205
 
207
206
  /*
208
207
  * call-seq:
209
- * node.child -> node
208
+ * node.first -> XML::Node
210
209
  *
211
- * Obtain this node's first child node, if any.
210
+ * Returns this node's first child node if any.
212
211
  */
213
212
  VALUE
214
- ruby_xml_node_child_get(VALUE self) {
213
+ ruby_xml_node_first_get(VALUE self) {
215
214
  xmlNodePtr xnode;
216
- xmlNodePtr tmp;
217
215
 
218
216
  Data_Get_Struct(self, xmlNode, xnode);
219
217
 
220
- switch (xnode->type) {
221
- case XML_ELEMENT_NODE:
222
- case XML_ENTITY_REF_NODE:
223
- case XML_ENTITY_NODE:
224
- case XML_PI_NODE:
225
- case XML_COMMENT_NODE:
226
- case XML_DOCUMENT_NODE:
227
- #ifdef LIBXML_DOCB_ENABLED
228
- case XML_DOCB_DOCUMENT_NODE:
229
- #endif
230
- case XML_HTML_DOCUMENT_NODE:
231
- case XML_DTD_NODE:
232
- tmp = xnode->children;
233
- break;
234
- case XML_ATTRIBUTE_NODE:
235
- {
236
- xmlAttrPtr attr = (xmlAttrPtr) xnode;
237
- tmp = attr->children;
238
- break;
239
- }
240
- default:
241
- tmp = NULL;
242
- break;
243
- }
244
-
245
- if (tmp == NULL)
246
- return(Qnil);
218
+ if (xnode->children)
219
+ return(ruby_xml_node2_wrap(cXMLNode, xnode->children));
247
220
  else
248
- return(ruby_xml_node2_wrap(cXMLNode, tmp));
221
+ return(Qnil);
249
222
  }
250
223
 
251
224
 
252
- /*
253
- * call-seq:
254
- * node.child? -> (true|false)
255
- *
256
- * Determine whether this node has at least one child.
257
- */
258
- VALUE
259
- ruby_xml_node_child_q(VALUE self) {
260
- xmlNodePtr xnode;
261
- xmlNodePtr node;
262
- Data_Get_Struct(self, xmlNode, xnode);
263
-
264
- node = NULL;
265
- switch (xnode->type) {
266
- case XML_ELEMENT_NODE:
267
- case XML_ENTITY_REF_NODE:
268
- case XML_ENTITY_NODE:
269
- case XML_PI_NODE:
270
- case XML_COMMENT_NODE:
271
- case XML_DOCUMENT_NODE:
272
- #ifdef LIBXML_DOCB_ENABLED
273
- case XML_DOCB_DOCUMENT_NODE:
274
- #endif
275
- case XML_HTML_DOCUMENT_NODE:
276
- case XML_DTD_NODE:
277
- node = xnode->children;
278
- break;
279
- case XML_ATTRIBUTE_NODE:
280
- {
281
- xmlAttrPtr attr = (xmlAttrPtr) xnode;
282
- node = attr->children;
283
- break;
284
- }
285
- default:
286
- node = NULL;
287
- }
288
-
289
- if (node == NULL)
290
- return(Qfalse);
291
- else
292
- return(Qtrue);
293
- }
294
-
295
225
  /*
296
226
  * underlying for child_set and child_add, difference being
297
227
  * former raises on implicit copy, latter does not.
@@ -335,7 +265,7 @@ ruby_xml_node_child_set(VALUE self, VALUE rnode) {
335
265
 
336
266
  /*
337
267
  * call-seq:
338
- * node << ("string" | node) -> node
268
+ * node << ("string" | node) -> XML::Node
339
269
  *
340
270
  * Add the specified string or XML::Node to this node's
341
271
  * content.
@@ -538,6 +468,31 @@ ruby_xml_node_debug_dump(VALUE self) {
538
468
  return(Qtrue);
539
469
  }
540
470
 
471
+ /*
472
+ * call-seq:
473
+ * node.each -> XML::Node
474
+ *
475
+ * Iterates over all of this node's children, including text
476
+ * nodes, element nodes, etc. If you wish to iterate
477
+ * only over child elements, use XML::Node#each_element.
478
+ *
479
+ * doc = XML::Document.new('model/books.xml')
480
+ * doc.root.each {|node| puts node}
481
+ */
482
+ VALUE
483
+ ruby_xml_node_each(VALUE self) {
484
+ xmlNodePtr xnode;
485
+ xmlNodePtr xchild;
486
+ Data_Get_Struct(self, xmlNode, xnode);
487
+
488
+ xchild = xnode->children;
489
+
490
+ while (xchild) {
491
+ rb_yield(ruby_xml_node2_wrap(cXMLNode, xchild));
492
+ xchild = xchild->next;
493
+ }
494
+ return Qnil;
495
+ }
541
496
 
542
497
  /*
543
498
  * call-seq:
@@ -637,43 +592,25 @@ ruby_xml_node_eql_q(VALUE self, VALUE other) {
637
592
  {
638
593
  return Qtrue;
639
594
  }
595
+ else if NIL_P(other)
596
+ {
597
+ return Qfalse;
598
+ }
640
599
  else
641
600
  {
642
- VALUE self_xml = ruby_xml_node_to_s(self);
643
- VALUE other_xml = ruby_xml_node_to_s(other);
601
+ VALUE self_xml;
602
+ VALUE other_xml;
603
+
604
+ if (rb_obj_is_kind_of(other, cXMLNode) == Qfalse)
605
+ rb_raise(rb_eTypeError, "Nodes can only be compared against other nodes");
606
+
607
+ self_xml = ruby_xml_node_to_s(self);
608
+ other_xml = ruby_xml_node_to_s(other);
644
609
  return(rb_funcall(self_xml, rb_intern("=="), 1, other_xml));
645
610
  }
646
611
  }
647
612
 
648
613
 
649
- /*
650
- * call-seq:
651
- * node.find(xpath_expr, namespace = [any]) -> nodeset
652
- *
653
- * Find nodes matching the specified xpath expression, optionally
654
- * using the specified namespaces. Returns an XML::Node::Set.
655
- */
656
- VALUE
657
- ruby_xml_node_find(int argc, VALUE *argv, VALUE self) {
658
- if (argc > 2 || argc < 1)
659
- rb_raise(rb_eArgError, "wrong number of arguments (need 1 or 2)");
660
-
661
- return(ruby_xml_xpath_find2(self,argv[0],(argc==2)?argv[1]:Qnil));
662
- }
663
-
664
- /*
665
- * call-seq:
666
- * node.find_first(xpath_expr, namespace = [any]) -> nodeset
667
- *
668
- * Find the first node matching the specified xpath expression, optionally
669
- * using the specified namespaces. Returns an XML::Node.
670
- */
671
- VALUE
672
- ruby_xml_node_find_first(int argc, VALUE *argv, VALUE self) {
673
- return ruby_xml_xpath_object_first(ruby_xml_node_find(argc, argv, self));
674
- }
675
-
676
-
677
614
  /*
678
615
  * call-seq:
679
616
  * node.fragment? -> (true|false)
@@ -709,7 +646,7 @@ ruby_xml_node_html_doc_q(VALUE self) {
709
646
 
710
647
  /*
711
648
  * call-seq:
712
- * XML::Node.new_cdata(content = nil) -> node
649
+ * XML::Node.new_cdata(content = nil) -> XML::Node
713
650
  *
714
651
  * Create a new #CDATA node, optionally setting
715
652
  * the node's content.
@@ -745,7 +682,7 @@ ruby_xml_node_new_cdata(int argc, VALUE *argv, VALUE class) {
745
682
 
746
683
  /*
747
684
  * call-seq:
748
- * XML::Node.new_comment(content = nil) -> node
685
+ * XML::Node.new_comment(content = nil) -> XML::Node
749
686
  *
750
687
  * Create a new comment node, optionally setting
751
688
  * the node's content.
@@ -829,92 +766,22 @@ ruby_xml_node_lang_set(VALUE self, VALUE lang) {
829
766
 
830
767
  /*
831
768
  * call-seq:
832
- * node.last -> node
769
+ * node.last -> XML::Node
833
770
  *
834
771
  * Obtain the last child node of this node, if any.
835
772
  */
836
773
  VALUE
837
774
  ruby_xml_node_last_get(VALUE self) {
838
775
  xmlNodePtr xnode;
839
- xmlNodePtr node;
840
-
841
- Data_Get_Struct(self, xmlNode, xnode);
842
-
843
- switch (xnode->type) {
844
- case XML_ELEMENT_NODE:
845
- case XML_ENTITY_REF_NODE:
846
- case XML_ENTITY_NODE:
847
- case XML_PI_NODE:
848
- case XML_COMMENT_NODE:
849
- case XML_DOCUMENT_NODE:
850
- #ifdef LIBXML_DOCB_ENABLED
851
- case XML_DOCB_DOCUMENT_NODE:
852
- #endif
853
- case XML_HTML_DOCUMENT_NODE:
854
- case XML_DTD_NODE:
855
- node = xnode->last;
856
- break;
857
- case XML_ATTRIBUTE_NODE:
858
- {
859
- xmlAttrPtr attr = (xmlAttrPtr) xnode;
860
- node = attr->last;
861
- }
862
- default:
863
- node = NULL;
864
- break;
865
- }
866
-
867
- if (node == NULL)
868
- return(Qnil);
869
- else
870
- return(ruby_xml_node2_wrap(cXMLNode, node));
871
- }
872
-
873
-
874
- /*
875
- * call-seq:
876
- * node.last? -> (true|false)
877
- *
878
- * Determine whether this node has a last child node.
879
- */
880
- VALUE
881
- ruby_xml_node_last_q(VALUE self) {
882
- xmlNodePtr xnode;
883
- xmlNodePtr node;
884
776
 
885
777
  Data_Get_Struct(self, xmlNode, xnode);
886
778
 
887
- switch (xnode->type) {
888
- case XML_ELEMENT_NODE:
889
- case XML_ENTITY_REF_NODE:
890
- case XML_ENTITY_NODE:
891
- case XML_PI_NODE:
892
- case XML_COMMENT_NODE:
893
- case XML_DOCUMENT_NODE:
894
- #ifdef LIBXML_DOCB_ENABLED
895
- case XML_DOCB_DOCUMENT_NODE:
896
- #endif
897
- case XML_HTML_DOCUMENT_NODE:
898
- case XML_DTD_NODE:
899
- node = xnode->last;
900
- break;
901
- case XML_ATTRIBUTE_NODE:
902
- {
903
- xmlAttrPtr attr = (xmlAttrPtr) xnode;
904
- node = attr->last;
905
- }
906
- default:
907
- node = NULL;
908
- break;
909
- }
910
-
911
- if (node == NULL)
912
- return(Qfalse);
779
+ if (xnode->last)
780
+ return(ruby_xml_node2_wrap(cXMLNode, xnode->last));
913
781
  else
914
- return(Qtrue);
782
+ return(Qnil);
915
783
  }
916
784
 
917
-
918
785
  /*
919
786
  * call-seq:
920
787
  * node.line_num -> num
@@ -1340,8 +1207,8 @@ ruby_xml_node2_new_string(VALUE class, VALUE ns, VALUE name, VALUE val)
1340
1207
  }
1341
1208
  /*
1342
1209
  * call-seq:
1343
- * XML::Node.new(name, content = nil) -> node
1344
- * XML::Node.new_element(name, content = nil) -> node
1210
+ * XML::Node.new(name, content = nil) -> XML::Node
1211
+ * XML::Node.new_element(name, content = nil) -> XML::Node
1345
1212
  *
1346
1213
  * Create a new element node with the specified name, optionally setting
1347
1214
  * the node's content.
@@ -1369,90 +1236,20 @@ ruby_xml_node2_new_string_bc(int argc, VALUE *argv, VALUE class)
1369
1236
 
1370
1237
  /*
1371
1238
  * call-seq:
1372
- * node.next -> node
1239
+ * node.next -> XML::Node
1373
1240
  *
1374
1241
  * Obtain the next sibling node, if any.
1375
1242
  */
1376
1243
  VALUE
1377
1244
  ruby_xml_node_next_get(VALUE self) {
1378
1245
  xmlNodePtr xnode;
1379
- xmlNodePtr node;
1380
- Data_Get_Struct(self, xmlNode, xnode);
1381
-
1382
- switch (xnode->type) {
1383
- case XML_DOCUMENT_NODE:
1384
- #ifdef LIBXML_DOCB_ENABLED
1385
- case XML_DOCB_DOCUMENT_NODE:
1386
- #endif
1387
- case XML_HTML_DOCUMENT_NODE:
1388
- node = NULL;
1389
- break;
1390
- case XML_ATTRIBUTE_NODE:
1391
- {
1392
- xmlAttrPtr attr = (xmlAttrPtr) xnode;
1393
- node = (xmlNodePtr) attr->next;
1394
- break;
1395
- }
1396
- case XML_NAMESPACE_DECL:
1397
- {
1398
- xmlNsPtr ns = (xmlNsPtr) xnode;
1399
- node = (xmlNodePtr) ns->next;
1400
- break;
1401
- }
1402
- default:
1403
- node = xnode->next;
1404
- break;
1405
- }
1406
-
1407
- if (node == NULL) {
1408
- return(Qnil);
1409
- } else {
1410
- return(ruby_xml_node2_wrap(cXMLNode, node));
1411
- }
1412
- }
1413
1246
 
1414
-
1415
- /*
1416
- * call-seq:
1417
- * node.next? -> (true|false)
1418
- *
1419
- * Determine whether this node has a next sibling.
1420
- */
1421
- VALUE
1422
- ruby_xml_node_next_q(VALUE self) {
1423
- xmlNodePtr xnode;
1424
- xmlNodePtr node;
1425
1247
  Data_Get_Struct(self, xmlNode, xnode);
1426
1248
 
1427
- switch (xnode->type) {
1428
- case XML_DOCUMENT_NODE:
1429
- #ifdef LIBXML_DOCB_ENABLED
1430
- case XML_DOCB_DOCUMENT_NODE:
1431
- #endif
1432
- case XML_HTML_DOCUMENT_NODE:
1433
- node = NULL;
1434
- break;
1435
- case XML_ATTRIBUTE_NODE:
1436
- {
1437
- xmlAttrPtr attr = (xmlAttrPtr) xnode;
1438
- node = (xmlNodePtr) attr->next;
1439
- break;
1440
- }
1441
- case XML_NAMESPACE_DECL:
1442
- {
1443
- xmlNsPtr ns = (xmlNsPtr) xnode;
1444
- node = (xmlNodePtr) ns->next;
1445
- break;
1446
- }
1447
- default:
1448
- node = xnode->next;
1449
- break;
1450
- }
1451
-
1452
- if (node == NULL)
1453
- return(Qfalse);
1249
+ if (xnode->next)
1250
+ return(ruby_xml_node2_wrap(cXMLNode, xnode->next));
1454
1251
  else
1455
- return(Qtrue);
1252
+ return(Qnil);
1456
1253
  }
1457
1254
 
1458
1255
 
@@ -1551,89 +1348,20 @@ ruby_xml_node_ns_def_q(VALUE self) {
1551
1348
 
1552
1349
  /*
1553
1350
  * call-seq:
1554
- * node.parent -> node
1351
+ * node.parent -> XML::Node
1555
1352
  *
1556
1353
  * Obtain this node's parent node, if any.
1557
1354
  */
1558
1355
  VALUE
1559
1356
  ruby_xml_node_parent_get(VALUE self) {
1560
1357
  xmlNodePtr xnode;
1561
- xmlNodePtr node;
1562
1358
 
1563
1359
  Data_Get_Struct(self, xmlNode, xnode);
1564
1360
 
1565
- switch (xnode->type) {
1566
- case XML_DOCUMENT_NODE:
1567
- case XML_HTML_DOCUMENT_NODE:
1568
- #ifdef LIBXML_DOCB_ENABLED
1569
- case XML_DOCB_DOCUMENT_NODE:
1570
- #endif
1571
- node = NULL;
1572
- break;
1573
- case XML_ATTRIBUTE_NODE:
1574
- {
1575
- xmlAttrPtr attr = (xmlAttrPtr) xnode;
1576
- node = attr->parent;
1577
- }
1578
- case XML_ENTITY_DECL:
1579
- case XML_NAMESPACE_DECL:
1580
- case XML_XINCLUDE_START:
1581
- case XML_XINCLUDE_END:
1582
- node = NULL;
1583
- break;
1584
- default:
1585
- node = xnode->parent;
1586
- break;
1587
- }
1588
-
1589
- if (node == NULL)
1590
- return(Qnil);
1361
+ if (xnode->parent)
1362
+ return(ruby_xml_node2_wrap(cXMLNode, xnode->parent));
1591
1363
  else
1592
- return(ruby_xml_node2_wrap(cXMLNode, node));
1593
- }
1594
-
1595
-
1596
- /*
1597
- * call-seq:
1598
- * node.parent? -> (true|false)
1599
- *
1600
- * Determine whether this node has a parent node.
1601
- */
1602
- VALUE
1603
- ruby_xml_node_parent_q(VALUE self) {
1604
- xmlNodePtr xnode;
1605
- xmlNodePtr node;
1606
-
1607
- Data_Get_Struct(self, xmlNode, xnode);
1608
-
1609
- switch (xnode->type) {
1610
- case XML_DOCUMENT_NODE:
1611
- case XML_HTML_DOCUMENT_NODE:
1612
- #ifdef LIBXML_DOCB_ENABLED
1613
- case XML_DOCB_DOCUMENT_NODE:
1614
- #endif
1615
- node = NULL;
1616
- break;
1617
- case XML_ATTRIBUTE_NODE:
1618
- {
1619
- xmlAttrPtr attr = (xmlAttrPtr) xnode;
1620
- node = attr->parent;
1621
- }
1622
- case XML_ENTITY_DECL:
1623
- case XML_NAMESPACE_DECL:
1624
- case XML_XINCLUDE_START:
1625
- case XML_XINCLUDE_END:
1626
- node = NULL;
1627
- break;
1628
- default:
1629
- node = xnode->parent;
1630
- break;
1631
- }
1632
-
1633
- if (node == NULL)
1634
- return(Qfalse);
1635
- else
1636
- return(Qtrue);
1364
+ return(Qnil);
1637
1365
  }
1638
1366
 
1639
1367
 
@@ -1677,7 +1405,7 @@ ruby_xml_node_pi_q(VALUE self) {
1677
1405
 
1678
1406
  /*
1679
1407
  * call-seq:
1680
- * node.pointer -> node_set
1408
+ * node.pointer -> XML::Node_set
1681
1409
  *
1682
1410
  * Evaluates an XPointer expression relative to this node.
1683
1411
  */
@@ -1689,7 +1417,7 @@ ruby_xml_node_pointer(VALUE self, VALUE xptr_str) {
1689
1417
 
1690
1418
  /*
1691
1419
  * call-seq:
1692
- * node.prev -> node
1420
+ * node.prev -> XML::Node
1693
1421
  *
1694
1422
  * Obtain the previous sibling, if any.
1695
1423
  */
@@ -1726,46 +1454,6 @@ ruby_xml_node_prev_get(VALUE self) {
1726
1454
  }
1727
1455
 
1728
1456
 
1729
- /*
1730
- * call-seq:
1731
- * node.prev? -> (true|false)
1732
- *
1733
- * Determines whether this node has a previous sibling node.
1734
- */
1735
- VALUE
1736
- ruby_xml_node_prev_q(VALUE self) {
1737
- xmlNodePtr xnode;
1738
- xmlNodePtr node;
1739
-
1740
- Data_Get_Struct(self, xmlNode, xnode);
1741
-
1742
- switch (xnode->type) {
1743
- case XML_DOCUMENT_NODE:
1744
- #ifdef LIBXML_DOCB_ENABLED
1745
- case XML_DOCB_DOCUMENT_NODE:
1746
- #endif
1747
- case XML_HTML_DOCUMENT_NODE:
1748
- case XML_NAMESPACE_DECL:
1749
- node = NULL;
1750
- break;
1751
- case XML_ATTRIBUTE_NODE:
1752
- {
1753
- xmlAttrPtr attr = (xmlAttrPtr) xnode;
1754
- node = (xmlNodePtr) attr->prev;
1755
- }
1756
- break;
1757
- default:
1758
- node = xnode->prev;
1759
- break;
1760
- }
1761
-
1762
- if (node == NULL)
1763
- return(Qfalse);
1764
- else
1765
- return(Qtrue);
1766
- }
1767
-
1768
-
1769
1457
  /*
1770
1458
  * call-seq:
1771
1459
  * node.prev = node
@@ -1904,7 +1592,7 @@ ruby_xml_node_search_ns(VALUE self, VALUE ns) {
1904
1592
 
1905
1593
  /*
1906
1594
  * call-seq:
1907
- * node.sibling(node) -> node
1595
+ * node.sibling(node) -> XML::Node
1908
1596
  *
1909
1597
  * Add the specified node as a sibling of this node.
1910
1598
  */
@@ -2020,69 +1708,6 @@ ruby_xml_node_type(VALUE self) {
2020
1708
  }
2021
1709
 
2022
1710
 
2023
- /*
2024
- * call-seq:
2025
- * node.type_name -> num
2026
- *
2027
- * Obtain this node's type name.
2028
- */
2029
- VALUE
2030
- ruby_xml_node_type_name(VALUE self) {
2031
- xmlNodePtr xnode;
2032
- Data_Get_Struct(self, xmlNode, xnode);
2033
-
2034
- switch(xnode->type) {
2035
- case XML_ELEMENT_NODE:
2036
- return(rb_str_new2("element"));
2037
- case XML_ATTRIBUTE_NODE:
2038
- return(rb_str_new2("attribute"));
2039
- case XML_TEXT_NODE:
2040
- return(rb_str_new2("text"));
2041
- case XML_CDATA_SECTION_NODE:
2042
- return(rb_str_new2("cdata"));
2043
- case XML_ENTITY_REF_NODE:
2044
- return(rb_str_new2("entity_ref"));
2045
- case XML_ENTITY_NODE:
2046
- return(rb_str_new2("entity"));
2047
- case XML_PI_NODE:
2048
- return(rb_str_new2("pi"));
2049
- case XML_COMMENT_NODE:
2050
- return(rb_str_new2("comment"));
2051
- case XML_DOCUMENT_NODE:
2052
- return(rb_str_new2("document_xml"));
2053
- case XML_DOCUMENT_TYPE_NODE:
2054
- return(rb_str_new2("doctype"));
2055
- case XML_DOCUMENT_FRAG_NODE:
2056
- return(rb_str_new2("fragment"));
2057
- case XML_NOTATION_NODE:
2058
- return(rb_str_new2("notation"));
2059
- case XML_HTML_DOCUMENT_NODE:
2060
- return(rb_str_new2("document_html"));
2061
- case XML_DTD_NODE:
2062
- return(rb_str_new2("dtd"));
2063
- case XML_ELEMENT_DECL:
2064
- return(rb_str_new2("elem_decl"));
2065
- case XML_ATTRIBUTE_DECL:
2066
- return(rb_str_new2("attribute_decl"));
2067
- case XML_ENTITY_DECL:
2068
- return(rb_str_new2("entity_decl"));
2069
- case XML_NAMESPACE_DECL:
2070
- return(rb_str_new2("namespace"));
2071
- case XML_XINCLUDE_START:
2072
- return(rb_str_new2("xinclude_start"));
2073
- case XML_XINCLUDE_END:
2074
- return(rb_str_new2("xinclude_end"));
2075
- #ifdef LIBXML_DOCB_ENABLED
2076
- case XML_DOCB_DOCUMENT_NODE:
2077
- return(rb_str_new2("document_docbook"));
2078
- #endif
2079
- default:
2080
- rb_raise(eXMLNodeUnknownType, "Unknown node type: %n", xnode->type);
2081
- return(Qfalse);
2082
- }
2083
- }
2084
-
2085
-
2086
1711
  /*
2087
1712
  * call-seq:
2088
1713
  * node.xinclude_end? -> num
@@ -2119,9 +1744,13 @@ ruby_xml_node_xinclude_start_q(VALUE self) {
2119
1744
 
2120
1745
  /*
2121
1746
  * call-seq:
2122
- * node.copy -> node
1747
+ * node.copy -> XML::Node
2123
1748
  *
2124
- * Create a copy of this node.
1749
+ * Creates a copy of this node. To create a
1750
+ * shallow copy set the deep parameter to false.
1751
+ * To create a deep copy set the deep parameter
1752
+ * to true.
1753
+ *
2125
1754
  */
2126
1755
  VALUE
2127
1756
  ruby_xml_node_copy(VALUE self, VALUE deep) {
@@ -2140,7 +1769,7 @@ ruby_xml_node_copy(VALUE self, VALUE deep) {
2140
1769
 
2141
1770
  /*
2142
1771
  * call-seq:
2143
- * XML::Node.new_text(content = nil) -> node
1772
+ * XML::Node.new_text(content = nil) -> XML::Node
2144
1773
  *
2145
1774
  * Create a new text node, optionally setting
2146
1775
  * the node's content.
@@ -2185,13 +1814,12 @@ ruby_xml_node_deregisterNode(xmlNodePtr xnode)
2185
1814
 
2186
1815
  // Rdoc needs to know
2187
1816
  #ifdef RDOC_NEVER_DEFINED
2188
- mXML = rb_define_module("XML");
1817
+ mLibXML = rb_define_module("LibXML");
1818
+ mXML = rb_define_module_under(mLibXML, "XML");
2189
1819
  #endif
2190
1820
 
2191
1821
  void
2192
1822
  ruby_init_xml_node(void) {
2193
- VALUE singleton;
2194
-
2195
1823
  xmlRegisterNodeDefault(ruby_xml_node_registerNode);
2196
1824
  xmlDeregisterNodeDefault(ruby_xml_node_deregisterNode);
2197
1825
 
@@ -2200,8 +1828,6 @@ ruby_init_xml_node(void) {
2200
1828
  eXMLNodeFailedModify = rb_define_class_under(cXMLNode, "FailedModify", eXMLError);
2201
1829
  eXMLNodeUnknownType = rb_define_class_under(cXMLNode, "UnknownType", eXMLError);
2202
1830
 
2203
- singleton = rb_singleton_class(cXMLNode);
2204
-
2205
1831
  rb_define_const(cXMLNode, "SPACE_DEFAULT", INT2NUM(0));
2206
1832
  rb_define_const(cXMLNode, "SPACE_PRESERVE", INT2NUM(1));
2207
1833
  rb_define_const(cXMLNode, "SPACE_NOT_INHERIT", INT2NUM(-1));
@@ -2216,6 +1842,34 @@ ruby_init_xml_node(void) {
2216
1842
  rb_define_const(cXMLNode, "XLINK_TYPE_EXTENDED_SET", INT2NUM(3));
2217
1843
  rb_define_const(cXMLNode, "XLINK_TYPE_NONE", INT2NUM(0));
2218
1844
  rb_define_const(cXMLNode, "XLINK_TYPE_SIMPLE", INT2NUM(1));
1845
+
1846
+ rb_define_const(cXMLNode, "ELEMENT_NODE", INT2FIX(XML_ELEMENT_NODE));
1847
+ rb_define_const(cXMLNode, "ATTRIBUTE_NODE", INT2FIX(XML_ATTRIBUTE_NODE));
1848
+ rb_define_const(cXMLNode, "TEXT_NODE", INT2FIX(XML_TEXT_NODE));
1849
+ rb_define_const(cXMLNode, "CDATA_SECTION_NODE", INT2FIX(XML_CDATA_SECTION_NODE));
1850
+ rb_define_const(cXMLNode, "ENTITY_REF_NODE", INT2FIX(XML_ENTITY_REF_NODE));
1851
+ rb_define_const(cXMLNode, "ENTITY_NODE", INT2FIX(XML_ENTITY_NODE));
1852
+ rb_define_const(cXMLNode, "PI_NODE", INT2FIX(XML_PI_NODE));
1853
+ rb_define_const(cXMLNode, "COMMENT_NODE", INT2FIX(XML_COMMENT_NODE));
1854
+ rb_define_const(cXMLNode, "DOCUMENT_NODE", INT2FIX(XML_DOCUMENT_NODE));
1855
+ rb_define_const(cXMLNode, "DOCUMENT_TYPE_NODE", INT2FIX(XML_DOCUMENT_TYPE_NODE));
1856
+ rb_define_const(cXMLNode, "DOCUMENT_FRAG_NODE", INT2FIX(XML_DOCUMENT_FRAG_NODE));
1857
+ rb_define_const(cXMLNode, "NOTATION_NODE", INT2FIX(XML_NOTATION_NODE));
1858
+ rb_define_const(cXMLNode, "HTML_DOCUMENT_NODE", INT2FIX(XML_HTML_DOCUMENT_NODE));
1859
+ rb_define_const(cXMLNode, "DTD_NODE", INT2FIX(XML_DTD_NODE));
1860
+ rb_define_const(cXMLNode, "ELEMENT_DECL", INT2FIX(XML_ELEMENT_DECL));
1861
+ rb_define_const(cXMLNode, "ATTRIBUTE_DECL", INT2FIX(XML_ATTRIBUTE_DECL));
1862
+ rb_define_const(cXMLNode, "ENTITY_DECL", INT2FIX(XML_ENTITY_DECL));
1863
+ rb_define_const(cXMLNode, "NAMESPACE_DECL", INT2FIX(XML_NAMESPACE_DECL));
1864
+ rb_define_const(cXMLNode, "XINCLUDE_START", INT2FIX(XML_XINCLUDE_START));
1865
+ rb_define_const(cXMLNode, "XINCLUDE_END", INT2FIX(XML_XINCLUDE_END));
1866
+
1867
+ #ifdef LIBXML_DOCB_ENABLED
1868
+ rb_define_const(cXMLNode, "DOCB_DOCUMENT_NODE", INT2FIX(XML_DOCB_DOCUMENT_NODE));
1869
+ #else
1870
+ rb_define_const(cXMLNode, "DOCB_DOCUMENT_NODE", Qnil);
1871
+ #endif
1872
+
2219
1873
 
2220
1874
  rb_define_singleton_method(cXMLNode, "new2", ruby_xml_node2_new_native, 2);
2221
1875
  rb_define_singleton_method(cXMLNode, "new", ruby_xml_node2_new_string_bc, -1);
@@ -2223,11 +1877,27 @@ ruby_init_xml_node(void) {
2223
1877
  rb_define_singleton_method(cXMLNode, "new_comment", ruby_xml_node_new_comment, -1);
2224
1878
  rb_define_singleton_method(cXMLNode, "new_text", ruby_xml_node_new_text, 1);
2225
1879
 
2226
- rb_define_alias(singleton, "new_element", "new");
2227
-
2228
- rb_define_method(cXMLNode, "<<", ruby_xml_node_content_add, 1);
1880
+ /* Traversal */
1881
+ rb_include_module(cXMLNode, rb_mEnumerable);
2229
1882
  rb_define_method(cXMLNode, "[]", ruby_xml_node_property_get, 1);
1883
+ rb_define_method(cXMLNode, "each", ruby_xml_node_each, 0);
1884
+ rb_define_method(cXMLNode, "first", ruby_xml_node_first_get, 0);
1885
+ rb_define_method(cXMLNode, "last", ruby_xml_node_last_get, 0);
1886
+ rb_define_method(cXMLNode, "next", ruby_xml_node_next_get, 0);
1887
+ rb_define_method(cXMLNode, "parent", ruby_xml_node_parent_get, 0);
1888
+ rb_define_method(cXMLNode, "prev", ruby_xml_node_prev_get, 0);
1889
+
1890
+ /* Modification */
1891
+ rb_define_method(cXMLNode, "<<", ruby_xml_node_content_add, 1);
2230
1892
  rb_define_method(cXMLNode, "[]=", ruby_xml_node_property_set, 2);
1893
+ rb_define_method(cXMLNode, "child_add", ruby_xml_node_child_add, 1);
1894
+ rb_define_method(cXMLNode, "child=", ruby_xml_node_child_set, 1);
1895
+ rb_define_method(cXMLNode, "sibling=", ruby_xml_node_sibling_set, 1);
1896
+ rb_define_method(cXMLNode, "next=", ruby_xml_node_next_set, 1);
1897
+ rb_define_method(cXMLNode, "prev=", ruby_xml_node_prev_set, 1);
1898
+
1899
+
1900
+ /* Rest of the node api */
2231
1901
  rb_define_method(cXMLNode, "attribute?", ruby_xml_node_attribute_q, 0);
2232
1902
  rb_define_method(cXMLNode, "attribute_decl?", ruby_xml_node_attribute_decl_q, 0);
2233
1903
  rb_define_method(cXMLNode, "attributes", ruby_xml_node_attributes_get, 0);
@@ -2238,12 +1908,6 @@ ruby_init_xml_node(void) {
2238
1908
  rb_define_method(cXMLNode, "cdata?", ruby_xml_node_cdata_q, 0);
2239
1909
  rb_define_method(cXMLNode, "comment?", ruby_xml_node_comment_q, 0);
2240
1910
  rb_define_method(cXMLNode, "copy", ruby_xml_node_copy, 1);
2241
- rb_define_method(cXMLNode, "child", ruby_xml_node_child_get, 0);
2242
- rb_define_method(cXMLNode, "child?", ruby_xml_node_child_q, 0);
2243
- rb_define_method(cXMLNode, "child=", ruby_xml_node_child_set, 1);
2244
- rb_define_method(cXMLNode, "child_add", ruby_xml_node_child_add, 1);
2245
- rb_define_method(cXMLNode, "children", ruby_xml_node_child_get, 0);
2246
- rb_define_method(cXMLNode, "children?", ruby_xml_node_child_q, 0);
2247
1911
  rb_define_method(cXMLNode, "content", ruby_xml_node_content_get, 0);
2248
1912
  rb_define_method(cXMLNode, "content=", ruby_xml_node_content_set, 1);
2249
1913
  rb_define_method(cXMLNode, "content_stripped", ruby_xml_node_content_stripped_get, 0);
@@ -2260,14 +1924,10 @@ ruby_init_xml_node(void) {
2260
1924
  rb_define_method(cXMLNode, "entity?", ruby_xml_node_entity_q, 0);
2261
1925
  rb_define_method(cXMLNode, "entity_ref?", ruby_xml_node_entity_ref_q, 0);
2262
1926
  rb_define_method(cXMLNode, "eql?", ruby_xml_node_eql_q, 1);
2263
- rb_define_method(cXMLNode, "find", ruby_xml_node_find, -1);
2264
- rb_define_method(cXMLNode, "find_first", ruby_xml_node_find_first, -1);
2265
1927
  rb_define_method(cXMLNode, "fragment?", ruby_xml_node_fragment_q, 0);
2266
1928
  rb_define_method(cXMLNode, "html_doc?", ruby_xml_node_html_doc_q, 0);
2267
1929
  rb_define_method(cXMLNode, "lang", ruby_xml_node_lang_get, 0);
2268
1930
  rb_define_method(cXMLNode, "lang=", ruby_xml_node_lang_set, 1);
2269
- rb_define_method(cXMLNode, "last", ruby_xml_node_last_get, 0);
2270
- rb_define_method(cXMLNode, "last?", ruby_xml_node_last_q, 0);
2271
1931
  rb_define_method(cXMLNode, "line_num", ruby_xml_node_line_num, 0);
2272
1932
  rb_define_method(cXMLNode, "name", ruby_xml_node_name_get, 0);
2273
1933
  rb_define_method(cXMLNode, "name=", ruby_xml_node_name_set, 1);
@@ -2275,28 +1935,18 @@ ruby_init_xml_node(void) {
2275
1935
  rb_define_method(cXMLNode, "namespace_node", ruby_xml_node_namespace_get_node, 0);
2276
1936
  rb_define_method(cXMLNode, "namespace?", ruby_xml_node_namespace_q, 0);
2277
1937
  rb_define_method(cXMLNode, "namespace=", ruby_xml_node_namespace_set, -1);
2278
- rb_define_method(cXMLNode, "next", ruby_xml_node_next_get, 0);
2279
- rb_define_method(cXMLNode, "next?", ruby_xml_node_next_q, 0);
2280
- rb_define_method(cXMLNode, "next=", ruby_xml_node_next_set, 1);
2281
1938
  rb_define_method(cXMLNode, "node_type", ruby_xml_node_type, 0);
2282
- rb_define_method(cXMLNode, "node_type_name", ruby_xml_node_type_name, 0);
2283
1939
  rb_define_method(cXMLNode, "notation?", ruby_xml_node_notation_q, 0);
2284
1940
  rb_define_method(cXMLNode, "ns", ruby_xml_node_namespace_get, 0);
2285
1941
  rb_define_method(cXMLNode, "ns?", ruby_xml_node_ns_q, 0);
2286
1942
  rb_define_method(cXMLNode, "ns_def", ruby_xml_node_ns_def_get, 0);
2287
1943
  rb_define_method(cXMLNode, "ns_def?", ruby_xml_node_ns_def_q, 0);
2288
- rb_define_method(cXMLNode, "parent", ruby_xml_node_parent_get, 0);
2289
- rb_define_method(cXMLNode, "parent?", ruby_xml_node_parent_q, 0);
2290
1944
  rb_define_method(cXMLNode, "path", ruby_xml_node_path, 0);
2291
1945
  rb_define_method(cXMLNode, "pi?", ruby_xml_node_pi_q, 0);
2292
1946
  rb_define_method(cXMLNode, "pointer", ruby_xml_node_pointer, 1);
2293
- rb_define_method(cXMLNode, "prev", ruby_xml_node_prev_get, 0);
2294
- rb_define_method(cXMLNode, "prev?", ruby_xml_node_prev_q, 0);
2295
- rb_define_method(cXMLNode, "prev=", ruby_xml_node_prev_set, 1);
2296
1947
  rb_define_method(cXMLNode, "remove!", ruby_xml_node_remove_ex, 0);
2297
1948
  rb_define_method(cXMLNode, "search_ns", ruby_xml_node_search_ns, 1);
2298
1949
  rb_define_method(cXMLNode, "search_href", ruby_xml_node_search_href, 1);
2299
- rb_define_method(cXMLNode, "sibling=", ruby_xml_node_sibling_set, 1);
2300
1950
  rb_define_method(cXMLNode, "space_preserve", ruby_xml_node_space_preserve_get, 0);
2301
1951
  rb_define_method(cXMLNode, "space_preserve=", ruby_xml_node_space_preserve_set, 1);
2302
1952
  rb_define_method(cXMLNode, "text?", ruby_xml_node_text_q, 0);
@@ -2309,4 +1959,11 @@ ruby_init_xml_node(void) {
2309
1959
 
2310
1960
  rb_define_alias(cXMLNode, "==", "eql?");
2311
1961
  rb_define_alias(cXMLNode, "properties?", "attributes?");
1962
+
1963
+ /* :nodoc: */
1964
+ {
1965
+ VALUE singleton;
1966
+ singleton = rb_singleton_class(cXMLNode);
1967
+ rb_define_alias(singleton, "new_element", "new");
1968
+ }
2312
1969
  }