libxml-ruby 2.9.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +811 -790
  3. data/LICENSE +20 -20
  4. data/MANIFEST +166 -166
  5. data/README.rdoc +188 -184
  6. data/Rakefile +1 -1
  7. data/ext/libxml/libxml.c +80 -80
  8. data/ext/libxml/ruby_libxml.h +75 -75
  9. data/ext/libxml/ruby_xml.c +0 -84
  10. data/ext/libxml/ruby_xml.h +0 -10
  11. data/ext/libxml/ruby_xml_attr.h +12 -12
  12. data/ext/libxml/ruby_xml_attr_decl.c +153 -153
  13. data/ext/libxml/ruby_xml_attr_decl.h +11 -11
  14. data/ext/libxml/ruby_xml_attributes.c +275 -275
  15. data/ext/libxml/ruby_xml_attributes.h +15 -15
  16. data/ext/libxml/ruby_xml_document.c +21 -27
  17. data/ext/libxml/ruby_xml_document.h +11 -11
  18. data/ext/libxml/ruby_xml_dtd.c +2 -13
  19. data/ext/libxml/ruby_xml_dtd.h +9 -9
  20. data/ext/libxml/ruby_xml_error.c +996 -996
  21. data/ext/libxml/ruby_xml_error.h +12 -12
  22. data/ext/libxml/ruby_xml_html_parser.c +89 -92
  23. data/ext/libxml/ruby_xml_html_parser.h +10 -10
  24. data/ext/libxml/ruby_xml_html_parser_context.h +10 -10
  25. data/ext/libxml/ruby_xml_html_parser_options.c +46 -46
  26. data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
  27. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  28. data/ext/libxml/ruby_xml_io.c +0 -1
  29. data/ext/libxml/ruby_xml_io.h +10 -10
  30. data/ext/libxml/ruby_xml_namespace.c +153 -153
  31. data/ext/libxml/ruby_xml_namespace.h +10 -10
  32. data/ext/libxml/ruby_xml_namespaces.c +293 -293
  33. data/ext/libxml/ruby_xml_namespaces.h +9 -9
  34. data/ext/libxml/ruby_xml_node.c +100 -143
  35. data/ext/libxml/ruby_xml_node.h +13 -11
  36. data/ext/libxml/ruby_xml_parser.c +91 -94
  37. data/ext/libxml/ruby_xml_parser.h +12 -12
  38. data/ext/libxml/ruby_xml_parser_context.h +10 -10
  39. data/ext/libxml/ruby_xml_parser_options.c +66 -66
  40. data/ext/libxml/ruby_xml_parser_options.h +12 -12
  41. data/ext/libxml/ruby_xml_reader.c +45 -37
  42. data/ext/libxml/ruby_xml_reader.h +17 -17
  43. data/ext/libxml/ruby_xml_relaxng.h +10 -10
  44. data/ext/libxml/ruby_xml_sax2_handler.c +3 -3
  45. data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
  46. data/ext/libxml/ruby_xml_sax_parser.c +116 -120
  47. data/ext/libxml/ruby_xml_sax_parser.h +10 -10
  48. data/ext/libxml/ruby_xml_schema.h +809 -809
  49. data/ext/libxml/ruby_xml_schema_attribute.c +109 -109
  50. data/ext/libxml/ruby_xml_schema_attribute.h +15 -15
  51. data/ext/libxml/ruby_xml_schema_element.c +94 -94
  52. data/ext/libxml/ruby_xml_schema_element.h +14 -14
  53. data/ext/libxml/ruby_xml_schema_facet.c +52 -52
  54. data/ext/libxml/ruby_xml_schema_facet.h +13 -13
  55. data/ext/libxml/ruby_xml_schema_type.c +259 -259
  56. data/ext/libxml/ruby_xml_schema_type.h +9 -9
  57. data/ext/libxml/ruby_xml_version.h +9 -9
  58. data/ext/libxml/ruby_xml_writer.c +1136 -1136
  59. data/ext/libxml/ruby_xml_writer.h +10 -10
  60. data/ext/libxml/ruby_xml_xinclude.c +16 -16
  61. data/ext/libxml/ruby_xml_xinclude.h +11 -11
  62. data/ext/libxml/ruby_xml_xpath.c +42 -36
  63. data/ext/libxml/ruby_xml_xpath.h +13 -13
  64. data/ext/libxml/ruby_xml_xpath_context.c +1 -1
  65. data/ext/libxml/ruby_xml_xpath_context.h +9 -9
  66. data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
  67. data/ext/libxml/ruby_xml_xpath_expression.h +10 -10
  68. data/ext/libxml/ruby_xml_xpath_object.c +5 -2
  69. data/ext/libxml/ruby_xml_xpath_object.h +17 -17
  70. data/ext/libxml/ruby_xml_xpointer.c +99 -99
  71. data/ext/libxml/ruby_xml_xpointer.h +11 -11
  72. data/ext/vc/libxml_ruby.sln +17 -15
  73. data/lib/libxml.rb +1 -6
  74. data/lib/libxml/node.rb +2 -78
  75. data/lib/libxml/parser.rb +0 -266
  76. data/lib/libxml/sax_parser.rb +0 -17
  77. data/lib/libxml/schema.rb +66 -66
  78. data/lib/libxml/schema/attribute.rb +19 -19
  79. data/lib/libxml/schema/element.rb +27 -27
  80. data/lib/libxml/schema/type.rb +29 -29
  81. data/script/benchmark/depixelate +634 -634
  82. data/script/benchmark/hamlet.xml +9054 -9054
  83. data/script/benchmark/parsecount +170 -170
  84. data/script/benchmark/throughput +41 -41
  85. data/script/test +6 -6
  86. data/test/c14n/given/example-1.xml +14 -14
  87. data/test/c14n/given/example-2.xml +11 -11
  88. data/test/c14n/given/example-3.xml +18 -18
  89. data/test/c14n/given/example-4.xml +9 -9
  90. data/test/c14n/given/example-5.xml +12 -12
  91. data/test/c14n/given/example-6.xml +2 -2
  92. data/test/c14n/given/example-7.xml +11 -11
  93. data/test/c14n/given/example-8.xml +11 -11
  94. data/test/c14n/given/example-8.xpath +9 -9
  95. data/test/c14n/result/1-1-without-comments/example-1 +3 -3
  96. data/test/c14n/result/1-1-without-comments/example-2 +10 -10
  97. data/test/c14n/result/1-1-without-comments/example-3 +13 -13
  98. data/test/c14n/result/1-1-without-comments/example-4 +8 -8
  99. data/test/c14n/result/1-1-without-comments/example-5 +2 -2
  100. data/test/c14n/result/with-comments/example-1 +5 -5
  101. data/test/c14n/result/with-comments/example-2 +10 -10
  102. data/test/c14n/result/with-comments/example-3 +13 -13
  103. data/test/c14n/result/with-comments/example-4 +8 -8
  104. data/test/c14n/result/with-comments/example-5 +3 -3
  105. data/test/c14n/result/without-comments/example-1 +3 -3
  106. data/test/c14n/result/without-comments/example-2 +10 -10
  107. data/test/c14n/result/without-comments/example-3 +13 -13
  108. data/test/c14n/result/without-comments/example-4 +8 -8
  109. data/test/c14n/result/without-comments/example-5 +2 -2
  110. data/test/model/atom.xml +12 -12
  111. data/test/model/bands.iso-8859-1.xml +4 -4
  112. data/test/model/bands.utf-8.xml +4 -4
  113. data/test/model/bands.xml +4 -4
  114. data/test/model/books.xml +153 -153
  115. data/test/model/merge_bug_data.xml +58 -58
  116. data/test/model/ruby-lang.html +238 -238
  117. data/test/model/rubynet.xml +79 -79
  118. data/test/model/shiporder.rnc +28 -28
  119. data/test/model/shiporder.rng +86 -86
  120. data/test/model/shiporder.xml +22 -22
  121. data/test/model/shiporder.xsd +39 -39
  122. data/test/model/soap.xml +27 -27
  123. data/test/model/xinclude.xml +4 -4
  124. data/test/tc_attributes.rb +0 -6
  125. data/test/tc_error.rb +157 -158
  126. data/test/tc_node.rb +33 -17
  127. data/test/tc_node_edit.rb +0 -15
  128. data/test/tc_node_pi.rb +39 -39
  129. data/test/tc_parser.rb +0 -48
  130. data/test/tc_reader.rb +12 -53
  131. data/test/tc_writer.rb +447 -447
  132. data/test/tc_xpath.rb +1 -1
  133. data/test/test_helper.rb +2 -2
  134. metadata +3 -8
  135. data/ext/libxml/extconf.h +0 -4
  136. data/lib/libxml/ns.rb +0 -22
  137. data/lib/libxml/properties.rb +0 -23
  138. data/lib/libxml/reader.rb +0 -29
  139. data/lib/libxml/xpath_object.rb +0 -16
@@ -1,12 +1,12 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #ifndef __RXML_PARSER__
4
- #define __RXML_PARSER__
5
-
6
- #define MAX_LIBXML_FEATURES_LEN 50
7
-
8
- extern VALUE cXMLParser;
9
-
10
- void rxml_init_parser();
11
-
12
- #endif
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #ifndef __RXML_PARSER__
4
+ #define __RXML_PARSER__
5
+
6
+ #define MAX_LIBXML_FEATURES_LEN 50
7
+
8
+ extern VALUE cXMLParser;
9
+
10
+ void rxml_init_parser();
11
+
12
+ #endif
@@ -1,10 +1,10 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #ifndef __RXML_PARSER_CONTEXT__
4
- #define __RXML_PARSER_CONTEXT__
5
-
6
- extern VALUE cXMLParserContext;
7
-
8
- void rxml_init_parser_context(void);
9
-
10
- #endif
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #ifndef __RXML_PARSER_CONTEXT__
4
+ #define __RXML_PARSER_CONTEXT__
5
+
6
+ extern VALUE cXMLParserContext;
7
+
8
+ void rxml_init_parser_context(void);
9
+
10
+ #endif
@@ -1,66 +1,66 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #include <stdarg.h>
4
- #include "ruby_libxml.h"
5
-
6
- /* Document-class: LibXML::XML::Parser::Options
7
- *
8
- * Options that control the operation of the HTMLParser. The easiest
9
- * way to set a parser's options is to use the methods
10
- * XML::Parser.file, XML::Parser.io or XML::Parser.string.
11
- * For additional control, see XML::Parser::Context#options=.
12
- */
13
-
14
- VALUE mXMLParserOptions;
15
-
16
- void rxml_init_parser_options(void)
17
- {
18
- mXMLParserOptions = rb_define_module_under(cXMLParser, "Options");
19
-
20
- /* recover on errors */
21
- rb_define_const(mXMLParserOptions, "RECOVER", INT2NUM(XML_PARSE_RECOVER));
22
- /* substitute entities */
23
- rb_define_const(mXMLParserOptions, "NOENT", INT2NUM(XML_PARSE_NOENT));
24
- /* load the external subset */
25
- rb_define_const(mXMLParserOptions, "DTDLOAD", INT2NUM(XML_PARSE_DTDLOAD));
26
- /* default DTD attributes */
27
- rb_define_const(mXMLParserOptions, "DTDATTR", INT2NUM(XML_PARSE_DTDATTR));
28
- /* validate with the DTD */
29
- rb_define_const(mXMLParserOptions, "DTDVALID", INT2NUM(XML_PARSE_DTDVALID));
30
- /* suppress error reports */
31
- rb_define_const(mXMLParserOptions, "NOERROR", INT2NUM(XML_PARSE_NOERROR));
32
- /* suppress warning reports */
33
- rb_define_const(mXMLParserOptions, "NOWARNING", INT2NUM(XML_PARSE_NOWARNING));
34
- /* pedantic error reporting */
35
- rb_define_const(mXMLParserOptions, "PEDANTIC", INT2NUM(XML_PARSE_PEDANTIC));
36
- /* remove blank nodes */
37
- rb_define_const(mXMLParserOptions, "NOBLANKS", INT2NUM(XML_PARSE_NOBLANKS));
38
- /* use the SAX1 interface internally */
39
- rb_define_const(mXMLParserOptions, "SAX1", INT2NUM(XML_PARSE_SAX1));
40
- /* Implement XInclude substitition */
41
- rb_define_const(mXMLParserOptions, "XINCLUDE", INT2NUM(XML_PARSE_XINCLUDE));
42
- /* Forbid network access */
43
- rb_define_const(mXMLParserOptions, "NONET", INT2NUM(XML_PARSE_NONET));
44
- /* Do not reuse the context dictionnary */
45
- rb_define_const(mXMLParserOptions, "NODICT", INT2NUM(XML_PARSE_NODICT));
46
- /* remove redundant namespaces declarations */
47
- rb_define_const(mXMLParserOptions, "NSCLEAN", INT2NUM(XML_PARSE_NSCLEAN));
48
- /* merge CDATA as text nodes */
49
- rb_define_const(mXMLParserOptions, "NOCDATA", INT2NUM(XML_PARSE_NOCDATA));
50
- #if LIBXML_VERSION >= 20621
51
- /* do not generate XINCLUDE START/END nodes */
52
- rb_define_const(mXMLParserOptions, "NOXINCNODE", INT2NUM(XML_PARSE_NOXINCNODE));
53
- #endif
54
- #if LIBXML_VERSION >= 20700
55
- /* compact small text nodes */
56
- rb_define_const(mXMLParserOptions, "COMPACT", INT2NUM(XML_PARSE_COMPACT));
57
- /* parse using XML-1.0 before update 5 */
58
- rb_define_const(mXMLParserOptions, "PARSE_OLD10", INT2NUM(XML_PARSE_OLD10));
59
- /* do not fixup XINCLUDE xml:base uris */
60
- rb_define_const(mXMLParserOptions, "NOBASEFIX", INT2NUM(XML_PARSE_NOBASEFIX));
61
- #endif
62
- #if LIBXML_VERSION >= 20703
63
- /* relax any hardcoded limit from the parser */
64
- rb_define_const(mXMLParserOptions, "HUGE", INT2NUM(XML_PARSE_HUGE));
65
- #endif
66
- }
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #include <stdarg.h>
4
+ #include "ruby_libxml.h"
5
+
6
+ /* Document-class: LibXML::XML::Parser::Options
7
+ *
8
+ * Options that control the operation of the HTMLParser. The easiest
9
+ * way to set a parser's options is to use the methods
10
+ * XML::Parser.file, XML::Parser.io or XML::Parser.string.
11
+ * For additional control, see XML::Parser::Context#options=.
12
+ */
13
+
14
+ VALUE mXMLParserOptions;
15
+
16
+ void rxml_init_parser_options(void)
17
+ {
18
+ mXMLParserOptions = rb_define_module_under(cXMLParser, "Options");
19
+
20
+ /* recover on errors */
21
+ rb_define_const(mXMLParserOptions, "RECOVER", INT2NUM(XML_PARSE_RECOVER));
22
+ /* substitute entities */
23
+ rb_define_const(mXMLParserOptions, "NOENT", INT2NUM(XML_PARSE_NOENT));
24
+ /* load the external subset */
25
+ rb_define_const(mXMLParserOptions, "DTDLOAD", INT2NUM(XML_PARSE_DTDLOAD));
26
+ /* default DTD attributes */
27
+ rb_define_const(mXMLParserOptions, "DTDATTR", INT2NUM(XML_PARSE_DTDATTR));
28
+ /* validate with the DTD */
29
+ rb_define_const(mXMLParserOptions, "DTDVALID", INT2NUM(XML_PARSE_DTDVALID));
30
+ /* suppress error reports */
31
+ rb_define_const(mXMLParserOptions, "NOERROR", INT2NUM(XML_PARSE_NOERROR));
32
+ /* suppress warning reports */
33
+ rb_define_const(mXMLParserOptions, "NOWARNING", INT2NUM(XML_PARSE_NOWARNING));
34
+ /* pedantic error reporting */
35
+ rb_define_const(mXMLParserOptions, "PEDANTIC", INT2NUM(XML_PARSE_PEDANTIC));
36
+ /* remove blank nodes */
37
+ rb_define_const(mXMLParserOptions, "NOBLANKS", INT2NUM(XML_PARSE_NOBLANKS));
38
+ /* use the SAX1 interface internally */
39
+ rb_define_const(mXMLParserOptions, "SAX1", INT2NUM(XML_PARSE_SAX1));
40
+ /* Implement XInclude substitition */
41
+ rb_define_const(mXMLParserOptions, "XINCLUDE", INT2NUM(XML_PARSE_XINCLUDE));
42
+ /* Forbid network access */
43
+ rb_define_const(mXMLParserOptions, "NONET", INT2NUM(XML_PARSE_NONET));
44
+ /* Do not reuse the context dictionnary */
45
+ rb_define_const(mXMLParserOptions, "NODICT", INT2NUM(XML_PARSE_NODICT));
46
+ /* remove redundant namespaces declarations */
47
+ rb_define_const(mXMLParserOptions, "NSCLEAN", INT2NUM(XML_PARSE_NSCLEAN));
48
+ /* merge CDATA as text nodes */
49
+ rb_define_const(mXMLParserOptions, "NOCDATA", INT2NUM(XML_PARSE_NOCDATA));
50
+ #if LIBXML_VERSION >= 20621
51
+ /* do not generate XINCLUDE START/END nodes */
52
+ rb_define_const(mXMLParserOptions, "NOXINCNODE", INT2NUM(XML_PARSE_NOXINCNODE));
53
+ #endif
54
+ #if LIBXML_VERSION >= 20700
55
+ /* compact small text nodes */
56
+ rb_define_const(mXMLParserOptions, "COMPACT", INT2NUM(XML_PARSE_COMPACT));
57
+ /* parse using XML-1.0 before update 5 */
58
+ rb_define_const(mXMLParserOptions, "PARSE_OLD10", INT2NUM(XML_PARSE_OLD10));
59
+ /* do not fixup XINCLUDE xml:base uris */
60
+ rb_define_const(mXMLParserOptions, "NOBASEFIX", INT2NUM(XML_PARSE_NOBASEFIX));
61
+ #endif
62
+ #if LIBXML_VERSION >= 20703
63
+ /* relax any hardcoded limit from the parser */
64
+ rb_define_const(mXMLParserOptions, "HUGE", INT2NUM(XML_PARSE_HUGE));
65
+ #endif
66
+ }
@@ -1,12 +1,12 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #ifndef __RXML_PARSER_OPTIONS__
4
- #define __RXML_PARSER_OPTIONS__
5
-
6
- #define MAX_LIBXML_FEATURES_LEN 50
7
-
8
- extern VALUE mXMLParserOptions;
9
-
10
- void rxml_init_parser_options();
11
-
12
- #endif
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #ifndef __RXML_PARSER_OPTIONS__
4
+ #define __RXML_PARSER_OPTIONS__
5
+
6
+ #define MAX_LIBXML_FEATURES_LEN 50
7
+
8
+ extern VALUE mXMLParserOptions;
9
+
10
+ void rxml_init_parser_options();
11
+
12
+ #endif
@@ -62,8 +62,8 @@ static void rxml_reader_free(xmlTextReaderPtr xreader)
62
62
  static void rxml_reader_mark(xmlTextReaderPtr xreader)
63
63
  {
64
64
  xmlDocPtr xdoc = xmlTextReaderCurrentDoc(xreader);
65
- VALUE value = rxml_lookup_doc(xdoc);
66
- rb_gc_mark(value);
65
+ VALUE doc = (VALUE)xdoc->_private;
66
+ rb_gc_mark(doc);
67
67
  }
68
68
 
69
69
  static VALUE rxml_reader_wrap(xmlTextReaderPtr xreader)
@@ -311,24 +311,14 @@ static VALUE rxml_reader_move_to_attr_no(VALUE self, VALUE index)
311
311
  */
312
312
  static VALUE rxml_reader_move_to_attr(VALUE self, VALUE val)
313
313
  {
314
- if (TYPE(val) == T_FIXNUM)
315
- {
316
- rb_warn("%s::move_to_attribute with a Fixnum argument is deprecated. "
317
- "Please, consider move_to_attribute_no method instead.",
318
- rb_class2name(cXMLReader));
319
- return rxml_reader_move_to_attr_no(self, val);
320
- }
321
- else
322
- {
323
- int ret;
324
- xmlTextReaderPtr xreader;
314
+ int ret;
315
+ xmlTextReaderPtr xreader;
325
316
 
326
- xreader = rxml_text_reader_get(self);
327
- ret = xmlTextReaderMoveToAttribute(xreader,
328
- (const xmlChar *) StringValueCStr(val));
317
+ xreader = rxml_text_reader_get(self);
318
+ ret = xmlTextReaderMoveToAttribute(xreader,
319
+ (const xmlChar *) StringValueCStr(val));
329
320
 
330
- return INT2FIX(ret);
331
- }
321
+ return INT2FIX(ret);
332
322
  }
333
323
 
334
324
  /*
@@ -991,26 +981,14 @@ static VALUE rxml_reader_lookup_namespace(VALUE self, VALUE prefix)
991
981
  * reader.expand -> node
992
982
  *
993
983
  * Returns the current node and its full subtree. Note the returned node
994
- * is valid ONLY until the next read call.
984
+ * is valid ONLY until the next read call. If you would like to preserve
985
+ * the node, or search it via xpath, call reader.doc first.
995
986
  */
996
987
  static VALUE rxml_reader_expand(VALUE self)
997
988
  {
998
989
  xmlTextReaderPtr xreader = rxml_text_reader_get(self);
999
- xmlNodePtr xnode = NULL;
990
+ xmlNodePtr xnode = xmlTextReaderExpand(xreader);
1000
991
 
1001
- /* At this point we need to wrap the reader's document as explained above. */
1002
- xmlDocPtr xdoc = xmlTextReaderCurrentDoc(xreader);
1003
-
1004
- if (!xdoc)
1005
- rb_raise(rb_eRuntimeError, "The reader does not have a document. Did you forget to call read?");
1006
-
1007
- rxml_document_wrap(xdoc);
1008
-
1009
- /* And now hook in a mark function */
1010
- RDATA(self)->dmark = (RUBY_DATA_FUNC)rxml_reader_mark;
1011
-
1012
- xnode = xmlTextReaderExpand(xreader);
1013
-
1014
992
  if (!xnode)
1015
993
  {
1016
994
  return Qnil;
@@ -1021,6 +999,35 @@ static VALUE rxml_reader_expand(VALUE self)
1021
999
  }
1022
1000
  }
1023
1001
 
1002
+ /*
1003
+ * call-seq:
1004
+ * reader.document -> doc
1005
+ *
1006
+ * Hacking interface that provides access to the current document being accessed by the
1007
+ * reader. NOTE: as a result of this call, the reader will not destroy the associated XML
1008
+ * document. Instead, it will be destroyed when the returned document goes out of scope.
1009
+ *
1010
+ * Returns: document
1011
+ */
1012
+ static VALUE rxml_reader_doc(VALUE self)
1013
+ {
1014
+ VALUE result = Qnil;
1015
+ xmlTextReaderPtr xreader = rxml_text_reader_get(self);
1016
+ xmlDocPtr xdoc = xmlTextReaderCurrentDoc(xreader);
1017
+
1018
+ if (!xdoc)
1019
+ rb_raise(rb_eRuntimeError, "The reader does not have a document. Did you forget to call read?");
1020
+
1021
+ result = rxml_document_wrap(xdoc);
1022
+
1023
+ // And now hook in a mark function to keep the document alive as long as the reader is valid
1024
+ RDATA(self)->dmark = (RUBY_DATA_FUNC)rxml_reader_mark;
1025
+
1026
+ return result;
1027
+ }
1028
+
1029
+
1030
+
1024
1031
  #if LIBXML_VERSION >= 20618
1025
1032
  /*
1026
1033
  * call-seq:
@@ -1140,6 +1147,7 @@ void rxml_init_reader(void)
1140
1147
  rb_define_method(cXMLReader, "column_number", rxml_reader_column_number, 0);
1141
1148
  #endif
1142
1149
  rb_define_method(cXMLReader, "depth", rxml_reader_depth, 0);
1150
+ rb_define_method(cXMLReader, "doc", rxml_reader_doc, 0);
1143
1151
  rb_define_method(cXMLReader, "encoding", rxml_reader_encoding, 0);
1144
1152
  rb_define_method(cXMLReader, "expand", rxml_reader_expand, 0);
1145
1153
  rb_define_method(cXMLReader, "get_attribute", rxml_reader_get_attribute, 1);
@@ -1151,12 +1159,12 @@ void rxml_init_reader(void)
1151
1159
  rb_define_method(cXMLReader, "line_number", rxml_reader_line_number, 0);
1152
1160
  #endif
1153
1161
  rb_define_method(cXMLReader, "local_name", rxml_reader_local_name, 0);
1154
- rb_define_method(cXMLReader, "lookup_namespace", rxml_reader_lookup_namespace, 1);
1162
+ rb_define_method(cXMLReader, "lookup_namespace", rxml_reader_lookup_namespace, 1);
1155
1163
  rb_define_method(cXMLReader, "move_to_attribute", rxml_reader_move_to_attr, 1);
1156
1164
  rb_define_method(cXMLReader, "move_to_attribute_no", rxml_reader_move_to_attr_no, 1);
1157
1165
  rb_define_method(cXMLReader, "move_to_attribute_ns", rxml_reader_move_to_attr_ns, 2);
1158
- rb_define_method(cXMLReader, "move_to_first_attribute", rxml_reader_move_to_first_attr, 0);
1159
- rb_define_method(cXMLReader, "move_to_next_attribute", rxml_reader_move_to_next_attr, 0);
1166
+ rb_define_method(cXMLReader, "move_to_first_attribute", rxml_reader_move_to_first_attr, 0);
1167
+ rb_define_method(cXMLReader, "move_to_next_attribute", rxml_reader_move_to_next_attr, 0);
1160
1168
  rb_define_method(cXMLReader, "move_to_element", rxml_reader_move_to_element, 0);
1161
1169
  rb_define_method(cXMLReader, "name", rxml_reader_name, 0);
1162
1170
  rb_define_method(cXMLReader, "namespace_uri", rxml_reader_namespace_uri, 0);
@@ -1173,7 +1181,7 @@ void rxml_init_reader(void)
1173
1181
  rb_define_method(cXMLReader, "read_outer_xml", rxml_reader_read_outer_xml, 0);
1174
1182
  rb_define_method(cXMLReader, "read_state", rxml_reader_read_state, 0);
1175
1183
  rb_define_method(cXMLReader, "read_string", rxml_reader_read_string, 0);
1176
- rb_define_method(cXMLReader, "relax_ng_validate", rxml_reader_relax_ng_validate, 1);
1184
+ rb_define_method(cXMLReader, "relax_ng_validate", rxml_reader_relax_ng_validate, 1);
1177
1185
  rb_define_method(cXMLReader, "standalone", rxml_reader_standalone, 0);
1178
1186
  #if LIBXML_VERSION >= 20620
1179
1187
  rb_define_method(cXMLReader, "schema_validate", rxml_reader_schema_validate, 1);
@@ -1,17 +1,17 @@
1
- /* Copyright (c) 2006 Apple Computer Inc.
2
- * Please see the LICENSE file for copyright and distribution information. */
3
-
4
- #ifndef __RXML_READER__
5
- #define __RXML_READER__
6
-
7
- #include <libxml/xmlreader.h>
8
- #include <libxml/xmlschemas.h>
9
-
10
- extern VALUE cXMLReader;
11
-
12
- void rxml_init_reader(void);
13
-
14
- /* Exported to be used by XML::Document#reader */
15
- VALUE rxml_reader_new_walker(VALUE self, VALUE doc);
16
-
17
- #endif /* __rxml_READER__ */
1
+ /* Copyright (c) 2006 Apple Computer Inc.
2
+ * Please see the LICENSE file for copyright and distribution information. */
3
+
4
+ #ifndef __RXML_READER__
5
+ #define __RXML_READER__
6
+
7
+ #include <libxml/xmlreader.h>
8
+ #include <libxml/xmlschemas.h>
9
+
10
+ extern VALUE cXMLReader;
11
+
12
+ void rxml_init_reader(void);
13
+
14
+ /* Exported to be used by XML::Document#reader */
15
+ VALUE rxml_reader_new_walker(VALUE self, VALUE doc);
16
+
17
+ #endif /* __rxml_READER__ */
@@ -1,10 +1,10 @@
1
- #ifndef __RXML_RELAXNG__
2
- #define __RXML_RELAXNG__
3
-
4
- #include <libxml/relaxng.h>
5
-
6
- extern VALUE cXMLRelaxNG;
7
-
8
- void rxml_init_relaxng(void);
9
- #endif
10
-
1
+ #ifndef __RXML_RELAXNG__
2
+ #define __RXML_RELAXNG__
3
+
4
+ #include <libxml/relaxng.h>
5
+
6
+ extern VALUE cXMLRelaxNG;
7
+
8
+ void rxml_init_relaxng(void);
9
+ #endif
10
+
@@ -184,8 +184,8 @@ static void start_document_callback(void *ctx)
184
184
 
185
185
  static void start_element_ns_callback(void *ctx,
186
186
  const xmlChar *xlocalname, const xmlChar *xprefix, const xmlChar *xURI,
187
- int nb_namespaces, const xmlChar **xnamespaces,
188
- int nb_attributes, int nb_defaulted, const xmlChar **xattributes)
187
+ int nb_namespaces, const xmlChar **xnamespaces,
188
+ int nb_attributes, int nb_defaulted, const xmlChar **xattributes)
189
189
  {
190
190
  VALUE handler = (VALUE) ctx;
191
191
  VALUE attributes = rb_hash_new();
@@ -201,7 +201,7 @@ static void start_element_ns_callback(void *ctx,
201
201
  for (i = 0;i < nb_attributes * 5; i+=5)
202
202
  {
203
203
  VALUE attrName = rxml_new_cstr(xattributes[i+0], NULL);
204
- long attrLen = xattributes[i+4] - xattributes[i+3];
204
+ long attrLen = (long)(xattributes[i+4] - xattributes[i+3]);
205
205
  VALUE attrValue = rxml_new_cstr_len(xattributes[i+3], attrLen, NULL);
206
206
  rb_hash_aset(attributes, attrName, attrValue);
207
207
  }
@@ -1,10 +1,10 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #ifndef __RXML_SAX2_HANDLER__
4
- #define __RXML_SAX2_HANDLER__
5
-
6
- extern xmlSAXHandler rxml_sax_handler;
7
-
8
- void rxml_init_sax2_handler(void);
9
-
10
- #endif
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #ifndef __RXML_SAX2_HANDLER__
4
+ #define __RXML_SAX2_HANDLER__
5
+
6
+ extern xmlSAXHandler rxml_sax_handler;
7
+
8
+ void rxml_init_sax2_handler(void);
9
+
10
+ #endif
@@ -1,120 +1,116 @@
1
- /* Please see the LICENSE file for copyright and distribution information */
2
-
3
- #include "ruby_libxml.h"
4
- #include "ruby_xml_sax_parser.h"
5
-
6
- /*
7
- * Document-class: LibXML::XML::SaxParser
8
- *
9
- * XML::SaxParser provides a callback based API for parsing documents,
10
- * in contrast to XML::Parser's tree based API and XML::Reader's stream
11
- * based API.
12
- *
13
- * The XML::SaxParser API is fairly complex, not well standardized,
14
- * and does not directly support validation making entity, namespace and
15
- * base processing relatively hard.
16
- *
17
- * To use the XML::SaxParser, register a callback class via the
18
- * XML::SaxParser#callbacks=. It is easiest to include the
19
- * XML::SaxParser::Callbacks module in your class and override
20
- * the methods as needed.
21
- *
22
- * Basic example:
23
- *
24
- * class MyCallbacks
25
- * include XML::SaxParser::Callbacks
26
- * def on_start_element(element, attributes)
27
- * puts #Element started: #{element}"
28
- * end
29
- * end
30
- *
31
- * parser = XML::SaxParser.string(my_string)
32
- * parser.callbacks = MyCallbacks.new
33
- * parser.parse
34
- *
35
- * You can also parse strings (see XML::SaxParser.string) and
36
- * io objects (see XML::SaxParser.io).
37
- */
38
-
39
- VALUE cXMLSaxParser;
40
- static ID CALLBACKS_ATTR;
41
- static ID CONTEXT_ATTR;
42
-
43
-
44
- /* ====== Parser =========== */
45
-
46
- /*
47
- * call-seq:
48
- * parser.initialize(context) -> XML::Parser
49
- *
50
- * Creates a new XML::Parser from the specified
51
- * XML::Parser::Context.
52
- */
53
- static VALUE rxml_sax_parser_initialize(int argc, VALUE *argv, VALUE self)
54
- {
55
- VALUE context = Qnil;
56
-
57
- rb_scan_args(argc, argv, "01", &context);
58
-
59
- if (context == Qnil)
60
- {
61
- rb_warn("Passing no parameters to XML::SaxParser.new is deprecated. Pass an instance of XML::Parser::Context instead.");
62
- context = rb_class_new_instance(0, NULL, cXMLParserContext);
63
- }
64
-
65
- rb_ivar_set(self, CONTEXT_ATTR, context);
66
- return self;
67
- }
68
-
69
- /*
70
- * call-seq:
71
- * parser.parse -> (true|false)
72
- *
73
- * Parse the input XML, generating callbacks to the object
74
- * registered via the +callbacks+ attributesibute.
75
- */
76
- static VALUE rxml_sax_parser_parse(VALUE self)
77
- {
78
- int status;
79
- VALUE context = rb_ivar_get(self, CONTEXT_ATTR);
80
- xmlParserCtxtPtr ctxt;
81
- Data_Get_Struct(context, xmlParserCtxt, ctxt);
82
-
83
- ctxt->sax2 = 1;
84
- ctxt->userData = (void*)rb_ivar_get(self, CALLBACKS_ATTR);
85
-
86
- if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
87
- xmlFree(ctxt->sax);
88
-
89
- ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(rxml_sax_handler));
90
- if (ctxt->sax == NULL)
91
- rb_fatal("Not enough memory.");
92
- memcpy(ctxt->sax, &rxml_sax_handler, sizeof(rxml_sax_handler));
93
-
94
- status = xmlParseDocument(ctxt);
95
-
96
- /* Now check the parsing result*/
97
- if (status == -1 || !ctxt->wellFormed)
98
- {
99
- if (ctxt->myDoc)
100
- xmlFreeDoc(ctxt->myDoc);
101
-
102
- rxml_raise(&ctxt->lastError);
103
- }
104
- return Qtrue;
105
- }
106
-
107
- void rxml_init_sax_parser(void)
108
- {
109
- /* SaxParser */
110
- cXMLSaxParser = rb_define_class_under(mXML, "SaxParser", rb_cObject);
111
-
112
- /* Atributes */
113
- CALLBACKS_ATTR = rb_intern("@callbacks");
114
- CONTEXT_ATTR = rb_intern("@context");
115
- rb_define_attr(cXMLSaxParser, "callbacks", 1, 1);
116
-
117
- /* Instance Methods */
118
- rb_define_method(cXMLSaxParser, "initialize", rxml_sax_parser_initialize, -1);
119
- rb_define_method(cXMLSaxParser, "parse", rxml_sax_parser_parse, 0);
120
- }
1
+ /* Please see the LICENSE file for copyright and distribution information */
2
+
3
+ #include "ruby_libxml.h"
4
+ #include "ruby_xml_sax_parser.h"
5
+
6
+ /*
7
+ * Document-class: LibXML::XML::SaxParser
8
+ *
9
+ * XML::SaxParser provides a callback based API for parsing documents,
10
+ * in contrast to XML::Parser's tree based API and XML::Reader's stream
11
+ * based API.
12
+ *
13
+ * The XML::SaxParser API is fairly complex, not well standardized,
14
+ * and does not directly support validation making entity, namespace and
15
+ * base processing relatively hard.
16
+ *
17
+ * To use the XML::SaxParser, register a callback class via the
18
+ * XML::SaxParser#callbacks=. It is easiest to include the
19
+ * XML::SaxParser::Callbacks module in your class and override
20
+ * the methods as needed.
21
+ *
22
+ * Basic example:
23
+ *
24
+ * class MyCallbacks
25
+ * include XML::SaxParser::Callbacks
26
+ * def on_start_element(element, attributes)
27
+ * puts #Element started: #{element}"
28
+ * end
29
+ * end
30
+ *
31
+ * parser = XML::SaxParser.string(my_string)
32
+ * parser.callbacks = MyCallbacks.new
33
+ * parser.parse
34
+ *
35
+ * You can also parse strings (see XML::SaxParser.string) and
36
+ * io objects (see XML::SaxParser.io).
37
+ */
38
+
39
+ VALUE cXMLSaxParser;
40
+ static ID CALLBACKS_ATTR;
41
+ static ID CONTEXT_ATTR;
42
+
43
+
44
+ /* ====== Parser =========== */
45
+
46
+ /*
47
+ * call-seq:
48
+ * parser.initialize(context) -> XML::Parser
49
+ *
50
+ * Creates a new XML::Parser from the specified
51
+ * XML::Parser::Context.
52
+ */
53
+ static VALUE rxml_sax_parser_initialize(int argc, VALUE *argv, VALUE self)
54
+ {
55
+ VALUE context = Qnil;
56
+
57
+ rb_scan_args(argc, argv, "01", &context);
58
+
59
+ if (context == Qnil)
60
+ {
61
+ rb_raise(rb_eArgError, "An instance of a XML::Parser::Context must be passed to XML::SaxParser.new");
62
+ }
63
+
64
+ rb_ivar_set(self, CONTEXT_ATTR, context);
65
+ return self;
66
+ }
67
+
68
+ /*
69
+ * call-seq:
70
+ * parser.parse -> (true|false)
71
+ *
72
+ * Parse the input XML, generating callbacks to the object
73
+ * registered via the +callbacks+ attributesibute.
74
+ */
75
+ static VALUE rxml_sax_parser_parse(VALUE self)
76
+ {
77
+ int status;
78
+ VALUE context = rb_ivar_get(self, CONTEXT_ATTR);
79
+ xmlParserCtxtPtr ctxt;
80
+ Data_Get_Struct(context, xmlParserCtxt, ctxt);
81
+
82
+ ctxt->sax2 = 1;
83
+ ctxt->userData = (void*)rb_ivar_get(self, CALLBACKS_ATTR);
84
+
85
+ if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
86
+ xmlFree(ctxt->sax);
87
+
88
+ ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(rxml_sax_handler));
89
+ if (ctxt->sax == NULL)
90
+ rb_fatal("Not enough memory.");
91
+ memcpy(ctxt->sax, &rxml_sax_handler, sizeof(rxml_sax_handler));
92
+
93
+ status = xmlParseDocument(ctxt);
94
+
95
+ /* Now check the parsing result*/
96
+ if (status == -1 || !ctxt->wellFormed)
97
+ {
98
+ rxml_raise(&ctxt->lastError);
99
+ }
100
+ return Qtrue;
101
+ }
102
+
103
+ void rxml_init_sax_parser(void)
104
+ {
105
+ /* SaxParser */
106
+ cXMLSaxParser = rb_define_class_under(mXML, "SaxParser", rb_cObject);
107
+
108
+ /* Atributes */
109
+ CALLBACKS_ATTR = rb_intern("@callbacks");
110
+ CONTEXT_ATTR = rb_intern("@context");
111
+ rb_define_attr(cXMLSaxParser, "callbacks", 1, 1);
112
+
113
+ /* Instance Methods */
114
+ rb_define_method(cXMLSaxParser, "initialize", rxml_sax_parser_initialize, -1);
115
+ rb_define_method(cXMLSaxParser, "parse", rxml_sax_parser_parse, 0);
116
+ }