libxml-ruby 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/CHANGES +13 -0
  2. data/ext/libxml/libxml.c +885 -886
  3. data/ext/libxml/ruby_libxml.h +70 -72
  4. data/ext/libxml/ruby_xml_attr.c +76 -76
  5. data/ext/libxml/ruby_xml_attr.h +8 -8
  6. data/ext/libxml/ruby_xml_attributes.c +36 -36
  7. data/ext/libxml/ruby_xml_attributes.h +6 -6
  8. data/ext/libxml/ruby_xml_document.c +133 -220
  9. data/ext/libxml/ruby_xml_document.h +4 -7
  10. data/ext/libxml/ruby_xml_dtd.c +30 -109
  11. data/ext/libxml/ruby_xml_dtd.h +2 -11
  12. data/ext/libxml/ruby_xml_error.c +10 -10
  13. data/ext/libxml/ruby_xml_error.h +4 -4
  14. data/ext/libxml/ruby_xml_html_parser.c +28 -40
  15. data/ext/libxml/ruby_xml_html_parser.h +4 -4
  16. data/ext/libxml/ruby_xml_input.c +208 -32
  17. data/ext/libxml/ruby_xml_input.h +7 -5
  18. data/ext/libxml/ruby_xml_input_cbg.c +3 -3
  19. data/ext/libxml/ruby_xml_node.c +217 -217
  20. data/ext/libxml/ruby_xml_node.h +5 -5
  21. data/ext/libxml/ruby_xml_ns.c +26 -26
  22. data/ext/libxml/ruby_xml_ns.h +4 -4
  23. data/ext/libxml/ruby_xml_parser.c +151 -164
  24. data/ext/libxml/ruby_xml_parser.h +3 -8
  25. data/ext/libxml/ruby_xml_parser_context.c +105 -105
  26. data/ext/libxml/ruby_xml_parser_context.h +4 -4
  27. data/ext/libxml/ruby_xml_reader.c +145 -162
  28. data/ext/libxml/ruby_xml_reader.h +4 -4
  29. data/ext/libxml/ruby_xml_relaxng.c +30 -43
  30. data/ext/libxml/ruby_xml_relaxng.h +2 -7
  31. data/ext/libxml/ruby_xml_sax_parser.c +174 -228
  32. data/ext/libxml/ruby_xml_sax_parser.h +12 -20
  33. data/ext/libxml/ruby_xml_schema.c +31 -44
  34. data/ext/libxml/ruby_xml_schema.h +2 -7
  35. data/ext/libxml/ruby_xml_state.c +6 -6
  36. data/ext/libxml/ruby_xml_state.h +2 -2
  37. data/ext/libxml/ruby_xml_xinclude.c +1 -1
  38. data/ext/libxml/ruby_xml_xinclude.h +3 -3
  39. data/ext/libxml/ruby_xml_xpath.c +1 -1
  40. data/ext/libxml/ruby_xml_xpath.h +3 -12
  41. data/ext/libxml/ruby_xml_xpath_context.c +293 -294
  42. data/ext/libxml/ruby_xml_xpath_context.h +3 -7
  43. data/ext/libxml/ruby_xml_xpath_expression.c +11 -11
  44. data/ext/libxml/ruby_xml_xpath_expression.h +2 -2
  45. data/ext/libxml/ruby_xml_xpath_object.c +52 -66
  46. data/ext/libxml/ruby_xml_xpath_object.h +3 -14
  47. data/ext/libxml/ruby_xml_xpointer.c +11 -12
  48. data/ext/libxml/ruby_xml_xpointer.h +5 -7
  49. data/ext/libxml/sax_parser_callbacks.inc +53 -36
  50. data/ext/libxml/version.h +2 -2
  51. data/ext/vc/libxml_ruby.vcproj +1 -9
  52. data/lib/libxml/html_parser.rb +5 -5
  53. data/lib/libxml/parser.rb +4 -4
  54. data/lib/libxml/sax_parser.rb +24 -0
  55. data/test/tc_document_write.rb +2 -16
  56. data/test/tc_html_parser.rb +57 -5
  57. data/test/tc_input.rb +13 -0
  58. data/test/tc_parser.rb +11 -3
  59. data/test/tc_reader.rb +53 -34
  60. data/test/tc_sax_parser.rb +30 -8
  61. data/test/test.rb +8 -0
  62. data/test/test_suite.rb +1 -1
  63. metadata +5 -6
  64. data/ext/libxml/ruby_xml_encoding.c +0 -164
  65. data/ext/libxml/ruby_xml_encoding.h +0 -13
  66. data/test/tc_encoding.rb +0 -13
@@ -1,14 +1,14 @@
1
- /* $Id: ruby_xml_node.h 553 2008-11-18 02:34:38Z cfis $ */
1
+ /* $Id: ruby_xml_node.h 612 2008-11-21 08:01:29Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
5
- #ifndef __RUBY_XML_NODE__
6
- #define __RUBY_XML_NODE__
5
+ #ifndef __rxml_NODE__
6
+ #define __rxml_NODE__
7
7
 
8
8
  extern VALUE cXMLNode;
9
9
 
10
10
  void ruby_init_xml_node(void);
11
- void ruby_xml_node_mark_common(xmlNodePtr xnode);
12
- VALUE ruby_xml_node2_wrap(VALUE class, xmlNodePtr xnode);
11
+ void rxml_node_mark_common(xmlNodePtr xnode);
12
+ VALUE rxml_node2_wrap(VALUE class, xmlNodePtr xnode);
13
13
  VALUE check_string_or_symbol(VALUE val);
14
14
  #endif
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_ns.c 553 2008-11-18 02:34:38Z cfis $ */
1
+ /* $Id: ruby_xml_ns.c 614 2008-11-22 08:04:39Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -16,9 +16,9 @@ VALUE cXMLNS;
16
16
  * with an node. */
17
17
 
18
18
 
19
- VALUE
20
- ruby_xml_ns_alloc(VALUE klass) {
21
- return Data_Wrap_Struct(cXMLNS, NULL, NULL, NULL);
19
+ static VALUE
20
+ rxml_ns_alloc(VALUE klass) {
21
+ return Data_Wrap_Struct(klass, NULL, NULL, NULL);
22
22
  }
23
23
 
24
24
  /*
@@ -30,8 +30,8 @@ ruby_xml_ns_alloc(VALUE klass) {
30
30
  *
31
31
  * XML::NS.new(node, "xlink", "http://www.w3.org/1999/xlink")
32
32
  */
33
- VALUE
34
- ruby_xml_ns_initialize(VALUE self, VALUE node, VALUE href, VALUE prefix) {
33
+ static VALUE
34
+ rxml_ns_initialize(VALUE self, VALUE node, VALUE href, VALUE prefix) {
35
35
  xmlNodePtr xnode;
36
36
  xmlChar *xmlPrefix;
37
37
  xmlNsPtr xns;
@@ -46,7 +46,7 @@ ruby_xml_ns_initialize(VALUE self, VALUE node, VALUE href, VALUE prefix) {
46
46
  }
47
47
 
48
48
  VALUE
49
- ruby_xml_ns_wrap(xmlNsPtr xns) {
49
+ rxml_ns_wrap(xmlNsPtr xns) {
50
50
  return(Data_Wrap_Struct(cXMLNS, NULL, NULL, xns));
51
51
  }
52
52
 
@@ -57,8 +57,8 @@ ruby_xml_ns_wrap(xmlNsPtr xns) {
57
57
  *
58
58
  * Obtain the namespace's href.
59
59
  */
60
- VALUE
61
- ruby_xml_ns_href_get(VALUE self) {
60
+ static VALUE
61
+ rxml_ns_href_get(VALUE self) {
62
62
  xmlNsPtr xns;
63
63
  Data_Get_Struct(self, xmlNs, xns);
64
64
  if (xns == NULL || xns->href == NULL)
@@ -74,8 +74,8 @@ ruby_xml_ns_href_get(VALUE self) {
74
74
  *
75
75
  * Determine whether this namespace has an href.
76
76
  */
77
- VALUE
78
- ruby_xml_ns_href_q(VALUE self) {
77
+ static VALUE
78
+ rxml_ns_href_q(VALUE self) {
79
79
  xmlNsPtr xns;
80
80
  Data_Get_Struct(self, xmlNs, xns);
81
81
  if (xns == NULL || xns->href == NULL)
@@ -91,14 +91,14 @@ ruby_xml_ns_href_q(VALUE self) {
91
91
  *
92
92
  * Obtain the next namespace.
93
93
  */
94
- VALUE
95
- ruby_xml_ns_next(VALUE self) {
94
+ static VALUE
95
+ rxml_ns_next(VALUE self) {
96
96
  xmlNsPtr xns;
97
97
  Data_Get_Struct(self, xmlNs, xns);
98
98
  if (xns == NULL || xns->next == NULL)
99
99
  return(Qnil);
100
100
  else
101
- return(ruby_xml_ns_wrap(xns->next));
101
+ return(rxml_ns_wrap(xns->next));
102
102
  }
103
103
 
104
104
 
@@ -109,8 +109,8 @@ ruby_xml_ns_next(VALUE self) {
109
109
  *
110
110
  * Obtain the namespace's prefix.
111
111
  */
112
- VALUE
113
- ruby_xml_ns_prefix_get(VALUE self) {
112
+ static VALUE
113
+ rxml_ns_prefix_get(VALUE self) {
114
114
  xmlNsPtr xns;
115
115
  Data_Get_Struct(self, xmlNs, xns);
116
116
  if (xns == NULL || xns->prefix == NULL)
@@ -126,8 +126,8 @@ ruby_xml_ns_prefix_get(VALUE self) {
126
126
  *
127
127
  * Determine whether this namespace has a prefix.
128
128
  */
129
- VALUE
130
- ruby_xml_ns_prefix_q(VALUE self) {
129
+ static VALUE
130
+ rxml_ns_prefix_q(VALUE self) {
131
131
  xmlNsPtr xns;
132
132
  Data_Get_Struct(self, xmlNs, xns);
133
133
  if (xns == NULL || xns->prefix == NULL)
@@ -145,12 +145,12 @@ ruby_xml_ns_prefix_q(VALUE self) {
145
145
  void
146
146
  ruby_init_xml_ns(void) {
147
147
  cXMLNS = rb_define_class_under(mXML, "NS", rb_cObject);
148
- rb_define_alloc_func(cXMLNS, ruby_xml_ns_alloc);
149
- rb_define_method(cXMLNS, "initialize", ruby_xml_ns_initialize, 3);
150
- rb_define_method(cXMLNS, "href", ruby_xml_ns_href_get, 0);
151
- rb_define_method(cXMLNS, "href?", ruby_xml_ns_href_q, 0);
152
- rb_define_method(cXMLNS, "next", ruby_xml_ns_next, 0);
153
- rb_define_method(cXMLNS, "prefix", ruby_xml_ns_prefix_get, 0);
154
- rb_define_method(cXMLNS, "prefix?", ruby_xml_ns_prefix_q, 0);
155
- rb_define_method(cXMLNS, "to_s", ruby_xml_ns_prefix_get, 0);
148
+ rb_define_alloc_func(cXMLNS, rxml_ns_alloc);
149
+ rb_define_method(cXMLNS, "initialize", rxml_ns_initialize, 3);
150
+ rb_define_method(cXMLNS, "href", rxml_ns_href_get, 0);
151
+ rb_define_method(cXMLNS, "href?", rxml_ns_href_q, 0);
152
+ rb_define_method(cXMLNS, "next", rxml_ns_next, 0);
153
+ rb_define_method(cXMLNS, "prefix", rxml_ns_prefix_get, 0);
154
+ rb_define_method(cXMLNS, "prefix?", rxml_ns_prefix_q, 0);
155
+ rb_define_method(cXMLNS, "to_s", rxml_ns_prefix_get, 0);
156
156
  }
@@ -1,12 +1,12 @@
1
- /* $Id: ruby_xml_ns.h 324 2008-07-08 23:00:02Z cfis $ */
1
+ /* $Id: ruby_xml_ns.h 612 2008-11-21 08:01:29Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
5
- #ifndef __RUBY_XML_NS__
6
- #define __RUBY_XML_NS__
5
+ #ifndef __rxml_NS__
6
+ #define __rxml_NS__
7
7
 
8
8
  extern VALUE cXMLNS;
9
9
 
10
10
  void ruby_init_xml_ns(void);
11
- VALUE ruby_xml_ns_wrap(xmlNsPtr ns);
11
+ VALUE rxml_ns_wrap(xmlNsPtr ns);
12
12
  #endif
@@ -1,164 +1,151 @@
1
- /* $Id: ruby_xml_parser.c 604 2008-11-19 18:01:55Z cfis $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
4
-
5
- #include <stdarg.h>
6
- #include "ruby_libxml.h"
7
-
8
- VALUE cXMLParser;
9
- static ID INPUT_ATTR;
10
- static ID CONTEXT_ATTR;
11
-
12
- /*
13
- * Document-class: LibXML::XML::Parser
14
- *
15
- * The XML::Parser provides a tree based API for processing
16
- * xml documents, in contract to XML::Reader's stream
17
- * based api and XML::SaxParser callback based API.
18
- *
19
- * As a result, parsing a document creates an in-memory document object
20
- * that consist of any number of XML::Node instances. This is simple
21
- * and powerful model, but has the major limitation that the size of
22
- * the document that can be processed is limited by the amount of
23
- * memory available. In such cases, it is better to use the XML::Reader.
24
- *
25
- * Using the parser is simple:
26
- *
27
- * parser = XML::Parser.new
28
- * parser.file = 'my_file'
29
- * doc = parser.parse
30
- *
31
- * You can also parse strings (see XML::Parser.string) and io objects (see
32
- * XML::Parser.io).
33
- */
34
-
35
- static int
36
- ctxtRead(FILE *f, char * buf, size_t len) {
37
- return(rb_io_fread(buf, len, f));
38
- }
39
-
40
-
41
- /*
42
- * call-seq:
43
- * parser.initialize -> parser
44
- *
45
- * Initiliazes instance of parser.
46
- */
47
- VALUE
48
- ruby_xml_parser_initialize(VALUE self) {
49
- VALUE input = rb_class_new_instance(0, NULL, cXMLInput);
50
- rb_iv_set(self, "@input", input);
51
- rb_iv_set(self, "@context", Qnil);
52
- return self;
53
- }
54
-
55
-
56
- xmlParserCtxtPtr
57
- ruby_xml_parser_filename_ctxt(VALUE input) {
58
- xmlParserCtxtPtr ctxt;
59
- int retry_count = 0;
60
- VALUE filename = rb_ivar_get(input, FILE_ATTR);
61
-
62
- retry:
63
- ctxt = xmlCreateFileParserCtxt(StringValuePtr(filename));
64
- if (ctxt == NULL) {
65
- if ((errno == EMFILE || errno == ENFILE) && retry_count == 0) {
66
- retry_count++;
67
- rb_gc();
68
- goto retry;
69
- } else {
70
- rb_raise(rb_eIOError, StringValuePtr(filename));
71
- }
72
- }
73
-
74
- return ctxt;
75
- }
76
-
77
- xmlParserCtxtPtr
78
- ruby_xml_parser_str_ctxt(VALUE input) {
79
- VALUE str = rb_ivar_get(input, STRING_ATTR);
80
- return xmlCreateMemoryParserCtxt(StringValuePtr(str), RSTRING_LEN(str));
81
- }
82
-
83
- xmlParserCtxtPtr
84
- ruby_xml_parser_io_ctxt(VALUE input) {
85
- VALUE io = rb_ivar_get(input, IO_ATTR);
86
- VALUE encoding = rb_ivar_get(input, ENCODING_ATTR);
87
- xmlCharEncoding xmlEncoding = NUM2INT(encoding);
88
- OpenFile *fptr;
89
- FILE *f;
90
-
91
- GetOpenFile(io, fptr);
92
- rb_io_check_readable(fptr);
93
- f = GetReadFile(fptr);
94
-
95
- return xmlCreateIOParserCtxt(NULL, NULL,
96
- (xmlInputReadCallback) ctxtRead,
97
- NULL, f, xmlEncoding);
98
- }
99
-
100
-
101
- /*
102
- * call-seq:
103
- * parser.parse -> document
104
- *
105
- * Parse the input XML and create an XML::Document with
106
- * it's content. If an error occurs, XML::Parser::ParseError
107
- * is thrown.
108
- */
109
- VALUE
110
- ruby_xml_parser_parse(VALUE self) {
111
- xmlParserCtxtPtr ctxt;
112
- VALUE context;
113
- VALUE input = rb_ivar_get(self, INPUT_ATTR);
114
-
115
- context = rb_ivar_get(self, CONTEXT_ATTR);
116
- if (context != Qnil)
117
- rb_raise(rb_eRuntimeError, "You cannot parse a data source twice");
118
-
119
- if (rb_ivar_get(input, FILE_ATTR) != Qnil)
120
- ctxt = ruby_xml_parser_filename_ctxt(input);
121
- else if (rb_ivar_get(input, STRING_ATTR) != Qnil)
122
- ctxt = ruby_xml_parser_str_ctxt(input);
123
- /*else if (rb_ivar_get(input, DOCUMENT_ATTR) != Qnil)
124
- ctxt = ruby_xml_parser_parse_document(input);*/
125
- else if (rb_ivar_get(input, IO_ATTR) != Qnil)
126
- ctxt = ruby_xml_parser_io_ctxt(input);
127
- else
128
- rb_raise(rb_eArgError, "You must specify a parser data source");
129
-
130
- if (!ctxt)
131
- ruby_xml_raise(&xmlLastError);
132
-
133
- context = ruby_xml_parser_context_wrap(ctxt);
134
- rb_ivar_set(self, CONTEXT_ATTR, context);
135
-
136
- if (xmlParseDocument(ctxt) == -1 || !ctxt->wellFormed) {
137
- xmlFreeDoc(ctxt->myDoc);
138
- ruby_xml_raise(&ctxt->lastError);
139
- }
140
-
141
- return ruby_xml_document_wrap(ctxt->myDoc);
142
- }
143
-
144
-
145
- // Rdoc needs to know
146
- #ifdef RDOC_NEVER_DEFINED
147
- mLibXML = rb_define_module("LibXML");
148
- mXML = rb_define_module_under(mLibXML, "XML");
149
- #endif
150
-
151
- void
152
- ruby_init_parser(void) {
153
- cXMLParser = rb_define_class_under(mXML, "Parser", rb_cObject);
154
-
155
- /* Atributes */
156
- INPUT_ATTR = rb_intern("@input");
157
- CONTEXT_ATTR = rb_intern("@context");
158
- rb_define_attr(cXMLParser, "input", 1, 0);
159
- rb_define_attr(cXMLParser, "context", 1, 0);
160
-
161
- /* Instance Methods */
162
- rb_define_method(cXMLParser, "initialize", ruby_xml_parser_initialize, 0);
163
- rb_define_method(cXMLParser, "parse", ruby_xml_parser_parse, 0);
164
- }
1
+ /* $Id: ruby_xml_parser.c 613 2008-11-21 08:39:51Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include <stdarg.h>
6
+ #include "ruby_libxml.h"
7
+
8
+ VALUE cXMLParser;
9
+ static ID INPUT_ATTR;
10
+ static ID CONTEXT_ATTR;
11
+
12
+ /*
13
+ * Document-class: LibXML::XML::Parser
14
+ *
15
+ * The XML::Parser provides a tree based API for processing
16
+ * xml documents, in contract to XML::Reader's stream
17
+ * based api and XML::SaxParser callback based API.
18
+ *
19
+ * As a result, parsing a document creates an in-memory document object
20
+ * that consist of any number of XML::Node instances. This is simple
21
+ * and powerful model, but has the major limitation that the size of
22
+ * the document that can be processed is limited by the amount of
23
+ * memory available. In such cases, it is better to use the XML::Reader.
24
+ *
25
+ * Using the parser is simple:
26
+ *
27
+ * parser = XML::Parser.new
28
+ * parser.file = 'my_file'
29
+ * doc = parser.parse
30
+ *
31
+ * You can also parse strings (see XML::Parser.string) and io objects (see
32
+ * XML::Parser.io).
33
+ */
34
+
35
+ /*
36
+ * call-seq:
37
+ * parser.initialize -> parser
38
+ *
39
+ * Initiliazes instance of parser.
40
+ */
41
+ static VALUE
42
+ rxml_parser_initialize(VALUE self) {
43
+ VALUE input = rb_class_new_instance(0, NULL, cXMLInput);
44
+ rb_iv_set(self, "@input", input);
45
+ rb_iv_set(self, "@context", Qnil);
46
+ return self;
47
+ }
48
+
49
+ static xmlParserCtxtPtr
50
+ rxml_parser_filename_ctxt(VALUE input) {
51
+ xmlParserCtxtPtr ctxt;
52
+ int retry_count = 0;
53
+ VALUE filename = rb_ivar_get(input, FILE_ATTR);
54
+
55
+ retry:
56
+ ctxt = xmlCreateFileParserCtxt(StringValuePtr(filename));
57
+ if (ctxt == NULL) {
58
+ if ((errno == EMFILE || errno == ENFILE) && retry_count == 0) {
59
+ retry_count++;
60
+ rb_gc();
61
+ goto retry;
62
+ } else {
63
+ rb_raise(rb_eIOError, StringValuePtr(filename));
64
+ }
65
+ }
66
+
67
+ return ctxt;
68
+ }
69
+
70
+ static xmlParserCtxtPtr
71
+ rxml_parser_str_ctxt(VALUE input) {
72
+ VALUE str = rb_ivar_get(input, STRING_ATTR);
73
+ return xmlCreateMemoryParserCtxt(StringValuePtr(str), RSTRING_LEN(str));
74
+ }
75
+
76
+ static xmlParserCtxtPtr
77
+ rxml_parser_io_ctxt(VALUE input) {
78
+ VALUE io = rb_ivar_get(input, IO_ATTR);
79
+ VALUE encoding = rb_ivar_get(input, ENCODING_ATTR);
80
+ xmlCharEncoding xmlEncoding = NUM2INT(encoding);
81
+
82
+ return xmlCreateIOParserCtxt(NULL, NULL,
83
+ (xmlInputReadCallback) rxml_read_callback,
84
+ NULL, io, xmlEncoding);
85
+ }
86
+
87
+
88
+ /*
89
+ * call-seq:
90
+ * parser.parse -> document
91
+ *
92
+ * Parse the input XML and create an XML::Document with
93
+ * it's content. If an error occurs, XML::Parser::ParseError
94
+ * is thrown.
95
+ */
96
+ static VALUE
97
+ rxml_parser_parse(VALUE self) {
98
+ xmlParserCtxtPtr ctxt;
99
+ VALUE context;
100
+ VALUE input = rb_ivar_get(self, INPUT_ATTR);
101
+
102
+ context = rb_ivar_get(self, CONTEXT_ATTR);
103
+ if (context != Qnil)
104
+ rb_raise(rb_eRuntimeError, "You cannot parse a data source twice");
105
+
106
+ if (rb_ivar_get(input, FILE_ATTR) != Qnil)
107
+ ctxt = rxml_parser_filename_ctxt(input);
108
+ else if (rb_ivar_get(input, STRING_ATTR) != Qnil)
109
+ ctxt = rxml_parser_str_ctxt(input);
110
+ /*else if (rb_ivar_get(input, DOCUMENT_ATTR) != Qnil)
111
+ ctxt = rxml_parser_parse_document(input);*/
112
+ else if (rb_ivar_get(input, IO_ATTR) != Qnil)
113
+ ctxt = rxml_parser_io_ctxt(input);
114
+ else
115
+ rb_raise(rb_eArgError, "You must specify a parser data source");
116
+
117
+ if (!ctxt)
118
+ rxml_raise(&xmlLastError);
119
+
120
+ context = rxml_parser_context_wrap(ctxt);
121
+ rb_ivar_set(self, CONTEXT_ATTR, context);
122
+
123
+ if (xmlParseDocument(ctxt) == -1 || !ctxt->wellFormed) {
124
+ xmlFreeDoc(ctxt->myDoc);
125
+ rxml_raise(&ctxt->lastError);
126
+ }
127
+
128
+ return rxml_document_wrap(ctxt->myDoc);
129
+ }
130
+
131
+
132
+ // Rdoc needs to know
133
+ #ifdef RDOC_NEVER_DEFINED
134
+ mLibXML = rb_define_module("LibXML");
135
+ mXML = rb_define_module_under(mLibXML, "XML");
136
+ #endif
137
+
138
+ void
139
+ ruby_init_parser(void) {
140
+ cXMLParser = rb_define_class_under(mXML, "Parser", rb_cObject);
141
+
142
+ /* Atributes */
143
+ INPUT_ATTR = rb_intern("@input");
144
+ CONTEXT_ATTR = rb_intern("@context");
145
+ rb_define_attr(cXMLParser, "input", 1, 0);
146
+ rb_define_attr(cXMLParser, "context", 1, 0);
147
+
148
+ /* Instance Methods */
149
+ rb_define_method(cXMLParser, "initialize", rxml_parser_initialize, 0);
150
+ rb_define_method(cXMLParser, "parse", rxml_parser_parse, 0);
151
+ }