libxml-ruby 0.5.2.0 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +122 -0
- data/LICENSE +2 -1
- data/MANIFEST +138 -0
- data/NOTES +9 -0
- data/README +1 -1
- data/Rakefile +27 -205
- data/TODO +0 -2
- data/VERSION +1 -0
- data/ext/{xml → libxml}/cbg.c +0 -0
- data/ext/libxml/extconf.rb +309 -0
- data/ext/{xml → libxml}/libxml.c +1 -1
- data/ext/{xml → libxml}/libxml.h +7 -4
- data/ext/{xml → libxml}/ruby_xml_attr.c +1 -1
- data/ext/{xml → libxml}/ruby_xml_attr.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_document.c +16 -8
- data/ext/{xml → libxml}/ruby_xml_document.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_dtd.c +0 -0
- data/ext/{xml → libxml}/ruby_xml_dtd.h +0 -0
- data/ext/{xml → libxml}/ruby_xml_html_parser.c +1 -1
- data/ext/{xml → libxml}/ruby_xml_html_parser.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_input_cbg.c +0 -0
- data/ext/{xml → libxml}/ruby_xml_input_cbg.h +0 -0
- data/ext/{xml → libxml}/ruby_xml_node.c +47 -6
- data/ext/{xml → libxml}/ruby_xml_node.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_node_set.c +1 -1
- data/ext/{xml → libxml}/ruby_xml_node_set.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_ns.c +1 -1
- data/ext/{xml → libxml}/ruby_xml_ns.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_parser.c +6 -4
- data/ext/{xml → libxml}/ruby_xml_parser.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_parser_context.c +1 -1
- data/ext/{xml → libxml}/ruby_xml_parser_context.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_reader.c +3 -0
- data/ext/{xml → libxml}/ruby_xml_reader.h +0 -0
- data/ext/{xml → libxml}/ruby_xml_sax_parser.c +1 -1
- data/ext/{xml → libxml}/ruby_xml_sax_parser.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_schema.c +0 -0
- data/ext/{xml → libxml}/ruby_xml_schema.h +0 -0
- data/ext/{xml → libxml}/ruby_xml_state.c +0 -0
- data/ext/{xml → libxml}/ruby_xml_state.h +0 -0
- data/ext/{xml → libxml}/ruby_xml_tree.c +1 -1
- data/ext/{xml → libxml}/ruby_xml_tree.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_xinclude.c +1 -1
- data/ext/{xml → libxml}/ruby_xml_xinclude.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_xpath.c +7 -4
- data/ext/{xml → libxml}/ruby_xml_xpath.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_xpath_context.c +1 -1
- data/ext/{xml → libxml}/ruby_xml_xpath_context.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_xpath_object.c +65 -32
- data/ext/{xml → libxml}/ruby_xml_xpath_object.h +0 -0
- data/ext/{xml → libxml}/ruby_xml_xpointer.c +1 -1
- data/ext/{xml → libxml}/ruby_xml_xpointer.h +1 -1
- data/ext/{xml → libxml}/ruby_xml_xpointer_context.c +1 -1
- data/ext/{xml → libxml}/ruby_xml_xpointer_context.h +1 -1
- data/ext/{xml → libxml}/sax_parser_callbacks.inc +1 -1
- data/ext/libxml/version.h +9 -0
- data/{ext/xml → lib}/libxml.rb +7 -2
- data/lib/xml/libxml.rb +5 -0
- data/{ChangeLog → log/Changelog-0.txt} +0 -0
- data/log/Changelog.txt +435 -0
- data/meta/project.yaml +27 -0
- data/meta/unixname +1 -0
- data/setup.rb +1469 -0
- data/site/css/normal.css +182 -0
- data/site/img/raze-tiny.png +0 -0
- data/site/img/red-cube.jpg +0 -0
- data/site/img/xml-ruby.png +0 -0
- data/site/index.xml +43 -0
- data/site/install.xml +77 -0
- data/site/layout.rhtml +38 -0
- data/site/layout.xsl +67 -0
- data/site/license.xml +32 -0
- data/site/log/changelog.xml +1324 -0
- data/site/log/changelog.xsl +42 -0
- data/{tests → test}/dtd-test.rb +2 -2
- data/test/etc_doc_to_s.rb +21 -0
- data/test/ets_copy_bug.rb +21 -0
- data/test/ets_copy_bug2.rb +32 -0
- data/test/ets_doc_file.rb +14 -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/{tests → test}/merge_bug.rb +4 -5
- data/{tests → test}/model/default_validation_bug.rb +0 -0
- data/{tests → test}/model/merge_bug_data.xml +0 -0
- data/{tests → test}/model/rubynet.xml +0 -0
- data/{tests → test}/model/rubynet_project +1 -1
- data/{tests → test}/model/saxtest.xml +0 -0
- data/{tests → test}/model/simple.xml +0 -0
- data/{tests → test}/model/xinclude.xml +0 -0
- data/{tests → test}/schema-test.rb +2 -2
- data/{tests → test}/tc_xml_document.rb +2 -2
- data/{tests → test}/tc_xml_document_write.rb +1 -2
- data/{tests → test}/tc_xml_document_write2.rb +1 -2
- data/{tests → test}/tc_xml_document_write3.rb +1 -2
- data/{tests → test}/tc_xml_html_parser.rb +7 -8
- data/{tests → test}/tc_xml_node.rb +1 -2
- data/{tests → test}/tc_xml_node2.rb +1 -2
- data/{tests → test}/tc_xml_node3.rb +2 -3
- data/{tests → test}/tc_xml_node4.rb +19 -20
- data/{tests → test}/tc_xml_node5.rb +8 -9
- data/{tests → test}/tc_xml_node6.rb +1 -2
- data/{tests → test}/tc_xml_node7.rb +5 -6
- data/{tests → test}/tc_xml_node8.rb +5 -5
- data/{tests → test}/tc_xml_node9.rb +5 -5
- data/test/tc_xml_node_copy.rb +40 -0
- data/{tests → test}/tc_xml_node_set.rb +2 -3
- data/{tests → test}/tc_xml_node_set2.rb +4 -5
- data/test/tc_xml_node_text.rb +17 -0
- data/{tests → test}/tc_xml_node_xlink.rb +2 -2
- data/{tests → test}/tc_xml_parser.rb +5 -6
- data/{tests → test}/tc_xml_parser2.rb +2 -2
- data/{tests → test}/tc_xml_parser3.rb +2 -2
- data/{tests → test}/tc_xml_parser4.rb +2 -2
- data/{tests → test}/tc_xml_parser5.rb +2 -2
- data/{tests → test}/tc_xml_parser6.rb +3 -3
- data/{tests → test}/tc_xml_parser7.rb +3 -3
- data/{tests → test}/tc_xml_parser8.rb +13 -13
- data/{tests → test}/tc_xml_parser_context.rb +1 -2
- data/{tests → test}/tc_xml_reader.rb +22 -14
- data/{tests → test}/tc_xml_sax_parser.rb +21 -22
- data/{tests → test}/tc_xml_xinclude.rb +4 -4
- data/{tests → test}/tc_xml_xpath.rb +17 -3
- data/{tests → test}/tc_xml_xpointer.rb +4 -5
- metadata +231 -158
- data/CHANGELOG_to200701 +0 -82
- data/ext/xml/extconf.rb +0 -98
- data/tests/libxml_test.rb +0 -3
- data/tests/runner.rb +0 -11
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* $Id: ruby_xml_node.c
|
|
1
|
+
/* $Id: ruby_xml_node.c 235 2007-12-11 20:28:30Z danj $ */
|
|
2
2
|
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
4
|
|
|
@@ -326,12 +326,20 @@ ruby_xml_node_child_set_aux(VALUE self, VALUE rnode, int do_raise) {
|
|
|
326
326
|
Data_Get_Struct(rnode, ruby_xml_node, cnode);
|
|
327
327
|
|
|
328
328
|
chld = cnode->node;
|
|
329
|
+
/* Since an add operation may destroy a textnode by merging, we need to work
|
|
330
|
+
* with a copy, so that the ruby instance is not left with a dangling reference
|
|
331
|
+
*/
|
|
332
|
+
if ( chld->type == XML_TEXT_NODE ) {
|
|
333
|
+
chld = xmlCopyNode(chld,1);
|
|
334
|
+
copied=1;
|
|
335
|
+
}
|
|
329
336
|
|
|
330
337
|
if ( chld->parent != NULL || chld->doc != NULL ) {
|
|
331
|
-
|
|
332
|
-
copied=1;
|
|
338
|
+
/* raise before copying if applicable */
|
|
333
339
|
if ( do_raise == 1 )
|
|
334
340
|
rb_raise(rb_eRuntimeError, "implicit copy not legal for child= or <<");
|
|
341
|
+
chld=xmlCopyNode(chld,1);
|
|
342
|
+
copied=1;
|
|
335
343
|
}
|
|
336
344
|
|
|
337
345
|
ret = xmlAddChild(pnode->node, chld);
|
|
@@ -339,10 +347,13 @@ ruby_xml_node_child_set_aux(VALUE self, VALUE rnode, int do_raise) {
|
|
|
339
347
|
if ( copied == 1 )
|
|
340
348
|
xmlFreeNode(chld);
|
|
341
349
|
rb_raise(eXMLNodeFailedModify, "unable to add a child to the document");
|
|
350
|
+
} else if ( ret==chld ) {
|
|
351
|
+
/* child was added whole to parent and we need to return it as a new object */
|
|
352
|
+
return ruby_xml_node2_wrap(cXMLNode,chld);
|
|
342
353
|
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
return ruby_xml_node2_wrap(cXMLNode,
|
|
354
|
+
/* else */
|
|
355
|
+
/* If it was a text node, then ret should be parent->last, so we will just return ret. */
|
|
356
|
+
return ruby_xml_node2_wrap(cXMLNode,ret);
|
|
346
357
|
}
|
|
347
358
|
|
|
348
359
|
/*
|
|
@@ -2210,6 +2221,35 @@ ruby_xml_node_copy(VALUE self, VALUE deep) {
|
|
|
2210
2221
|
return obj;
|
|
2211
2222
|
}
|
|
2212
2223
|
|
|
2224
|
+
/*
|
|
2225
|
+
* call-seq:
|
|
2226
|
+
* XML::Node.new_text(content = nil) => node
|
|
2227
|
+
*
|
|
2228
|
+
* Create a new text node, optionally setting
|
|
2229
|
+
* the node's content.
|
|
2230
|
+
*
|
|
2231
|
+
*/
|
|
2232
|
+
VALUE
|
|
2233
|
+
ruby_xml_node_new_text(VALUE class, VALUE text)
|
|
2234
|
+
{
|
|
2235
|
+
VALUE obj;
|
|
2236
|
+
xmlNodePtr xnode;
|
|
2237
|
+
|
|
2238
|
+
if ( NIL_P(text) )
|
|
2239
|
+
return Qnil;
|
|
2240
|
+
|
|
2241
|
+
if (TYPE(text) != T_STRING )
|
|
2242
|
+
rb_raise(rb_eTypeError, "requires string argument");
|
|
2243
|
+
|
|
2244
|
+
xnode=xmlNewText((xmlChar*)STR2CSTR(text));
|
|
2245
|
+
if ( xnode == NULL )
|
|
2246
|
+
return Qnil;
|
|
2247
|
+
|
|
2248
|
+
obj=ruby_xml_node2_wrap(class,xnode);
|
|
2249
|
+
rb_obj_call_init(obj,0,NULL);
|
|
2250
|
+
return obj;
|
|
2251
|
+
}
|
|
2252
|
+
|
|
2213
2253
|
void
|
|
2214
2254
|
ruby_xml_node_registerNode(xmlNodePtr node)
|
|
2215
2255
|
{
|
|
@@ -2263,6 +2303,7 @@ ruby_init_xml_node(void) {
|
|
|
2263
2303
|
rb_define_singleton_method(cXMLNode, "new", ruby_xml_node2_new_string_bc, -1);
|
|
2264
2304
|
rb_define_singleton_method(cXMLNode, "new_cdata", ruby_xml_node_new_cdata, -1);
|
|
2265
2305
|
rb_define_singleton_method(cXMLNode, "new_comment", ruby_xml_node_new_comment, -1);
|
|
2306
|
+
rb_define_singleton_method(cXMLNode, "new_text", ruby_xml_node_new_text, 1);
|
|
2266
2307
|
|
|
2267
2308
|
rb_define_alias(singleton, "new_element", "new");
|
|
2268
2309
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* $Id: ruby_xml_parser.c
|
|
1
|
+
/* $Id: ruby_xml_parser.c 225 2007-12-07 04:58:09Z transami $ */
|
|
2
2
|
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
4
|
|
|
@@ -435,7 +435,7 @@ ruby_xml_parser_default_keep_blanks_set(VALUE class, VALUE bool) {
|
|
|
435
435
|
*/
|
|
436
436
|
VALUE
|
|
437
437
|
ruby_xml_parser_default_load_external_dtd_get(VALUE class) {
|
|
438
|
-
if (
|
|
438
|
+
if (xmlLoadExtDtdDefaultValue)
|
|
439
439
|
return(Qtrue);
|
|
440
440
|
else
|
|
441
441
|
return(Qfalse);
|
|
@@ -1214,6 +1214,8 @@ ruby_xml_parser_str_set(VALUE self, VALUE str) {
|
|
|
1214
1214
|
|
|
1215
1215
|
Data_Get_Struct(rxp->ctxt, ruby_xml_parser_context, rxpc);
|
|
1216
1216
|
rxpc->ctxt = xmlCreateMemoryParserCtxt(StringValuePtr(data->str), RSTRING_LEN(data->str));
|
|
1217
|
+
if ( rxpc->ctxt == NULL )
|
|
1218
|
+
rb_raise(eXMLParserParseError,"Cannot initialize parser with given string (maybe empty?)");
|
|
1217
1219
|
|
|
1218
1220
|
return(data->str);
|
|
1219
1221
|
}
|
|
@@ -1359,9 +1361,9 @@ ruby_init_parser(void) {
|
|
|
1359
1361
|
rb_define_singleton_method(cXMLParser, "default_keep_blanks=",
|
|
1360
1362
|
ruby_xml_parser_default_keep_blanks_set, 1);
|
|
1361
1363
|
rb_define_singleton_method(cXMLParser, "default_load_external_dtd",
|
|
1362
|
-
|
|
1364
|
+
ruby_xml_parser_default_load_external_dtd_get, 0);
|
|
1363
1365
|
rb_define_singleton_method(cXMLParser, "default_load_external_dtd=",
|
|
1364
|
-
|
|
1366
|
+
ruby_xml_parser_default_load_external_dtd_set, 1);
|
|
1365
1367
|
rb_define_singleton_method(cXMLParser, "default_line_numbers",
|
|
1366
1368
|
ruby_xml_parser_default_line_numbers_get, 0);
|
|
1367
1369
|
rb_define_singleton_method(cXMLParser, "default_line_numbers=",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* $Id: ruby_xml_xpath.c
|
|
1
|
+
/* $Id: ruby_xml_xpath.c 225 2007-12-07 04:58:09Z transami $ */
|
|
2
2
|
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
4
|
|
|
@@ -76,9 +76,9 @@ ruby_xml_xpath_register_namespaces(VALUE nslist, VALUE xxpc, int level) {
|
|
|
76
76
|
}
|
|
77
77
|
else {
|
|
78
78
|
// tuples of prefix/uri
|
|
79
|
-
if (RARRAY(
|
|
80
|
-
rprefix = RARRAY(
|
|
81
|
-
ruri = RARRAY(
|
|
79
|
+
if (RARRAY(nslist)->len == 2) {
|
|
80
|
+
rprefix = RARRAY(nslist)->ptr[0];
|
|
81
|
+
ruri = RARRAY(nslist)->ptr[1];
|
|
82
82
|
ruby_xml_xpath_context_register_namespace(xxpc, rprefix, ruri);
|
|
83
83
|
} else {
|
|
84
84
|
rb_raise(rb_eArgError, "nested array must be an array of strings, prefix and href/uri");
|
|
@@ -173,6 +173,9 @@ ruby_xml_xpath_find(VALUE class, VALUE anode, VALUE xpath_expr, VALUE nslist) {
|
|
|
173
173
|
"Invalid XPath expression (expr does not compile)");
|
|
174
174
|
}
|
|
175
175
|
xxpop=xmlXPathCompiledEval(comp, ctxt);
|
|
176
|
+
if ( xxpop == NULL )
|
|
177
|
+
return Qnil;
|
|
178
|
+
|
|
176
179
|
#define ALT
|
|
177
180
|
#ifdef ALT
|
|
178
181
|
rxpop = ruby_xml_xpath_object_wrap(xxpop);
|
|
@@ -18,7 +18,7 @@ ruby_xml_xpath_object_mark(xmlXPathObjectPtr xpop)
|
|
|
18
18
|
void * xnp;
|
|
19
19
|
int i;
|
|
20
20
|
|
|
21
|
-
if ( xpop->type == XPATH_NODESET ) {
|
|
21
|
+
if ( xpop->type == XPATH_NODESET && xpop->nodesetval != NULL ) {
|
|
22
22
|
for (i=0; i<xpop->nodesetval->nodeNr; i++) {
|
|
23
23
|
xnp=xpop->nodesetval->nodeTab[i]->_private;
|
|
24
24
|
if (xnp != NULL)
|
|
@@ -36,13 +36,35 @@ ruby_xml_xpath_object_free(xmlXPathObjectPtr xpop)
|
|
|
36
36
|
VALUE
|
|
37
37
|
ruby_xml_xpath_object_wrap(xmlXPathObjectPtr xpop)
|
|
38
38
|
{
|
|
39
|
+
VALUE rval;
|
|
40
|
+
|
|
39
41
|
if ( xpop==NULL )
|
|
40
42
|
return Qnil;
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
switch(xpop->type) {
|
|
45
|
+
case XPATH_NODESET:
|
|
46
|
+
return Data_Wrap_Struct(cXMLXPathObject,
|
|
47
|
+
ruby_xml_xpath_object_mark,
|
|
48
|
+
ruby_xml_xpath_object_free,
|
|
49
|
+
xpop);
|
|
50
|
+
break;
|
|
51
|
+
case XPATH_BOOLEAN:
|
|
52
|
+
if (xpop->boolval != 0)
|
|
53
|
+
rval=Qtrue;
|
|
54
|
+
else
|
|
55
|
+
rval=Qfalse;
|
|
56
|
+
break;
|
|
57
|
+
case XPATH_NUMBER:
|
|
58
|
+
rval=rb_float_new(xpop->floatval);
|
|
59
|
+
break;
|
|
60
|
+
case XPATH_STRING:
|
|
61
|
+
rval=rb_str_new2(xpop->stringval);
|
|
62
|
+
break;
|
|
63
|
+
default:
|
|
64
|
+
rval=Qnil;
|
|
65
|
+
}
|
|
66
|
+
xmlXPathFreeObject(xpop);
|
|
67
|
+
return rval;
|
|
46
68
|
}
|
|
47
69
|
|
|
48
70
|
/*
|
|
@@ -112,6 +134,26 @@ ruby_xml_xpath_object_empty_q(VALUE self) {
|
|
|
112
134
|
return ( xpop->nodesetval == NULL || xpop->nodesetval->nodeNr <= 0 ) ? Qtrue : Qfalse;
|
|
113
135
|
}
|
|
114
136
|
|
|
137
|
+
static VALUE
|
|
138
|
+
ruby_xml_xpath_object_tabref(xmlXPathObjectPtr xpop, int apos) {
|
|
139
|
+
|
|
140
|
+
if (apos < 0 )
|
|
141
|
+
apos=xpop->nodesetval->nodeNr+apos;
|
|
142
|
+
|
|
143
|
+
if (apos < 0 || apos+1 > xpop->nodesetval->nodeNr )
|
|
144
|
+
return Qnil;
|
|
145
|
+
|
|
146
|
+
switch(xpop->nodesetval->nodeTab[apos]->type) {
|
|
147
|
+
case XML_ATTRIBUTE_NODE:
|
|
148
|
+
return ruby_xml_attr_wrap(cXMLAttr,
|
|
149
|
+
(xmlAttrPtr)xpop->nodesetval->nodeTab[apos]);
|
|
150
|
+
break;
|
|
151
|
+
default:
|
|
152
|
+
return ruby_xml_node2_wrap(cXMLNode,
|
|
153
|
+
xpop->nodesetval->nodeTab[apos]);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
115
157
|
/*
|
|
116
158
|
* call-seq:
|
|
117
159
|
* xpath_object.each { |node| ... } => self
|
|
@@ -123,7 +165,6 @@ ruby_xml_xpath_object_each(VALUE self)
|
|
|
123
165
|
{
|
|
124
166
|
xmlXPathObjectPtr xpop;
|
|
125
167
|
int i;
|
|
126
|
-
VALUE nodeobj;
|
|
127
168
|
|
|
128
169
|
if ( ruby_xml_xpath_object_empty_q(self) == Qtrue )
|
|
129
170
|
return Qnil;
|
|
@@ -131,16 +172,7 @@ ruby_xml_xpath_object_each(VALUE self)
|
|
|
131
172
|
Data_Get_Struct(self,xmlXPathObject,xpop);
|
|
132
173
|
|
|
133
174
|
for (i = 0; i < xpop->nodesetval->nodeNr; i++) {
|
|
134
|
-
|
|
135
|
-
case XML_ATTRIBUTE_NODE:
|
|
136
|
-
nodeobj = ruby_xml_attr_wrap(cXMLAttr,
|
|
137
|
-
(xmlAttrPtr)xpop->nodesetval->nodeTab[i]);
|
|
138
|
-
break;
|
|
139
|
-
default:
|
|
140
|
-
nodeobj = ruby_xml_node2_wrap(cXMLNode, xpop->nodesetval->nodeTab[i]);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
rb_yield(nodeobj);
|
|
175
|
+
rb_yield(ruby_xml_xpath_object_tabref(xpop,i));
|
|
144
176
|
}
|
|
145
177
|
return(self);
|
|
146
178
|
}
|
|
@@ -153,26 +185,26 @@ ruby_xml_xpath_object_each(VALUE self)
|
|
|
153
185
|
*/
|
|
154
186
|
VALUE
|
|
155
187
|
ruby_xml_xpath_object_first(VALUE self) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
188
|
+
if ( ruby_xml_xpath_object_empty_q(self) == Qtrue )
|
|
189
|
+
return Qnil;
|
|
190
|
+
|
|
191
|
+
return ruby_xml_xpath_object_tabref((xmlXPathObjectPtr)DATA_PTR(self),0);
|
|
192
|
+
}
|
|
159
193
|
|
|
194
|
+
/*
|
|
195
|
+
* call-seq:
|
|
196
|
+
* xpath_object[i] => node
|
|
197
|
+
*
|
|
198
|
+
* array index into set of nodes
|
|
199
|
+
*/
|
|
200
|
+
VALUE
|
|
201
|
+
ruby_xml_xpath_object_aref(VALUE self, VALUE aref) {
|
|
160
202
|
if ( ruby_xml_xpath_object_empty_q(self) == Qtrue )
|
|
161
203
|
return Qnil;
|
|
162
204
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
case XML_ATTRIBUTE_NODE:
|
|
167
|
-
nodeobj = ruby_xml_attr_wrap(cXMLAttr,
|
|
168
|
-
(xmlAttrPtr)xpop->nodesetval->nodeTab[0]);
|
|
169
|
-
break;
|
|
170
|
-
default:
|
|
171
|
-
nodeobj = ruby_xml_node2_wrap(cXMLNode,
|
|
172
|
-
xpop->nodesetval->nodeTab[0]);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return(nodeobj);
|
|
205
|
+
return ruby_xml_xpath_object_tabref(
|
|
206
|
+
(xmlXPathObjectPtr)DATA_PTR(self),
|
|
207
|
+
NUM2INT(aref));
|
|
176
208
|
}
|
|
177
209
|
|
|
178
210
|
/*
|
|
@@ -235,6 +267,7 @@ ruby_init_xml_xpath_object(void) {
|
|
|
235
267
|
rb_define_method(cXMLXPathObject, "length", ruby_xml_xpath_object_length, 0);
|
|
236
268
|
rb_define_method(cXMLXPathObject, "size", ruby_xml_xpath_object_length, 0);
|
|
237
269
|
rb_define_method(cXMLXPathObject, "to_a", ruby_xml_xpath_object_to_a, 0);
|
|
270
|
+
rb_define_method(cXMLXPathObject, "[]", ruby_xml_xpath_object_aref, 1);
|
|
238
271
|
|
|
239
272
|
rb_define_method(cXMLXPathObject, "string", ruby_xml_xpath_object_string, 0);
|
|
240
273
|
|