libxml-ruby 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +22 -0
- data/README +3 -1
- data/ext/libxml/cbg.c +86 -76
- data/ext/libxml/extconf.rb +2 -1
- data/ext/libxml/libxml.c +899 -885
- data/ext/libxml/ruby_libxml.h +65 -70
- data/ext/libxml/ruby_xml_attr.c +485 -500
- data/ext/libxml/ruby_xml_attributes.c +107 -106
- data/ext/libxml/ruby_xml_document.c +355 -356
- data/ext/libxml/ruby_xml_dtd.c +119 -117
- data/ext/libxml/ruby_xml_error.c +1112 -581
- data/ext/libxml/ruby_xml_html_parser.c +35 -34
- data/ext/libxml/ruby_xml_input.c +182 -187
- data/ext/libxml/ruby_xml_input_cbg.c +197 -179
- data/ext/libxml/ruby_xml_node.c +1529 -1566
- data/ext/libxml/ruby_xml_node.h +2 -2
- data/ext/libxml/ruby_xml_ns.c +150 -156
- data/ext/libxml/ruby_xml_parser.c +37 -36
- data/ext/libxml/ruby_xml_parser_context.c +657 -659
- data/ext/libxml/ruby_xml_reader.c +203 -209
- data/ext/libxml/ruby_xml_relaxng.c +29 -25
- data/ext/libxml/ruby_xml_sax_parser.c +33 -32
- data/ext/libxml/ruby_xml_schema.c +165 -161
- data/ext/libxml/ruby_xml_state.c +19 -21
- data/ext/libxml/ruby_xml_xinclude.c +24 -25
- data/ext/libxml/ruby_xml_xpath.c +108 -108
- data/ext/libxml/ruby_xml_xpath_context.c +305 -293
- data/ext/libxml/ruby_xml_xpath_expression.c +24 -24
- data/ext/libxml/ruby_xml_xpath_object.c +89 -96
- data/ext/libxml/ruby_xml_xpointer.c +107 -109
- data/ext/libxml/ruby_xml_xpointer.h +13 -13
- data/ext/libxml/version.h +2 -2
- data/ext/mingw/Rakefile +1 -1
- data/ext/vc/libxml_ruby.vcproj +1 -1
- data/lib/libxml/error.rb +4 -4
- data/test/tc_node_edit.rb +14 -2
- data/test/tc_node_text.rb +9 -9
- metadata +2 -2
@@ -11,11 +11,11 @@ VALUE cXMLReader;
|
|
11
11
|
*
|
12
12
|
* The XML::Reader class provides a simpler, alternative way of parsing an XML
|
13
13
|
* document in contrast to XML::Parser or XML::SaxParser. A XML::Reader instance
|
14
|
-
* acts like a cursor going forward in a document stream, stopping at each node
|
14
|
+
* acts like a cursor going forward in a document stream, stopping at each node
|
15
15
|
* it encounters. To advance to the next node, simply cadd XML::Reader#read.
|
16
|
-
*
|
16
|
+
*
|
17
17
|
* The XML::Reader API closely matches the DOM Core specification and supports
|
18
|
-
* namespaces, xml:base, entity handling and DTDs.
|
18
|
+
* namespaces, xml:base, entity handling and DTDs.
|
19
19
|
*
|
20
20
|
* To summarize, XML::Reader provides a far simpler API to use versus XML::SaxParser
|
21
21
|
* and is more memory efficient than using XML::Parser to create a DOM tree.
|
@@ -26,7 +26,7 @@ VALUE cXMLReader;
|
|
26
26
|
* parser.read
|
27
27
|
* assert_equal('foo', parser.name)
|
28
28
|
* assert_equal(nil, parser.value)
|
29
|
-
*
|
29
|
+
*
|
30
30
|
* 3.times do |i|
|
31
31
|
* parser.read
|
32
32
|
* assert_equal(XML::Reader::TYPE_ELEMENT, parser.node_type)
|
@@ -40,15 +40,12 @@ VALUE cXMLReader;
|
|
40
40
|
*
|
41
41
|
* For a more in depth tutorial, albeit in C, see http://xmlsoft.org/xmlreader.html.*/
|
42
42
|
|
43
|
-
|
44
|
-
static VALUE
|
45
|
-
rxml_reader_new(VALUE class, xmlTextReaderPtr reader)
|
43
|
+
static VALUE rxml_reader_new(VALUE class, xmlTextReaderPtr reader)
|
46
44
|
{
|
47
45
|
return Data_Wrap_Struct(class, NULL, xmlFreeTextReader, reader);
|
48
46
|
}
|
49
47
|
|
50
|
-
static xmlTextReaderPtr
|
51
|
-
rxml_text_reader_get(VALUE obj)
|
48
|
+
static xmlTextReaderPtr rxml_text_reader_get(VALUE obj)
|
52
49
|
{
|
53
50
|
xmlTextReaderPtr xreader;
|
54
51
|
Data_Get_Struct(obj, xmlTextReader, xreader);
|
@@ -59,11 +56,10 @@ rxml_text_reader_get(VALUE obj)
|
|
59
56
|
* call-seq:
|
60
57
|
* XML::Reader.file(path, encoding=nil, options=0) -> reader
|
61
58
|
*
|
62
|
-
* Parse an XML file from the filesystem or the network. The parsing flags
|
63
|
-
* options are a combination of xmlParserOption.
|
59
|
+
* Parse an XML file from the filesystem or the network. The parsing flags
|
60
|
+
* options are a combination of xmlParserOption.
|
64
61
|
*/
|
65
|
-
static VALUE
|
66
|
-
rxml_reader_new_file(int argc, VALUE *argv, VALUE self)
|
62
|
+
static VALUE rxml_reader_new_file(int argc, VALUE *argv, VALUE self)
|
67
63
|
{
|
68
64
|
xmlTextReaderPtr xreader;
|
69
65
|
VALUE rpath, rencoding, roptions;
|
@@ -82,7 +78,7 @@ rxml_reader_new_file(int argc, VALUE *argv, VALUE self)
|
|
82
78
|
if (xreader == NULL)
|
83
79
|
rxml_raise(&xmlLastError);
|
84
80
|
|
85
|
-
return rxml_reader_new(self, xreader);
|
81
|
+
return rxml_reader_new(self, xreader);
|
86
82
|
}
|
87
83
|
|
88
84
|
/*
|
@@ -90,10 +86,9 @@ rxml_reader_new_file(int argc, VALUE *argv, VALUE self)
|
|
90
86
|
* XML::Reader.io(io, url=nil, encoding=nil, options=0) -> reader
|
91
87
|
*
|
92
88
|
* Parse an XML file from a file handle. The parsing flags options are
|
93
|
-
* a combination of xmlParserOption.
|
89
|
+
* a combination of xmlParserOption.
|
94
90
|
*/
|
95
|
-
static VALUE
|
96
|
-
rxml_reader_new_io(int argc, VALUE *argv, VALUE self)
|
91
|
+
static VALUE rxml_reader_new_io(int argc, VALUE *argv, VALUE self)
|
97
92
|
{
|
98
93
|
xmlTextReaderPtr xreader;
|
99
94
|
VALUE rio, rurl, rencoding, roptions;
|
@@ -108,13 +103,12 @@ rxml_reader_new_io(int argc, VALUE *argv, VALUE self)
|
|
108
103
|
options = NIL_P(roptions) ? 0 : FIX2INT(roptions);
|
109
104
|
|
110
105
|
xreader = xmlReaderForIO((xmlInputReadCallback) rxml_read_callback, NULL,
|
111
|
-
|
112
|
-
xurl, xencoding, options);
|
106
|
+
(void *) rio, xurl, xencoding, options);
|
113
107
|
|
114
108
|
if (xreader == NULL)
|
115
109
|
rxml_raise(&xmlLastError);
|
116
110
|
|
117
|
-
return rxml_reader_new(self, xreader);
|
111
|
+
return rxml_reader_new(self, xreader);
|
118
112
|
}
|
119
113
|
|
120
114
|
/*
|
@@ -124,20 +118,19 @@ rxml_reader_new_io(int argc, VALUE *argv, VALUE self)
|
|
124
118
|
*
|
125
119
|
* Create an XML text reader for a preparsed document.
|
126
120
|
*/
|
127
|
-
VALUE
|
128
|
-
rxml_reader_new_walker(VALUE self, VALUE doc)
|
121
|
+
VALUE rxml_reader_new_walker(VALUE self, VALUE doc)
|
129
122
|
{
|
130
123
|
xmlDocPtr xdoc;
|
131
124
|
xmlTextReaderPtr xreader;
|
132
|
-
|
125
|
+
|
133
126
|
Data_Get_Struct(doc, xmlDoc, xdoc);
|
134
|
-
|
135
|
-
xreader = xmlReaderWalker(xdoc);
|
127
|
+
|
128
|
+
xreader = xmlReaderWalker(xdoc);
|
136
129
|
|
137
130
|
if (xreader == NULL)
|
138
131
|
rxml_raise(&xmlLastError);
|
139
132
|
|
140
|
-
return rxml_reader_new(self, xreader);
|
133
|
+
return rxml_reader_new(self, xreader);
|
141
134
|
}
|
142
135
|
|
143
136
|
/*
|
@@ -148,8 +141,7 @@ rxml_reader_new_walker(VALUE self, VALUE doc)
|
|
148
141
|
* Create an XML text reader for an XML in-memory document. The parsing flags
|
149
142
|
* options are a combination of xmlParserOption.
|
150
143
|
*/
|
151
|
-
static VALUE
|
152
|
-
rxml_reader_new_data(int argc, VALUE *argv, VALUE self)
|
144
|
+
static VALUE rxml_reader_new_data(int argc, VALUE *argv, VALUE self)
|
153
145
|
{
|
154
146
|
xmlTextReaderPtr xreader;
|
155
147
|
VALUE rdata, rurl, rencoding, roptions;
|
@@ -165,24 +157,22 @@ rxml_reader_new_data(int argc, VALUE *argv, VALUE self)
|
|
165
157
|
xencoding = NIL_P(rencoding) ? NULL : StringValueCStr(rencoding);
|
166
158
|
options = NIL_P(roptions) ? 0 : FIX2INT(roptions);
|
167
159
|
|
168
|
-
xreader = xmlReaderForMemory(xdata, strlen(xdata),
|
169
|
-
xurl, xencoding, options);
|
160
|
+
xreader = xmlReaderForMemory(xdata, strlen(xdata), xurl, xencoding, options);
|
170
161
|
|
171
162
|
if (xreader == NULL)
|
172
163
|
rxml_raise(&xmlLastError);
|
173
164
|
|
174
|
-
return rxml_reader_new(self, xreader);
|
165
|
+
return rxml_reader_new(self, xreader);
|
175
166
|
}
|
176
167
|
|
177
168
|
/*
|
178
169
|
* call-seq:
|
179
170
|
* parser.close -> code
|
180
171
|
*
|
181
|
-
* This method releases any resources allocated by the current instance
|
172
|
+
* This method releases any resources allocated by the current instance
|
182
173
|
* changes the state to Closed and close any underlying input.
|
183
174
|
*/
|
184
|
-
static VALUE
|
185
|
-
rxml_reader_close(VALUE self)
|
175
|
+
static VALUE rxml_reader_close(VALUE self)
|
186
176
|
{
|
187
177
|
return INT2FIX(xmlTextReaderClose(rxml_text_reader_get(self)));
|
188
178
|
}
|
@@ -191,23 +181,25 @@ rxml_reader_close(VALUE self)
|
|
191
181
|
* call-seq:
|
192
182
|
* parser.move_to_attribute(val) -> code
|
193
183
|
*
|
194
|
-
* Move the position of the current instance to the attribute with the
|
195
|
-
* specified index (if +val+ is an integer) or name (if +val+ is a string)
|
184
|
+
* Move the position of the current instance to the attribute with the
|
185
|
+
* specified index (if +val+ is an integer) or name (if +val+ is a string)
|
196
186
|
* relative to the containing element.
|
197
187
|
*/
|
198
|
-
static VALUE
|
199
|
-
rxml_reader_move_to_attr(VALUE self, VALUE val)
|
188
|
+
static VALUE rxml_reader_move_to_attr(VALUE self, VALUE val)
|
200
189
|
{
|
201
190
|
xmlTextReaderPtr xreader;
|
202
191
|
int ret;
|
203
192
|
|
204
193
|
xreader = rxml_text_reader_get(self);
|
205
194
|
|
206
|
-
if (TYPE(val) == T_FIXNUM)
|
195
|
+
if (TYPE(val) == T_FIXNUM)
|
196
|
+
{
|
207
197
|
ret = xmlTextReaderMoveToAttributeNo(xreader, FIX2INT(val));
|
208
198
|
}
|
209
|
-
else
|
210
|
-
|
199
|
+
else
|
200
|
+
{
|
201
|
+
ret = xmlTextReaderMoveToAttribute(xreader,
|
202
|
+
(const xmlChar *) StringValueCStr(val));
|
211
203
|
}
|
212
204
|
|
213
205
|
return INT2FIX(ret);
|
@@ -220,8 +212,7 @@ rxml_reader_move_to_attr(VALUE self, VALUE val)
|
|
220
212
|
* Move the position of the current instance to the first attribute associated
|
221
213
|
* with the current node.
|
222
214
|
*/
|
223
|
-
static VALUE
|
224
|
-
rxml_reader_move_to_first_attr(VALUE self)
|
215
|
+
static VALUE rxml_reader_move_to_first_attr(VALUE self)
|
225
216
|
{
|
226
217
|
return INT2FIX(xmlTextReaderMoveToFirstAttribute(rxml_text_reader_get(self)));
|
227
218
|
}
|
@@ -230,11 +221,10 @@ rxml_reader_move_to_first_attr(VALUE self)
|
|
230
221
|
* call-seq:
|
231
222
|
* reader.move_to_next_attribute -> code
|
232
223
|
*
|
233
|
-
* Move the position of the current instance to the next attribute associated
|
224
|
+
* Move the position of the current instance to the next attribute associated
|
234
225
|
* with the current node.
|
235
226
|
*/
|
236
|
-
static VALUE
|
237
|
-
rxml_reader_move_to_next_attr(VALUE self)
|
227
|
+
static VALUE rxml_reader_move_to_next_attr(VALUE self)
|
238
228
|
{
|
239
229
|
return INT2FIX(xmlTextReaderMoveToNextAttribute(rxml_text_reader_get(self)));
|
240
230
|
}
|
@@ -243,11 +233,10 @@ rxml_reader_move_to_next_attr(VALUE self)
|
|
243
233
|
* call-seq:
|
244
234
|
* reader.move_to_element -> code
|
245
235
|
*
|
246
|
-
* Move the position of the current instance to the node that contains the
|
236
|
+
* Move the position of the current instance to the node that contains the
|
247
237
|
* current attribute node.
|
248
238
|
*/
|
249
|
-
static VALUE
|
250
|
-
rxml_reader_move_to_element(VALUE self)
|
239
|
+
static VALUE rxml_reader_move_to_element(VALUE self)
|
251
240
|
{
|
252
241
|
return INT2FIX(xmlTextReaderMoveToElement(rxml_text_reader_get(self)));
|
253
242
|
}
|
@@ -256,11 +245,10 @@ rxml_reader_move_to_element(VALUE self)
|
|
256
245
|
* call-seq:
|
257
246
|
* reader.next -> code
|
258
247
|
*
|
259
|
-
* Skip to the node following the current one in document order while avoiding
|
248
|
+
* Skip to the node following the current one in document order while avoiding
|
260
249
|
* the subtree if any.
|
261
250
|
*/
|
262
|
-
static VALUE
|
263
|
-
rxml_reader_next(VALUE self)
|
251
|
+
static VALUE rxml_reader_next(VALUE self)
|
264
252
|
{
|
265
253
|
return INT2FIX(xmlTextReaderNext(rxml_text_reader_get(self)));
|
266
254
|
}
|
@@ -269,12 +257,11 @@ rxml_reader_next(VALUE self)
|
|
269
257
|
* call-seq:
|
270
258
|
* reader.next_sibling -> code
|
271
259
|
*
|
272
|
-
* Skip to the node following the current one in document order while avoiding
|
273
|
-
* the subtree if any. Currently implemented only for Readers built on a
|
260
|
+
* Skip to the node following the current one in document order while avoiding
|
261
|
+
* the subtree if any. Currently implemented only for Readers built on a
|
274
262
|
* document.
|
275
263
|
*/
|
276
|
-
static VALUE
|
277
|
-
rxml_reader_next_sibling(VALUE self)
|
264
|
+
static VALUE rxml_reader_next_sibling(VALUE self)
|
278
265
|
{
|
279
266
|
return INT2FIX(xmlTextReaderNextSibling(rxml_text_reader_get(self)));
|
280
267
|
}
|
@@ -283,11 +270,10 @@ rxml_reader_next_sibling(VALUE self)
|
|
283
270
|
* call-seq:
|
284
271
|
* reader.node_type -> type
|
285
272
|
*
|
286
|
-
* Get the node type of the current node. Reference:
|
273
|
+
* Get the node type of the current node. Reference:
|
287
274
|
* http://dotgnu.org/pnetlib-doc/System/Xml/XmlNodeType.html
|
288
275
|
*/
|
289
|
-
static VALUE
|
290
|
-
rxml_reader_node_type(VALUE self)
|
276
|
+
static VALUE rxml_reader_node_type(VALUE self)
|
291
277
|
{
|
292
278
|
return INT2FIX(xmlTextReaderNodeType(rxml_text_reader_get(self)));
|
293
279
|
}
|
@@ -296,16 +282,15 @@ rxml_reader_node_type(VALUE self)
|
|
296
282
|
* call-seq:
|
297
283
|
* reader.normalization -> value
|
298
284
|
*
|
299
|
-
* The value indicating whether to normalize white space and attribute values.
|
300
|
-
* Since attribute value and end of line normalizations are a MUST in the XML
|
301
|
-
* specification only the value true is accepted. The broken bahaviour of
|
302
|
-
* accepting out of range character entities like � is of course not
|
285
|
+
* The value indicating whether to normalize white space and attribute values.
|
286
|
+
* Since attribute value and end of line normalizations are a MUST in the XML
|
287
|
+
* specification only the value true is accepted. The broken bahaviour of
|
288
|
+
* accepting out of range character entities like � is of course not
|
303
289
|
* supported either.
|
304
290
|
*
|
305
291
|
* Return 1 or -1 in case of error.
|
306
292
|
*/
|
307
|
-
static VALUE
|
308
|
-
rxml_reader_normalization(VALUE self)
|
293
|
+
static VALUE rxml_reader_normalization(VALUE self)
|
309
294
|
{
|
310
295
|
return INT2FIX(xmlTextReaderNormalization(rxml_text_reader_get(self)));
|
311
296
|
}
|
@@ -314,14 +299,13 @@ rxml_reader_normalization(VALUE self)
|
|
314
299
|
* call-seq:
|
315
300
|
* reader.read -> code
|
316
301
|
*
|
317
|
-
* Move the position of the current instance to the next node in the stream,
|
302
|
+
* Move the position of the current instance to the next node in the stream,
|
318
303
|
* exposing its properties.
|
319
304
|
*
|
320
|
-
* Return 1 if the node was read successfully, 0 if there is no more nodes to
|
305
|
+
* Return 1 if the node was read successfully, 0 if there is no more nodes to
|
321
306
|
* read, or -1 in case of error.
|
322
307
|
*/
|
323
|
-
static VALUE
|
324
|
-
rxml_reader_read(VALUE self)
|
308
|
+
static VALUE rxml_reader_read(VALUE self)
|
325
309
|
{
|
326
310
|
return INT2FIX(xmlTextReaderRead(rxml_text_reader_get(self)));
|
327
311
|
}
|
@@ -332,12 +316,11 @@ rxml_reader_read(VALUE self)
|
|
332
316
|
*
|
333
317
|
* Parse an attribute value into one or more Text and EntityReference nodes.
|
334
318
|
*
|
335
|
-
* Return 1 in case of success, 0 if the reader was not positionned on an
|
336
|
-
* attribute node or all the attribute values have been read, or -1 in case of
|
319
|
+
* Return 1 in case of success, 0 if the reader was not positionned on an
|
320
|
+
* attribute node or all the attribute values have been read, or -1 in case of
|
337
321
|
* error.
|
338
322
|
*/
|
339
|
-
static VALUE
|
340
|
-
rxml_reader_read_attr_value(VALUE self)
|
323
|
+
static VALUE rxml_reader_read_attr_value(VALUE self)
|
341
324
|
{
|
342
325
|
return INT2FIX(xmlTextReaderReadAttributeValue(rxml_text_reader_get(self)));
|
343
326
|
}
|
@@ -348,11 +331,10 @@ rxml_reader_read_attr_value(VALUE self)
|
|
348
331
|
*
|
349
332
|
* Read the contents of the current node, including child nodes and markup.
|
350
333
|
*
|
351
|
-
* Return a string containing the XML content, or nil if the current node is
|
352
|
-
* neither an element nor attribute, or has no child nodes.
|
334
|
+
* Return a string containing the XML content, or nil if the current node is
|
335
|
+
* neither an element nor attribute, or has no child nodes.
|
353
336
|
*/
|
354
|
-
static VALUE
|
355
|
-
rxml_reader_read_inner_xml(VALUE self)
|
337
|
+
static VALUE rxml_reader_read_inner_xml(VALUE self)
|
356
338
|
{
|
357
339
|
const xmlChar *result = xmlTextReaderReadInnerXml(rxml_text_reader_get(self));
|
358
340
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
@@ -364,11 +346,10 @@ rxml_reader_read_inner_xml(VALUE self)
|
|
364
346
|
*
|
365
347
|
* Read the contents of the current node, including child nodes and markup.
|
366
348
|
*
|
367
|
-
* Return a string containing the XML content, or nil if the current node is
|
368
|
-
* neither an element nor attribute, or has no child nodes.
|
349
|
+
* Return a string containing the XML content, or nil if the current node is
|
350
|
+
* neither an element nor attribute, or has no child nodes.
|
369
351
|
*/
|
370
|
-
static VALUE
|
371
|
-
rxml_reader_read_outer_xml(VALUE self)
|
352
|
+
static VALUE rxml_reader_read_outer_xml(VALUE self)
|
372
353
|
{
|
373
354
|
const xmlChar *result = xmlTextReaderReadOuterXml(rxml_text_reader_get(self));
|
374
355
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
@@ -380,8 +361,7 @@ rxml_reader_read_outer_xml(VALUE self)
|
|
380
361
|
*
|
381
362
|
* Get the read state of the reader.
|
382
363
|
*/
|
383
|
-
static VALUE
|
384
|
-
rxml_reader_read_state(VALUE self)
|
364
|
+
static VALUE rxml_reader_read_state(VALUE self)
|
385
365
|
{
|
386
366
|
return INT2FIX(xmlTextReaderReadState(rxml_text_reader_get(self)));
|
387
367
|
}
|
@@ -392,11 +372,10 @@ rxml_reader_read_state(VALUE self)
|
|
392
372
|
*
|
393
373
|
* Read the contents of an element or a text node as a string.
|
394
374
|
*
|
395
|
-
* Return a string containing the contents of the Element or Text node, or nil
|
375
|
+
* Return a string containing the contents of the Element or Text node, or nil
|
396
376
|
* if the reader is positioned on any other type of node.
|
397
377
|
*/
|
398
|
-
static VALUE
|
399
|
-
rxml_reader_read_string(VALUE self)
|
378
|
+
static VALUE rxml_reader_read_string(VALUE self)
|
400
379
|
{
|
401
380
|
const xmlChar *result = xmlTextReaderReadString(rxml_text_reader_get(self));
|
402
381
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
@@ -406,15 +385,14 @@ rxml_reader_read_string(VALUE self)
|
|
406
385
|
* call-seq:
|
407
386
|
* reader.relax_ng_validate(rng) -> code
|
408
387
|
*
|
409
|
-
* Use RelaxNG to validate the document as it is processed. Activation is only
|
388
|
+
* Use RelaxNG to validate the document as it is processed. Activation is only
|
410
389
|
* possible before the first read. If +rng+ is nil, the RelaxNG validation is
|
411
390
|
* desactivated.
|
412
391
|
*
|
413
|
-
* Return 0 in case the RelaxNG validation could be (des)activated and -1 in
|
392
|
+
* Return 0 in case the RelaxNG validation could be (des)activated and -1 in
|
414
393
|
* case of error.
|
415
|
-
*/
|
416
|
-
static VALUE
|
417
|
-
rxml_reader_relax_ng_validate(VALUE self, VALUE rng)
|
394
|
+
*/
|
395
|
+
static VALUE rxml_reader_relax_ng_validate(VALUE self, VALUE rng)
|
418
396
|
{
|
419
397
|
char *xrng = NIL_P(rng) ? NULL : StringValueCStr(rng);
|
420
398
|
return INT2FIX(xmlTextReaderRelaxNGValidate(rxml_text_reader_get(self), xrng));
|
@@ -424,46 +402,45 @@ rxml_reader_relax_ng_validate(VALUE self, VALUE rng)
|
|
424
402
|
/*
|
425
403
|
* call-seq:
|
426
404
|
* reader.schema_validate(schema) -> code
|
427
|
-
*
|
428
|
-
* Use W3C XSD schema to validate the document as it is processed. Activation
|
405
|
+
*
|
406
|
+
* Use W3C XSD schema to validate the document as it is processed. Activation
|
429
407
|
* is only possible before the first read. If +schema+ is nil, then XML Schema
|
430
408
|
* validation is desactivated.
|
431
409
|
*
|
432
|
-
* Return 0 in case the schemas validation could be (de)activated and -1 in
|
410
|
+
* Return 0 in case the schemas validation could be (de)activated and -1 in
|
433
411
|
* case of error.
|
434
412
|
*/
|
435
413
|
static VALUE
|
436
414
|
rxml_reader_schema_validate(VALUE self, VALUE xsd)
|
437
415
|
{
|
438
|
-
|
439
|
-
|
440
|
-
|
416
|
+
char *xxsd = NIL_P(xsd) ? NULL : StringValueCStr(xsd);
|
417
|
+
int status = xmlTextReaderSchemaValidate(rxml_text_reader_get(self), xxsd);
|
418
|
+
return INT2FIX(status);
|
441
419
|
}
|
442
420
|
#endif
|
443
421
|
|
444
|
-
/*
|
422
|
+
/*
|
445
423
|
* call-seq:
|
446
424
|
* reader.name -> name
|
447
425
|
*
|
448
426
|
* Return the qualified name of the node.
|
449
427
|
*/
|
450
|
-
static VALUE
|
451
|
-
rxml_reader_name(VALUE self)
|
428
|
+
static VALUE rxml_reader_name(VALUE self)
|
452
429
|
{
|
453
430
|
const xmlChar *result = xmlTextReaderConstName(rxml_text_reader_get(self));
|
454
431
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
455
432
|
}
|
456
433
|
|
457
|
-
/*
|
434
|
+
/*
|
458
435
|
* call-seq:
|
459
436
|
* reader.local_name -> name
|
460
437
|
*
|
461
438
|
* Return the local name of the node.
|
462
439
|
*/
|
463
|
-
static VALUE
|
464
|
-
rxml_reader_local_name(VALUE self)
|
440
|
+
static VALUE rxml_reader_local_name(VALUE self)
|
465
441
|
{
|
466
|
-
const xmlChar *result = xmlTextReaderConstLocalName(
|
442
|
+
const xmlChar *result = xmlTextReaderConstLocalName(
|
443
|
+
rxml_text_reader_get(self));
|
467
444
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
468
445
|
}
|
469
446
|
|
@@ -473,8 +450,7 @@ rxml_reader_local_name(VALUE self)
|
|
473
450
|
*
|
474
451
|
* Provide the number of attributes of the current node.
|
475
452
|
*/
|
476
|
-
static VALUE
|
477
|
-
rxml_reader_attr_count(VALUE self)
|
453
|
+
static VALUE rxml_reader_attr_count(VALUE self)
|
478
454
|
{
|
479
455
|
return INT2FIX(xmlTextReaderAttributeCount(rxml_text_reader_get(self)));
|
480
456
|
}
|
@@ -485,10 +461,10 @@ rxml_reader_attr_count(VALUE self)
|
|
485
461
|
*
|
486
462
|
* Determine the encoding of the document being read.
|
487
463
|
*/
|
488
|
-
static VALUE
|
489
|
-
rxml_reader_encoding(VALUE self)
|
464
|
+
static VALUE rxml_reader_encoding(VALUE self)
|
490
465
|
{
|
491
|
-
const xmlChar *result =
|
466
|
+
const xmlChar *result =
|
467
|
+
xmlTextReaderConstEncoding(rxml_text_reader_get(self));
|
492
468
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
493
469
|
}
|
494
470
|
|
@@ -498,8 +474,7 @@ rxml_reader_encoding(VALUE self)
|
|
498
474
|
*
|
499
475
|
* Determine the base URI of the node.
|
500
476
|
*/
|
501
|
-
static VALUE
|
502
|
-
rxml_reader_base_uri(VALUE self)
|
477
|
+
static VALUE rxml_reader_base_uri(VALUE self)
|
503
478
|
{
|
504
479
|
const xmlChar *result = xmlTextReaderConstBaseUri(rxml_text_reader_get(self));
|
505
480
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
@@ -511,10 +486,10 @@ rxml_reader_base_uri(VALUE self)
|
|
511
486
|
*
|
512
487
|
* Determine the namespace URI of the node.
|
513
488
|
*/
|
514
|
-
static VALUE
|
515
|
-
rxml_reader_namespace_uri(VALUE self)
|
489
|
+
static VALUE rxml_reader_namespace_uri(VALUE self)
|
516
490
|
{
|
517
|
-
const xmlChar *result = xmlTextReaderConstNamespaceUri(rxml_text_reader_get(
|
491
|
+
const xmlChar *result = xmlTextReaderConstNamespaceUri(rxml_text_reader_get(
|
492
|
+
self));
|
518
493
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
519
494
|
}
|
520
495
|
|
@@ -524,21 +499,19 @@ rxml_reader_namespace_uri(VALUE self)
|
|
524
499
|
*
|
525
500
|
* Provide the text value of the node if present.
|
526
501
|
*/
|
527
|
-
static VALUE
|
528
|
-
rxml_reader_value(VALUE self)
|
502
|
+
static VALUE rxml_reader_value(VALUE self)
|
529
503
|
{
|
530
504
|
const xmlChar *result = xmlTextReaderConstValue(rxml_text_reader_get(self));
|
531
505
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
532
506
|
}
|
533
507
|
|
534
|
-
/*
|
508
|
+
/*
|
535
509
|
* call-seq:
|
536
510
|
* reader.prefix -> prefix
|
537
511
|
*
|
538
512
|
* Get a shorthand reference to the namespace associated with the node.
|
539
513
|
*/
|
540
|
-
static VALUE
|
541
|
-
rxml_reader_prefix(VALUE self)
|
514
|
+
static VALUE rxml_reader_prefix(VALUE self)
|
542
515
|
{
|
543
516
|
const xmlChar *result = xmlTextReaderConstPrefix(rxml_text_reader_get(self));
|
544
517
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
@@ -550,8 +523,7 @@ rxml_reader_prefix(VALUE self)
|
|
550
523
|
*
|
551
524
|
* Get the depth of the node in the tree.
|
552
525
|
*/
|
553
|
-
static VALUE
|
554
|
-
rxml_reader_depth(VALUE self)
|
526
|
+
static VALUE rxml_reader_depth(VALUE self)
|
555
527
|
{
|
556
528
|
return INT2FIX(xmlTextReaderDepth(rxml_text_reader_get(self)));
|
557
529
|
}
|
@@ -563,8 +535,7 @@ rxml_reader_depth(VALUE self)
|
|
563
535
|
* Get the quotation mark character used to enclose the value of an attribute,
|
564
536
|
* as an integer value (and -1 in case of error).
|
565
537
|
*/
|
566
|
-
static VALUE
|
567
|
-
rxml_reader_quote_char(VALUE self)
|
538
|
+
static VALUE rxml_reader_quote_char(VALUE self)
|
568
539
|
{
|
569
540
|
return INT2FIX(xmlTextReaderQuoteChar(rxml_text_reader_get(self)));
|
570
541
|
}
|
@@ -575,12 +546,11 @@ rxml_reader_quote_char(VALUE self)
|
|
575
546
|
*
|
576
547
|
* Determine the standalone status of the document being read.
|
577
548
|
*
|
578
|
-
* Return 1 if the document was declared to be standalone, 0 if it was
|
579
|
-
* declared to be not standalone, or -1 if the document did not specify its
|
549
|
+
* Return 1 if the document was declared to be standalone, 0 if it was
|
550
|
+
* declared to be not standalone, or -1 if the document did not specify its
|
580
551
|
* standalone status or in case of error.
|
581
552
|
*/
|
582
|
-
static VALUE
|
583
|
-
rxml_reader_standalone(VALUE self)
|
553
|
+
static VALUE rxml_reader_standalone(VALUE self)
|
584
554
|
{
|
585
555
|
return INT2FIX(xmlTextReaderStandalone(rxml_text_reader_get(self)));
|
586
556
|
}
|
@@ -591,8 +561,7 @@ rxml_reader_standalone(VALUE self)
|
|
591
561
|
*
|
592
562
|
* Get the xml:lang scope within which the node resides.
|
593
563
|
*/
|
594
|
-
static VALUE
|
595
|
-
rxml_reader_xml_lang(VALUE self)
|
564
|
+
static VALUE rxml_reader_xml_lang(VALUE self)
|
596
565
|
{
|
597
566
|
const xmlChar *result = xmlTextReaderConstXmlLang(rxml_text_reader_get(self));
|
598
567
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
@@ -604,10 +573,10 @@ rxml_reader_xml_lang(VALUE self)
|
|
604
573
|
*
|
605
574
|
* Determine the XML version of the document being read.
|
606
575
|
*/
|
607
|
-
static VALUE
|
608
|
-
rxml_reader_xml_version(VALUE self)
|
576
|
+
static VALUE rxml_reader_xml_version(VALUE self)
|
609
577
|
{
|
610
|
-
const xmlChar *result = xmlTextReaderConstXmlVersion(rxml_text_reader_get(
|
578
|
+
const xmlChar *result = xmlTextReaderConstXmlVersion(rxml_text_reader_get(
|
579
|
+
self));
|
611
580
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
612
581
|
}
|
613
582
|
|
@@ -617,10 +586,10 @@ rxml_reader_xml_version(VALUE self)
|
|
617
586
|
*
|
618
587
|
* Get whether the node has attributes.
|
619
588
|
*/
|
620
|
-
static VALUE
|
621
|
-
rxml_reader_has_attributes(VALUE self)
|
589
|
+
static VALUE rxml_reader_has_attributes(VALUE self)
|
622
590
|
{
|
623
|
-
return xmlTextReaderHasAttributes(rxml_text_reader_get(self)) ? Qtrue
|
591
|
+
return xmlTextReaderHasAttributes(rxml_text_reader_get(self)) ? Qtrue
|
592
|
+
: Qfalse;
|
624
593
|
}
|
625
594
|
|
626
595
|
/*
|
@@ -629,8 +598,7 @@ rxml_reader_has_attributes(VALUE self)
|
|
629
598
|
*
|
630
599
|
* Get whether the node can have a text value.
|
631
600
|
*/
|
632
|
-
static VALUE
|
633
|
-
rxml_reader_has_value(VALUE self)
|
601
|
+
static VALUE rxml_reader_has_value(VALUE self)
|
634
602
|
{
|
635
603
|
return xmlTextReaderHasValue(rxml_text_reader_get(self)) ? Qtrue : Qfalse;
|
636
604
|
}
|
@@ -639,23 +607,25 @@ rxml_reader_has_value(VALUE self)
|
|
639
607
|
* call-seq:
|
640
608
|
* reader[key] -> value
|
641
609
|
*
|
642
|
-
* Provide the value of the attribute with the specified index (if +key+ is an
|
643
|
-
* integer) or with the specified name (if +key+ is a string) relative to the
|
610
|
+
* Provide the value of the attribute with the specified index (if +key+ is an
|
611
|
+
* integer) or with the specified name (if +key+ is a string) relative to the
|
644
612
|
* containing element, as a string.
|
645
613
|
*/
|
646
|
-
static VALUE
|
647
|
-
rxml_reader_attribute(VALUE self, VALUE key)
|
614
|
+
static VALUE rxml_reader_attribute(VALUE self, VALUE key)
|
648
615
|
{
|
649
616
|
xmlTextReaderPtr reader;
|
650
617
|
xmlChar *attr;
|
651
618
|
|
652
619
|
reader = rxml_text_reader_get(self);
|
653
620
|
|
654
|
-
if (TYPE(key) == T_FIXNUM)
|
621
|
+
if (TYPE(key) == T_FIXNUM)
|
622
|
+
{
|
655
623
|
attr = xmlTextReaderGetAttributeNo(reader, FIX2INT(key));
|
656
624
|
}
|
657
|
-
else
|
658
|
-
|
625
|
+
else
|
626
|
+
{
|
627
|
+
attr = xmlTextReaderGetAttribute(reader, (const xmlChar *) StringValueCStr(
|
628
|
+
key));
|
659
629
|
}
|
660
630
|
return (attr == NULL ? Qnil : rb_str_new2(attr));
|
661
631
|
}
|
@@ -667,10 +637,10 @@ rxml_reader_attribute(VALUE self, VALUE key)
|
|
667
637
|
* Resolve a namespace prefix in the scope of the current element.
|
668
638
|
* To return the default namespace, specify nil as +prefix+.
|
669
639
|
*/
|
670
|
-
static VALUE
|
671
|
-
rxml_reader_lookup_namespace(VALUE self, VALUE prefix)
|
640
|
+
static VALUE rxml_reader_lookup_namespace(VALUE self, VALUE prefix)
|
672
641
|
{
|
673
|
-
const xmlChar *result = xmlTextReaderLookupNamespace(rxml_text_reader_get(
|
642
|
+
const xmlChar *result = xmlTextReaderLookupNamespace(rxml_text_reader_get(
|
643
|
+
self), (const xmlChar *) StringValueCStr(prefix));
|
674
644
|
return (result == NULL ? Qnil : rb_str_new2(result));
|
675
645
|
}
|
676
646
|
|
@@ -678,33 +648,32 @@ rxml_reader_lookup_namespace(VALUE self, VALUE prefix)
|
|
678
648
|
* call-seq:
|
679
649
|
* reader.expand -> node
|
680
650
|
*
|
681
|
-
* Read the contents of the current node and the full subtree. It then makes
|
651
|
+
* Read the contents of the current node and the full subtree. It then makes
|
682
652
|
* the subtree available until the next read call.
|
683
653
|
*
|
684
654
|
* Return an XML::Node object, or nil in case of error.
|
685
655
|
*/
|
686
|
-
static VALUE
|
687
|
-
rxml_reader_expand(VALUE self)
|
656
|
+
static VALUE rxml_reader_expand(VALUE self)
|
688
657
|
{
|
689
658
|
xmlNodePtr node;
|
690
659
|
xmlDocPtr doc;
|
691
660
|
xmlTextReaderPtr reader = rxml_text_reader_get(self);
|
692
661
|
node = xmlTextReaderExpand(reader);
|
693
|
-
|
662
|
+
|
694
663
|
if (!node)
|
695
664
|
return Qnil;
|
696
|
-
|
665
|
+
|
697
666
|
/* Okay this is tricky. By accessing the returned node, we
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
667
|
+
take ownership of the reader's document. Thus we need to
|
668
|
+
tell the reader to not free it. Otherwise it will be
|
669
|
+
freed twice - once when the Ruby document wrapper goes
|
670
|
+
out of scope and once when the reader goes out of scope. */
|
702
671
|
|
703
672
|
xmlTextReaderPreserve(reader);
|
704
673
|
doc = xmlTextReaderCurrentDoc(reader);
|
705
674
|
rxml_document_wrap(doc);
|
706
675
|
|
707
|
-
return
|
676
|
+
return rxml_node_wrap(cXMLNode, node);
|
708
677
|
}
|
709
678
|
|
710
679
|
#if LIBXML_VERSION >= 20618
|
@@ -712,8 +681,8 @@ rxml_reader_expand(VALUE self)
|
|
712
681
|
* call-seq:
|
713
682
|
* reader.byte_consumed -> value
|
714
683
|
*
|
715
|
-
* This method provides the current index of the parser used by the reader,
|
716
|
-
* relative to the start of the current entity.
|
684
|
+
* This method provides the current index of the parser used by the reader,
|
685
|
+
* relative to the start of the current entity.
|
717
686
|
*/
|
718
687
|
static VALUE
|
719
688
|
rxml_reader_byte_consumed(VALUE self)
|
@@ -752,11 +721,10 @@ rxml_reader_line_number(VALUE self)
|
|
752
721
|
* call-seq:
|
753
722
|
* reader.default? -> bool
|
754
723
|
*
|
755
|
-
* Return whether an Attribute node was generated from the default value
|
724
|
+
* Return whether an Attribute node was generated from the default value
|
756
725
|
* defined in the DTD or schema.
|
757
726
|
*/
|
758
|
-
static VALUE
|
759
|
-
rxml_reader_default(VALUE self)
|
727
|
+
static VALUE rxml_reader_default(VALUE self)
|
760
728
|
{
|
761
729
|
return xmlTextReaderIsDefault(rxml_text_reader_get(self)) ? Qtrue : Qfalse;
|
762
730
|
}
|
@@ -765,13 +733,13 @@ rxml_reader_default(VALUE self)
|
|
765
733
|
* call-seq:
|
766
734
|
* reader.namespace_declaration? -> bool
|
767
735
|
*
|
768
|
-
* Determine whether the current node is a namespace declaration rather than a
|
736
|
+
* Determine whether the current node is a namespace declaration rather than a
|
769
737
|
* regular attribute.
|
770
738
|
*/
|
771
|
-
static VALUE
|
772
|
-
rxml_reader_namespace_declaration(VALUE self)
|
739
|
+
static VALUE rxml_reader_namespace_declaration(VALUE self)
|
773
740
|
{
|
774
|
-
return xmlTextReaderIsNamespaceDecl(rxml_text_reader_get(self)) ? Qtrue
|
741
|
+
return xmlTextReaderIsNamespaceDecl(rxml_text_reader_get(self)) ? Qtrue
|
742
|
+
: Qfalse;
|
775
743
|
}
|
776
744
|
|
777
745
|
/*
|
@@ -780,10 +748,10 @@ rxml_reader_namespace_declaration(VALUE self)
|
|
780
748
|
*
|
781
749
|
* Check if the current node is empty.
|
782
750
|
*/
|
783
|
-
static VALUE
|
784
|
-
rxml_reader_empty_element(VALUE self)
|
751
|
+
static VALUE rxml_reader_empty_element(VALUE self)
|
785
752
|
{
|
786
|
-
return xmlTextReaderIsEmptyElement(rxml_text_reader_get(self)) ? Qtrue
|
753
|
+
return xmlTextReaderIsEmptyElement(rxml_text_reader_get(self)) ? Qtrue
|
754
|
+
: Qfalse;
|
787
755
|
}
|
788
756
|
|
789
757
|
/*
|
@@ -792,23 +760,21 @@ rxml_reader_empty_element(VALUE self)
|
|
792
760
|
*
|
793
761
|
* Retrieve the validity status from the parser context.
|
794
762
|
*/
|
795
|
-
static VALUE
|
796
|
-
rxml_reader_valid(VALUE self)
|
763
|
+
static VALUE rxml_reader_valid(VALUE self)
|
797
764
|
{
|
798
765
|
return xmlTextReaderIsValid(rxml_text_reader_get(self)) ? Qtrue : Qfalse;
|
799
766
|
}
|
800
767
|
|
801
|
-
/* Rdoc needs to know. */
|
768
|
+
/* Rdoc needs to know. */
|
802
769
|
#ifdef RDOC_NEVER_DEFINED
|
803
|
-
|
804
|
-
|
770
|
+
mLibXML = rb_define_module("LibXML");
|
771
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
805
772
|
#endif
|
806
773
|
|
807
|
-
void
|
808
|
-
ruby_init_xml_reader(void)
|
774
|
+
void ruby_init_xml_reader(void)
|
809
775
|
{
|
810
776
|
cXMLReader = rb_define_class_under(mXML, "Reader", rb_cObject);
|
811
|
-
|
777
|
+
|
812
778
|
rb_define_singleton_method(cXMLReader, "file", rxml_reader_new_file, -1);
|
813
779
|
rb_define_singleton_method(cXMLReader, "io", rxml_reader_new_io, -1);
|
814
780
|
rb_define_singleton_method(cXMLReader, "walker", rxml_reader_new_walker, 1);
|
@@ -819,23 +785,28 @@ ruby_init_xml_reader(void)
|
|
819
785
|
rb_define_method(cXMLReader, "close", rxml_reader_close, 0);
|
820
786
|
|
821
787
|
rb_define_method(cXMLReader, "move_to_attribute", rxml_reader_move_to_attr, 1);
|
822
|
-
rb_define_method(cXMLReader, "move_to_first_attribute",
|
823
|
-
|
824
|
-
rb_define_method(cXMLReader, "
|
788
|
+
rb_define_method(cXMLReader, "move_to_first_attribute",
|
789
|
+
rxml_reader_move_to_first_attr, 0);
|
790
|
+
rb_define_method(cXMLReader, "move_to_next_attribute",
|
791
|
+
rxml_reader_move_to_next_attr, 0);
|
792
|
+
rb_define_method(cXMLReader, "move_to_element", rxml_reader_move_to_element,
|
793
|
+
0);
|
825
794
|
rb_define_method(cXMLReader, "next", rxml_reader_next, 0);
|
826
795
|
rb_define_method(cXMLReader, "next_sibling", rxml_reader_next_sibling, 0);
|
827
796
|
rb_define_method(cXMLReader, "read", rxml_reader_read, 0);
|
828
|
-
rb_define_method(cXMLReader, "read_attribute_value",
|
797
|
+
rb_define_method(cXMLReader, "read_attribute_value",
|
798
|
+
rxml_reader_read_attr_value, 0);
|
829
799
|
rb_define_method(cXMLReader, "read_inner_xml", rxml_reader_read_inner_xml, 0);
|
830
800
|
rb_define_method(cXMLReader, "read_outer_xml", rxml_reader_read_outer_xml, 0);
|
831
801
|
rb_define_method(cXMLReader, "read_state", rxml_reader_read_state, 0);
|
832
802
|
rb_define_method(cXMLReader, "read_string", rxml_reader_read_string, 0);
|
833
803
|
|
834
|
-
rb_define_method(cXMLReader, "relax_ng_validate",
|
804
|
+
rb_define_method(cXMLReader, "relax_ng_validate",
|
805
|
+
rxml_reader_relax_ng_validate, 1);
|
835
806
|
#if LIBXML_VERSION >= 20620
|
836
807
|
rb_define_method(cXMLReader, "schema_validate", rxml_reader_schema_validate, 1);
|
837
808
|
#endif
|
838
|
-
|
809
|
+
|
839
810
|
rb_define_method(cXMLReader, "node_type", rxml_reader_node_type, 0);
|
840
811
|
rb_define_method(cXMLReader, "normalization", rxml_reader_normalization, 0);
|
841
812
|
rb_define_method(cXMLReader, "attribute_count", rxml_reader_attr_count, 0);
|
@@ -848,15 +819,16 @@ ruby_init_xml_reader(void)
|
|
848
819
|
rb_define_method(cXMLReader, "xml_version", rxml_reader_xml_version, 0);
|
849
820
|
rb_define_method(cXMLReader, "prefix", rxml_reader_prefix, 0);
|
850
821
|
rb_define_method(cXMLReader, "depth", rxml_reader_depth, 0);
|
851
|
-
rb_define_method(cXMLReader, "quote_char", rxml_reader_quote_char, 0);
|
822
|
+
rb_define_method(cXMLReader, "quote_char", rxml_reader_quote_char, 0);
|
852
823
|
rb_define_method(cXMLReader, "standalone", rxml_reader_standalone, 0);
|
853
|
-
|
824
|
+
|
854
825
|
rb_define_method(cXMLReader, "has_attributes?", rxml_reader_has_attributes, 0);
|
855
826
|
rb_define_method(cXMLReader, "[]", rxml_reader_attribute, 1);
|
856
827
|
rb_define_method(cXMLReader, "has_value?", rxml_reader_has_value, 0);
|
857
828
|
rb_define_method(cXMLReader, "value", rxml_reader_value, 0);
|
858
829
|
|
859
|
-
rb_define_method(cXMLReader, "lookup_namespace",
|
830
|
+
rb_define_method(cXMLReader, "lookup_namespace",
|
831
|
+
rxml_reader_lookup_namespace, 1);
|
860
832
|
rb_define_method(cXMLReader, "expand", rxml_reader_expand, 0);
|
861
833
|
|
862
834
|
#if LIBXML_VERSION >= 20618
|
@@ -868,43 +840,65 @@ ruby_init_xml_reader(void)
|
|
868
840
|
#endif
|
869
841
|
rb_define_method(cXMLReader, "default?", rxml_reader_default, 0);
|
870
842
|
rb_define_method(cXMLReader, "empty_element?", rxml_reader_empty_element, 0);
|
871
|
-
rb_define_method(cXMLReader, "namespace_declaration?",
|
843
|
+
rb_define_method(cXMLReader, "namespace_declaration?",
|
844
|
+
rxml_reader_namespace_declaration, 0);
|
872
845
|
rb_define_method(cXMLReader, "valid?", rxml_reader_valid, 0);
|
873
846
|
|
874
847
|
rb_define_const(cXMLReader, "LOADDTD", INT2FIX(XML_PARSER_LOADDTD));
|
875
848
|
rb_define_const(cXMLReader, "DEFAULTATTRS", INT2FIX(XML_PARSER_DEFAULTATTRS));
|
876
849
|
rb_define_const(cXMLReader, "VALIDATE", INT2FIX(XML_PARSER_VALIDATE));
|
877
|
-
rb_define_const(cXMLReader, "SUBST_ENTITIES", INT2FIX(
|
878
|
-
|
879
|
-
|
880
|
-
rb_define_const(cXMLReader, "
|
881
|
-
|
882
|
-
rb_define_const(cXMLReader, "
|
850
|
+
rb_define_const(cXMLReader, "SUBST_ENTITIES", INT2FIX(
|
851
|
+
XML_PARSER_SUBST_ENTITIES));
|
852
|
+
|
853
|
+
rb_define_const(cXMLReader, "SEVERITY_VALIDITY_WARNING", INT2FIX(
|
854
|
+
XML_PARSER_SEVERITY_VALIDITY_WARNING));
|
855
|
+
rb_define_const(cXMLReader, "SEVERITY_VALIDITY_ERROR", INT2FIX(
|
856
|
+
XML_PARSER_SEVERITY_VALIDITY_ERROR));
|
857
|
+
rb_define_const(cXMLReader, "SEVERITY_WARNING", INT2FIX(
|
858
|
+
XML_PARSER_SEVERITY_WARNING));
|
859
|
+
rb_define_const(cXMLReader, "SEVERITY_ERROR", INT2FIX(
|
860
|
+
XML_PARSER_SEVERITY_ERROR));
|
883
861
|
|
884
862
|
rb_define_const(cXMLReader, "TYPE_NONE", INT2FIX(XML_READER_TYPE_NONE));
|
885
863
|
rb_define_const(cXMLReader, "TYPE_ELEMENT", INT2FIX(XML_READER_TYPE_ELEMENT));
|
886
|
-
rb_define_const(cXMLReader, "TYPE_ATTRIBUTE", INT2FIX(
|
864
|
+
rb_define_const(cXMLReader, "TYPE_ATTRIBUTE", INT2FIX(
|
865
|
+
XML_READER_TYPE_ATTRIBUTE));
|
887
866
|
rb_define_const(cXMLReader, "TYPE_TEXT", INT2FIX(XML_READER_TYPE_TEXT));
|
888
867
|
rb_define_const(cXMLReader, "TYPE_CDATA", INT2FIX(XML_READER_TYPE_CDATA));
|
889
|
-
rb_define_const(cXMLReader, "TYPE_ENTITY_REFERENCE", INT2FIX(
|
868
|
+
rb_define_const(cXMLReader, "TYPE_ENTITY_REFERENCE", INT2FIX(
|
869
|
+
XML_READER_TYPE_ENTITY_REFERENCE));
|
890
870
|
rb_define_const(cXMLReader, "TYPE_ENTITY", INT2FIX(XML_READER_TYPE_ENTITY));
|
891
|
-
rb_define_const(cXMLReader, "TYPE_PROCESSING_INSTRUCTION", INT2FIX(
|
871
|
+
rb_define_const(cXMLReader, "TYPE_PROCESSING_INSTRUCTION", INT2FIX(
|
872
|
+
XML_READER_TYPE_PROCESSING_INSTRUCTION));
|
892
873
|
rb_define_const(cXMLReader, "TYPE_COMMENT", INT2FIX(XML_READER_TYPE_COMMENT));
|
893
|
-
rb_define_const(cXMLReader, "TYPE_DOCUMENT",
|
894
|
-
|
895
|
-
rb_define_const(cXMLReader, "
|
896
|
-
|
897
|
-
rb_define_const(cXMLReader, "
|
898
|
-
|
899
|
-
rb_define_const(cXMLReader, "
|
900
|
-
|
901
|
-
rb_define_const(cXMLReader, "
|
874
|
+
rb_define_const(cXMLReader, "TYPE_DOCUMENT",
|
875
|
+
INT2FIX(XML_READER_TYPE_DOCUMENT));
|
876
|
+
rb_define_const(cXMLReader, "TYPE_DOCUMENT_TYPE", INT2FIX(
|
877
|
+
XML_READER_TYPE_DOCUMENT_TYPE));
|
878
|
+
rb_define_const(cXMLReader, "TYPE_DOCUMENT_FRAGMENT", INT2FIX(
|
879
|
+
XML_READER_TYPE_DOCUMENT_FRAGMENT));
|
880
|
+
rb_define_const(cXMLReader, "TYPE_NOTATION",
|
881
|
+
INT2FIX(XML_READER_TYPE_NOTATION));
|
882
|
+
rb_define_const(cXMLReader, "TYPE_WHITESPACE", INT2FIX(
|
883
|
+
XML_READER_TYPE_WHITESPACE));
|
884
|
+
rb_define_const(cXMLReader, "TYPE_SIGNIFICANT_WHITESPACE", INT2FIX(
|
885
|
+
XML_READER_TYPE_SIGNIFICANT_WHITESPACE));
|
886
|
+
rb_define_const(cXMLReader, "TYPE_END_ELEMENT", INT2FIX(
|
887
|
+
XML_READER_TYPE_END_ELEMENT));
|
888
|
+
rb_define_const(cXMLReader, "TYPE_END_ENTITY", INT2FIX(
|
889
|
+
XML_READER_TYPE_END_ENTITY));
|
890
|
+
rb_define_const(cXMLReader, "TYPE_XML_DECLARATION", INT2FIX(
|
891
|
+
XML_READER_TYPE_XML_DECLARATION));
|
902
892
|
|
903
893
|
/* Read states */
|
904
|
-
rb_define_const(cXMLReader, "MODE_INITIAL", INT2FIX(
|
905
|
-
|
894
|
+
rb_define_const(cXMLReader, "MODE_INITIAL", INT2FIX(
|
895
|
+
XML_TEXTREADER_MODE_INITIAL));
|
896
|
+
rb_define_const(cXMLReader, "MODE_INTERACTIVE", INT2FIX(
|
897
|
+
XML_TEXTREADER_MODE_INTERACTIVE));
|
906
898
|
rb_define_const(cXMLReader, "MODE_ERROR", INT2FIX(XML_TEXTREADER_MODE_ERROR));
|
907
899
|
rb_define_const(cXMLReader, "MODE_EOF", INT2FIX(XML_TEXTREADER_MODE_EOF));
|
908
|
-
rb_define_const(cXMLReader, "MODE_CLOSED",
|
909
|
-
|
900
|
+
rb_define_const(cXMLReader, "MODE_CLOSED",
|
901
|
+
INT2FIX(XML_TEXTREADER_MODE_CLOSED));
|
902
|
+
rb_define_const(cXMLReader, "MODE_READING", INT2FIX(
|
903
|
+
XML_TEXTREADER_MODE_READING));
|
910
904
|
}
|