libxml-ruby 5.0.3 → 5.0.5

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +13 -2
  3. data/README.rdoc +1 -1
  4. data/ext/libxml/extconf.rb +5 -0
  5. data/ext/libxml/ruby_xml.c +556 -556
  6. data/ext/libxml/ruby_xml_attributes.h +17 -17
  7. data/ext/libxml/ruby_xml_document.c +1129 -1129
  8. data/ext/libxml/ruby_xml_dtd.c +257 -257
  9. data/ext/libxml/ruby_xml_encoding.c +250 -250
  10. data/ext/libxml/ruby_xml_error.c +1003 -1003
  11. data/ext/libxml/ruby_xml_error.h +14 -14
  12. data/ext/libxml/ruby_xml_html_parser_context.c +351 -351
  13. data/ext/libxml/ruby_xml_input_cbg.c +188 -188
  14. data/ext/libxml/ruby_xml_namespace.c +151 -151
  15. data/ext/libxml/ruby_xml_parser.h +10 -10
  16. data/ext/libxml/ruby_xml_parser_context.c +1009 -1009
  17. data/ext/libxml/ruby_xml_parser_options.c +74 -74
  18. data/ext/libxml/ruby_xml_parser_options.h +10 -10
  19. data/ext/libxml/ruby_xml_sax2_handler.c +326 -326
  20. data/ext/libxml/ruby_xml_sax_parser.c +108 -108
  21. data/ext/libxml/ruby_xml_version.h +9 -9
  22. data/ext/libxml/ruby_xml_writer.c +1124 -1138
  23. data/lib/libxml/attr.rb +122 -122
  24. data/lib/libxml/attr_decl.rb +80 -80
  25. data/lib/libxml/attributes.rb +13 -13
  26. data/lib/libxml/document.rb +194 -194
  27. data/lib/libxml/error.rb +95 -95
  28. data/lib/libxml/hpricot.rb +77 -77
  29. data/lib/libxml/html_parser.rb +96 -96
  30. data/lib/libxml/namespace.rb +61 -61
  31. data/lib/libxml/namespaces.rb +37 -37
  32. data/lib/libxml/node.rb +323 -323
  33. data/lib/libxml/parser.rb +102 -102
  34. data/lib/libxml/sax_callbacks.rb +179 -179
  35. data/lib/libxml/sax_parser.rb +40 -40
  36. data/lib/libxml/tree.rb +28 -28
  37. data/lib/libxml.rb +4 -4
  38. data/lib/xml/libxml.rb +10 -10
  39. data/lib/xml.rb +13 -13
  40. data/libxml-ruby.gemspec +50 -48
  41. data/test/test_document.rb +140 -140
  42. data/test/test_document_write.rb +142 -142
  43. data/test/test_dtd.rb +126 -126
  44. data/test/test_encoding.rb +126 -126
  45. data/test/test_error.rb +194 -194
  46. data/test/test_helper.rb +20 -20
  47. data/test/test_namespace.rb +58 -58
  48. data/test/test_node.rb +235 -235
  49. data/test/test_node_write.rb +93 -93
  50. data/test/test_parser.rb +333 -333
  51. data/test/test_reader.rb +364 -364
  52. data/test/test_sax_parser.rb +25 -6
  53. data/test/test_xml.rb +168 -168
  54. metadata +19 -8
@@ -1,108 +1,108 @@
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
- VALUE context = rb_ivar_get(self, CONTEXT_ATTR);
78
- xmlParserCtxtPtr ctxt;
79
- Data_Get_Struct(context, xmlParserCtxt, ctxt);
80
-
81
- ctxt->sax2 = 1;
82
- ctxt->userData = (void*)rb_ivar_get(self, CALLBACKS_ATTR);
83
- memcpy(ctxt->sax, &rxml_sax_handler, sizeof(rxml_sax_handler));
84
-
85
- int status = xmlParseDocument(ctxt);
86
-
87
- /* Now check the parsing result*/
88
- if (status == -1 || !ctxt->wellFormed)
89
- {
90
- rxml_raise(&ctxt->lastError);
91
- }
92
- return Qtrue;
93
- }
94
-
95
- void rxml_init_sax_parser(void)
96
- {
97
- /* SaxParser */
98
- cXMLSaxParser = rb_define_class_under(mXML, "SaxParser", rb_cObject);
99
-
100
- /* Atributes */
101
- CALLBACKS_ATTR = rb_intern("@callbacks");
102
- CONTEXT_ATTR = rb_intern("@context");
103
- rb_define_attr(cXMLSaxParser, "callbacks", 1, 1);
104
-
105
- /* Instance Methods */
106
- rb_define_method(cXMLSaxParser, "initialize", rxml_sax_parser_initialize, -1);
107
- rb_define_method(cXMLSaxParser, "parse", rxml_sax_parser_parse, 0);
108
- }
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
+ VALUE context = rb_ivar_get(self, CONTEXT_ATTR);
78
+ xmlParserCtxtPtr ctxt;
79
+ Data_Get_Struct(context, xmlParserCtxt, ctxt);
80
+
81
+ ctxt->sax2 = 1;
82
+ ctxt->userData = (void*)rb_ivar_get(self, CALLBACKS_ATTR);
83
+ memcpy(ctxt->sax, &rxml_sax_handler, sizeof(rxml_sax_handler));
84
+
85
+ int status = xmlParseDocument(ctxt);
86
+
87
+ /* Now check the parsing result*/
88
+ if (status == -1 || !ctxt->wellFormed)
89
+ {
90
+ rxml_raise(&ctxt->lastError);
91
+ }
92
+ return Qtrue;
93
+ }
94
+
95
+ void rxml_init_sax_parser(void)
96
+ {
97
+ /* SaxParser */
98
+ cXMLSaxParser = rb_define_class_under(mXML, "SaxParser", rb_cObject);
99
+
100
+ /* Atributes */
101
+ CALLBACKS_ATTR = rb_intern("@callbacks");
102
+ CONTEXT_ATTR = rb_intern("@context");
103
+ rb_define_attr(cXMLSaxParser, "callbacks", 1, 1);
104
+
105
+ /* Instance Methods */
106
+ rb_define_method(cXMLSaxParser, "initialize", rxml_sax_parser_initialize, -1);
107
+ rb_define_method(cXMLSaxParser, "parse", rxml_sax_parser_parse, 0);
108
+ }
@@ -1,9 +1,9 @@
1
- /* Don't nuke this block! It is used for automatically updating the
2
- * versions below. VERSION = string formatting, VERNUM = numbered
3
- * version for inline testing: increment both or none at all.*/
4
- #define RUBY_LIBXML_VERSION "5.0.3"
5
- #define RUBY_LIBXML_VERNUM 503
6
- #define RUBY_LIBXML_VER_MAJ 5
7
- #define RUBY_LIBXML_VER_MIN 0
8
- #define RUBY_LIBXML_VER_MIC 3
9
- #define RUBY_LIBXML_VER_PATCH 0
1
+ /* Don't nuke this block! It is used for automatically updating the
2
+ * versions below. VERSION = string formatting, VERNUM = numbered
3
+ * version for inline testing: increment both or none at all.*/
4
+ #define RUBY_LIBXML_VERSION "5.0.5"
5
+ #define RUBY_LIBXML_VERNUM 505
6
+ #define RUBY_LIBXML_VER_MAJ 5
7
+ #define RUBY_LIBXML_VER_MIN 0
8
+ #define RUBY_LIBXML_VER_MIC 5
9
+ #define RUBY_LIBXML_VER_PATCH 0