libxml-ruby 0.6.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +122 -0
- data/LICENSE +23 -0
- data/README +144 -0
- data/ext/libxml/cbg.c +76 -0
- data/ext/libxml/extconf.rb +308 -0
- data/ext/libxml/libxml.c +62 -0
- data/ext/libxml/ruby_libxml.h +93 -0
- data/ext/libxml/ruby_xml_attr.c +405 -0
- data/ext/libxml/ruby_xml_attr.h +19 -0
- data/ext/libxml/ruby_xml_document.c +1111 -0
- data/ext/libxml/ruby_xml_document.h +27 -0
- data/ext/libxml/ruby_xml_dtd.c +168 -0
- data/ext/libxml/ruby_xml_dtd.h +17 -0
- data/ext/libxml/ruby_xml_html_parser.c +449 -0
- data/ext/libxml/ruby_xml_html_parser.h +29 -0
- data/ext/libxml/ruby_xml_input_cbg.c +158 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -0
- data/ext/libxml/ruby_xml_node.c +2410 -0
- data/ext/libxml/ruby_xml_node.h +27 -0
- data/ext/libxml/ruby_xml_node_set.c +170 -0
- data/ext/libxml/ruby_xml_node_set.h +20 -0
- data/ext/libxml/ruby_xml_ns.c +153 -0
- data/ext/libxml/ruby_xml_ns.h +21 -0
- data/ext/libxml/ruby_xml_parser.c +1425 -0
- data/ext/libxml/ruby_xml_parser.h +31 -0
- data/ext/libxml/ruby_xml_parser_context.c +750 -0
- data/ext/libxml/ruby_xml_parser_context.h +22 -0
- data/ext/libxml/ruby_xml_reader.c +900 -0
- data/ext/libxml/ruby_xml_reader.h +14 -0
- data/ext/libxml/ruby_xml_sax_parser.c +485 -0
- data/ext/libxml/ruby_xml_sax_parser.h +56 -0
- data/ext/libxml/ruby_xml_schema.c +146 -0
- data/ext/libxml/ruby_xml_schema.h +16 -0
- data/ext/libxml/ruby_xml_state.c +113 -0
- data/ext/libxml/ruby_xml_state.h +12 -0
- data/ext/libxml/ruby_xml_tree.c +43 -0
- data/ext/libxml/ruby_xml_tree.h +12 -0
- data/ext/libxml/ruby_xml_xinclude.c +20 -0
- data/ext/libxml/ruby_xml_xinclude.h +13 -0
- data/ext/libxml/ruby_xml_xpath.c +243 -0
- data/ext/libxml/ruby_xml_xpath.h +23 -0
- data/ext/libxml/ruby_xml_xpath_context.c +118 -0
- data/ext/libxml/ruby_xml_xpath_context.h +20 -0
- data/ext/libxml/ruby_xml_xpath_object.c +293 -0
- data/ext/libxml/ruby_xml_xpath_object.h +28 -0
- data/ext/libxml/ruby_xml_xpointer.c +100 -0
- data/ext/libxml/ruby_xml_xpointer.h +27 -0
- data/ext/libxml/ruby_xml_xpointer_context.c +21 -0
- data/ext/libxml/ruby_xml_xpointer_context.h +18 -0
- data/ext/libxml/sax_parser_callbacks.inc +213 -0
- data/ext/libxml/version.h +9 -0
- data/lib/libxml.rb +125 -0
- data/lib/libxml_ruby.so +0 -0
- data/lib/xml/libxml.rb +5 -0
- data/mingw/libiconv-2.dll +0 -0
- data/mingw/libxml2-2.dll +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/mingw/mingw.rake +36 -0
- data/test/dtd-test.rb +24 -0
- data/test/etc_doc_to_s.rb +19 -0
- data/test/ets_copy_bug.rb +21 -0
- data/test/ets_copy_bug2.rb +32 -0
- data/test/ets_copy_bug3.rb +38 -0
- data/test/ets_doc_file.rb +15 -0
- data/test/ets_doc_to_s.rb +21 -0
- data/test/ets_gpx.rb +26 -0
- data/test/ets_node_gc.rb +21 -0
- data/test/ets_test.xml +2 -0
- data/test/ets_tsr.rb +9 -0
- data/test/gc.log +0 -0
- data/test/merge_bug.rb +55 -0
- data/test/schema-test.rb +74 -0
- data/test/tc_well_formed.rb +11 -0
- data/test/tc_xml_document.rb +52 -0
- data/test/tc_xml_document_write.rb +24 -0
- data/test/tc_xml_document_write2.rb +54 -0
- data/test/tc_xml_document_write3.rb +96 -0
- data/test/tc_xml_html_parser.rb +63 -0
- data/test/tc_xml_node.rb +59 -0
- data/test/tc_xml_node2.rb +25 -0
- data/test/tc_xml_node3.rb +27 -0
- data/test/tc_xml_node4.rb +86 -0
- data/test/tc_xml_node5.rb +52 -0
- data/test/tc_xml_node6.rb +27 -0
- data/test/tc_xml_node7.rb +35 -0
- data/test/tc_xml_node8.rb +32 -0
- data/test/tc_xml_node9.rb +32 -0
- data/test/tc_xml_node_copy.rb +40 -0
- data/test/tc_xml_node_set.rb +24 -0
- data/test/tc_xml_node_set2.rb +37 -0
- data/test/tc_xml_node_text.rb +17 -0
- data/test/tc_xml_node_xlink.rb +28 -0
- data/test/tc_xml_parser.rb +190 -0
- data/test/tc_xml_parser2.rb +16 -0
- data/test/tc_xml_parser3.rb +23 -0
- data/test/tc_xml_parser4.rb +33 -0
- data/test/tc_xml_parser5.rb +27 -0
- data/test/tc_xml_parser6.rb +23 -0
- data/test/tc_xml_parser7.rb +28 -0
- data/test/tc_xml_parser8.rb +32 -0
- data/test/tc_xml_parser9.rb +11 -0
- data/test/tc_xml_parser_context.rb +88 -0
- data/test/tc_xml_reader.rb +112 -0
- data/test/tc_xml_sax_parser.rb +104 -0
- data/test/tc_xml_sax_parser2.rb +51 -0
- data/test/tc_xml_xinclude.rb +30 -0
- data/test/tc_xml_xpath.rb +38 -0
- data/test/tc_xml_xpath2.rb +14 -0
- data/test/tc_xml_xpointer.rb +78 -0
- data/vc/libxml.sln +20 -0
- data/vc/libxml.vcproj +389 -0
- data/work/Rakefile +247 -0
- data/work/task/make +26 -0
- data/work/task/memory +37 -0
- data/work/task/rdoc +39 -0
- data/work/task/setup +1616 -0
- data/work/task/test +29 -0
- data/work/test/ets_runner.rb +33 -0
- data/work/test/libxml_test.rb +3 -0
- data/work/test/runner.rb +0 -0
- data/work/test/runner_ets.rb +33 -0
- data/work/vc/debug/libxml.exp +0 -0
- data/work/vc/debug/libxml.ilk +0 -0
- data/work/vc/debug/libxml.lib +0 -0
- data/work/vc/debug/libxml.pdb +0 -0
- data/work/vc/debug/libxml.so +0 -0
- metadata +224 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
/* $Id: ruby_xml_parser_context.h 39 2006-02-21 20:40:16Z roscopeco $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_PARSER_CONTEXT__
|
6
|
+
#define __RUBY_XML_PARSER_CONTEXT__
|
7
|
+
|
8
|
+
extern VALUE cXMLParserContext;
|
9
|
+
|
10
|
+
typedef struct ruby_xml_parser_context {
|
11
|
+
xmlParserCtxtPtr ctxt;
|
12
|
+
int is_ptr;
|
13
|
+
} ruby_xml_parser_context;
|
14
|
+
|
15
|
+
void ruby_xml_parser_context_free(ruby_xml_parser_context *ctxt);
|
16
|
+
void ruby_init_xml_parser_context(void);
|
17
|
+
VALUE ruby_xml_parser_context_new(VALUE class, xmlParserCtxtPtr ctxt);
|
18
|
+
VALUE ruby_xml_parser_context_new2(VALUE class);
|
19
|
+
VALUE ruby_xml_parser_context_new3();
|
20
|
+
VALUE ruby_xml_parser_context_each(VALUE self);
|
21
|
+
|
22
|
+
#endif
|
@@ -0,0 +1,900 @@
|
|
1
|
+
/* Copyright (c) 2006-2007 Apple Inc.
|
2
|
+
* Please see the LICENSE file for copyright and distribution information. */
|
3
|
+
|
4
|
+
#include "ruby_libxml.h"
|
5
|
+
#include "ruby_xml_reader.h"
|
6
|
+
|
7
|
+
#define CSTR2RVAL(x) (x == NULL ? Qnil : rb_str_new2((const char *)x))
|
8
|
+
#define RVAL2CSTR(x) (StringValueCStr(x))
|
9
|
+
|
10
|
+
static inline VALUE
|
11
|
+
__rb_str_new_and_free(xmlChar *x)
|
12
|
+
{
|
13
|
+
if (x != NULL) {
|
14
|
+
VALUE v = rb_str_new2((const char *)x);
|
15
|
+
xmlFree(x);
|
16
|
+
return v;
|
17
|
+
}
|
18
|
+
return Qnil;
|
19
|
+
}
|
20
|
+
|
21
|
+
#define CSTR2RVAL2(x) (__rb_str_new_and_free(x))
|
22
|
+
|
23
|
+
VALUE cXMLReader;
|
24
|
+
static ID error_handler_block_ivar_id;
|
25
|
+
|
26
|
+
static VALUE
|
27
|
+
ruby_xml_reader_new(VALUE class, xmlTextReaderPtr reader)
|
28
|
+
{
|
29
|
+
return Data_Wrap_Struct(class, NULL, xmlFreeTextReader, reader);
|
30
|
+
}
|
31
|
+
|
32
|
+
static xmlTextReaderPtr
|
33
|
+
ruby_xml_text_reader_get(VALUE obj)
|
34
|
+
{
|
35
|
+
xmlTextReaderPtr ptr;
|
36
|
+
Data_Get_Struct(obj, xmlTextReader, ptr);
|
37
|
+
return ptr;
|
38
|
+
}
|
39
|
+
|
40
|
+
/*
|
41
|
+
* call-seq:
|
42
|
+
* XML::Reader.file(path, encoding=nil, options=0) -> reader
|
43
|
+
*
|
44
|
+
* Parse an XML file from the filesystem or the network. The parsing flags
|
45
|
+
* options are a combination of xmlParserOption.
|
46
|
+
*/
|
47
|
+
static VALUE
|
48
|
+
ruby_xml_reader_new_file(int argc, VALUE *argv, VALUE self)
|
49
|
+
{
|
50
|
+
xmlTextReaderPtr reader;
|
51
|
+
VALUE path, encoding, options;
|
52
|
+
|
53
|
+
rb_scan_args(argc, argv, "12", &path, &encoding, &options);
|
54
|
+
|
55
|
+
reader = xmlReaderForFile(RVAL2CSTR(path),
|
56
|
+
NIL_P(encoding) ? NULL : RVAL2CSTR(encoding),
|
57
|
+
NIL_P(options) ? 0 : FIX2INT(options));
|
58
|
+
if (reader == NULL)
|
59
|
+
rb_raise(rb_eRuntimeError,
|
60
|
+
"cannot create text reader for given XML file at path '%s'",
|
61
|
+
RVAL2CSTR(path));
|
62
|
+
|
63
|
+
return ruby_xml_reader_new(self, reader);
|
64
|
+
}
|
65
|
+
|
66
|
+
/*
|
67
|
+
* call-seq:
|
68
|
+
* XML::Reader.walker(doc) -> reader
|
69
|
+
* XML::Reader.document(doc) -> reader
|
70
|
+
*
|
71
|
+
* Create an XML text reader for a preparsed document.
|
72
|
+
*/
|
73
|
+
VALUE
|
74
|
+
ruby_xml_reader_new_walker(VALUE self, VALUE doc)
|
75
|
+
{
|
76
|
+
ruby_xml_document_t *rxd;
|
77
|
+
xmlTextReaderPtr reader;
|
78
|
+
|
79
|
+
Data_Get_Struct(doc, ruby_xml_document_t, rxd);
|
80
|
+
|
81
|
+
reader = xmlReaderWalker(rxd->doc);
|
82
|
+
if (reader == NULL)
|
83
|
+
rb_raise(rb_eRuntimeError, "cannot create text reader for given document");
|
84
|
+
|
85
|
+
return ruby_xml_reader_new(self, reader);
|
86
|
+
}
|
87
|
+
|
88
|
+
/*
|
89
|
+
* call-seq:
|
90
|
+
* XML::Reader.new(data, url=nil, encoding=nil, options=0) -> reader
|
91
|
+
* XML::Reader.string(data, url=nil, encoding=nil, options=0) -> reader
|
92
|
+
*
|
93
|
+
* Create an XML text reader for an XML in-memory document. The parsing flags
|
94
|
+
* options are a combination of xmlParserOption.
|
95
|
+
*/
|
96
|
+
static VALUE
|
97
|
+
ruby_xml_reader_new_data(int argc, VALUE *argv, VALUE self)
|
98
|
+
{
|
99
|
+
xmlTextReaderPtr reader;
|
100
|
+
VALUE data, url, encoding, options;
|
101
|
+
char *c_data;
|
102
|
+
|
103
|
+
rb_scan_args(argc, argv, "13", &data, &url, &encoding, &options);
|
104
|
+
|
105
|
+
c_data = RVAL2CSTR(data);
|
106
|
+
reader = xmlReaderForMemory(c_data,
|
107
|
+
strlen(c_data),
|
108
|
+
NIL_P(url) ? NULL : RVAL2CSTR(url),
|
109
|
+
NIL_P(encoding) ? NULL : RVAL2CSTR(encoding),
|
110
|
+
NIL_P(options) ? 0 : FIX2INT(options));
|
111
|
+
if (reader == NULL)
|
112
|
+
rb_raise(rb_eRuntimeError, "cannot create text reader for given data");
|
113
|
+
|
114
|
+
return ruby_xml_reader_new(self, reader);
|
115
|
+
}
|
116
|
+
|
117
|
+
/*
|
118
|
+
* call-seq:
|
119
|
+
* parser.close -> code
|
120
|
+
*
|
121
|
+
* This method releases any resources allocated by the current instance
|
122
|
+
* changes the state to Closed and close any underlying input.
|
123
|
+
*/
|
124
|
+
static VALUE
|
125
|
+
ruby_xml_reader_close(VALUE self)
|
126
|
+
{
|
127
|
+
return INT2FIX(xmlTextReaderClose(ruby_xml_text_reader_get(self)));
|
128
|
+
}
|
129
|
+
|
130
|
+
/*
|
131
|
+
* call-seq:
|
132
|
+
* parser.move_to_attribute(val) -> code
|
133
|
+
*
|
134
|
+
* Move the position of the current instance to the attribute with the
|
135
|
+
* specified index (if +val+ is an integer) or name (if +val+ is a string)
|
136
|
+
* relative to the containing element.
|
137
|
+
*/
|
138
|
+
static VALUE
|
139
|
+
ruby_xml_reader_move_to_attr(VALUE self, VALUE val)
|
140
|
+
{
|
141
|
+
xmlTextReaderPtr reader;
|
142
|
+
int ret;
|
143
|
+
|
144
|
+
reader = ruby_xml_text_reader_get(self);
|
145
|
+
|
146
|
+
if (TYPE(val) == T_FIXNUM) {
|
147
|
+
ret = xmlTextReaderMoveToAttributeNo(reader, FIX2INT(val));
|
148
|
+
}
|
149
|
+
else {
|
150
|
+
ret = xmlTextReaderMoveToAttribute(reader, (const xmlChar *)RVAL2CSTR(val));
|
151
|
+
}
|
152
|
+
|
153
|
+
return INT2FIX(ret);
|
154
|
+
}
|
155
|
+
|
156
|
+
/*
|
157
|
+
* call-seq:
|
158
|
+
* reader.move_to_first_attribute -> code
|
159
|
+
*
|
160
|
+
* Move the position of the current instance to the first attribute associated
|
161
|
+
* with the current node.
|
162
|
+
*/
|
163
|
+
static VALUE
|
164
|
+
ruby_xml_reader_move_to_first_attr(VALUE self)
|
165
|
+
{
|
166
|
+
return INT2FIX(xmlTextReaderMoveToFirstAttribute(ruby_xml_text_reader_get(self)));
|
167
|
+
}
|
168
|
+
|
169
|
+
/*
|
170
|
+
* call-seq:
|
171
|
+
* reader.move_to_next_attribute -> code
|
172
|
+
*
|
173
|
+
* Move the position of the current instance to the next attribute associated
|
174
|
+
* with the current node.
|
175
|
+
*/
|
176
|
+
static VALUE
|
177
|
+
ruby_xml_reader_move_to_next_attr(VALUE self)
|
178
|
+
{
|
179
|
+
return INT2FIX(xmlTextReaderMoveToNextAttribute(ruby_xml_text_reader_get(self)));
|
180
|
+
}
|
181
|
+
|
182
|
+
/*
|
183
|
+
* call-seq:
|
184
|
+
* reader.move_to_element -> code
|
185
|
+
*
|
186
|
+
* Move the position of the current instance to the node that contains the
|
187
|
+
* current attribute node.
|
188
|
+
*/
|
189
|
+
static VALUE
|
190
|
+
ruby_xml_reader_move_to_element(VALUE self)
|
191
|
+
{
|
192
|
+
return INT2FIX(xmlTextReaderMoveToElement(ruby_xml_text_reader_get(self)));
|
193
|
+
}
|
194
|
+
|
195
|
+
/*
|
196
|
+
* call-seq:
|
197
|
+
* reader.next -> code
|
198
|
+
*
|
199
|
+
* Skip to the node following the current one in document order while avoiding
|
200
|
+
* the subtree if any.
|
201
|
+
*/
|
202
|
+
static VALUE
|
203
|
+
ruby_xml_reader_next(VALUE self)
|
204
|
+
{
|
205
|
+
return INT2FIX(xmlTextReaderNext(ruby_xml_text_reader_get(self)));
|
206
|
+
}
|
207
|
+
|
208
|
+
/*
|
209
|
+
* call-seq:
|
210
|
+
* reader.next_sibling -> code
|
211
|
+
*
|
212
|
+
* Skip to the node following the current one in document order while avoiding
|
213
|
+
* the subtree if any. Currently implemented only for Readers built on a
|
214
|
+
* document.
|
215
|
+
*/
|
216
|
+
static VALUE
|
217
|
+
ruby_xml_reader_next_sibling(VALUE self)
|
218
|
+
{
|
219
|
+
return INT2FIX(xmlTextReaderNextSibling(ruby_xml_text_reader_get(self)));
|
220
|
+
}
|
221
|
+
|
222
|
+
/*
|
223
|
+
* call-seq:
|
224
|
+
* reader.node_type -> type
|
225
|
+
*
|
226
|
+
* Get the node type of the current node. Reference:
|
227
|
+
* http://dotgnu.org/pnetlib-doc/System/Xml/XmlNodeType.html
|
228
|
+
*/
|
229
|
+
static VALUE
|
230
|
+
ruby_xml_reader_node_type(VALUE self)
|
231
|
+
{
|
232
|
+
return INT2FIX(xmlTextReaderNodeType(ruby_xml_text_reader_get(self)));
|
233
|
+
}
|
234
|
+
|
235
|
+
/*
|
236
|
+
* call-seq:
|
237
|
+
* reader.normalization -> value
|
238
|
+
*
|
239
|
+
* The value indicating whether to normalize white space and attribute values.
|
240
|
+
* Since attribute value and end of line normalizations are a MUST in the XML
|
241
|
+
* specification only the value true is accepted. The broken bahaviour of
|
242
|
+
* accepting out of range character entities like � is of course not
|
243
|
+
* supported either.
|
244
|
+
*
|
245
|
+
* Return 1 or -1 in case of error.
|
246
|
+
*/
|
247
|
+
static VALUE
|
248
|
+
ruby_xml_reader_normalization(VALUE self)
|
249
|
+
{
|
250
|
+
return INT2FIX(xmlTextReaderNormalization(ruby_xml_text_reader_get(self)));
|
251
|
+
}
|
252
|
+
|
253
|
+
/*
|
254
|
+
* call-seq:
|
255
|
+
* reader.read -> code
|
256
|
+
*
|
257
|
+
* Move the position of the current instance to the next node in the stream,
|
258
|
+
* exposing its properties.
|
259
|
+
*
|
260
|
+
* Return 1 if the node was read successfully, 0 if there is no more nodes to
|
261
|
+
* read, or -1 in case of error.
|
262
|
+
*/
|
263
|
+
static VALUE
|
264
|
+
ruby_xml_reader_read(VALUE self)
|
265
|
+
{
|
266
|
+
return INT2FIX(xmlTextReaderRead(ruby_xml_text_reader_get(self)));
|
267
|
+
}
|
268
|
+
|
269
|
+
/*
|
270
|
+
* call-seq:
|
271
|
+
* reader.read_attribute_value -> code
|
272
|
+
*
|
273
|
+
* Parse an attribute value into one or more Text and EntityReference nodes.
|
274
|
+
*
|
275
|
+
* Return 1 in case of success, 0 if the reader was not positionned on an
|
276
|
+
* attribute node or all the attribute values have been read, or -1 in case of
|
277
|
+
* error.
|
278
|
+
*/
|
279
|
+
static VALUE
|
280
|
+
ruby_xml_reader_read_attr_value(VALUE self)
|
281
|
+
{
|
282
|
+
return INT2FIX(xmlTextReaderReadAttributeValue(ruby_xml_text_reader_get(self)));
|
283
|
+
}
|
284
|
+
|
285
|
+
/*
|
286
|
+
* call-seq:
|
287
|
+
* reader.read_inner_xml -> data
|
288
|
+
*
|
289
|
+
* Read the contents of the current node, including child nodes and markup.
|
290
|
+
*
|
291
|
+
* Return a string containing the XML content, or nil if the current node is
|
292
|
+
* neither an element nor attribute, or has no child nodes.
|
293
|
+
*/
|
294
|
+
static VALUE
|
295
|
+
ruby_xml_reader_read_inner_xml(VALUE self)
|
296
|
+
{
|
297
|
+
return CSTR2RVAL2(xmlTextReaderReadInnerXml(ruby_xml_text_reader_get(self)));
|
298
|
+
}
|
299
|
+
|
300
|
+
/*
|
301
|
+
* call-seq:
|
302
|
+
* reader.read_outer_xml -> data
|
303
|
+
*
|
304
|
+
* Read the contents of the current node, including child nodes and markup.
|
305
|
+
*
|
306
|
+
* Return a string containing the XML content, or nil if the current node is
|
307
|
+
* neither an element nor attribute, or has no child nodes.
|
308
|
+
*/
|
309
|
+
static VALUE
|
310
|
+
ruby_xml_reader_read_outer_xml(VALUE self)
|
311
|
+
{
|
312
|
+
return CSTR2RVAL2(xmlTextReaderReadOuterXml(ruby_xml_text_reader_get(self)));
|
313
|
+
}
|
314
|
+
|
315
|
+
/*
|
316
|
+
* call-seq:
|
317
|
+
* reader.read_state -> state
|
318
|
+
*
|
319
|
+
* Get the read state of the reader.
|
320
|
+
*/
|
321
|
+
static VALUE
|
322
|
+
ruby_xml_reader_read_state(VALUE self)
|
323
|
+
{
|
324
|
+
return INT2FIX(xmlTextReaderReadState(ruby_xml_text_reader_get(self)));
|
325
|
+
}
|
326
|
+
|
327
|
+
/*
|
328
|
+
* call-seq:
|
329
|
+
* reader.read_string -> string
|
330
|
+
*
|
331
|
+
* Read the contents of an element or a text node as a string.
|
332
|
+
*
|
333
|
+
* Return a string containing the contents of the Element or Text node, or nil
|
334
|
+
* if the reader is positioned on any other type of node.
|
335
|
+
*/
|
336
|
+
static VALUE
|
337
|
+
ruby_xml_reader_read_string(VALUE self)
|
338
|
+
{
|
339
|
+
return CSTR2RVAL2(xmlTextReaderReadString(ruby_xml_text_reader_get(self)));
|
340
|
+
}
|
341
|
+
|
342
|
+
static void
|
343
|
+
__xml_reader_error_cb(void *arg,
|
344
|
+
const char *msg, xmlParserSeverities severity,
|
345
|
+
xmlTextReaderLocatorPtr locator)
|
346
|
+
{
|
347
|
+
VALUE reader;
|
348
|
+
VALUE block;
|
349
|
+
|
350
|
+
reader = (VALUE)arg;
|
351
|
+
block = rb_ivar_get(reader, error_handler_block_ivar_id);
|
352
|
+
if (NIL_P(block))
|
353
|
+
rb_bug("no ivar block");
|
354
|
+
|
355
|
+
rb_funcall(block,
|
356
|
+
rb_intern("call"),
|
357
|
+
5,
|
358
|
+
reader,
|
359
|
+
CSTR2RVAL(msg),
|
360
|
+
INT2FIX(severity),
|
361
|
+
CSTR2RVAL2(xmlTextReaderLocatorBaseURI(locator)),
|
362
|
+
INT2FIX(xmlTextReaderLocatorLineNumber(locator)));
|
363
|
+
}
|
364
|
+
|
365
|
+
/*
|
366
|
+
* call-seq:
|
367
|
+
* reader.set_error_handler { ... }
|
368
|
+
*
|
369
|
+
* Register a callback block that will be called on error and warnings. The
|
370
|
+
* block will be called with 5 parameters: the reader, the error message, the
|
371
|
+
* severity, the base URI and the line number.
|
372
|
+
*/
|
373
|
+
static VALUE
|
374
|
+
ruby_xml_reader_set_error_handler(VALUE self)
|
375
|
+
{
|
376
|
+
VALUE block;
|
377
|
+
xmlTextReaderPtr reader;
|
378
|
+
|
379
|
+
if (rb_block_given_p() == Qfalse)
|
380
|
+
rb_raise(rb_eRuntimeError, "No block given");
|
381
|
+
|
382
|
+
block = rb_block_proc();
|
383
|
+
|
384
|
+
/* Embed the block within the parser object to avoid it to be collected.
|
385
|
+
* Previous handler if exits is overwritten.
|
386
|
+
*/
|
387
|
+
rb_ivar_set(self, error_handler_block_ivar_id, block);
|
388
|
+
reader = ruby_xml_text_reader_get(self);
|
389
|
+
xmlTextReaderSetErrorHandler(reader, __xml_reader_error_cb, (void *)self);
|
390
|
+
|
391
|
+
return self;
|
392
|
+
}
|
393
|
+
|
394
|
+
/*
|
395
|
+
* call-seq:
|
396
|
+
* reader.reset_error_handler
|
397
|
+
*
|
398
|
+
* Restore the default error and warning handlers.
|
399
|
+
*/
|
400
|
+
static VALUE
|
401
|
+
ruby_xml_reader_reset_error_handler(VALUE self)
|
402
|
+
{
|
403
|
+
xmlTextReaderSetErrorHandler(ruby_xml_text_reader_get(self), NULL, NULL);
|
404
|
+
return self;
|
405
|
+
}
|
406
|
+
|
407
|
+
/*
|
408
|
+
* call-seq:
|
409
|
+
* reader.relax_ng_validate(rng) -> code
|
410
|
+
*
|
411
|
+
* Use RelaxNG to validate the document as it is processed. Activation is only
|
412
|
+
* possible before the first read. If +rng+ is nil, the RelaxNG validation is
|
413
|
+
* desactivated.
|
414
|
+
*
|
415
|
+
* Return 0 in case the RelaxNG validation could be (des)activated and -1 in
|
416
|
+
* case of error.
|
417
|
+
*/
|
418
|
+
static VALUE
|
419
|
+
ruby_xml_reader_relax_ng_validate(VALUE self, VALUE rng)
|
420
|
+
{
|
421
|
+
return INT2FIX(xmlTextReaderRelaxNGValidate(ruby_xml_text_reader_get(self), NIL_P(rng) ? NULL : RVAL2CSTR(rng)));
|
422
|
+
}
|
423
|
+
|
424
|
+
#if LIBXML_VERSION >= 20620
|
425
|
+
/*
|
426
|
+
* call-seq:
|
427
|
+
* reader.schema_validate(schema) -> code
|
428
|
+
*
|
429
|
+
* Use W3C XSD schema to validate the document as it is processed. Activation
|
430
|
+
* is only possible before the first read. If +schema+ is nil, then XML Schema
|
431
|
+
* validation is desactivated.
|
432
|
+
*
|
433
|
+
* Return 0 in case the schemas validation could be (de)activated and -1 in
|
434
|
+
* case of error.
|
435
|
+
*/
|
436
|
+
static VALUE
|
437
|
+
ruby_xml_reader_schema_validate(VALUE self, VALUE xsd)
|
438
|
+
{
|
439
|
+
return INT2FIX(xmlTextReaderSchemaValidate(ruby_xml_text_reader_get(self), NIL_P(xsd) ? NULL : RVAL2CSTR(xsd)));
|
440
|
+
}
|
441
|
+
#endif
|
442
|
+
|
443
|
+
/*
|
444
|
+
* call-seq:
|
445
|
+
* reader.name -> name
|
446
|
+
*
|
447
|
+
* Return the qualified name of the node.
|
448
|
+
*/
|
449
|
+
static VALUE
|
450
|
+
ruby_xml_reader_name(VALUE self)
|
451
|
+
{
|
452
|
+
return CSTR2RVAL(xmlTextReaderConstName(ruby_xml_text_reader_get(self)));
|
453
|
+
}
|
454
|
+
|
455
|
+
/*
|
456
|
+
* call-seq:
|
457
|
+
* reader.local_name -> name
|
458
|
+
*
|
459
|
+
* Return the local name of the node.
|
460
|
+
*/
|
461
|
+
static VALUE
|
462
|
+
ruby_xml_reader_local_name(VALUE self)
|
463
|
+
{
|
464
|
+
return CSTR2RVAL(xmlTextReaderConstLocalName(ruby_xml_text_reader_get(self)));
|
465
|
+
}
|
466
|
+
|
467
|
+
/*
|
468
|
+
* call-seq:
|
469
|
+
* reader.attribute_count -> count
|
470
|
+
*
|
471
|
+
* Provide the number of attributes of the current node.
|
472
|
+
*/
|
473
|
+
static VALUE
|
474
|
+
ruby_xml_reader_attr_count(VALUE self)
|
475
|
+
{
|
476
|
+
return INT2FIX(xmlTextReaderAttributeCount(ruby_xml_text_reader_get(self)));
|
477
|
+
}
|
478
|
+
|
479
|
+
/*
|
480
|
+
* call-seq:
|
481
|
+
* reader.encoding -> encoding
|
482
|
+
*
|
483
|
+
* Determine the encoding of the document being read.
|
484
|
+
*/
|
485
|
+
static VALUE
|
486
|
+
ruby_xml_reader_encoding(VALUE self)
|
487
|
+
{
|
488
|
+
return CSTR2RVAL(xmlTextReaderConstEncoding(ruby_xml_text_reader_get(self)));
|
489
|
+
}
|
490
|
+
|
491
|
+
/*
|
492
|
+
* call-seq:
|
493
|
+
* reader.base_uri -> URI
|
494
|
+
*
|
495
|
+
* Determine the base URI of the node.
|
496
|
+
*/
|
497
|
+
static VALUE
|
498
|
+
ruby_xml_reader_base_uri(VALUE self)
|
499
|
+
{
|
500
|
+
return CSTR2RVAL(xmlTextReaderConstBaseUri(ruby_xml_text_reader_get(self)));
|
501
|
+
}
|
502
|
+
|
503
|
+
/*
|
504
|
+
* call-seq:
|
505
|
+
* reader.namespace_uri -> URI
|
506
|
+
*
|
507
|
+
* Determine the namespace URI of the node.
|
508
|
+
*/
|
509
|
+
static VALUE
|
510
|
+
ruby_xml_reader_namespace_uri(VALUE self)
|
511
|
+
{
|
512
|
+
return CSTR2RVAL(xmlTextReaderConstNamespaceUri(ruby_xml_text_reader_get(self)));
|
513
|
+
}
|
514
|
+
|
515
|
+
/*
|
516
|
+
* call-seq:
|
517
|
+
* reader.value -> text
|
518
|
+
*
|
519
|
+
* Provide the text value of the node if present.
|
520
|
+
*/
|
521
|
+
static VALUE
|
522
|
+
ruby_xml_reader_value(VALUE self)
|
523
|
+
{
|
524
|
+
return CSTR2RVAL(xmlTextReaderConstValue(ruby_xml_text_reader_get(self)));
|
525
|
+
}
|
526
|
+
|
527
|
+
/*
|
528
|
+
* call-seq:
|
529
|
+
* reader.prefix -> prefix
|
530
|
+
*
|
531
|
+
* Get a shorthand reference to the namespace associated with the node.
|
532
|
+
*/
|
533
|
+
static VALUE
|
534
|
+
ruby_xml_reader_prefix(VALUE self)
|
535
|
+
{
|
536
|
+
return CSTR2RVAL(xmlTextReaderConstPrefix(ruby_xml_text_reader_get(self)));
|
537
|
+
}
|
538
|
+
|
539
|
+
/*
|
540
|
+
* call-seq:
|
541
|
+
* reader.depth -> depth
|
542
|
+
*
|
543
|
+
* Get the depth of the node in the tree.
|
544
|
+
*/
|
545
|
+
static VALUE
|
546
|
+
ruby_xml_reader_depth(VALUE self)
|
547
|
+
{
|
548
|
+
return INT2FIX(xmlTextReaderDepth(ruby_xml_text_reader_get(self)));
|
549
|
+
}
|
550
|
+
|
551
|
+
/*
|
552
|
+
* call-seq:
|
553
|
+
* reader.quote_char -> char
|
554
|
+
*
|
555
|
+
* Get the quotation mark character used to enclose the value of an attribute,
|
556
|
+
* as an integer value (and -1 in case of error).
|
557
|
+
*/
|
558
|
+
static VALUE
|
559
|
+
ruby_xml_reader_quote_char(VALUE self)
|
560
|
+
{
|
561
|
+
return INT2FIX(xmlTextReaderQuoteChar(ruby_xml_text_reader_get(self)));
|
562
|
+
}
|
563
|
+
|
564
|
+
/*
|
565
|
+
* call-seq:
|
566
|
+
* reader.standalone -> code
|
567
|
+
*
|
568
|
+
* Determine the standalone status of the document being read.
|
569
|
+
*
|
570
|
+
* Return 1 if the document was declared to be standalone, 0 if it was
|
571
|
+
* declared to be not standalone, or -1 if the document did not specify its
|
572
|
+
* standalone status or in case of error.
|
573
|
+
*/
|
574
|
+
static VALUE
|
575
|
+
ruby_xml_reader_standalone(VALUE self)
|
576
|
+
{
|
577
|
+
return INT2FIX(xmlTextReaderStandalone(ruby_xml_text_reader_get(self)));
|
578
|
+
}
|
579
|
+
|
580
|
+
/*
|
581
|
+
* call-seq:
|
582
|
+
* reader.xml_lang -> value
|
583
|
+
*
|
584
|
+
* Get the xml:lang scope within which the node resides.
|
585
|
+
*/
|
586
|
+
static VALUE
|
587
|
+
ruby_xml_reader_xml_lang(VALUE self)
|
588
|
+
{
|
589
|
+
return CSTR2RVAL(xmlTextReaderConstXmlLang(ruby_xml_text_reader_get(self)));
|
590
|
+
}
|
591
|
+
|
592
|
+
/*
|
593
|
+
* call-seq:
|
594
|
+
* reader.xml_version -> version
|
595
|
+
*
|
596
|
+
* Determine the XML version of the document being read.
|
597
|
+
*/
|
598
|
+
static VALUE
|
599
|
+
ruby_xml_reader_xml_version(VALUE self)
|
600
|
+
{
|
601
|
+
return CSTR2RVAL(xmlTextReaderConstXmlVersion(ruby_xml_text_reader_get(self)));
|
602
|
+
}
|
603
|
+
|
604
|
+
/*
|
605
|
+
* call-seq:
|
606
|
+
* reader.has_attributes? -> bool
|
607
|
+
*
|
608
|
+
* Get whether the node has attributes.
|
609
|
+
*/
|
610
|
+
static VALUE
|
611
|
+
ruby_xml_reader_has_attributes(VALUE self)
|
612
|
+
{
|
613
|
+
return xmlTextReaderHasAttributes(ruby_xml_text_reader_get(self)) ? Qtrue : Qfalse;
|
614
|
+
}
|
615
|
+
|
616
|
+
/*
|
617
|
+
* call-seq:
|
618
|
+
* reader.has_value? -> bool
|
619
|
+
*
|
620
|
+
* Get whether the node can have a text value.
|
621
|
+
*/
|
622
|
+
static VALUE
|
623
|
+
ruby_xml_reader_has_value(VALUE self)
|
624
|
+
{
|
625
|
+
return xmlTextReaderHasValue(ruby_xml_text_reader_get(self)) ? Qtrue : Qfalse;
|
626
|
+
}
|
627
|
+
|
628
|
+
/*
|
629
|
+
* call-seq:
|
630
|
+
* reader[key] -> value
|
631
|
+
*
|
632
|
+
* Provide the value of the attribute with the specified index (if +key+ is an
|
633
|
+
* integer) or with the specified name (if +key+ is a string) relative to the
|
634
|
+
* containing element, as a string.
|
635
|
+
*/
|
636
|
+
static VALUE
|
637
|
+
ruby_xml_reader_attribute(VALUE self, VALUE key)
|
638
|
+
{
|
639
|
+
xmlTextReaderPtr reader;
|
640
|
+
xmlChar *attr;
|
641
|
+
|
642
|
+
reader = ruby_xml_text_reader_get(self);
|
643
|
+
|
644
|
+
if (TYPE(key) == T_FIXNUM) {
|
645
|
+
attr = xmlTextReaderGetAttributeNo(reader, FIX2INT(key));
|
646
|
+
}
|
647
|
+
else {
|
648
|
+
attr = xmlTextReaderGetAttribute(reader, (const xmlChar *)RVAL2CSTR(key));
|
649
|
+
}
|
650
|
+
return CSTR2RVAL2(attr);
|
651
|
+
}
|
652
|
+
|
653
|
+
/*
|
654
|
+
* call-seq:
|
655
|
+
* reader.lookup_namespace(prefix) -> value
|
656
|
+
*
|
657
|
+
* Resolve a namespace prefix in the scope of the current element.
|
658
|
+
* To return the default namespace, specify nil as +prefix+.
|
659
|
+
*/
|
660
|
+
static VALUE
|
661
|
+
ruby_xml_reader_lookup_namespace(VALUE self, VALUE prefix)
|
662
|
+
{
|
663
|
+
return CSTR2RVAL2(xmlTextReaderLookupNamespace(ruby_xml_text_reader_get(self), (const xmlChar *)RVAL2CSTR(prefix)));
|
664
|
+
}
|
665
|
+
|
666
|
+
/*
|
667
|
+
* call-seq:
|
668
|
+
* reader.expand -> node
|
669
|
+
*
|
670
|
+
* Read the contents of the current node and the full subtree. It then makes
|
671
|
+
* the subtree available until the next read call.
|
672
|
+
*
|
673
|
+
* Return an XML::Node object, or nil in case of error.
|
674
|
+
*/
|
675
|
+
static VALUE
|
676
|
+
ruby_xml_reader_expand(VALUE self)
|
677
|
+
{
|
678
|
+
xmlNodePtr node;
|
679
|
+
xmlDocPtr doc;
|
680
|
+
xmlTextReaderPtr reader = ruby_xml_text_reader_get(self);
|
681
|
+
node = xmlTextReaderExpand(reader);
|
682
|
+
|
683
|
+
if (!node)
|
684
|
+
return Qnil;
|
685
|
+
|
686
|
+
/* Okay this is tricky. By accessing the returned node, we
|
687
|
+
take ownership of the reader's document. Thus we need to
|
688
|
+
tell the reader to not free it. Otherwise it will be
|
689
|
+
freed twice - once when the Ruby document wrapper goes
|
690
|
+
out of scope and once when the reader goes out of scope. */
|
691
|
+
|
692
|
+
xmlTextReaderPreserve(reader);
|
693
|
+
doc = xmlTextReaderCurrentDoc(reader);
|
694
|
+
ruby_xml_document_wrap(doc);
|
695
|
+
|
696
|
+
return ruby_xml_node2_wrap(cXMLNode, node);
|
697
|
+
}
|
698
|
+
|
699
|
+
#if LIBXML_VERSION >= 20618
|
700
|
+
/*
|
701
|
+
* call-seq:
|
702
|
+
* reader.byte_consumed -> value
|
703
|
+
*
|
704
|
+
* This method provides the current index of the parser used by the reader,
|
705
|
+
* relative to the start of the current entity.
|
706
|
+
*/
|
707
|
+
static VALUE
|
708
|
+
ruby_xml_reader_byte_consumed(VALUE self)
|
709
|
+
{
|
710
|
+
return INT2NUM(xmlTextReaderByteConsumed(ruby_xml_text_reader_get(self)));
|
711
|
+
}
|
712
|
+
#endif
|
713
|
+
|
714
|
+
#if LIBXML_VERSION >= 20617
|
715
|
+
/*
|
716
|
+
* call-seq:
|
717
|
+
* reader.column_number -> number
|
718
|
+
*
|
719
|
+
* Provide the column number of the current parsing point.
|
720
|
+
*/
|
721
|
+
static VALUE
|
722
|
+
ruby_xml_reader_column_number(VALUE self)
|
723
|
+
{
|
724
|
+
return INT2NUM(xmlTextReaderGetParserColumnNumber(ruby_xml_text_reader_get(self)));
|
725
|
+
}
|
726
|
+
|
727
|
+
/*
|
728
|
+
* call-seq:
|
729
|
+
* reader.line_number -> number
|
730
|
+
*
|
731
|
+
* Provide the line number of the current parsing point.
|
732
|
+
*/
|
733
|
+
static VALUE
|
734
|
+
ruby_xml_reader_line_number(VALUE self)
|
735
|
+
{
|
736
|
+
return INT2NUM(xmlTextReaderGetParserLineNumber(ruby_xml_text_reader_get(self)));
|
737
|
+
}
|
738
|
+
#endif
|
739
|
+
|
740
|
+
/*
|
741
|
+
* call-seq:
|
742
|
+
* reader.default? -> bool
|
743
|
+
*
|
744
|
+
* Return whether an Attribute node was generated from the default value
|
745
|
+
* defined in the DTD or schema.
|
746
|
+
*/
|
747
|
+
static VALUE
|
748
|
+
ruby_xml_reader_default(VALUE self)
|
749
|
+
{
|
750
|
+
return xmlTextReaderIsDefault(ruby_xml_text_reader_get(self)) ? Qtrue : Qfalse;
|
751
|
+
}
|
752
|
+
|
753
|
+
/*
|
754
|
+
* call-seq:
|
755
|
+
* reader.namespace_declaration? -> bool
|
756
|
+
*
|
757
|
+
* Determine whether the current node is a namespace declaration rather than a
|
758
|
+
* regular attribute.
|
759
|
+
*/
|
760
|
+
static VALUE
|
761
|
+
ruby_xml_reader_namespace_declaration(VALUE self)
|
762
|
+
{
|
763
|
+
return xmlTextReaderIsNamespaceDecl(ruby_xml_text_reader_get(self)) ? Qtrue : Qfalse;
|
764
|
+
}
|
765
|
+
|
766
|
+
/*
|
767
|
+
* call-seq:
|
768
|
+
* reader.empty_element? -> bool
|
769
|
+
*
|
770
|
+
* Check if the current node is empty.
|
771
|
+
*/
|
772
|
+
static VALUE
|
773
|
+
ruby_xml_reader_empty_element(VALUE self)
|
774
|
+
{
|
775
|
+
return xmlTextReaderIsEmptyElement(ruby_xml_text_reader_get(self)) ? Qtrue : Qfalse;
|
776
|
+
}
|
777
|
+
|
778
|
+
/*
|
779
|
+
* call-seq:
|
780
|
+
* reader.valid? -> bool
|
781
|
+
*
|
782
|
+
* Retrieve the validity status from the parser context.
|
783
|
+
*/
|
784
|
+
static VALUE
|
785
|
+
ruby_xml_reader_valid(VALUE self)
|
786
|
+
{
|
787
|
+
return xmlTextReaderIsValid(ruby_xml_text_reader_get(self)) ? Qtrue : Qfalse;
|
788
|
+
}
|
789
|
+
|
790
|
+
/* Rdoc needs to know. */
|
791
|
+
#ifdef RDOC_NEVER_DEFINED
|
792
|
+
mXML = rb_define_module("XML");
|
793
|
+
#endif
|
794
|
+
|
795
|
+
void
|
796
|
+
ruby_init_xml_reader(void)
|
797
|
+
{
|
798
|
+
cXMLReader = rb_define_class_under(mXML, "Reader", rb_cObject);
|
799
|
+
error_handler_block_ivar_id = rb_intern("@__error_handler_callback__");
|
800
|
+
|
801
|
+
rb_define_singleton_method(cXMLReader, "file", ruby_xml_reader_new_file, -1);
|
802
|
+
rb_define_singleton_method(cXMLReader, "walker", ruby_xml_reader_new_walker, 1);
|
803
|
+
rb_define_alias(CLASS_OF(cXMLReader), "document", "walker");
|
804
|
+
rb_define_singleton_method(cXMLReader, "new", ruby_xml_reader_new_data, -1);
|
805
|
+
rb_define_alias(CLASS_OF(cXMLReader), "string", "new");
|
806
|
+
|
807
|
+
rb_define_method(cXMLReader, "close", ruby_xml_reader_close, 0);
|
808
|
+
|
809
|
+
rb_define_method(cXMLReader, "move_to_attribute", ruby_xml_reader_move_to_attr, 1);
|
810
|
+
rb_define_method(cXMLReader, "move_to_first_attribute", ruby_xml_reader_move_to_first_attr, 0);
|
811
|
+
rb_define_method(cXMLReader, "move_to_next_attribute", ruby_xml_reader_move_to_next_attr, 0);
|
812
|
+
rb_define_method(cXMLReader, "move_to_element", ruby_xml_reader_move_to_element, 0);
|
813
|
+
rb_define_method(cXMLReader, "next", ruby_xml_reader_next, 0);
|
814
|
+
rb_define_method(cXMLReader, "next_sibling", ruby_xml_reader_next_sibling, 0);
|
815
|
+
rb_define_method(cXMLReader, "read", ruby_xml_reader_read, 0);
|
816
|
+
rb_define_method(cXMLReader, "read_attribute_value", ruby_xml_reader_read_attr_value, 0);
|
817
|
+
rb_define_method(cXMLReader, "read_inner_xml", ruby_xml_reader_read_inner_xml, 0);
|
818
|
+
rb_define_method(cXMLReader, "read_outer_xml", ruby_xml_reader_read_outer_xml, 0);
|
819
|
+
rb_define_method(cXMLReader, "read_state", ruby_xml_reader_read_state, 0);
|
820
|
+
rb_define_method(cXMLReader, "read_string", ruby_xml_reader_read_string, 0);
|
821
|
+
|
822
|
+
rb_define_method(cXMLReader, "set_error_handler", ruby_xml_reader_set_error_handler, 0);
|
823
|
+
rb_define_method(cXMLReader, "reset_error_handler", ruby_xml_reader_reset_error_handler, 0);
|
824
|
+
|
825
|
+
rb_define_method(cXMLReader, "relax_ng_validate", ruby_xml_reader_relax_ng_validate, 1);
|
826
|
+
#if LIBXML_VERSION >= 20620
|
827
|
+
rb_define_method(cXMLReader, "schema_validate", ruby_xml_reader_schema_validate, 1);
|
828
|
+
#endif
|
829
|
+
|
830
|
+
rb_define_method(cXMLReader, "node_type", ruby_xml_reader_node_type, 0);
|
831
|
+
rb_define_method(cXMLReader, "normalization", ruby_xml_reader_normalization, 0);
|
832
|
+
rb_define_method(cXMLReader, "attribute_count", ruby_xml_reader_attr_count, 0);
|
833
|
+
rb_define_method(cXMLReader, "name", ruby_xml_reader_name, 0);
|
834
|
+
rb_define_method(cXMLReader, "local_name", ruby_xml_reader_local_name, 0);
|
835
|
+
rb_define_method(cXMLReader, "encoding", ruby_xml_reader_encoding, 0);
|
836
|
+
rb_define_method(cXMLReader, "base_uri", ruby_xml_reader_base_uri, 0);
|
837
|
+
rb_define_method(cXMLReader, "namespace_uri", ruby_xml_reader_namespace_uri, 0);
|
838
|
+
rb_define_method(cXMLReader, "xml_lang", ruby_xml_reader_xml_lang, 0);
|
839
|
+
rb_define_method(cXMLReader, "xml_version", ruby_xml_reader_xml_version, 0);
|
840
|
+
rb_define_method(cXMLReader, "prefix", ruby_xml_reader_prefix, 0);
|
841
|
+
rb_define_method(cXMLReader, "depth", ruby_xml_reader_depth, 0);
|
842
|
+
rb_define_method(cXMLReader, "quote_char", ruby_xml_reader_quote_char, 0);
|
843
|
+
rb_define_method(cXMLReader, "standalone", ruby_xml_reader_standalone, 0);
|
844
|
+
|
845
|
+
rb_define_method(cXMLReader, "has_attributes?", ruby_xml_reader_has_attributes, 0);
|
846
|
+
rb_define_method(cXMLReader, "[]", ruby_xml_reader_attribute, 1);
|
847
|
+
rb_define_method(cXMLReader, "has_value?", ruby_xml_reader_has_value, 0);
|
848
|
+
rb_define_method(cXMLReader, "value", ruby_xml_reader_value, 0);
|
849
|
+
|
850
|
+
rb_define_method(cXMLReader, "lookup_namespace", ruby_xml_reader_lookup_namespace, 1);
|
851
|
+
rb_define_method(cXMLReader, "expand", ruby_xml_reader_expand, 0);
|
852
|
+
|
853
|
+
#if LIBXML_VERSION >= 20618
|
854
|
+
rb_define_method(cXMLReader, "byte_consumed", ruby_xml_reader_byte_consumed, 0);
|
855
|
+
#endif
|
856
|
+
#if LIBXML_VERSION >= 20617
|
857
|
+
rb_define_method(cXMLReader, "column_number", ruby_xml_reader_column_number, 0);
|
858
|
+
rb_define_method(cXMLReader, "line_number", ruby_xml_reader_line_number, 0);
|
859
|
+
#endif
|
860
|
+
rb_define_method(cXMLReader, "default?", ruby_xml_reader_default, 0);
|
861
|
+
rb_define_method(cXMLReader, "empty_element?", ruby_xml_reader_empty_element, 0);
|
862
|
+
rb_define_method(cXMLReader, "namespace_declaration?", ruby_xml_reader_namespace_declaration, 0);
|
863
|
+
rb_define_method(cXMLReader, "valid?", ruby_xml_reader_valid, 0);
|
864
|
+
|
865
|
+
rb_define_const(cXMLReader, "LOADDTD", INT2FIX(XML_PARSER_LOADDTD));
|
866
|
+
rb_define_const(cXMLReader, "DEFAULTATTRS", INT2FIX(XML_PARSER_DEFAULTATTRS));
|
867
|
+
rb_define_const(cXMLReader, "VALIDATE", INT2FIX(XML_PARSER_VALIDATE));
|
868
|
+
rb_define_const(cXMLReader, "SUBST_ENTITIES", INT2FIX(XML_PARSER_SUBST_ENTITIES));
|
869
|
+
|
870
|
+
rb_define_const(cXMLReader, "SEVERITY_VALIDITY_WARNING", INT2FIX(XML_PARSER_SEVERITY_VALIDITY_WARNING));
|
871
|
+
rb_define_const(cXMLReader, "SEVERITY_VALIDITY_ERROR", INT2FIX(XML_PARSER_SEVERITY_VALIDITY_ERROR));
|
872
|
+
rb_define_const(cXMLReader, "SEVERITY_WARNING", INT2FIX(XML_PARSER_SEVERITY_WARNING));
|
873
|
+
rb_define_const(cXMLReader, "SEVERITY_ERROR", INT2FIX(XML_PARSER_SEVERITY_ERROR));
|
874
|
+
|
875
|
+
rb_define_const(cXMLReader, "TYPE_NONE", INT2FIX(XML_READER_TYPE_NONE));
|
876
|
+
rb_define_const(cXMLReader, "TYPE_ELEMENT", INT2FIX(XML_READER_TYPE_ELEMENT));
|
877
|
+
rb_define_const(cXMLReader, "TYPE_ATTRIBUTE", INT2FIX(XML_READER_TYPE_ATTRIBUTE));
|
878
|
+
rb_define_const(cXMLReader, "TYPE_TEXT", INT2FIX(XML_READER_TYPE_TEXT));
|
879
|
+
rb_define_const(cXMLReader, "TYPE_CDATA", INT2FIX(XML_READER_TYPE_CDATA));
|
880
|
+
rb_define_const(cXMLReader, "TYPE_ENTITY_REFERENCE", INT2FIX(XML_READER_TYPE_ENTITY_REFERENCE));
|
881
|
+
rb_define_const(cXMLReader, "TYPE_ENTITY", INT2FIX(XML_READER_TYPE_ENTITY));
|
882
|
+
rb_define_const(cXMLReader, "TYPE_PROCESSING_INSTRUCTION", INT2FIX(XML_READER_TYPE_PROCESSING_INSTRUCTION));
|
883
|
+
rb_define_const(cXMLReader, "TYPE_COMMENT", INT2FIX(XML_READER_TYPE_COMMENT));
|
884
|
+
rb_define_const(cXMLReader, "TYPE_DOCUMENT", INT2FIX(XML_READER_TYPE_DOCUMENT));
|
885
|
+
rb_define_const(cXMLReader, "TYPE_DOCUMENT_TYPE", INT2FIX(XML_READER_TYPE_DOCUMENT_TYPE));
|
886
|
+
rb_define_const(cXMLReader, "TYPE_DOCUMENT_FRAGMENT", INT2FIX(XML_READER_TYPE_DOCUMENT_FRAGMENT));
|
887
|
+
rb_define_const(cXMLReader, "TYPE_NOTATION", INT2FIX(XML_READER_TYPE_NOTATION));
|
888
|
+
rb_define_const(cXMLReader, "TYPE_WHITESPACE", INT2FIX(XML_READER_TYPE_WHITESPACE));
|
889
|
+
rb_define_const(cXMLReader, "TYPE_SIGNIFICANT_WHITESPACE", INT2FIX(XML_READER_TYPE_SIGNIFICANT_WHITESPACE));
|
890
|
+
rb_define_const(cXMLReader, "TYPE_END_ELEMENT", INT2FIX(XML_READER_TYPE_END_ELEMENT));
|
891
|
+
rb_define_const(cXMLReader, "TYPE_END_ENTITY", INT2FIX(XML_READER_TYPE_END_ENTITY));
|
892
|
+
rb_define_const(cXMLReader, "TYPE_XML_DECLARATION", INT2FIX(XML_READER_TYPE_XML_DECLARATION));
|
893
|
+
|
894
|
+
rb_define_const(cXMLReader, "MODE_INITIAL", INT2FIX(XML_TEXTREADER_MODE_INITIAL));
|
895
|
+
rb_define_const(cXMLReader, "MODE_INTERACTIVE", INT2FIX(XML_TEXTREADER_MODE_INTERACTIVE));
|
896
|
+
rb_define_const(cXMLReader, "MODE_ERROR", INT2FIX(XML_TEXTREADER_MODE_ERROR));
|
897
|
+
rb_define_const(cXMLReader, "MODE_EOF", INT2FIX(XML_TEXTREADER_MODE_EOF));
|
898
|
+
rb_define_const(cXMLReader, "MODE_CLOSED", INT2FIX(XML_TEXTREADER_MODE_CLOSED));
|
899
|
+
rb_define_const(cXMLReader, "MODE_READING", INT2FIX(XML_TEXTREADER_MODE_READING));
|
900
|
+
}
|