libxml-ruby 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +13 -0
- data/ext/libxml/libxml.c +885 -886
- data/ext/libxml/ruby_libxml.h +70 -72
- data/ext/libxml/ruby_xml_attr.c +76 -76
- data/ext/libxml/ruby_xml_attr.h +8 -8
- data/ext/libxml/ruby_xml_attributes.c +36 -36
- data/ext/libxml/ruby_xml_attributes.h +6 -6
- data/ext/libxml/ruby_xml_document.c +133 -220
- data/ext/libxml/ruby_xml_document.h +4 -7
- data/ext/libxml/ruby_xml_dtd.c +30 -109
- data/ext/libxml/ruby_xml_dtd.h +2 -11
- data/ext/libxml/ruby_xml_error.c +10 -10
- data/ext/libxml/ruby_xml_error.h +4 -4
- data/ext/libxml/ruby_xml_html_parser.c +28 -40
- data/ext/libxml/ruby_xml_html_parser.h +4 -4
- data/ext/libxml/ruby_xml_input.c +208 -32
- data/ext/libxml/ruby_xml_input.h +7 -5
- data/ext/libxml/ruby_xml_input_cbg.c +3 -3
- data/ext/libxml/ruby_xml_node.c +217 -217
- data/ext/libxml/ruby_xml_node.h +5 -5
- data/ext/libxml/ruby_xml_ns.c +26 -26
- data/ext/libxml/ruby_xml_ns.h +4 -4
- data/ext/libxml/ruby_xml_parser.c +151 -164
- data/ext/libxml/ruby_xml_parser.h +3 -8
- data/ext/libxml/ruby_xml_parser_context.c +105 -105
- data/ext/libxml/ruby_xml_parser_context.h +4 -4
- data/ext/libxml/ruby_xml_reader.c +145 -162
- data/ext/libxml/ruby_xml_reader.h +4 -4
- data/ext/libxml/ruby_xml_relaxng.c +30 -43
- data/ext/libxml/ruby_xml_relaxng.h +2 -7
- data/ext/libxml/ruby_xml_sax_parser.c +174 -228
- data/ext/libxml/ruby_xml_sax_parser.h +12 -20
- data/ext/libxml/ruby_xml_schema.c +31 -44
- data/ext/libxml/ruby_xml_schema.h +2 -7
- data/ext/libxml/ruby_xml_state.c +6 -6
- data/ext/libxml/ruby_xml_state.h +2 -2
- data/ext/libxml/ruby_xml_xinclude.c +1 -1
- data/ext/libxml/ruby_xml_xinclude.h +3 -3
- data/ext/libxml/ruby_xml_xpath.c +1 -1
- data/ext/libxml/ruby_xml_xpath.h +3 -12
- data/ext/libxml/ruby_xml_xpath_context.c +293 -294
- data/ext/libxml/ruby_xml_xpath_context.h +3 -7
- data/ext/libxml/ruby_xml_xpath_expression.c +11 -11
- data/ext/libxml/ruby_xml_xpath_expression.h +2 -2
- data/ext/libxml/ruby_xml_xpath_object.c +52 -66
- data/ext/libxml/ruby_xml_xpath_object.h +3 -14
- data/ext/libxml/ruby_xml_xpointer.c +11 -12
- data/ext/libxml/ruby_xml_xpointer.h +5 -7
- data/ext/libxml/sax_parser_callbacks.inc +53 -36
- data/ext/libxml/version.h +2 -2
- data/ext/vc/libxml_ruby.vcproj +1 -9
- data/lib/libxml/html_parser.rb +5 -5
- data/lib/libxml/parser.rb +4 -4
- data/lib/libxml/sax_parser.rb +24 -0
- data/test/tc_document_write.rb +2 -16
- data/test/tc_html_parser.rb +57 -5
- data/test/tc_input.rb +13 -0
- data/test/tc_parser.rb +11 -3
- data/test/tc_reader.rb +53 -34
- data/test/tc_sax_parser.rb +30 -8
- data/test/test.rb +8 -0
- data/test/test_suite.rb +1 -1
- metadata +5 -6
- data/ext/libxml/ruby_xml_encoding.c +0 -164
- data/ext/libxml/ruby_xml_encoding.h +0 -13
- data/test/tc_encoding.rb +0 -13
data/ext/libxml/ruby_xml_input.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id:
|
1
|
+
/* $Id: rxml_input.c 528 2008-11-15 23:43:48Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
@@ -20,7 +20,38 @@ VALUE cXMLInput;
|
|
20
20
|
* but instead will use the various Document and Parser apis.
|
21
21
|
* For example:
|
22
22
|
*
|
23
|
-
* document = Document.file('my_file')
|
23
|
+
* document = Document.file('my_file')
|
24
|
+
*
|
25
|
+
* LibXML converts all data sources to UTF8 internally before
|
26
|
+
* processing them. By default, LibXML will determine a data
|
27
|
+
* source's encoding using the algorithm described on its
|
28
|
+
* website[* http://xmlsoft.org/encoding.html].
|
29
|
+
*
|
30
|
+
* However, its some cases it is possible to tell LibXML
|
31
|
+
* the data source's encoding via the constants defined in
|
32
|
+
* the Encoding module.
|
33
|
+
*
|
34
|
+
* Example 1:
|
35
|
+
*
|
36
|
+
* parser = XML::Parser.new
|
37
|
+
* parser.input.encoding = XML::Input::ISO_8859_1
|
38
|
+
* parser.io = File.open('some_file', 'rb')
|
39
|
+
* doc = parser.parse
|
40
|
+
*
|
41
|
+
* Example 2:
|
42
|
+
*
|
43
|
+
* parser = XML::HTMLParser.new
|
44
|
+
* parser.encoding = XML::Input::ISO_8859_1
|
45
|
+
* parser.file = "some_file"
|
46
|
+
* doc = parser.parse
|
47
|
+
*
|
48
|
+
* Example 3:
|
49
|
+
*
|
50
|
+
* document = XML::Document.new
|
51
|
+
* encoding_string = XML::Input.encoding_to_s(XML::Encoding::ISO_8859_1)
|
52
|
+
* document.encoding = document
|
53
|
+
* doc << XML::Node.new */
|
54
|
+
|
24
55
|
|
25
56
|
ID ENCODING_ATTR;
|
26
57
|
ID FILE_ATTR;
|
@@ -28,14 +59,125 @@ ID STRING_ATTR;
|
|
28
59
|
ID DOCUMENT_ATTR;
|
29
60
|
ID IO_ATTR;
|
30
61
|
|
62
|
+
static ID READ_METHOD;
|
63
|
+
|
64
|
+
|
65
|
+
/* This method is called by libxml when it wants to read
|
66
|
+
more data from a stream. We go with the duck typing
|
67
|
+
solution to support StringIO objects. */
|
68
|
+
int rxml_read_callback(void *context, char *buffer, int len) {
|
69
|
+
VALUE io = (VALUE)context;
|
70
|
+
VALUE string = rb_funcall(io, READ_METHOD, 1, INT2NUM(len));
|
71
|
+
int size;
|
72
|
+
|
73
|
+
if(string == Qnil)
|
74
|
+
return 0;
|
75
|
+
|
76
|
+
size = RSTRING_LEN(string);
|
77
|
+
memcpy(buffer, StringValuePtr(string), size);
|
78
|
+
|
79
|
+
return size;
|
80
|
+
}
|
81
|
+
|
82
|
+
/*
|
83
|
+
* call-seq:
|
84
|
+
* Input.encoding_to_s(Input::ENCODING) -> "encoding"
|
85
|
+
*
|
86
|
+
* Converts an encoding contstant defined on the XML::Input
|
87
|
+
* class to its text representation.
|
88
|
+
*/
|
89
|
+
VALUE
|
90
|
+
rxml_input_encoding_to_s(VALUE self, VALUE encoding)
|
91
|
+
{
|
92
|
+
char* encodingStr = NULL;
|
93
|
+
|
94
|
+
switch (NUM2INT(encoding))
|
95
|
+
{
|
96
|
+
case XML_CHAR_ENCODING_ERROR:
|
97
|
+
encodingStr = "Error";
|
98
|
+
break;
|
99
|
+
case XML_CHAR_ENCODING_NONE:
|
100
|
+
encodingStr = "None";
|
101
|
+
break;
|
102
|
+
case XML_CHAR_ENCODING_UTF8:
|
103
|
+
encodingStr = "UTF-8";
|
104
|
+
break;
|
105
|
+
case XML_CHAR_ENCODING_UTF16LE:
|
106
|
+
encodingStr = "UTF-16LE";
|
107
|
+
break;
|
108
|
+
case XML_CHAR_ENCODING_UTF16BE:
|
109
|
+
encodingStr = "UTF-16BE";
|
110
|
+
break;
|
111
|
+
case XML_CHAR_ENCODING_UCS4LE:
|
112
|
+
encodingStr = "UCS-4LE";
|
113
|
+
break;
|
114
|
+
case XML_CHAR_ENCODING_UCS4BE:
|
115
|
+
encodingStr = "UCS-4BE";
|
116
|
+
break;
|
117
|
+
case XML_CHAR_ENCODING_EBCDIC:
|
118
|
+
encodingStr = "EBCDIC";
|
119
|
+
break;
|
120
|
+
case XML_CHAR_ENCODING_UCS4_2143:
|
121
|
+
encodingStr = "UCS-4";
|
122
|
+
break;
|
123
|
+
case XML_CHAR_ENCODING_UCS4_3412:
|
124
|
+
encodingStr = "UCS-4";
|
125
|
+
break;
|
126
|
+
case XML_CHAR_ENCODING_UCS2:
|
127
|
+
encodingStr = "UCS-2";
|
128
|
+
break;
|
129
|
+
case XML_CHAR_ENCODING_8859_1:
|
130
|
+
encodingStr = "ISO-8859-1";
|
131
|
+
break;
|
132
|
+
case XML_CHAR_ENCODING_8859_2:
|
133
|
+
encodingStr = "ISO-8859-2";
|
134
|
+
break;
|
135
|
+
case XML_CHAR_ENCODING_8859_3:
|
136
|
+
encodingStr = "ISO-8859-3";
|
137
|
+
break;
|
138
|
+
case XML_CHAR_ENCODING_8859_4:
|
139
|
+
encodingStr = "ISO-8859-4";
|
140
|
+
break;
|
141
|
+
case XML_CHAR_ENCODING_8859_5:
|
142
|
+
encodingStr = "ISO-8859-5";
|
143
|
+
break;
|
144
|
+
case XML_CHAR_ENCODING_8859_6:
|
145
|
+
encodingStr = "ISO-8859-6";
|
146
|
+
break;
|
147
|
+
case XML_CHAR_ENCODING_8859_7:
|
148
|
+
encodingStr = "ISO-8859-7";
|
149
|
+
break;
|
150
|
+
case XML_CHAR_ENCODING_8859_8:
|
151
|
+
encodingStr = "ISO-8859-8";
|
152
|
+
break;
|
153
|
+
case XML_CHAR_ENCODING_8859_9:
|
154
|
+
encodingStr = "ISO-8859-9";
|
155
|
+
break;
|
156
|
+
case XML_CHAR_ENCODING_2022_JP:
|
157
|
+
encodingStr = "ISO-2022-JP";
|
158
|
+
break;
|
159
|
+
case XML_CHAR_ENCODING_SHIFT_JIS:
|
160
|
+
encodingStr = "Shift_JIS";
|
161
|
+
break;
|
162
|
+
case XML_CHAR_ENCODING_EUC_JP:
|
163
|
+
encodingStr = "EUC-JP";
|
164
|
+
break;
|
165
|
+
case XML_CHAR_ENCODING_ASCII:
|
166
|
+
encodingStr = "ASCII";
|
167
|
+
break;
|
168
|
+
}
|
169
|
+
|
170
|
+
return rb_str_new2(encodingStr);
|
171
|
+
}
|
172
|
+
|
31
173
|
/*
|
32
174
|
* call-seq:
|
33
175
|
* initialize -> LibXML::XML::Input instance
|
34
176
|
*
|
35
177
|
* Initialize a new intput object.
|
36
178
|
*/
|
37
|
-
VALUE
|
38
|
-
|
179
|
+
static VALUE
|
180
|
+
rxml_input_initialize(VALUE self) {
|
39
181
|
rb_ivar_set(self, ENCODING_ATTR, INT2NUM(XML_CHAR_ENCODING_UTF8));
|
40
182
|
return self;
|
41
183
|
}
|
@@ -47,8 +189,8 @@ ruby_xml_input_initialize(VALUE self) {
|
|
47
189
|
*
|
48
190
|
* Obtain the FILE this parser will read from.
|
49
191
|
*/
|
50
|
-
VALUE
|
51
|
-
|
192
|
+
static VALUE
|
193
|
+
rxml_input_file_get(VALUE self) {
|
52
194
|
return rb_ivar_get(self, FILE_ATTR);
|
53
195
|
}
|
54
196
|
|
@@ -58,8 +200,8 @@ ruby_xml_input_file_get(VALUE self) {
|
|
58
200
|
*
|
59
201
|
* Set the FILE this parser will read from.
|
60
202
|
*/
|
61
|
-
VALUE
|
62
|
-
|
203
|
+
static VALUE
|
204
|
+
rxml_input_file_set(VALUE self, VALUE FILE) {
|
63
205
|
Check_Type(FILE, T_STRING);
|
64
206
|
rb_ivar_set(self, FILE_ATTR, FILE);
|
65
207
|
rb_ivar_set(self, STRING_ATTR, Qnil);
|
@@ -75,8 +217,8 @@ ruby_xml_input_file_set(VALUE self, VALUE FILE) {
|
|
75
217
|
*
|
76
218
|
* Obtain the string this parser will read from.
|
77
219
|
*/
|
78
|
-
VALUE
|
79
|
-
|
220
|
+
static VALUE
|
221
|
+
rxml_input_string_get(VALUE self) {
|
80
222
|
return rb_ivar_get(self, STRING_ATTR);
|
81
223
|
}
|
82
224
|
|
@@ -87,8 +229,8 @@ ruby_xml_input_string_get(VALUE self) {
|
|
87
229
|
*
|
88
230
|
* Set the string this parser will read from.
|
89
231
|
*/
|
90
|
-
VALUE
|
91
|
-
|
232
|
+
static VALUE
|
233
|
+
rxml_input_string_set(VALUE self, VALUE string) {
|
92
234
|
Check_Type(string, T_STRING);
|
93
235
|
rb_ivar_set(self, FILE_ATTR, Qnil);
|
94
236
|
rb_ivar_set(self, STRING_ATTR, string);
|
@@ -103,8 +245,8 @@ ruby_xml_input_string_set(VALUE self, VALUE string) {
|
|
103
245
|
*
|
104
246
|
* Obtain the document this parser will read from.
|
105
247
|
*/
|
106
|
-
VALUE
|
107
|
-
|
248
|
+
static VALUE
|
249
|
+
rxml_input_document_get(VALUE self) {
|
108
250
|
return rb_ivar_get(self, DOCUMENT_ATTR);
|
109
251
|
}
|
110
252
|
|
@@ -114,8 +256,8 @@ ruby_xml_input_document_get(VALUE self) {
|
|
114
256
|
*
|
115
257
|
* Set the document this parser will read from.
|
116
258
|
*/
|
117
|
-
VALUE
|
118
|
-
|
259
|
+
static VALUE
|
260
|
+
rxml_input_document_set(VALUE self, VALUE document) {
|
119
261
|
rb_ivar_set(self, FILE_ATTR, Qnil);
|
120
262
|
rb_ivar_set(self, STRING_ATTR, Qnil);
|
121
263
|
rb_ivar_set(self, DOCUMENT_ATTR, document);
|
@@ -129,8 +271,8 @@ ruby_xml_input_document_set(VALUE self, VALUE document) {
|
|
129
271
|
*
|
130
272
|
* Obtain the IO instance this parser works with.
|
131
273
|
*/
|
132
|
-
VALUE
|
133
|
-
|
274
|
+
static VALUE
|
275
|
+
rxml_input_io_get(VALUE self) {
|
134
276
|
return rb_ivar_get(self, IO_ATTR);
|
135
277
|
}
|
136
278
|
|
@@ -140,11 +282,8 @@ ruby_xml_input_io_get(VALUE self) {
|
|
140
282
|
*
|
141
283
|
* Set the IO instance this parser works with.
|
142
284
|
*/
|
143
|
-
VALUE
|
144
|
-
|
145
|
-
if (!rb_obj_is_kind_of(io, rb_cIO))
|
146
|
-
rb_raise(rb_eTypeError, "Invalid argument, must be an IO object");
|
147
|
-
|
285
|
+
static VALUE
|
286
|
+
rxml_input_io_set(VALUE self, VALUE io) {
|
148
287
|
rb_ivar_set(self, FILE_ATTR, Qnil);
|
149
288
|
rb_ivar_set(self, STRING_ATTR, Qnil);
|
150
289
|
rb_ivar_set(self, DOCUMENT_ATTR, Qnil);
|
@@ -152,6 +291,14 @@ ruby_xml_input_io_set(VALUE self, VALUE io) {
|
|
152
291
|
return self;
|
153
292
|
}
|
154
293
|
|
294
|
+
// Rdoc needs to know
|
295
|
+
#ifdef RDOC_NEVER_DEFINED
|
296
|
+
mLibXML = rb_define_module("LibXML");
|
297
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
298
|
+
#endif
|
299
|
+
|
300
|
+
|
301
|
+
|
155
302
|
// Rdoc needs to know
|
156
303
|
#ifdef RDOC_NEVER_DEFINED
|
157
304
|
mLibXML = rb_define_module("LibXML");
|
@@ -164,16 +311,45 @@ ruby_init_xml_input(void) {
|
|
164
311
|
STRING_ATTR = rb_intern("@string");
|
165
312
|
DOCUMENT_ATTR = rb_intern("@document");
|
166
313
|
IO_ATTR = rb_intern("@io");
|
314
|
+
READ_METHOD = rb_intern("read");
|
167
315
|
|
168
316
|
cXMLInput = rb_define_class_under(mXML, "Input", rb_cObject);
|
317
|
+
rb_define_singleton_method(cXMLInput, "encoding_to_s", rxml_input_encoding_to_s, 1);
|
318
|
+
|
319
|
+
rb_define_const(cXMLInput, "UNDEFINED", INT2NUM(XPATH_UNDEFINED));
|
320
|
+
rb_define_const(cXMLInput, "ERROR", INT2NUM(XML_CHAR_ENCODING_ERROR)); /* No char encoding detected */
|
321
|
+
rb_define_const(cXMLInput, "NONE", INT2NUM(XML_CHAR_ENCODING_NONE)); /* No char encoding detected */
|
322
|
+
rb_define_const(cXMLInput, "UTF8", INT2NUM(XML_CHAR_ENCODING_UTF8)); /* UTF-8 */
|
323
|
+
rb_define_const(cXMLInput, "UTF16LE", INT2NUM(XML_CHAR_ENCODING_UTF16LE)); /* UTF-16 little endian */
|
324
|
+
rb_define_const(cXMLInput, "UTF16BE", INT2NUM(XML_CHAR_ENCODING_UTF16BE)); /* UTF-16 big endian */
|
325
|
+
rb_define_const(cXMLInput, "UCS4LE", INT2NUM(XML_CHAR_ENCODING_UCS4LE)); /* UCS-4 little endian */
|
326
|
+
rb_define_const(cXMLInput, "UCS4BE", INT2NUM(XML_CHAR_ENCODING_UCS4BE)); /* UCS-4 big endian */
|
327
|
+
rb_define_const(cXMLInput, "EBCDIC", INT2NUM(XML_CHAR_ENCODING_EBCDIC)); /* EBCDIC uh! */
|
328
|
+
rb_define_const(cXMLInput, "UCS4_2143", INT2NUM(XML_CHAR_ENCODING_UCS4_2143)); /* UCS-4 unusual ordering */
|
329
|
+
rb_define_const(cXMLInput, "UCS4_3412", INT2NUM(XML_CHAR_ENCODING_UCS4_3412)); /* UCS-4 unusual ordering */
|
330
|
+
rb_define_const(cXMLInput, "UCS2", INT2NUM(XML_CHAR_ENCODING_UCS2)); /* UCS-2 */
|
331
|
+
rb_define_const(cXMLInput, "ISO_8859_1", INT2NUM(XML_CHAR_ENCODING_8859_1)); /* ISO-8859-1 ISO Latin 1 */
|
332
|
+
rb_define_const(cXMLInput, "ISO_8859_2", INT2NUM(XML_CHAR_ENCODING_8859_2)); /* ISO-8859-2 ISO Latin 2 */
|
333
|
+
rb_define_const(cXMLInput, "ISO_8859_3", INT2NUM(XML_CHAR_ENCODING_8859_3)); /* ISO-8859-3 */
|
334
|
+
rb_define_const(cXMLInput, "ISO_8859_4", INT2NUM(XML_CHAR_ENCODING_8859_4)); /* ISO-8859-4 */
|
335
|
+
rb_define_const(cXMLInput, "ISO_8859_5", INT2NUM(XML_CHAR_ENCODING_8859_5)); /* ISO-8859-5 */
|
336
|
+
rb_define_const(cXMLInput, "ISO_8859_6", INT2NUM(XML_CHAR_ENCODING_8859_6)); /* ISO-8859-6 */
|
337
|
+
rb_define_const(cXMLInput, "ISO_8859_7", INT2NUM(XML_CHAR_ENCODING_8859_7)); /* ISO-8859-7 */
|
338
|
+
rb_define_const(cXMLInput, "ISO_8859_8", INT2NUM(XML_CHAR_ENCODING_8859_8)); /* ISO-8859-8 */
|
339
|
+
rb_define_const(cXMLInput, "ISO_8859_9", INT2NUM(XML_CHAR_ENCODING_8859_9)); /* ISO-8859-9 */
|
340
|
+
rb_define_const(cXMLInput, "ISO_2022_JP", INT2NUM(XML_CHAR_ENCODING_2022_JP)); /* ISO-2022-JP */
|
341
|
+
rb_define_const(cXMLInput, "SHIFT_JIS", INT2NUM(XML_CHAR_ENCODING_SHIFT_JIS)); /* Shift_JIS */
|
342
|
+
rb_define_const(cXMLInput, "EUC_JP", INT2NUM(XML_CHAR_ENCODING_EUC_JP)); /* EUC-JP */
|
343
|
+
rb_define_const(cXMLInput, "ASCII", INT2NUM(XML_CHAR_ENCODING_ASCII)); /* pure ASCII */
|
344
|
+
|
169
345
|
rb_define_attr(cXMLInput, "encoding", 1, 1);
|
170
|
-
rb_define_method(cXMLInput, "initialize",
|
171
|
-
rb_define_method(cXMLInput, "file",
|
172
|
-
rb_define_method(cXMLInput, "file=",
|
173
|
-
rb_define_method(cXMLInput, "string",
|
174
|
-
rb_define_method(cXMLInput, "string=",
|
175
|
-
rb_define_method(cXMLInput, "document",
|
176
|
-
rb_define_method(cXMLInput, "document=",
|
177
|
-
rb_define_method(cXMLInput, "io",
|
178
|
-
rb_define_method(cXMLInput, "io=",
|
346
|
+
rb_define_method(cXMLInput, "initialize", rxml_input_initialize, 0);
|
347
|
+
rb_define_method(cXMLInput, "file", rxml_input_file_get, 0);
|
348
|
+
rb_define_method(cXMLInput, "file=", rxml_input_file_set, 1);
|
349
|
+
rb_define_method(cXMLInput, "string", rxml_input_string_get, 0);
|
350
|
+
rb_define_method(cXMLInput, "string=", rxml_input_string_set, 1);
|
351
|
+
rb_define_method(cXMLInput, "document", rxml_input_document_get, 0);
|
352
|
+
rb_define_method(cXMLInput, "document=", rxml_input_document_set, 1);
|
353
|
+
rb_define_method(cXMLInput, "io", rxml_input_io_get, 0);
|
354
|
+
rb_define_method(cXMLInput, "io=", rxml_input_io_set, 1);
|
179
355
|
}
|
data/ext/libxml/ruby_xml_input.h
CHANGED
@@ -1,18 +1,20 @@
|
|
1
|
-
/* $Id:
|
1
|
+
/* $Id: rxml_parser.h 39 2006-02-21 20:40:16Z roscopeco $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
5
|
-
#ifndef
|
6
|
-
#define
|
5
|
+
#ifndef __rxml_INPUT__
|
6
|
+
#define __rxml_INPUT__
|
7
7
|
|
8
8
|
extern VALUE cXMLInput;
|
9
9
|
|
10
|
-
void ruby_init_xml_input();
|
11
|
-
|
12
10
|
extern ID ENCODING_ATTR;
|
13
11
|
extern ID FILE_ATTR;
|
14
12
|
extern ID STRING_ATTR;
|
15
13
|
extern ID DOCUMENT_ATTR;
|
16
14
|
extern ID IO_ATTR;
|
17
15
|
|
16
|
+
void ruby_init_xml_input();
|
17
|
+
int rxml_read_callback(void *context, char *buffer, int len);
|
18
|
+
VALUE rxml_input_encoding_to_s(VALUE self, VALUE encoding);
|
19
|
+
|
18
20
|
#endif
|
@@ -79,7 +79,7 @@ int ic_close (void *context) {
|
|
79
79
|
*
|
80
80
|
* Register a new set of I/O callback for handling parser input.
|
81
81
|
*/
|
82
|
-
VALUE input_callbacks_register_input_callbacks() {
|
82
|
+
static VALUE input_callbacks_register_input_callbacks() {
|
83
83
|
xmlRegisterInputCallbacks( ic_match, ic_open, ic_read, ic_close );
|
84
84
|
return(Qtrue);
|
85
85
|
}
|
@@ -91,7 +91,7 @@ VALUE input_callbacks_register_input_callbacks() {
|
|
91
91
|
*
|
92
92
|
* No documentation available.
|
93
93
|
*/
|
94
|
-
VALUE
|
94
|
+
static VALUE
|
95
95
|
input_callbacks_add_scheme (VALUE self, VALUE scheme_name, VALUE class) {
|
96
96
|
ic_scheme *scheme;
|
97
97
|
|
@@ -124,7 +124,7 @@ input_callbacks_add_scheme (VALUE self, VALUE scheme_name, VALUE class) {
|
|
124
124
|
*
|
125
125
|
* No documentation available.
|
126
126
|
*/
|
127
|
-
VALUE
|
127
|
+
static VALUE
|
128
128
|
input_callbacks_remove_scheme (VALUE self, VALUE scheme_name) {
|
129
129
|
char *name;
|
130
130
|
ic_scheme *save_scheme, *scheme;
|
data/ext/libxml/ruby_xml_node.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: ruby_xml_node.c
|
1
|
+
/* $Id: ruby_xml_node.c 612 2008-11-21 08:01:29Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
@@ -34,8 +34,8 @@ check_string_or_symbol( VALUE val ) {
|
|
34
34
|
*
|
35
35
|
* Obtain this node's base URI.
|
36
36
|
*/
|
37
|
-
VALUE
|
38
|
-
|
37
|
+
static VALUE
|
38
|
+
rxml_node_base_get(VALUE self) {
|
39
39
|
xmlNodePtr xnode;
|
40
40
|
xmlChar* base_uri;
|
41
41
|
VALUE result = Qnil;
|
@@ -63,8 +63,8 @@ ruby_xml_node_base_get(VALUE self) {
|
|
63
63
|
*
|
64
64
|
* Set this node's base URI.
|
65
65
|
*/
|
66
|
-
VALUE
|
67
|
-
|
66
|
+
static VALUE
|
67
|
+
rxml_node_base_set(VALUE self, VALUE uri) {
|
68
68
|
xmlNodePtr xnode;
|
69
69
|
|
70
70
|
Check_Type(uri, T_STRING);
|
@@ -83,8 +83,8 @@ ruby_xml_node_base_set(VALUE self, VALUE uri) {
|
|
83
83
|
*
|
84
84
|
* Obtain this node's content as a string.
|
85
85
|
*/
|
86
|
-
VALUE
|
87
|
-
|
86
|
+
static VALUE
|
87
|
+
rxml_node_content_get(VALUE self) {
|
88
88
|
xmlNodePtr xnode;
|
89
89
|
xmlChar *content;
|
90
90
|
VALUE result = Qnil;
|
@@ -105,8 +105,8 @@ ruby_xml_node_content_get(VALUE self) {
|
|
105
105
|
*
|
106
106
|
* Set this node's content to the specified string.
|
107
107
|
*/
|
108
|
-
VALUE
|
109
|
-
|
108
|
+
static VALUE
|
109
|
+
rxml_node_content_set(VALUE self, VALUE content) {
|
110
110
|
xmlNodePtr xnode;
|
111
111
|
|
112
112
|
Check_Type(content, T_STRING);
|
@@ -126,8 +126,8 @@ ruby_xml_node_content_set(VALUE self, VALUE content) {
|
|
126
126
|
* *Deprecated*: Stripped content can be obtained via the
|
127
127
|
* +content+ method.
|
128
128
|
*/
|
129
|
-
VALUE
|
130
|
-
|
129
|
+
static VALUE
|
130
|
+
rxml_node_content_stripped_get(VALUE self) {
|
131
131
|
xmlNodePtr xnode;
|
132
132
|
xmlChar* content;
|
133
133
|
VALUE result = Qnil;
|
@@ -151,14 +151,14 @@ ruby_xml_node_content_stripped_get(VALUE self) {
|
|
151
151
|
*
|
152
152
|
* Returns this node's first child node if any.
|
153
153
|
*/
|
154
|
-
VALUE
|
155
|
-
|
154
|
+
static VALUE
|
155
|
+
rxml_node_first_get(VALUE self) {
|
156
156
|
xmlNodePtr xnode;
|
157
157
|
|
158
158
|
Data_Get_Struct(self, xmlNode, xnode);
|
159
159
|
|
160
160
|
if (xnode->children)
|
161
|
-
return(
|
161
|
+
return(rxml_node2_wrap(cXMLNode, xnode->children));
|
162
162
|
else
|
163
163
|
return(Qnil);
|
164
164
|
}
|
@@ -168,8 +168,8 @@ ruby_xml_node_first_get(VALUE self) {
|
|
168
168
|
* underlying for child_set and child_add, difference being
|
169
169
|
* former raises on implicit copy, latter does not.
|
170
170
|
*/
|
171
|
-
VALUE
|
172
|
-
|
171
|
+
static VALUE
|
172
|
+
rxml_node_child_set_aux(VALUE self, VALUE rnode) {
|
173
173
|
xmlNodePtr pnode, chld, ret;
|
174
174
|
|
175
175
|
if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
|
@@ -183,14 +183,14 @@ ruby_xml_node_child_set_aux(VALUE self, VALUE rnode) {
|
|
183
183
|
|
184
184
|
ret = xmlAddChild(pnode, chld);
|
185
185
|
if (ret == NULL) {
|
186
|
-
|
186
|
+
rxml_raise(&xmlLastError);
|
187
187
|
} else if ( ret==chld ) {
|
188
188
|
/* child was added whole to parent and we need to return it as a new object */
|
189
|
-
return
|
189
|
+
return rxml_node2_wrap(cXMLNode,chld);
|
190
190
|
}
|
191
191
|
/* else */
|
192
192
|
/* If it was a text node, then ret should be parent->last, so we will just return ret. */
|
193
|
-
return
|
193
|
+
return rxml_node2_wrap(cXMLNode,ret);
|
194
194
|
}
|
195
195
|
|
196
196
|
/*
|
@@ -199,9 +199,9 @@ ruby_xml_node_child_set_aux(VALUE self, VALUE rnode) {
|
|
199
199
|
*
|
200
200
|
* Set a child node for this node. Also called for <<
|
201
201
|
*/
|
202
|
-
VALUE
|
203
|
-
|
204
|
-
return
|
202
|
+
static VALUE
|
203
|
+
rxml_node_child_set(VALUE self, VALUE rnode) {
|
204
|
+
return rxml_node_child_set_aux(self, rnode);
|
205
205
|
}
|
206
206
|
|
207
207
|
|
@@ -214,8 +214,8 @@ ruby_xml_node_child_set(VALUE self, VALUE rnode) {
|
|
214
214
|
* added and not self, thereby allowing << calls to
|
215
215
|
* be chained.
|
216
216
|
*/
|
217
|
-
VALUE
|
218
|
-
|
217
|
+
static VALUE
|
218
|
+
rxml_node_content_add(VALUE self, VALUE obj) {
|
219
219
|
xmlNodePtr xnode;
|
220
220
|
VALUE str;
|
221
221
|
|
@@ -225,7 +225,7 @@ ruby_xml_node_content_add(VALUE self, VALUE obj) {
|
|
225
225
|
* danj 070827
|
226
226
|
*/
|
227
227
|
if (rb_obj_is_kind_of(obj, cXMLNode)) {
|
228
|
-
|
228
|
+
rxml_node_child_set(self, obj);
|
229
229
|
} else {
|
230
230
|
str = rb_obj_as_string(obj);
|
231
231
|
if (NIL_P(str) || TYPE(str) != T_STRING)
|
@@ -242,9 +242,9 @@ ruby_xml_node_content_add(VALUE self, VALUE obj) {
|
|
242
242
|
*
|
243
243
|
* Set a child node for this node.
|
244
244
|
*/
|
245
|
-
VALUE
|
246
|
-
|
247
|
-
return
|
245
|
+
static VALUE
|
246
|
+
rxml_node_child_add(VALUE self, VALUE rnode) {
|
247
|
+
return rxml_node_child_set_aux(self, rnode);
|
248
248
|
}
|
249
249
|
|
250
250
|
/*
|
@@ -253,8 +253,8 @@ ruby_xml_node_child_add(VALUE self, VALUE rnode) {
|
|
253
253
|
*
|
254
254
|
* Obtain the XML::Document this node belongs to.
|
255
255
|
*/
|
256
|
-
VALUE
|
257
|
-
|
256
|
+
static VALUE
|
257
|
+
rxml_node_doc(VALUE self) {
|
258
258
|
xmlNodePtr xnode;
|
259
259
|
xmlDocPtr doc=NULL;
|
260
260
|
|
@@ -298,8 +298,8 @@ ruby_xml_node_doc(VALUE self) {
|
|
298
298
|
*
|
299
299
|
* Dump this node to stdout.
|
300
300
|
*/
|
301
|
-
VALUE
|
302
|
-
|
301
|
+
static VALUE
|
302
|
+
rxml_node_dump(VALUE self) {
|
303
303
|
xmlNodePtr xnode;
|
304
304
|
xmlBufferPtr buf;
|
305
305
|
|
@@ -323,8 +323,8 @@ ruby_xml_node_dump(VALUE self) {
|
|
323
323
|
* Dump this node to stdout, including any debugging
|
324
324
|
* information.
|
325
325
|
*/
|
326
|
-
VALUE
|
327
|
-
|
326
|
+
static VALUE
|
327
|
+
rxml_node_debug_dump(VALUE self) {
|
328
328
|
xmlNodePtr xnode;
|
329
329
|
Data_Get_Struct(self, xmlNode, xnode);
|
330
330
|
|
@@ -346,8 +346,8 @@ ruby_xml_node_debug_dump(VALUE self) {
|
|
346
346
|
* doc = XML::Document.new('model/books.xml')
|
347
347
|
* doc.root.each {|node| puts node}
|
348
348
|
*/
|
349
|
-
VALUE
|
350
|
-
|
349
|
+
static VALUE
|
350
|
+
rxml_node_each(VALUE self) {
|
351
351
|
xmlNodePtr xnode;
|
352
352
|
xmlNodePtr xchild;
|
353
353
|
Data_Get_Struct(self, xmlNode, xnode);
|
@@ -355,7 +355,7 @@ ruby_xml_node_each(VALUE self) {
|
|
355
355
|
xchild = xnode->children;
|
356
356
|
|
357
357
|
while (xchild) {
|
358
|
-
rb_yield(
|
358
|
+
rb_yield(rxml_node2_wrap(cXMLNode, xchild));
|
359
359
|
xchild = xchild->next;
|
360
360
|
}
|
361
361
|
return Qnil;
|
@@ -368,8 +368,8 @@ ruby_xml_node_each(VALUE self) {
|
|
368
368
|
*
|
369
369
|
* Determine whether this node is empty.
|
370
370
|
*/
|
371
|
-
VALUE
|
372
|
-
|
371
|
+
static VALUE
|
372
|
+
rxml_node_empty_q(VALUE self) {
|
373
373
|
xmlNodePtr xnode;
|
374
374
|
Data_Get_Struct(self, xmlNode, xnode);
|
375
375
|
if (xnode == NULL)
|
@@ -379,7 +379,7 @@ ruby_xml_node_empty_q(VALUE self) {
|
|
379
379
|
}
|
380
380
|
|
381
381
|
|
382
|
-
VALUE
|
382
|
+
static VALUE rxml_node_to_s(VALUE self);
|
383
383
|
|
384
384
|
/*
|
385
385
|
* call-seq:
|
@@ -387,8 +387,8 @@ VALUE ruby_xml_node_to_s(VALUE self);
|
|
387
387
|
*
|
388
388
|
* Test equality between the two nodes. Two nodes are equal
|
389
389
|
* if they are the same node or have the same XML representation.*/
|
390
|
-
VALUE
|
391
|
-
|
390
|
+
static VALUE
|
391
|
+
rxml_node_eql_q(VALUE self, VALUE other) {
|
392
392
|
if (self == other)
|
393
393
|
{
|
394
394
|
return Qtrue;
|
@@ -405,8 +405,8 @@ ruby_xml_node_eql_q(VALUE self, VALUE other) {
|
|
405
405
|
if (rb_obj_is_kind_of(other, cXMLNode) == Qfalse)
|
406
406
|
rb_raise(rb_eTypeError, "Nodes can only be compared against other nodes");
|
407
407
|
|
408
|
-
self_xml =
|
409
|
-
other_xml =
|
408
|
+
self_xml = rxml_node_to_s(self);
|
409
|
+
other_xml = rxml_node_to_s(other);
|
410
410
|
return(rb_funcall(self_xml, rb_intern("=="), 1, other_xml));
|
411
411
|
}
|
412
412
|
}
|
@@ -418,8 +418,8 @@ ruby_xml_node_eql_q(VALUE self, VALUE other) {
|
|
418
418
|
* Create a new #CDATA node, optionally setting
|
419
419
|
* the node's content.
|
420
420
|
*/
|
421
|
-
VALUE
|
422
|
-
|
421
|
+
static VALUE
|
422
|
+
rxml_node_new_cdata(int argc, VALUE *argv, VALUE class) {
|
423
423
|
xmlNodePtr xnode;
|
424
424
|
VALUE str=Qnil;
|
425
425
|
|
@@ -436,7 +436,7 @@ ruby_xml_node_new_cdata(int argc, VALUE *argv, VALUE class) {
|
|
436
436
|
if (xnode == NULL)
|
437
437
|
return(Qnil);
|
438
438
|
|
439
|
-
return
|
439
|
+
return rxml_node2_wrap(class,xnode);
|
440
440
|
|
441
441
|
default:
|
442
442
|
rb_raise(rb_eArgError, "wrong number of arguments (1)");
|
@@ -455,8 +455,8 @@ ruby_xml_node_new_cdata(int argc, VALUE *argv, VALUE class) {
|
|
455
455
|
* the node's content.
|
456
456
|
*
|
457
457
|
*/
|
458
|
-
VALUE
|
459
|
-
|
458
|
+
static VALUE
|
459
|
+
rxml_node_new_comment(int argc, VALUE *argv, VALUE class) {
|
460
460
|
xmlNodePtr xnode;
|
461
461
|
VALUE str=Qnil;
|
462
462
|
|
@@ -474,7 +474,7 @@ ruby_xml_node_new_comment(int argc, VALUE *argv, VALUE class) {
|
|
474
474
|
if (xnode == NULL)
|
475
475
|
return(Qnil);
|
476
476
|
|
477
|
-
return
|
477
|
+
return rxml_node2_wrap(class,xnode);
|
478
478
|
|
479
479
|
default:
|
480
480
|
rb_raise(rb_eArgError, "wrong number of arguments (1)");
|
@@ -492,8 +492,8 @@ ruby_xml_node_new_comment(int argc, VALUE *argv, VALUE class) {
|
|
492
492
|
* Obtain the language set for this node, if any.
|
493
493
|
* This is set in XML via the xml:lang attribute.
|
494
494
|
*/
|
495
|
-
VALUE
|
496
|
-
|
495
|
+
static VALUE
|
496
|
+
rxml_node_lang_get(VALUE self) {
|
497
497
|
xmlNodePtr xnode;
|
498
498
|
xmlChar *lang;
|
499
499
|
VALUE result = Qnil;
|
@@ -519,8 +519,8 @@ ruby_xml_node_lang_get(VALUE self) {
|
|
519
519
|
* Set the language for this node. This affects the value
|
520
520
|
* of the xml:lang attribute.
|
521
521
|
*/
|
522
|
-
VALUE
|
523
|
-
|
522
|
+
static VALUE
|
523
|
+
rxml_node_lang_set(VALUE self, VALUE lang) {
|
524
524
|
xmlNodePtr xnode;
|
525
525
|
|
526
526
|
Check_Type(lang, T_STRING);
|
@@ -537,14 +537,14 @@ ruby_xml_node_lang_set(VALUE self, VALUE lang) {
|
|
537
537
|
*
|
538
538
|
* Obtain the last child node of this node, if any.
|
539
539
|
*/
|
540
|
-
VALUE
|
541
|
-
|
540
|
+
static VALUE
|
541
|
+
rxml_node_last_get(VALUE self) {
|
542
542
|
xmlNodePtr xnode;
|
543
543
|
|
544
544
|
Data_Get_Struct(self, xmlNode, xnode);
|
545
545
|
|
546
546
|
if (xnode->last)
|
547
|
-
return(
|
547
|
+
return(rxml_node2_wrap(cXMLNode, xnode->last));
|
548
548
|
else
|
549
549
|
return(Qnil);
|
550
550
|
}
|
@@ -557,8 +557,8 @@ ruby_xml_node_last_get(VALUE self) {
|
|
557
557
|
* node was read from. If +default_line_numbers+ is set
|
558
558
|
* false (the default), this method returns zero.
|
559
559
|
*/
|
560
|
-
VALUE
|
561
|
-
|
560
|
+
static VALUE
|
561
|
+
rxml_node_line_num(VALUE self) {
|
562
562
|
xmlNodePtr xnode;
|
563
563
|
long line_num;
|
564
564
|
Data_Get_Struct(self, xmlNode, xnode);
|
@@ -580,8 +580,8 @@ ruby_xml_node_line_num(VALUE self) {
|
|
580
580
|
*
|
581
581
|
* Determine whether this node is an xlink node.
|
582
582
|
*/
|
583
|
-
VALUE
|
584
|
-
|
583
|
+
static VALUE
|
584
|
+
rxml_node_xlink_q(VALUE self) {
|
585
585
|
xmlNodePtr xnode;
|
586
586
|
xlinkType xlt;
|
587
587
|
|
@@ -603,8 +603,8 @@ ruby_xml_node_xlink_q(VALUE self) {
|
|
603
603
|
* If this is not an xlink node (see +xlink?+), will return
|
604
604
|
* nil.
|
605
605
|
*/
|
606
|
-
VALUE
|
607
|
-
|
606
|
+
static VALUE
|
607
|
+
rxml_node_xlink_type(VALUE self) {
|
608
608
|
xmlNodePtr xnode;
|
609
609
|
xlinkType xlt;
|
610
610
|
|
@@ -626,8 +626,8 @@ ruby_xml_node_xlink_type(VALUE self) {
|
|
626
626
|
* If this is not an xlink node (see +xlink?+), will return
|
627
627
|
* nil.
|
628
628
|
*/
|
629
|
-
VALUE
|
630
|
-
|
629
|
+
static VALUE
|
630
|
+
rxml_node_xlink_type_name(VALUE self) {
|
631
631
|
xmlNodePtr xnode;
|
632
632
|
xlinkType xlt;
|
633
633
|
|
@@ -654,8 +654,8 @@ ruby_xml_node_xlink_type_name(VALUE self) {
|
|
654
654
|
*
|
655
655
|
* Obtain this node's name.
|
656
656
|
*/
|
657
|
-
VALUE
|
658
|
-
|
657
|
+
static VALUE
|
658
|
+
rxml_node_name_get(VALUE self) {
|
659
659
|
xmlNodePtr xnode;
|
660
660
|
const xmlChar *name;
|
661
661
|
|
@@ -702,8 +702,8 @@ ruby_xml_node_name_get(VALUE self) {
|
|
702
702
|
*
|
703
703
|
* Set this node's name.
|
704
704
|
*/
|
705
|
-
VALUE
|
706
|
-
|
705
|
+
static VALUE
|
706
|
+
rxml_node_name_set(VALUE self, VALUE name) {
|
707
707
|
xmlNodePtr xnode;
|
708
708
|
|
709
709
|
Check_Type(name, T_STRING);
|
@@ -720,8 +720,8 @@ ruby_xml_node_name_set(VALUE self, VALUE name) {
|
|
720
720
|
* Obtain an array of +XML::NS+ objects representing
|
721
721
|
* this node's xmlns attributes
|
722
722
|
*/
|
723
|
-
VALUE
|
724
|
-
|
723
|
+
static VALUE
|
724
|
+
rxml_node_namespace_get(VALUE self) {
|
725
725
|
xmlNodePtr xnode;
|
726
726
|
xmlNsPtr *nsList, *cur;
|
727
727
|
VALUE arr, ns;
|
@@ -737,7 +737,7 @@ ruby_xml_node_namespace_get(VALUE self) {
|
|
737
737
|
|
738
738
|
arr = rb_ary_new();
|
739
739
|
for (cur = nsList; *cur != NULL; cur++) {
|
740
|
-
ns =
|
740
|
+
ns = rxml_ns_wrap(*cur);
|
741
741
|
if (ns == Qnil)
|
742
742
|
continue;
|
743
743
|
else
|
@@ -755,15 +755,15 @@ ruby_xml_node_namespace_get(VALUE self) {
|
|
755
755
|
*
|
756
756
|
* Obtain this node's namespace node.
|
757
757
|
*/
|
758
|
-
VALUE
|
759
|
-
|
758
|
+
static VALUE
|
759
|
+
rxml_node_namespace_get_node(VALUE self) {
|
760
760
|
xmlNodePtr xnode;
|
761
761
|
|
762
762
|
Data_Get_Struct(self, xmlNode, xnode);
|
763
763
|
if (xnode->ns == NULL)
|
764
764
|
return(Qnil);
|
765
765
|
else
|
766
|
-
return
|
766
|
+
return rxml_ns_wrap(xnode->ns);
|
767
767
|
}
|
768
768
|
|
769
769
|
// TODO namespace_set can take varargs (in fact, must if used
|
@@ -779,8 +779,8 @@ ruby_xml_node_namespace_get_node(VALUE self) {
|
|
779
779
|
*
|
780
780
|
* Add the specified XML::NS object to this node's xmlns attributes.
|
781
781
|
*/
|
782
|
-
VALUE
|
783
|
-
|
782
|
+
static VALUE
|
783
|
+
rxml_node_namespace_set(int argc, VALUE *argv, VALUE self) {
|
784
784
|
VALUE rns, rprefix;
|
785
785
|
xmlNodePtr xnode;
|
786
786
|
xmlNsPtr xns;
|
@@ -818,9 +818,9 @@ ruby_xml_node_namespace_set(int argc, VALUE *argv, VALUE self) {
|
|
818
818
|
|
819
819
|
xns = xmlNewNs(xnode, (xmlChar*)href, (xmlChar*)StringValuePtr(rprefix));
|
820
820
|
if (xns == NULL)
|
821
|
-
|
821
|
+
rxml_raise(&xmlLastError);
|
822
822
|
else
|
823
|
-
return
|
823
|
+
return rxml_ns_wrap(xns);
|
824
824
|
break;
|
825
825
|
|
826
826
|
default:
|
@@ -844,7 +844,7 @@ ruby_xml_node_namespace_set(int argc, VALUE *argv, VALUE self) {
|
|
844
844
|
* If the xmlNode has no parent or document, then call xmlFree.
|
845
845
|
*/
|
846
846
|
void
|
847
|
-
|
847
|
+
rxml_node2_free(xmlNodePtr xnode) {
|
848
848
|
|
849
849
|
if (xnode != NULL) {
|
850
850
|
xnode->_private=NULL;
|
@@ -856,7 +856,7 @@ ruby_xml_node2_free(xmlNodePtr xnode) {
|
|
856
856
|
}
|
857
857
|
|
858
858
|
void
|
859
|
-
|
859
|
+
rxml_node_mark_common(xmlNodePtr xnode) {
|
860
860
|
if (xnode->parent == NULL ) {
|
861
861
|
#ifdef NODE_DEBUG
|
862
862
|
fprintf(stderr,"mark no parent r=0x%x *n=0x%x\n",rxn,node);
|
@@ -880,7 +880,7 @@ ruby_xml_node_mark_common(xmlNodePtr xnode) {
|
|
880
880
|
}
|
881
881
|
|
882
882
|
void
|
883
|
-
|
883
|
+
rxml_node2_mark(xmlNodePtr xnode) {
|
884
884
|
if (xnode == NULL ) return;
|
885
885
|
|
886
886
|
if (xnode->_private == NULL ) {
|
@@ -889,11 +889,11 @@ ruby_xml_node2_mark(xmlNodePtr xnode) {
|
|
889
889
|
return;
|
890
890
|
}
|
891
891
|
|
892
|
-
|
892
|
+
rxml_node_mark_common(xnode);
|
893
893
|
}
|
894
894
|
|
895
895
|
VALUE
|
896
|
-
|
896
|
+
rxml_node2_wrap(VALUE class, xmlNodePtr xnode)
|
897
897
|
{
|
898
898
|
VALUE obj;
|
899
899
|
|
@@ -903,7 +903,7 @@ ruby_xml_node2_wrap(VALUE class, xmlNodePtr xnode)
|
|
903
903
|
}
|
904
904
|
|
905
905
|
obj=Data_Wrap_Struct(class,
|
906
|
-
|
906
|
+
rxml_node2_mark, rxml_node2_free,
|
907
907
|
xnode);
|
908
908
|
|
909
909
|
xnode->_private=(void*)obj;
|
@@ -917,8 +917,8 @@ ruby_xml_node2_wrap(VALUE class, xmlNodePtr xnode)
|
|
917
917
|
* Create a new element node in the specified namespace with the
|
918
918
|
* supplied name and content.
|
919
919
|
*/
|
920
|
-
VALUE
|
921
|
-
|
920
|
+
static VALUE
|
921
|
+
rxml_node_new_string(VALUE klass, VALUE ns, VALUE name, VALUE val)
|
922
922
|
{
|
923
923
|
xmlNodePtr xnode;
|
924
924
|
xmlNsPtr xns = NULL;
|
@@ -931,7 +931,7 @@ ruby_xml_node_new_string(VALUE klass, VALUE ns, VALUE name, VALUE val)
|
|
931
931
|
xnode = xmlNewNode(xns,(xmlChar*)StringValuePtr(name));
|
932
932
|
xnode->_private=NULL;
|
933
933
|
|
934
|
-
node =
|
934
|
+
node = rxml_node2_wrap(klass, xnode);
|
935
935
|
rb_obj_call_init(node, 0, NULL);
|
936
936
|
|
937
937
|
if (!NIL_P(val))
|
@@ -939,7 +939,7 @@ ruby_xml_node_new_string(VALUE klass, VALUE ns, VALUE name, VALUE val)
|
|
939
939
|
if (TYPE(val) != T_STRING)
|
940
940
|
val = rb_obj_as_string(val);
|
941
941
|
|
942
|
-
|
942
|
+
rxml_node_content_set(node, val);
|
943
943
|
}
|
944
944
|
return node;
|
945
945
|
}
|
@@ -953,8 +953,8 @@ ruby_xml_node_new_string(VALUE klass, VALUE ns, VALUE name, VALUE val)
|
|
953
953
|
* the node's content.
|
954
954
|
* backward compatibility for <.5 new
|
955
955
|
*/
|
956
|
-
VALUE
|
957
|
-
|
956
|
+
static VALUE
|
957
|
+
rxml_node_new_string_bc(int argc, VALUE *argv, VALUE class)
|
958
958
|
{
|
959
959
|
VALUE content=Qnil;
|
960
960
|
VALUE name=Qnil;
|
@@ -966,7 +966,7 @@ ruby_xml_node_new_string_bc(int argc, VALUE *argv, VALUE class)
|
|
966
966
|
|
967
967
|
case 1:
|
968
968
|
name=check_string_or_symbol( argv[0] );
|
969
|
-
return
|
969
|
+
return rxml_node_new_string(class,Qnil,name,content);
|
970
970
|
|
971
971
|
default:
|
972
972
|
rb_raise(rb_eArgError, "wrong number of arguments (1 or 2) given %d",argc);
|
@@ -979,14 +979,14 @@ ruby_xml_node_new_string_bc(int argc, VALUE *argv, VALUE class)
|
|
979
979
|
*
|
980
980
|
* Obtain the next sibling node, if any.
|
981
981
|
*/
|
982
|
-
VALUE
|
983
|
-
|
982
|
+
static VALUE
|
983
|
+
rxml_node_next_get(VALUE self) {
|
984
984
|
xmlNodePtr xnode;
|
985
985
|
|
986
986
|
Data_Get_Struct(self, xmlNode, xnode);
|
987
987
|
|
988
988
|
if (xnode->next)
|
989
|
-
return(
|
989
|
+
return(rxml_node2_wrap(cXMLNode, xnode->next));
|
990
990
|
else
|
991
991
|
return(Qnil);
|
992
992
|
}
|
@@ -998,8 +998,8 @@ ruby_xml_node_next_get(VALUE self) {
|
|
998
998
|
*
|
999
999
|
* Insert the specified node as this node's next sibling.
|
1000
1000
|
*/
|
1001
|
-
VALUE
|
1002
|
-
|
1001
|
+
static VALUE
|
1002
|
+
rxml_node_next_set(VALUE self, VALUE rnode) {
|
1003
1003
|
xmlNodePtr cnode, pnode, ret;
|
1004
1004
|
|
1005
1005
|
if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
|
@@ -1010,9 +1010,9 @@ ruby_xml_node_next_set(VALUE self, VALUE rnode) {
|
|
1010
1010
|
|
1011
1011
|
ret = xmlAddNextSibling(pnode, cnode);
|
1012
1012
|
if (ret == NULL)
|
1013
|
-
|
1013
|
+
rxml_raise(&xmlLastError);
|
1014
1014
|
|
1015
|
-
return(
|
1015
|
+
return(rxml_node2_wrap(cXMLNode, ret));
|
1016
1016
|
}
|
1017
1017
|
|
1018
1018
|
|
@@ -1022,8 +1022,8 @@ ruby_xml_node_next_set(VALUE self, VALUE rnode) {
|
|
1022
1022
|
*
|
1023
1023
|
* Determine whether this node has a namespace.
|
1024
1024
|
*/
|
1025
|
-
VALUE
|
1026
|
-
|
1025
|
+
static VALUE
|
1026
|
+
rxml_node_ns_q(VALUE self) {
|
1027
1027
|
xmlNodePtr xnode;
|
1028
1028
|
Data_Get_Struct(self, xmlNode, xnode);
|
1029
1029
|
if (xnode->ns == NULL)
|
@@ -1039,8 +1039,8 @@ ruby_xml_node_ns_q(VALUE self) {
|
|
1039
1039
|
* Obtain an array of +XML::NS+ objects representing
|
1040
1040
|
* this node's xmlns attributes
|
1041
1041
|
*/
|
1042
|
-
VALUE
|
1043
|
-
|
1042
|
+
static VALUE
|
1043
|
+
rxml_node_ns_def_q(VALUE self) {
|
1044
1044
|
xmlNodePtr xnode;
|
1045
1045
|
Data_Get_Struct(self, xmlNode, xnode);
|
1046
1046
|
if (xnode->nsDef == NULL)
|
@@ -1056,14 +1056,14 @@ ruby_xml_node_ns_def_q(VALUE self) {
|
|
1056
1056
|
*
|
1057
1057
|
* Obtain this node's default namespace.
|
1058
1058
|
*/
|
1059
|
-
VALUE
|
1060
|
-
|
1059
|
+
static VALUE
|
1060
|
+
rxml_node_ns_def_get(VALUE self) {
|
1061
1061
|
xmlNodePtr xnode;
|
1062
1062
|
Data_Get_Struct(self, xmlNode, xnode);
|
1063
1063
|
if (xnode->nsDef == NULL)
|
1064
1064
|
return(Qnil);
|
1065
1065
|
else
|
1066
|
-
return(
|
1066
|
+
return(rxml_ns_wrap(xnode->nsDef));
|
1067
1067
|
}
|
1068
1068
|
|
1069
1069
|
|
@@ -1073,14 +1073,14 @@ ruby_xml_node_ns_def_get(VALUE self) {
|
|
1073
1073
|
*
|
1074
1074
|
* Obtain this node's parent node, if any.
|
1075
1075
|
*/
|
1076
|
-
VALUE
|
1077
|
-
|
1076
|
+
static VALUE
|
1077
|
+
rxml_node_parent_get(VALUE self) {
|
1078
1078
|
xmlNodePtr xnode;
|
1079
1079
|
|
1080
1080
|
Data_Get_Struct(self, xmlNode, xnode);
|
1081
1081
|
|
1082
1082
|
if (xnode->parent)
|
1083
|
-
return(
|
1083
|
+
return(rxml_node2_wrap(cXMLNode, xnode->parent));
|
1084
1084
|
else
|
1085
1085
|
return(Qnil);
|
1086
1086
|
}
|
@@ -1092,8 +1092,8 @@ ruby_xml_node_parent_get(VALUE self) {
|
|
1092
1092
|
*
|
1093
1093
|
* Obtain this node's path.
|
1094
1094
|
*/
|
1095
|
-
VALUE
|
1096
|
-
|
1095
|
+
static VALUE
|
1096
|
+
rxml_node_path(VALUE self) {
|
1097
1097
|
xmlNodePtr xnode;
|
1098
1098
|
xmlChar *path;
|
1099
1099
|
|
@@ -1113,9 +1113,9 @@ ruby_xml_node_path(VALUE self) {
|
|
1113
1113
|
*
|
1114
1114
|
* Evaluates an XPointer expression relative to this node.
|
1115
1115
|
*/
|
1116
|
-
VALUE
|
1117
|
-
|
1118
|
-
return(
|
1116
|
+
static VALUE
|
1117
|
+
rxml_node_pointer(VALUE self, VALUE xptr_str) {
|
1118
|
+
return(rxml_xpointer_point2(self, xptr_str));
|
1119
1119
|
}
|
1120
1120
|
|
1121
1121
|
|
@@ -1125,8 +1125,8 @@ ruby_xml_node_pointer(VALUE self, VALUE xptr_str) {
|
|
1125
1125
|
*
|
1126
1126
|
* Obtain the previous sibling, if any.
|
1127
1127
|
*/
|
1128
|
-
VALUE
|
1129
|
-
|
1128
|
+
static VALUE
|
1129
|
+
rxml_node_prev_get(VALUE self) {
|
1130
1130
|
xmlNodePtr xnode;
|
1131
1131
|
xmlNodePtr node;
|
1132
1132
|
Data_Get_Struct(self, xmlNode, xnode);
|
@@ -1154,7 +1154,7 @@ ruby_xml_node_prev_get(VALUE self) {
|
|
1154
1154
|
if (node == NULL)
|
1155
1155
|
return(Qnil);
|
1156
1156
|
else
|
1157
|
-
return(
|
1157
|
+
return(rxml_node2_wrap(cXMLNode, node));
|
1158
1158
|
}
|
1159
1159
|
|
1160
1160
|
|
@@ -1164,8 +1164,8 @@ ruby_xml_node_prev_get(VALUE self) {
|
|
1164
1164
|
*
|
1165
1165
|
* Insert the specified node as this node's previous sibling.
|
1166
1166
|
*/
|
1167
|
-
VALUE
|
1168
|
-
|
1167
|
+
static VALUE
|
1168
|
+
rxml_node_prev_set(VALUE self, VALUE rnode) {
|
1169
1169
|
xmlNodePtr cnode, pnode, ret;
|
1170
1170
|
|
1171
1171
|
if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
|
@@ -1176,9 +1176,9 @@ ruby_xml_node_prev_set(VALUE self, VALUE rnode) {
|
|
1176
1176
|
|
1177
1177
|
ret = xmlAddPrevSibling(pnode, cnode);
|
1178
1178
|
if (ret == NULL)
|
1179
|
-
|
1179
|
+
rxml_raise(&xmlLastError);
|
1180
1180
|
|
1181
|
-
return(
|
1181
|
+
return(rxml_node2_wrap(cXMLNode, ret));
|
1182
1182
|
}
|
1183
1183
|
|
1184
1184
|
/*
|
@@ -1187,12 +1187,12 @@ ruby_xml_node_prev_set(VALUE self, VALUE rnode) {
|
|
1187
1187
|
*
|
1188
1188
|
* Returns the XML::Attributes for this node.
|
1189
1189
|
*/
|
1190
|
-
VALUE
|
1191
|
-
|
1190
|
+
static VALUE
|
1191
|
+
rxml_node_attributes_get(VALUE self) {
|
1192
1192
|
xmlNodePtr xnode;
|
1193
1193
|
|
1194
1194
|
Data_Get_Struct(self, xmlNode, xnode);
|
1195
|
-
return
|
1195
|
+
return rxml_attributes_new(xnode);
|
1196
1196
|
}
|
1197
1197
|
|
1198
1198
|
/*
|
@@ -1202,10 +1202,10 @@ ruby_xml_node_attributes_get(VALUE self) {
|
|
1202
1202
|
*
|
1203
1203
|
* Obtain the named pyroperty.
|
1204
1204
|
*/
|
1205
|
-
VALUE
|
1206
|
-
|
1207
|
-
VALUE attributes =
|
1208
|
-
return
|
1205
|
+
static VALUE
|
1206
|
+
rxml_node_attribute_get(VALUE self, VALUE name) {
|
1207
|
+
VALUE attributes = rxml_node_attributes_get(self);
|
1208
|
+
return rxml_attributes_attribute_get(attributes, name);
|
1209
1209
|
}
|
1210
1210
|
|
1211
1211
|
/*
|
@@ -1214,10 +1214,10 @@ ruby_xml_node_attribute_get(VALUE self, VALUE name) {
|
|
1214
1214
|
*
|
1215
1215
|
* Set the named property.
|
1216
1216
|
*/
|
1217
|
-
VALUE
|
1218
|
-
|
1219
|
-
VALUE attributes =
|
1220
|
-
return
|
1217
|
+
static VALUE
|
1218
|
+
rxml_node_property_set(VALUE self, VALUE name, VALUE value) {
|
1219
|
+
VALUE attributes = rxml_node_attributes_get(self);
|
1220
|
+
return rxml_attributes_attribute_set(attributes, name, value);
|
1221
1221
|
}
|
1222
1222
|
|
1223
1223
|
|
@@ -1227,8 +1227,8 @@ ruby_xml_node_property_set(VALUE self, VALUE name, VALUE value) {
|
|
1227
1227
|
*
|
1228
1228
|
* Removes this node from it's parent.
|
1229
1229
|
*/
|
1230
|
-
VALUE
|
1231
|
-
|
1230
|
+
static VALUE
|
1231
|
+
rxml_node_remove_ex(VALUE self) {
|
1232
1232
|
xmlNodePtr xnode;
|
1233
1233
|
Data_Get_Struct(self, xmlNode, xnode);
|
1234
1234
|
xmlUnlinkNode(xnode);
|
@@ -1242,13 +1242,13 @@ ruby_xml_node_remove_ex(VALUE self) {
|
|
1242
1242
|
*
|
1243
1243
|
* Search for a namespace by href.
|
1244
1244
|
*/
|
1245
|
-
VALUE
|
1246
|
-
|
1245
|
+
static VALUE
|
1246
|
+
rxml_node_search_href(VALUE self, VALUE href) {
|
1247
1247
|
xmlNodePtr xnode;
|
1248
1248
|
|
1249
1249
|
Check_Type(href, T_STRING);
|
1250
1250
|
Data_Get_Struct(self, xmlNode, xnode);
|
1251
|
-
return(
|
1251
|
+
return(rxml_ns_wrap(xmlSearchNsByHref(xnode->doc, xnode,
|
1252
1252
|
(xmlChar*)StringValuePtr(href))));
|
1253
1253
|
}
|
1254
1254
|
|
@@ -1259,13 +1259,13 @@ ruby_xml_node_search_href(VALUE self, VALUE href) {
|
|
1259
1259
|
*
|
1260
1260
|
* Search for a namespace by namespace.
|
1261
1261
|
*/
|
1262
|
-
VALUE
|
1263
|
-
|
1262
|
+
static VALUE
|
1263
|
+
rxml_node_search_ns(VALUE self, VALUE ns) {
|
1264
1264
|
xmlNodePtr xnode;
|
1265
1265
|
|
1266
1266
|
Check_Type(ns, T_STRING);
|
1267
1267
|
Data_Get_Struct(self, xmlNode, xnode);
|
1268
|
-
return(
|
1268
|
+
return(rxml_ns_wrap(xmlSearchNs(xnode->doc, xnode,
|
1269
1269
|
(xmlChar*)StringValuePtr(ns))));
|
1270
1270
|
}
|
1271
1271
|
|
@@ -1276,8 +1276,8 @@ ruby_xml_node_search_ns(VALUE self, VALUE ns) {
|
|
1276
1276
|
*
|
1277
1277
|
* Add the specified node as a sibling of this node.
|
1278
1278
|
*/
|
1279
|
-
VALUE
|
1280
|
-
|
1279
|
+
static VALUE
|
1280
|
+
rxml_node_sibling_set(VALUE self, VALUE rnode) {
|
1281
1281
|
xmlNodePtr cnode, pnode, ret;
|
1282
1282
|
VALUE obj;
|
1283
1283
|
|
@@ -1289,10 +1289,10 @@ ruby_xml_node_sibling_set(VALUE self, VALUE rnode) {
|
|
1289
1289
|
|
1290
1290
|
ret = xmlAddSibling(pnode, cnode);
|
1291
1291
|
if (ret == NULL)
|
1292
|
-
|
1292
|
+
rxml_raise(&xmlLastError);
|
1293
1293
|
|
1294
1294
|
if (ret->_private==NULL)
|
1295
|
-
obj=
|
1295
|
+
obj=rxml_node2_wrap(cXMLNode,ret);
|
1296
1296
|
else
|
1297
1297
|
obj=(VALUE)ret->_private;
|
1298
1298
|
|
@@ -1306,8 +1306,8 @@ ruby_xml_node_sibling_set(VALUE self, VALUE rnode) {
|
|
1306
1306
|
*
|
1307
1307
|
* Determine whether this node preserves whitespace.
|
1308
1308
|
*/
|
1309
|
-
VALUE
|
1310
|
-
|
1309
|
+
static VALUE
|
1310
|
+
rxml_node_space_preserve_get(VALUE self) {
|
1311
1311
|
xmlNodePtr xnode;
|
1312
1312
|
|
1313
1313
|
Data_Get_Struct(self, xmlNode, xnode);
|
@@ -1321,8 +1321,8 @@ ruby_xml_node_space_preserve_get(VALUE self) {
|
|
1321
1321
|
*
|
1322
1322
|
* Control whether this node preserves whitespace.
|
1323
1323
|
*/
|
1324
|
-
VALUE
|
1325
|
-
|
1324
|
+
static VALUE
|
1325
|
+
rxml_node_space_preserve_set(VALUE self, VALUE bool) {
|
1326
1326
|
xmlNodePtr xnode;
|
1327
1327
|
Data_Get_Struct(self, xmlNode, xnode);
|
1328
1328
|
|
@@ -1341,8 +1341,8 @@ ruby_xml_node_space_preserve_set(VALUE self, VALUE bool) {
|
|
1341
1341
|
* Coerce this node to a string representation of
|
1342
1342
|
* it's XML.
|
1343
1343
|
*/
|
1344
|
-
VALUE
|
1345
|
-
|
1344
|
+
static VALUE
|
1345
|
+
rxml_node_to_s(VALUE self) {
|
1346
1346
|
xmlNodePtr xnode;
|
1347
1347
|
xmlBufferPtr buf;
|
1348
1348
|
VALUE result;
|
@@ -1363,8 +1363,8 @@ ruby_xml_node_to_s(VALUE self) {
|
|
1363
1363
|
*
|
1364
1364
|
* Obtain this node's type identifier.
|
1365
1365
|
*/
|
1366
|
-
VALUE
|
1367
|
-
|
1366
|
+
static VALUE
|
1367
|
+
rxml_node_type(VALUE self) {
|
1368
1368
|
xmlNodePtr xnode;
|
1369
1369
|
Data_Get_Struct(self, xmlNode, xnode);
|
1370
1370
|
return(INT2NUM(xnode->type));
|
@@ -1383,8 +1383,8 @@ ruby_xml_node_type(VALUE self) {
|
|
1383
1383
|
* to true.
|
1384
1384
|
*
|
1385
1385
|
*/
|
1386
|
-
VALUE
|
1387
|
-
|
1386
|
+
static VALUE
|
1387
|
+
rxml_node_copy(VALUE self, VALUE deep) {
|
1388
1388
|
xmlNodePtr xnode;
|
1389
1389
|
xmlNodePtr xcopy;
|
1390
1390
|
int recursive = (deep==Qnil || deep==Qfalse) ? 0 : 1;
|
@@ -1393,7 +1393,7 @@ ruby_xml_node_copy(VALUE self, VALUE deep) {
|
|
1393
1393
|
xcopy = xmlCopyNode(xnode, recursive);
|
1394
1394
|
|
1395
1395
|
if (xcopy)
|
1396
|
-
return
|
1396
|
+
return rxml_node2_wrap(cXMLNode, xcopy);
|
1397
1397
|
else
|
1398
1398
|
return Qnil;
|
1399
1399
|
}
|
@@ -1406,8 +1406,8 @@ ruby_xml_node_copy(VALUE self, VALUE deep) {
|
|
1406
1406
|
* the node's content.
|
1407
1407
|
*
|
1408
1408
|
*/
|
1409
|
-
VALUE
|
1410
|
-
|
1409
|
+
static VALUE
|
1410
|
+
rxml_node_new_text(VALUE class, VALUE text)
|
1411
1411
|
{
|
1412
1412
|
VALUE obj;
|
1413
1413
|
xmlNodePtr xnode;
|
@@ -1422,19 +1422,19 @@ ruby_xml_node_new_text(VALUE class, VALUE text)
|
|
1422
1422
|
if ( xnode == NULL )
|
1423
1423
|
return Qnil;
|
1424
1424
|
|
1425
|
-
obj=
|
1425
|
+
obj=rxml_node2_wrap(class,xnode);
|
1426
1426
|
rb_obj_call_init(obj,0,NULL);
|
1427
1427
|
return obj;
|
1428
1428
|
}
|
1429
1429
|
|
1430
1430
|
void
|
1431
|
-
|
1431
|
+
rxml_node_registerNode(xmlNodePtr node)
|
1432
1432
|
{
|
1433
1433
|
node->_private=NULL;
|
1434
1434
|
}
|
1435
1435
|
|
1436
1436
|
void
|
1437
|
-
|
1437
|
+
rxml_node_deregisterNode(xmlNodePtr xnode)
|
1438
1438
|
{
|
1439
1439
|
VALUE node;
|
1440
1440
|
|
@@ -1451,8 +1451,8 @@ ruby_xml_node_deregisterNode(xmlNodePtr xnode)
|
|
1451
1451
|
|
1452
1452
|
void
|
1453
1453
|
ruby_init_xml_node(void) {
|
1454
|
-
xmlRegisterNodeDefault(
|
1455
|
-
xmlDeregisterNodeDefault(
|
1454
|
+
xmlRegisterNodeDefault(rxml_node_registerNode);
|
1455
|
+
xmlDeregisterNodeDefault(rxml_node_deregisterNode);
|
1456
1456
|
|
1457
1457
|
cXMLNode = rb_define_class_under(mXML, "Node", rb_cObject);
|
1458
1458
|
|
@@ -1498,69 +1498,69 @@ ruby_init_xml_node(void) {
|
|
1498
1498
|
rb_define_const(cXMLNode, "DOCB_DOCUMENT_NODE", Qnil);
|
1499
1499
|
#endif
|
1500
1500
|
|
1501
|
-
rb_define_singleton_method(cXMLNode, "new",
|
1502
|
-
rb_define_singleton_method(cXMLNode, "new_cdata",
|
1503
|
-
rb_define_singleton_method(cXMLNode, "new_comment",
|
1504
|
-
rb_define_singleton_method(cXMLNode, "new_text",
|
1501
|
+
rb_define_singleton_method(cXMLNode, "new", rxml_node_new_string_bc, -1);
|
1502
|
+
rb_define_singleton_method(cXMLNode, "new_cdata", rxml_node_new_cdata, -1);
|
1503
|
+
rb_define_singleton_method(cXMLNode, "new_comment", rxml_node_new_comment, -1);
|
1504
|
+
rb_define_singleton_method(cXMLNode, "new_text", rxml_node_new_text, 1);
|
1505
1505
|
|
1506
1506
|
/* Traversal */
|
1507
1507
|
rb_include_module(cXMLNode, rb_mEnumerable);
|
1508
|
-
rb_define_method(cXMLNode, "[]",
|
1509
|
-
rb_define_method(cXMLNode, "each",
|
1510
|
-
rb_define_method(cXMLNode, "first",
|
1511
|
-
rb_define_method(cXMLNode, "last",
|
1512
|
-
rb_define_method(cXMLNode, "next",
|
1513
|
-
rb_define_method(cXMLNode, "parent",
|
1514
|
-
rb_define_method(cXMLNode, "prev",
|
1508
|
+
rb_define_method(cXMLNode, "[]", rxml_node_attribute_get, 1);
|
1509
|
+
rb_define_method(cXMLNode, "each", rxml_node_each, 0);
|
1510
|
+
rb_define_method(cXMLNode, "first", rxml_node_first_get, 0);
|
1511
|
+
rb_define_method(cXMLNode, "last", rxml_node_last_get, 0);
|
1512
|
+
rb_define_method(cXMLNode, "next", rxml_node_next_get, 0);
|
1513
|
+
rb_define_method(cXMLNode, "parent", rxml_node_parent_get, 0);
|
1514
|
+
rb_define_method(cXMLNode, "prev", rxml_node_prev_get, 0);
|
1515
1515
|
|
1516
1516
|
/* Modification */
|
1517
|
-
rb_define_method(cXMLNode, "<<",
|
1518
|
-
rb_define_method(cXMLNode, "[]=",
|
1519
|
-
rb_define_method(cXMLNode, "child_add",
|
1520
|
-
rb_define_method(cXMLNode, "child=",
|
1521
|
-
rb_define_method(cXMLNode, "sibling=",
|
1522
|
-
rb_define_method(cXMLNode, "next=",
|
1523
|
-
rb_define_method(cXMLNode, "prev=",
|
1517
|
+
rb_define_method(cXMLNode, "<<", rxml_node_content_add, 1);
|
1518
|
+
rb_define_method(cXMLNode, "[]=", rxml_node_property_set, 2);
|
1519
|
+
rb_define_method(cXMLNode, "child_add", rxml_node_child_add, 1);
|
1520
|
+
rb_define_method(cXMLNode, "child=", rxml_node_child_set, 1);
|
1521
|
+
rb_define_method(cXMLNode, "sibling=", rxml_node_sibling_set, 1);
|
1522
|
+
rb_define_method(cXMLNode, "next=", rxml_node_next_set, 1);
|
1523
|
+
rb_define_method(cXMLNode, "prev=", rxml_node_prev_set, 1);
|
1524
1524
|
|
1525
1525
|
|
1526
1526
|
/* Rest of the node api */
|
1527
|
-
rb_define_method(cXMLNode, "attributes",
|
1528
|
-
rb_define_method(cXMLNode, "base",
|
1529
|
-
rb_define_method(cXMLNode, "base=",
|
1530
|
-
rb_define_method(cXMLNode, "blank?",
|
1531
|
-
rb_define_method(cXMLNode, "copy",
|
1532
|
-
rb_define_method(cXMLNode, "content",
|
1533
|
-
rb_define_method(cXMLNode, "content=",
|
1534
|
-
rb_define_method(cXMLNode, "content_stripped",
|
1535
|
-
rb_define_method(cXMLNode, "doc",
|
1536
|
-
rb_define_method(cXMLNode, "dump",
|
1537
|
-
rb_define_method(cXMLNode, "debug_dump",
|
1538
|
-
rb_define_method(cXMLNode, "empty?",
|
1539
|
-
rb_define_method(cXMLNode, "eql?",
|
1540
|
-
rb_define_method(cXMLNode, "lang",
|
1541
|
-
rb_define_method(cXMLNode, "lang=",
|
1542
|
-
rb_define_method(cXMLNode, "line_num",
|
1543
|
-
rb_define_method(cXMLNode, "name",
|
1544
|
-
rb_define_method(cXMLNode, "name=",
|
1545
|
-
rb_define_method(cXMLNode, "namespace",
|
1546
|
-
rb_define_method(cXMLNode, "namespace_node",
|
1547
|
-
rb_define_method(cXMLNode, "namespace=",
|
1548
|
-
rb_define_method(cXMLNode, "node_type",
|
1549
|
-
rb_define_method(cXMLNode, "ns",
|
1550
|
-
rb_define_method(cXMLNode, "ns?",
|
1551
|
-
rb_define_method(cXMLNode, "ns_def?",
|
1552
|
-
rb_define_method(cXMLNode, "ns_def",
|
1553
|
-
rb_define_method(cXMLNode, "path",
|
1554
|
-
rb_define_method(cXMLNode, "pointer",
|
1555
|
-
rb_define_method(cXMLNode, "remove!",
|
1556
|
-
rb_define_method(cXMLNode, "search_ns",
|
1557
|
-
rb_define_method(cXMLNode, "search_href",
|
1558
|
-
rb_define_method(cXMLNode, "space_preserve",
|
1559
|
-
rb_define_method(cXMLNode, "space_preserve=",
|
1560
|
-
rb_define_method(cXMLNode, "to_s",
|
1561
|
-
rb_define_method(cXMLNode, "xlink?",
|
1562
|
-
rb_define_method(cXMLNode, "xlink_type",
|
1563
|
-
rb_define_method(cXMLNode, "xlink_type_name",
|
1527
|
+
rb_define_method(cXMLNode, "attributes", rxml_node_attributes_get, 0);
|
1528
|
+
rb_define_method(cXMLNode, "base", rxml_node_base_get, 0);
|
1529
|
+
rb_define_method(cXMLNode, "base=", rxml_node_base_set, 1);
|
1530
|
+
rb_define_method(cXMLNode, "blank?", rxml_node_empty_q, 0);
|
1531
|
+
rb_define_method(cXMLNode, "copy", rxml_node_copy, 1);
|
1532
|
+
rb_define_method(cXMLNode, "content", rxml_node_content_get, 0);
|
1533
|
+
rb_define_method(cXMLNode, "content=", rxml_node_content_set, 1);
|
1534
|
+
rb_define_method(cXMLNode, "content_stripped", rxml_node_content_stripped_get, 0);
|
1535
|
+
rb_define_method(cXMLNode, "doc", rxml_node_doc, 0);
|
1536
|
+
rb_define_method(cXMLNode, "dump", rxml_node_dump, 0);
|
1537
|
+
rb_define_method(cXMLNode, "debug_dump", rxml_node_debug_dump, 0);
|
1538
|
+
rb_define_method(cXMLNode, "empty?", rxml_node_empty_q, 0);
|
1539
|
+
rb_define_method(cXMLNode, "eql?", rxml_node_eql_q, 1);
|
1540
|
+
rb_define_method(cXMLNode, "lang", rxml_node_lang_get, 0);
|
1541
|
+
rb_define_method(cXMLNode, "lang=", rxml_node_lang_set, 1);
|
1542
|
+
rb_define_method(cXMLNode, "line_num", rxml_node_line_num, 0);
|
1543
|
+
rb_define_method(cXMLNode, "name", rxml_node_name_get, 0);
|
1544
|
+
rb_define_method(cXMLNode, "name=", rxml_node_name_set, 1);
|
1545
|
+
rb_define_method(cXMLNode, "namespace", rxml_node_namespace_get, 0);
|
1546
|
+
rb_define_method(cXMLNode, "namespace_node", rxml_node_namespace_get_node, 0);
|
1547
|
+
rb_define_method(cXMLNode, "namespace=", rxml_node_namespace_set, -1);
|
1548
|
+
rb_define_method(cXMLNode, "node_type", rxml_node_type, 0);
|
1549
|
+
rb_define_method(cXMLNode, "ns", rxml_node_namespace_get, 0);
|
1550
|
+
rb_define_method(cXMLNode, "ns?", rxml_node_ns_q, 0);
|
1551
|
+
rb_define_method(cXMLNode, "ns_def?", rxml_node_ns_def_q, 0);
|
1552
|
+
rb_define_method(cXMLNode, "ns_def", rxml_node_ns_def_get, 0);
|
1553
|
+
rb_define_method(cXMLNode, "path", rxml_node_path, 0);
|
1554
|
+
rb_define_method(cXMLNode, "pointer", rxml_node_pointer, 1);
|
1555
|
+
rb_define_method(cXMLNode, "remove!", rxml_node_remove_ex, 0);
|
1556
|
+
rb_define_method(cXMLNode, "search_ns", rxml_node_search_ns, 1);
|
1557
|
+
rb_define_method(cXMLNode, "search_href", rxml_node_search_href, 1);
|
1558
|
+
rb_define_method(cXMLNode, "space_preserve", rxml_node_space_preserve_get, 0);
|
1559
|
+
rb_define_method(cXMLNode, "space_preserve=", rxml_node_space_preserve_set, 1);
|
1560
|
+
rb_define_method(cXMLNode, "to_s", rxml_node_to_s, 0);
|
1561
|
+
rb_define_method(cXMLNode, "xlink?", rxml_node_xlink_q, 0);
|
1562
|
+
rb_define_method(cXMLNode, "xlink_type", rxml_node_xlink_type, 0);
|
1563
|
+
rb_define_method(cXMLNode, "xlink_type_name", rxml_node_xlink_type_name, 0);
|
1564
1564
|
|
1565
1565
|
rb_define_alias(cXMLNode, "==", "eql?");
|
1566
1566
|
}
|