libxml-ruby 5.0.4 → 5.0.6

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 (97) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +17 -6
  3. data/README.rdoc +1 -1
  4. data/Rakefile +98 -98
  5. data/ext/libxml/extconf.h +1 -0
  6. data/ext/libxml/extconf.rb +5 -0
  7. data/ext/libxml/libxml.c +79 -79
  8. data/ext/libxml/ruby_xml.c +556 -556
  9. data/ext/libxml/ruby_xml_attr.c +333 -333
  10. data/ext/libxml/ruby_xml_attr.h +12 -12
  11. data/ext/libxml/ruby_xml_attr_decl.h +11 -11
  12. data/ext/libxml/ruby_xml_attributes.h +17 -17
  13. data/ext/libxml/ruby_xml_cbg.c +85 -85
  14. data/ext/libxml/ruby_xml_document.c +1129 -1129
  15. data/ext/libxml/ruby_xml_dtd.c +257 -257
  16. data/ext/libxml/ruby_xml_dtd.h +9 -9
  17. data/ext/libxml/ruby_xml_encoding.c +250 -250
  18. data/ext/libxml/ruby_xml_error.c +1003 -1003
  19. data/ext/libxml/ruby_xml_error.h +14 -14
  20. data/ext/libxml/ruby_xml_html_parser.c +91 -91
  21. data/ext/libxml/ruby_xml_html_parser.h +10 -10
  22. data/ext/libxml/ruby_xml_html_parser_context.c +351 -351
  23. data/ext/libxml/ruby_xml_html_parser_context.h +10 -10
  24. data/ext/libxml/ruby_xml_html_parser_options.c +48 -48
  25. data/ext/libxml/ruby_xml_html_parser_options.h +10 -10
  26. data/ext/libxml/ruby_xml_input_cbg.c +188 -188
  27. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  28. data/ext/libxml/ruby_xml_io.c +47 -47
  29. data/ext/libxml/ruby_xml_io.h +10 -10
  30. data/ext/libxml/ruby_xml_namespace.c +151 -151
  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.h +13 -13
  35. data/ext/libxml/ruby_xml_parser.c +91 -91
  36. data/ext/libxml/ruby_xml_parser.h +10 -10
  37. data/ext/libxml/ruby_xml_parser_context.c +1009 -1009
  38. data/ext/libxml/ruby_xml_parser_context.h +10 -10
  39. data/ext/libxml/ruby_xml_parser_options.c +74 -74
  40. data/ext/libxml/ruby_xml_parser_options.h +10 -10
  41. data/ext/libxml/ruby_xml_reader.h +14 -14
  42. data/ext/libxml/ruby_xml_relaxng.h +8 -8
  43. data/ext/libxml/ruby_xml_sax2_handler.c +326 -326
  44. data/ext/libxml/ruby_xml_sax2_handler.h +10 -10
  45. data/ext/libxml/ruby_xml_sax_parser.c +108 -108
  46. data/ext/libxml/ruby_xml_sax_parser.h +10 -10
  47. data/ext/libxml/ruby_xml_schema.h +25 -25
  48. data/ext/libxml/ruby_xml_schema_attribute.h +37 -37
  49. data/ext/libxml/ruby_xml_schema_element.h +11 -11
  50. data/ext/libxml/ruby_xml_schema_facet.c +50 -50
  51. data/ext/libxml/ruby_xml_schema_facet.h +9 -9
  52. data/ext/libxml/ruby_xml_schema_type.h +9 -9
  53. data/ext/libxml/ruby_xml_version.h +9 -9
  54. data/ext/libxml/ruby_xml_writer.c +1124 -1124
  55. data/ext/libxml/ruby_xml_writer.h +6 -6
  56. data/ext/libxml/ruby_xml_xinclude.c +20 -20
  57. data/ext/libxml/ruby_xml_xinclude.h +11 -11
  58. data/ext/libxml/ruby_xml_xpath.c +195 -195
  59. data/ext/libxml/ruby_xml_xpath.h +15 -15
  60. data/ext/libxml/ruby_xml_xpath_context.c +362 -362
  61. data/ext/libxml/ruby_xml_xpath_context.h +9 -9
  62. data/ext/libxml/ruby_xml_xpath_expression.h +10 -10
  63. data/ext/libxml/ruby_xml_xpath_object.h +17 -17
  64. data/lib/libxml/attr.rb +122 -122
  65. data/lib/libxml/attr_decl.rb +80 -80
  66. data/lib/libxml/attributes.rb +13 -13
  67. data/lib/libxml/document.rb +194 -194
  68. data/lib/libxml/error.rb +95 -95
  69. data/lib/libxml/hpricot.rb +77 -77
  70. data/lib/libxml/html_parser.rb +96 -96
  71. data/lib/libxml/namespace.rb +61 -61
  72. data/lib/libxml/namespaces.rb +37 -37
  73. data/lib/libxml/node.rb +323 -323
  74. data/lib/libxml/parser.rb +102 -102
  75. data/lib/libxml/sax_callbacks.rb +179 -179
  76. data/lib/libxml/sax_parser.rb +40 -40
  77. data/lib/libxml/tree.rb +28 -28
  78. data/lib/libxml-ruby.rb +2 -2
  79. data/lib/libxml.rb +4 -4
  80. data/lib/xml/libxml.rb +10 -10
  81. data/lib/xml.rb +13 -13
  82. data/libxml-ruby.gemspec +50 -49
  83. data/test/test_document.rb +140 -140
  84. data/test/test_document_write.rb +142 -142
  85. data/test/test_dtd.rb +126 -126
  86. data/test/test_encoding.rb +126 -126
  87. data/test/test_error.rb +197 -194
  88. data/test/test_helper.rb +21 -20
  89. data/test/test_namespace.rb +58 -58
  90. data/test/test_node.rb +235 -235
  91. data/test/test_node_write.rb +93 -93
  92. data/test/test_parser.rb +333 -333
  93. data/test/test_reader.rb +364 -364
  94. data/test/test_writer.rb +500 -468
  95. data/test/test_xml.rb +168 -168
  96. metadata +5 -5
  97. data/test/test.rb +0 -5
@@ -1,257 +1,257 @@
1
- #include "ruby_libxml.h"
2
- #include "ruby_xml_dtd.h"
3
-
4
- /*
5
- * Document-class: LibXML::XML::Dtd
6
- *
7
- * The XML::Dtd class is used to prepare DTD's for validation of xml
8
- * documents.
9
- *
10
- * DTDs can be created from a string or a pair of public and system identifiers.
11
- * Once a Dtd object is instantiated, an XML document can be validated by the
12
- * XML::Document#validate method providing the XML::Dtd object as parameeter.
13
- * The method will raise an exception if the document is
14
- * not valid.
15
- *
16
- * Basic usage:
17
- *
18
- * # parse DTD
19
- * dtd = XML::Dtd.new(<<EOF)
20
- * <!ELEMENT root (item*) >
21
- * <!ELEMENT item (#PCDATA) >
22
- * EOF
23
- *
24
- * # parse xml document to be validated
25
- * instance = XML::Document.file('instance.xml')
26
- *
27
- * # validate
28
- * instance.validate(dtd)
29
- */
30
-
31
- VALUE cXMLDtd;
32
-
33
- void rxml_dtd_free(xmlDtdPtr xdtd)
34
- {
35
- if (xdtd->doc == NULL && xdtd->parent == NULL)
36
- xmlFreeDtd(xdtd);
37
- }
38
-
39
- void rxml_dtd_mark(xmlDtdPtr xdtd)
40
- {
41
- if (xdtd && xdtd->doc)
42
- {
43
- VALUE doc = (VALUE)xdtd->doc->_private;
44
- rb_gc_mark(doc);
45
- }
46
- }
47
-
48
- static VALUE rxml_dtd_alloc(VALUE klass)
49
- {
50
- return Data_Wrap_Struct(klass, rxml_dtd_mark, rxml_dtd_free, NULL);
51
- }
52
-
53
- VALUE rxml_dtd_wrap(xmlDtdPtr xdtd)
54
- {
55
- return Data_Wrap_Struct(cXMLDtd, NULL, NULL, xdtd);
56
- }
57
-
58
- /*
59
- * call-seq:
60
- * dtd.external_id -> "string"
61
- *
62
- * Obtain this dtd's external identifer (for a PUBLIC DTD).
63
- */
64
- static VALUE rxml_dtd_external_id_get(VALUE self)
65
- {
66
- xmlDtdPtr xdtd;
67
- Data_Get_Struct(self, xmlDtd, xdtd);
68
-
69
-
70
- if (xdtd->ExternalID == NULL)
71
- return (Qnil);
72
- else
73
- return (rxml_new_cstr( xdtd->ExternalID, NULL));
74
- }
75
-
76
- /*
77
- * call-seq:
78
- * dtd.name -> "string"
79
- *
80
- * Obtain this dtd's name.
81
- */
82
- static VALUE rxml_dtd_name_get(VALUE self)
83
- {
84
- xmlDtdPtr xdtd;
85
- Data_Get_Struct(self, xmlDtd, xdtd);
86
-
87
-
88
- if (xdtd->name == NULL)
89
- return (Qnil);
90
- else
91
- return (rxml_new_cstr( xdtd->name, NULL));
92
- }
93
-
94
-
95
- /*
96
- * call-seq:
97
- * dtd.uri -> "string"
98
- *
99
- * Obtain this dtd's URI (for a SYSTEM or PUBLIC DTD).
100
- */
101
- static VALUE rxml_dtd_uri_get(VALUE self)
102
- {
103
- xmlDtdPtr xdtd;
104
- Data_Get_Struct(self, xmlDtd, xdtd);
105
-
106
- if (xdtd->SystemID == NULL)
107
- return (Qnil);
108
- else
109
- return (rxml_new_cstr( xdtd->SystemID, NULL));
110
- }
111
-
112
- /*
113
- * call-seq:
114
- * node.type -> num
115
- *
116
- * Obtain this node's type identifier.
117
- */
118
- static VALUE rxml_dtd_type(VALUE self)
119
- {
120
- xmlDtdPtr xdtd;
121
- Data_Get_Struct(self, xmlDtd, xdtd);
122
- return (INT2NUM(xdtd->type));
123
- }
124
-
125
- /*
126
- * call-seq:
127
- * XML::Dtd.new(dtd_string) -> dtd
128
- * XML::Dtd.new(external_id, system_id) -> dtd
129
- * XML::Dtd.new(external_id, system_id, name, document, internal) -> dtd
130
- *
131
- * Create a new Dtd from the specified public and system identifiers:
132
- *
133
- * * The first usage creates a DTD from a string and requires 1 parameter.
134
- * * The second usage loads and parses an external DTD and requires 2 parameters.
135
- * * The third usage creates a new internal or external DTD and requires 2 parameters and 3 optional parameters.
136
- * The DTD is then attached to the specified document if it is not nil.
137
- *
138
- * Parameters:
139
- *
140
- * dtd_string - A string that contains a complete DTD
141
- * external_id - A string that specifies the DTD's external name. For example, "-//W3C//DTD XHTML 1.0 Transitional//EN"
142
- * system_id - A string that specififies the DTD's system name. For example, "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
143
- * name - A string that specifies the DTD's name. For example "xhtml1".
144
- * document - A xml document.
145
- * internal - Boolean value indicating whether this is an internal or external DTD. Optional. If not specified
146
- * then external is assumed.
147
- */
148
- static VALUE rxml_dtd_initialize(int argc, VALUE *argv, VALUE self)
149
- {
150
- xmlDtdPtr xdtd;
151
- VALUE external, system;
152
-
153
- switch (argc)
154
- {
155
- case 3:
156
- case 4:
157
- case 5:
158
- {
159
- const xmlChar *xname = NULL, *xpublic = NULL, *xsystem = NULL;
160
- xmlDocPtr xdoc = NULL;
161
-
162
- VALUE name, doc, internal;
163
- rb_scan_args(argc, argv, "23", &external, &system, &name, &doc, &internal);
164
-
165
- Check_Type(external, T_STRING);
166
- xpublic = (const xmlChar*) StringValuePtr(external);
167
-
168
- Check_Type(system, T_STRING);
169
- xsystem = (const xmlChar*) StringValuePtr(system);
170
-
171
- if (name != Qnil)
172
- {
173
- Check_Type(name, T_STRING);
174
- xname = (const xmlChar*)StringValuePtr(name);
175
- }
176
-
177
- if (doc != Qnil)
178
- {
179
- if (rb_obj_is_kind_of(doc, cXMLDocument) == Qfalse)
180
- rb_raise(rb_eTypeError, "Must pass an LibXML::XML::Document object");
181
- Data_Get_Struct(doc, xmlDoc, xdoc);
182
- }
183
-
184
- if (internal == Qnil || internal == Qfalse)
185
- xdtd = xmlNewDtd(xdoc, xname, xpublic, xsystem);
186
- else
187
- xdtd = xmlCreateIntSubset(xdoc, xname, xpublic, xsystem);
188
-
189
- if (xdtd == NULL)
190
- rxml_raise(xmlGetLastError());
191
-
192
- /* The document will free the dtd so Ruby should not */
193
- RDATA(self)->dfree = NULL;
194
- DATA_PTR(self) = xdtd;
195
-
196
- xmlSetTreeDoc((xmlNodePtr) xdtd, xdoc);
197
- }
198
- break;
199
-
200
- case 2:
201
- {
202
- rb_scan_args(argc, argv, "20", &external, &system);
203
-
204
- Check_Type(external, T_STRING);
205
- Check_Type(system, T_STRING);
206
-
207
- xdtd = xmlParseDTD((xmlChar*) StringValuePtr(external), (xmlChar*) StringValuePtr(system));
208
-
209
- if (xdtd == NULL)
210
- rxml_raise(xmlGetLastError());
211
-
212
- DATA_PTR(self) = xdtd;
213
-
214
- xmlSetTreeDoc((xmlNodePtr) xdtd, NULL);
215
- break;
216
- }
217
- case 1:
218
- {
219
- VALUE dtd_string;
220
- rb_scan_args(argc, argv, "10", &dtd_string);
221
- Check_Type(dtd_string, T_STRING);
222
-
223
- /* Note that buffer is freed by xmlParserInputBufferPush*/
224
- xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
225
- xmlParserInputBufferPtr buffer = xmlAllocParserInputBuffer(enc);
226
- xmlChar *new_string = xmlStrdup((xmlChar*) StringValuePtr(dtd_string));
227
- xmlParserInputBufferPush(buffer, xmlStrlen(new_string),
228
- (const char*) new_string);
229
-
230
- xdtd = xmlIOParseDTD(NULL, buffer, enc);
231
-
232
- if (xdtd == NULL)
233
- rxml_raise(xmlGetLastError());
234
-
235
- xmlFree(new_string);
236
-
237
- DATA_PTR(self) = xdtd;
238
- break;
239
- }
240
- default:
241
- rb_raise(rb_eArgError, "wrong number of arguments");
242
- }
243
-
244
- return self;
245
- }
246
-
247
- void rxml_init_dtd(void)
248
- {
249
- cXMLDtd = rb_define_class_under(mXML, "Dtd", rb_cObject);
250
- rb_define_alloc_func(cXMLDtd, rxml_dtd_alloc);
251
- rb_define_method(cXMLDtd, "initialize", rxml_dtd_initialize, -1);
252
- rb_define_method(cXMLDtd, "external_id", rxml_dtd_external_id_get, 0);
253
- rb_define_method(cXMLDtd, "name", rxml_dtd_name_get, 0);
254
- rb_define_method(cXMLDtd, "uri", rxml_dtd_uri_get, 0);
255
- rb_define_method(cXMLDtd, "node_type", rxml_dtd_type, 0);
256
- rb_define_alias(cXMLDtd, "system_id", "uri");
257
- }
1
+ #include "ruby_libxml.h"
2
+ #include "ruby_xml_dtd.h"
3
+
4
+ /*
5
+ * Document-class: LibXML::XML::Dtd
6
+ *
7
+ * The XML::Dtd class is used to prepare DTD's for validation of xml
8
+ * documents.
9
+ *
10
+ * DTDs can be created from a string or a pair of public and system identifiers.
11
+ * Once a Dtd object is instantiated, an XML document can be validated by the
12
+ * XML::Document#validate method providing the XML::Dtd object as parameeter.
13
+ * The method will raise an exception if the document is
14
+ * not valid.
15
+ *
16
+ * Basic usage:
17
+ *
18
+ * # parse DTD
19
+ * dtd = XML::Dtd.new(<<EOF)
20
+ * <!ELEMENT root (item*) >
21
+ * <!ELEMENT item (#PCDATA) >
22
+ * EOF
23
+ *
24
+ * # parse xml document to be validated
25
+ * instance = XML::Document.file('instance.xml')
26
+ *
27
+ * # validate
28
+ * instance.validate(dtd)
29
+ */
30
+
31
+ VALUE cXMLDtd;
32
+
33
+ void rxml_dtd_free(xmlDtdPtr xdtd)
34
+ {
35
+ if (xdtd->doc == NULL && xdtd->parent == NULL)
36
+ xmlFreeDtd(xdtd);
37
+ }
38
+
39
+ void rxml_dtd_mark(xmlDtdPtr xdtd)
40
+ {
41
+ if (xdtd && xdtd->doc)
42
+ {
43
+ VALUE doc = (VALUE)xdtd->doc->_private;
44
+ rb_gc_mark(doc);
45
+ }
46
+ }
47
+
48
+ static VALUE rxml_dtd_alloc(VALUE klass)
49
+ {
50
+ return Data_Wrap_Struct(klass, rxml_dtd_mark, rxml_dtd_free, NULL);
51
+ }
52
+
53
+ VALUE rxml_dtd_wrap(xmlDtdPtr xdtd)
54
+ {
55
+ return Data_Wrap_Struct(cXMLDtd, NULL, NULL, xdtd);
56
+ }
57
+
58
+ /*
59
+ * call-seq:
60
+ * dtd.external_id -> "string"
61
+ *
62
+ * Obtain this dtd's external identifer (for a PUBLIC DTD).
63
+ */
64
+ static VALUE rxml_dtd_external_id_get(VALUE self)
65
+ {
66
+ xmlDtdPtr xdtd;
67
+ Data_Get_Struct(self, xmlDtd, xdtd);
68
+
69
+
70
+ if (xdtd->ExternalID == NULL)
71
+ return (Qnil);
72
+ else
73
+ return (rxml_new_cstr( xdtd->ExternalID, NULL));
74
+ }
75
+
76
+ /*
77
+ * call-seq:
78
+ * dtd.name -> "string"
79
+ *
80
+ * Obtain this dtd's name.
81
+ */
82
+ static VALUE rxml_dtd_name_get(VALUE self)
83
+ {
84
+ xmlDtdPtr xdtd;
85
+ Data_Get_Struct(self, xmlDtd, xdtd);
86
+
87
+
88
+ if (xdtd->name == NULL)
89
+ return (Qnil);
90
+ else
91
+ return (rxml_new_cstr( xdtd->name, NULL));
92
+ }
93
+
94
+
95
+ /*
96
+ * call-seq:
97
+ * dtd.uri -> "string"
98
+ *
99
+ * Obtain this dtd's URI (for a SYSTEM or PUBLIC DTD).
100
+ */
101
+ static VALUE rxml_dtd_uri_get(VALUE self)
102
+ {
103
+ xmlDtdPtr xdtd;
104
+ Data_Get_Struct(self, xmlDtd, xdtd);
105
+
106
+ if (xdtd->SystemID == NULL)
107
+ return (Qnil);
108
+ else
109
+ return (rxml_new_cstr( xdtd->SystemID, NULL));
110
+ }
111
+
112
+ /*
113
+ * call-seq:
114
+ * node.type -> num
115
+ *
116
+ * Obtain this node's type identifier.
117
+ */
118
+ static VALUE rxml_dtd_type(VALUE self)
119
+ {
120
+ xmlDtdPtr xdtd;
121
+ Data_Get_Struct(self, xmlDtd, xdtd);
122
+ return (INT2NUM(xdtd->type));
123
+ }
124
+
125
+ /*
126
+ * call-seq:
127
+ * XML::Dtd.new(dtd_string) -> dtd
128
+ * XML::Dtd.new(external_id, system_id) -> dtd
129
+ * XML::Dtd.new(external_id, system_id, name, document, internal) -> dtd
130
+ *
131
+ * Create a new Dtd from the specified public and system identifiers:
132
+ *
133
+ * * The first usage creates a DTD from a string and requires 1 parameter.
134
+ * * The second usage loads and parses an external DTD and requires 2 parameters.
135
+ * * The third usage creates a new internal or external DTD and requires 2 parameters and 3 optional parameters.
136
+ * The DTD is then attached to the specified document if it is not nil.
137
+ *
138
+ * Parameters:
139
+ *
140
+ * dtd_string - A string that contains a complete DTD
141
+ * external_id - A string that specifies the DTD's external name. For example, "-//W3C//DTD XHTML 1.0 Transitional//EN"
142
+ * system_id - A string that specififies the DTD's system name. For example, "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
143
+ * name - A string that specifies the DTD's name. For example "xhtml1".
144
+ * document - A xml document.
145
+ * internal - Boolean value indicating whether this is an internal or external DTD. Optional. If not specified
146
+ * then external is assumed.
147
+ */
148
+ static VALUE rxml_dtd_initialize(int argc, VALUE *argv, VALUE self)
149
+ {
150
+ xmlDtdPtr xdtd;
151
+ VALUE external, system;
152
+
153
+ switch (argc)
154
+ {
155
+ case 3:
156
+ case 4:
157
+ case 5:
158
+ {
159
+ const xmlChar *xname = NULL, *xpublic = NULL, *xsystem = NULL;
160
+ xmlDocPtr xdoc = NULL;
161
+
162
+ VALUE name, doc, internal;
163
+ rb_scan_args(argc, argv, "23", &external, &system, &name, &doc, &internal);
164
+
165
+ Check_Type(external, T_STRING);
166
+ xpublic = (const xmlChar*) StringValuePtr(external);
167
+
168
+ Check_Type(system, T_STRING);
169
+ xsystem = (const xmlChar*) StringValuePtr(system);
170
+
171
+ if (name != Qnil)
172
+ {
173
+ Check_Type(name, T_STRING);
174
+ xname = (const xmlChar*)StringValuePtr(name);
175
+ }
176
+
177
+ if (doc != Qnil)
178
+ {
179
+ if (rb_obj_is_kind_of(doc, cXMLDocument) == Qfalse)
180
+ rb_raise(rb_eTypeError, "Must pass an LibXML::XML::Document object");
181
+ Data_Get_Struct(doc, xmlDoc, xdoc);
182
+ }
183
+
184
+ if (internal == Qnil || internal == Qfalse)
185
+ xdtd = xmlNewDtd(xdoc, xname, xpublic, xsystem);
186
+ else
187
+ xdtd = xmlCreateIntSubset(xdoc, xname, xpublic, xsystem);
188
+
189
+ if (xdtd == NULL)
190
+ rxml_raise(xmlGetLastError());
191
+
192
+ /* The document will free the dtd so Ruby should not */
193
+ RDATA(self)->dfree = NULL;
194
+ DATA_PTR(self) = xdtd;
195
+
196
+ xmlSetTreeDoc((xmlNodePtr) xdtd, xdoc);
197
+ }
198
+ break;
199
+
200
+ case 2:
201
+ {
202
+ rb_scan_args(argc, argv, "20", &external, &system);
203
+
204
+ Check_Type(external, T_STRING);
205
+ Check_Type(system, T_STRING);
206
+
207
+ xdtd = xmlParseDTD((xmlChar*) StringValuePtr(external), (xmlChar*) StringValuePtr(system));
208
+
209
+ if (xdtd == NULL)
210
+ rxml_raise(xmlGetLastError());
211
+
212
+ DATA_PTR(self) = xdtd;
213
+
214
+ xmlSetTreeDoc((xmlNodePtr) xdtd, NULL);
215
+ break;
216
+ }
217
+ case 1:
218
+ {
219
+ VALUE dtd_string;
220
+ rb_scan_args(argc, argv, "10", &dtd_string);
221
+ Check_Type(dtd_string, T_STRING);
222
+
223
+ /* Note that buffer is freed by xmlParserInputBufferPush*/
224
+ xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
225
+ xmlParserInputBufferPtr buffer = xmlAllocParserInputBuffer(enc);
226
+ xmlChar *new_string = xmlStrdup((xmlChar*) StringValuePtr(dtd_string));
227
+ xmlParserInputBufferPush(buffer, xmlStrlen(new_string),
228
+ (const char*) new_string);
229
+
230
+ xdtd = xmlIOParseDTD(NULL, buffer, enc);
231
+
232
+ if (xdtd == NULL)
233
+ rxml_raise(xmlGetLastError());
234
+
235
+ xmlFree(new_string);
236
+
237
+ DATA_PTR(self) = xdtd;
238
+ break;
239
+ }
240
+ default:
241
+ rb_raise(rb_eArgError, "wrong number of arguments");
242
+ }
243
+
244
+ return self;
245
+ }
246
+
247
+ void rxml_init_dtd(void)
248
+ {
249
+ cXMLDtd = rb_define_class_under(mXML, "Dtd", rb_cObject);
250
+ rb_define_alloc_func(cXMLDtd, rxml_dtd_alloc);
251
+ rb_define_method(cXMLDtd, "initialize", rxml_dtd_initialize, -1);
252
+ rb_define_method(cXMLDtd, "external_id", rxml_dtd_external_id_get, 0);
253
+ rb_define_method(cXMLDtd, "name", rxml_dtd_name_get, 0);
254
+ rb_define_method(cXMLDtd, "uri", rxml_dtd_uri_get, 0);
255
+ rb_define_method(cXMLDtd, "node_type", rxml_dtd_type, 0);
256
+ rb_define_alias(cXMLDtd, "system_id", "uri");
257
+ }
@@ -1,9 +1,9 @@
1
- #ifndef __RXML_DTD__
2
- #define __RXML_DTD__
3
-
4
- extern VALUE cXMLDtd;
5
-
6
- void rxml_init_dtd(void);
7
- VALUE rxml_dtd_wrap(xmlDtdPtr xdtd);
8
-
9
- #endif
1
+ #ifndef __RXML_DTD__
2
+ #define __RXML_DTD__
3
+
4
+ extern VALUE cXMLDtd;
5
+
6
+ void rxml_init_dtd(void);
7
+ VALUE rxml_dtd_wrap(xmlDtdPtr xdtd);
8
+
9
+ #endif