libxml-ruby 0.5.4 → 0.6.0
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/LICENSE +23 -23
- data/README +144 -144
- data/ext/libxml/extconf.rb +26 -27
- data/ext/libxml/libxml.c +7 -37
- data/ext/libxml/{libxml.h → ruby_libxml.h} +93 -98
- data/ext/libxml/ruby_xml_attr.c +405 -387
- data/ext/libxml/ruby_xml_attr.h +19 -18
- data/ext/libxml/ruby_xml_document.c +1111 -1115
- data/ext/libxml/ruby_xml_document.h +27 -24
- data/ext/libxml/ruby_xml_dtd.c +168 -168
- data/ext/libxml/ruby_xml_html_parser.c +449 -450
- data/ext/libxml/ruby_xml_html_parser.h +1 -1
- data/ext/libxml/ruby_xml_input_cbg.c +158 -158
- data/ext/libxml/ruby_xml_node.c +2410 -2395
- data/ext/libxml/ruby_xml_node.h +1 -1
- data/ext/libxml/ruby_xml_node_set.c +170 -170
- data/ext/libxml/ruby_xml_node_set.h +1 -1
- data/ext/libxml/ruby_xml_ns.c +153 -153
- data/ext/libxml/ruby_xml_ns.h +1 -1
- data/ext/libxml/ruby_xml_parser.c +1425 -1422
- data/ext/libxml/ruby_xml_parser.h +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +750 -716
- data/ext/libxml/ruby_xml_parser_context.h +1 -1
- data/ext/libxml/ruby_xml_reader.c +900 -896
- data/ext/libxml/ruby_xml_sax_parser.c +485 -485
- data/ext/libxml/ruby_xml_sax_parser.h +1 -1
- data/ext/libxml/ruby_xml_schema.c +146 -142
- data/ext/libxml/ruby_xml_state.c +5 -6
- data/ext/libxml/ruby_xml_state.h +1 -0
- data/ext/libxml/ruby_xml_tree.c +43 -43
- data/ext/libxml/ruby_xml_tree.h +1 -1
- data/ext/libxml/ruby_xml_xinclude.c +20 -20
- data/ext/libxml/ruby_xml_xinclude.h +1 -1
- data/ext/libxml/ruby_xml_xpath.c +243 -252
- data/ext/libxml/ruby_xml_xpath.h +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +118 -118
- data/ext/libxml/ruby_xml_xpath_context.h +1 -1
- data/ext/libxml/ruby_xml_xpath_object.c +43 -29
- data/ext/libxml/ruby_xml_xpath_object.h +0 -1
- data/ext/libxml/ruby_xml_xpointer.c +100 -100
- data/ext/libxml/ruby_xml_xpointer.h +1 -1
- data/ext/libxml/ruby_xml_xpointer_context.c +21 -21
- data/ext/libxml/ruby_xml_xpointer_context.h +1 -1
- data/ext/libxml/sax_parser_callbacks.inc +213 -213
- data/ext/libxml/version.h +9 -9
- data/lib/libxml.rb +24 -3
- 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 -24
- data/test/etc_doc_to_s.rb +1 -3
- data/test/ets_copy_bug.rb +21 -21
- data/test/ets_copy_bug2.rb +32 -32
- data/test/ets_copy_bug3.rb +38 -0
- data/test/ets_doc_file.rb +1 -0
- data/test/{model/default_validation_bug.rb → gc.log} +0 -0
- data/test/merge_bug.rb +55 -55
- data/test/schema-test.rb +74 -74
- data/test/tc_well_formed.rb +11 -0
- data/test/tc_xml_document.rb +52 -52
- data/test/tc_xml_document_write.rb +24 -24
- data/test/tc_xml_document_write2.rb +54 -54
- data/test/tc_xml_document_write3.rb +96 -96
- data/test/tc_xml_html_parser.rb +63 -63
- data/test/tc_xml_node.rb +59 -59
- data/test/tc_xml_node2.rb +25 -25
- data/test/tc_xml_node3.rb +27 -27
- data/test/tc_xml_node4.rb +86 -86
- data/test/tc_xml_node5.rb +52 -52
- data/test/tc_xml_node6.rb +27 -27
- data/test/tc_xml_node7.rb +35 -35
- data/test/tc_xml_node8.rb +32 -32
- data/test/tc_xml_node9.rb +32 -32
- data/test/tc_xml_node_set.rb +24 -24
- data/test/tc_xml_node_set2.rb +37 -37
- data/test/tc_xml_node_xlink.rb +28 -28
- data/test/tc_xml_parser.rb +190 -178
- data/test/tc_xml_parser2.rb +16 -17
- data/test/tc_xml_parser3.rb +23 -23
- data/test/tc_xml_parser4.rb +33 -33
- data/test/tc_xml_parser5.rb +27 -27
- data/test/tc_xml_parser6.rb +23 -23
- data/test/tc_xml_parser7.rb +28 -28
- data/test/tc_xml_parser8.rb +32 -32
- data/test/tc_xml_parser9.rb +11 -0
- data/test/tc_xml_parser_context.rb +88 -88
- data/test/tc_xml_reader.rb +112 -109
- data/test/tc_xml_sax_parser.rb +104 -94
- data/test/tc_xml_sax_parser2.rb +51 -0
- data/test/tc_xml_xinclude.rb +30 -30
- data/test/tc_xml_xpath.rb +38 -38
- data/test/tc_xml_xpath2.rb +14 -0
- data/test/tc_xml_xpointer.rb +78 -78
- 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 +158 -189
- data/MANIFEST +0 -138
- data/NOTES +0 -9
- data/Rakefile +0 -38
- data/TODO +0 -75
- data/VERSION +0 -1
- data/log/Changelog-0.txt +0 -426
- data/log/Changelog.txt +0 -435
- data/meta/project.yaml +0 -27
- data/meta/unixname +0 -1
- data/setup.rb +0 -1472
- data/site/css/normal.css +0 -182
- 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 +0 -43
- data/site/install.xml +0 -77
- data/site/layout.rhtml +0 -38
- data/site/layout.xsl +0 -67
- data/site/license.xml +0 -32
- data/site/log/changelog.xml +0 -1324
- data/site/log/changelog.xsl +0 -42
- data/test/model/merge_bug_data.xml +0 -58
- data/test/model/rubynet.xml +0 -78
- data/test/model/rubynet_project +0 -13
- data/test/model/saxtest.xml +0 -5
- data/test/model/simple.xml +0 -7
- data/test/model/xinclude.xml +0 -5
|
@@ -1,118 +1,118 @@
|
|
|
1
|
-
/* $Id: ruby_xml_xpath_context.c
|
|
2
|
-
|
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
|
-
|
|
5
|
-
#include "
|
|
6
|
-
#include "ruby_xml_xpath_context.h"
|
|
7
|
-
|
|
8
|
-
VALUE cXMLXPathContext;
|
|
9
|
-
|
|
10
|
-
/*
|
|
11
|
-
* call-seq:
|
|
12
|
-
* context.doc => document
|
|
13
|
-
*
|
|
14
|
-
* Obtain the XML::Document associated with this XPath.
|
|
15
|
-
*/
|
|
16
|
-
VALUE
|
|
17
|
-
ruby_xml_xpath_context_doc_get(VALUE self) {
|
|
18
|
-
xmlXPathContextPtr ctxt;
|
|
19
|
-
Data_Get_Struct(self, xmlXPathContext, ctxt);
|
|
20
|
-
|
|
21
|
-
return
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
void
|
|
26
|
-
ruby_xml_xpath_context_free(xmlXPathContextPtr ctxt) {
|
|
27
|
-
if (ctxt != NULL) {
|
|
28
|
-
xmlXPathFreeContext(ctxt);
|
|
29
|
-
ctxt = NULL;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
void
|
|
35
|
-
ruby_xml_xpath_context_mark(xmlXPathContextPtr ctxt) {
|
|
36
|
-
if (ctxt == NULL ) return;
|
|
37
|
-
if (ctxt->doc != NULL && ctxt->doc->_private != NULL)
|
|
38
|
-
rb_gc_mark((VALUE)ctxt->doc->_private);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
VALUE
|
|
43
|
-
ruby_xml_xpath_context_wrap(xmlXPathContextPtr ctxt) {
|
|
44
|
-
return Data_Wrap_Struct(cXMLXPathContext,
|
|
45
|
-
ruby_xml_xpath_context_mark,
|
|
46
|
-
ruby_xml_xpath_context_free,
|
|
47
|
-
ctxt);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
VALUE
|
|
52
|
-
ruby_xml_xpath_context_new(VALUE anode) {
|
|
53
|
-
ruby_xml_document_t *rxd;
|
|
54
|
-
ruby_xml_node *node;
|
|
55
|
-
xmlXPathContextPtr ctxt;
|
|
56
|
-
|
|
57
|
-
if (rb_obj_is_kind_of(anode,cXMLDocument) == Qtrue ) {
|
|
58
|
-
Data_Get_Struct(anode,ruby_xml_document_t,rxd);
|
|
59
|
-
if (rxd->doc == NULL) return(Qnil);
|
|
60
|
-
|
|
61
|
-
ctxt = xmlXPathNewContext(rxd->doc);
|
|
62
|
-
if (ctxt == NULL) return(Qnil);
|
|
63
|
-
|
|
64
|
-
} else if (rb_obj_is_kind_of(anode,cXMLNode) == Qtrue ) {
|
|
65
|
-
Data_Get_Struct(anode, ruby_xml_node, node);
|
|
66
|
-
if (node->node->doc == NULL)
|
|
67
|
-
rb_raise(rb_eTypeError,"Supplied node must be part of a document");
|
|
68
|
-
|
|
69
|
-
ctxt = xmlXPathNewContext(node->node->doc);
|
|
70
|
-
if (ctxt == NULL) return(Qnil);
|
|
71
|
-
|
|
72
|
-
} else {
|
|
73
|
-
rb_raise(rb_eTypeError,"create context requires a document or node. Supplied a %s?",
|
|
74
|
-
rb_obj_as_string(anode));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return ruby_xml_xpath_context_wrap(ctxt);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/*
|
|
81
|
-
* call-seq:
|
|
82
|
-
* context.register_namespace(prefix, uri) => (true|false)
|
|
83
|
-
*
|
|
84
|
-
* Register the specified namespace URI with the specified prefix
|
|
85
|
-
* in this context.
|
|
86
|
-
*/
|
|
87
|
-
VALUE
|
|
88
|
-
ruby_xml_xpath_context_register_namespace(VALUE self, VALUE prefix, VALUE uri) {
|
|
89
|
-
xmlXPathContextPtr ctxt;
|
|
90
|
-
|
|
91
|
-
Data_Get_Struct(self, xmlXPathContext, ctxt);
|
|
92
|
-
if (xmlXPathRegisterNs(ctxt,
|
|
93
|
-
(xmlChar*)StringValuePtr(prefix),
|
|
94
|
-
(xmlChar*)StringValuePtr(uri))
|
|
95
|
-
== 0) {
|
|
96
|
-
return(Qtrue);
|
|
97
|
-
} else {
|
|
98
|
-
/* Should raise an exception, IMHO (whose?, why shouldnt it? -danj)*/
|
|
99
|
-
rb_warning("register namespace failed");
|
|
100
|
-
return(Qfalse);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// Rdoc needs to know
|
|
105
|
-
#ifdef RDOC_NEVER_DEFINED
|
|
106
|
-
mXML = rb_define_module("XML");
|
|
107
|
-
cXMLXPath = rb_define_class_under(mXML, "XPath", rb_cObject);
|
|
108
|
-
#endif
|
|
109
|
-
|
|
110
|
-
void
|
|
111
|
-
ruby_init_xml_xpath_context(void) {
|
|
112
|
-
cXMLXPathContext = rb_define_class_under(cXMLXPath, "Context", rb_cObject);
|
|
113
|
-
|
|
114
|
-
rb_define_method(cXMLXPathContext, "register_namespace",
|
|
115
|
-
ruby_xml_xpath_context_register_namespace, 2);
|
|
116
|
-
rb_define_method(cXMLXPathContext, "doc",
|
|
117
|
-
ruby_xml_xpath_context_doc_get, 0);
|
|
118
|
-
}
|
|
1
|
+
/* $Id: ruby_xml_xpath_context.c 300 2008-07-01 19:14:15Z cfis $ */
|
|
2
|
+
|
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
|
+
|
|
5
|
+
#include "ruby_libxml.h"
|
|
6
|
+
#include "ruby_xml_xpath_context.h"
|
|
7
|
+
|
|
8
|
+
VALUE cXMLXPathContext;
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* call-seq:
|
|
12
|
+
* context.doc => document
|
|
13
|
+
*
|
|
14
|
+
* Obtain the XML::Document associated with this XPath.
|
|
15
|
+
*/
|
|
16
|
+
VALUE
|
|
17
|
+
ruby_xml_xpath_context_doc_get(VALUE self) {
|
|
18
|
+
xmlXPathContextPtr ctxt;
|
|
19
|
+
Data_Get_Struct(self, xmlXPathContext, ctxt);
|
|
20
|
+
|
|
21
|
+
return ruby_xml_document_wrap(ctxt->doc);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
void
|
|
26
|
+
ruby_xml_xpath_context_free(xmlXPathContextPtr ctxt) {
|
|
27
|
+
if (ctxt != NULL) {
|
|
28
|
+
xmlXPathFreeContext(ctxt);
|
|
29
|
+
ctxt = NULL;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
void
|
|
35
|
+
ruby_xml_xpath_context_mark(xmlXPathContextPtr ctxt) {
|
|
36
|
+
if (ctxt == NULL ) return;
|
|
37
|
+
if (ctxt->doc != NULL && ctxt->doc->_private != NULL)
|
|
38
|
+
rb_gc_mark((VALUE)ctxt->doc->_private);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
VALUE
|
|
43
|
+
ruby_xml_xpath_context_wrap(xmlXPathContextPtr ctxt) {
|
|
44
|
+
return Data_Wrap_Struct(cXMLXPathContext,
|
|
45
|
+
ruby_xml_xpath_context_mark,
|
|
46
|
+
ruby_xml_xpath_context_free,
|
|
47
|
+
ctxt);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
VALUE
|
|
52
|
+
ruby_xml_xpath_context_new(VALUE anode) {
|
|
53
|
+
ruby_xml_document_t *rxd;
|
|
54
|
+
ruby_xml_node *node;
|
|
55
|
+
xmlXPathContextPtr ctxt;
|
|
56
|
+
|
|
57
|
+
if (rb_obj_is_kind_of(anode,cXMLDocument) == Qtrue ) {
|
|
58
|
+
Data_Get_Struct(anode,ruby_xml_document_t,rxd);
|
|
59
|
+
if (rxd->doc == NULL) return(Qnil);
|
|
60
|
+
|
|
61
|
+
ctxt = xmlXPathNewContext(rxd->doc);
|
|
62
|
+
if (ctxt == NULL) return(Qnil);
|
|
63
|
+
|
|
64
|
+
} else if (rb_obj_is_kind_of(anode,cXMLNode) == Qtrue ) {
|
|
65
|
+
Data_Get_Struct(anode, ruby_xml_node, node);
|
|
66
|
+
if (node->node->doc == NULL)
|
|
67
|
+
rb_raise(rb_eTypeError,"Supplied node must be part of a document");
|
|
68
|
+
|
|
69
|
+
ctxt = xmlXPathNewContext(node->node->doc);
|
|
70
|
+
if (ctxt == NULL) return(Qnil);
|
|
71
|
+
|
|
72
|
+
} else {
|
|
73
|
+
rb_raise(rb_eTypeError,"create context requires a document or node. Supplied a %s?",
|
|
74
|
+
rb_obj_as_string(anode));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return ruby_xml_xpath_context_wrap(ctxt);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
* call-seq:
|
|
82
|
+
* context.register_namespace(prefix, uri) => (true|false)
|
|
83
|
+
*
|
|
84
|
+
* Register the specified namespace URI with the specified prefix
|
|
85
|
+
* in this context.
|
|
86
|
+
*/
|
|
87
|
+
VALUE
|
|
88
|
+
ruby_xml_xpath_context_register_namespace(VALUE self, VALUE prefix, VALUE uri) {
|
|
89
|
+
xmlXPathContextPtr ctxt;
|
|
90
|
+
|
|
91
|
+
Data_Get_Struct(self, xmlXPathContext, ctxt);
|
|
92
|
+
if (xmlXPathRegisterNs(ctxt,
|
|
93
|
+
(xmlChar*)StringValuePtr(prefix),
|
|
94
|
+
(xmlChar*)StringValuePtr(uri))
|
|
95
|
+
== 0) {
|
|
96
|
+
return(Qtrue);
|
|
97
|
+
} else {
|
|
98
|
+
/* Should raise an exception, IMHO (whose?, why shouldnt it? -danj)*/
|
|
99
|
+
rb_warning("register namespace failed");
|
|
100
|
+
return(Qfalse);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Rdoc needs to know
|
|
105
|
+
#ifdef RDOC_NEVER_DEFINED
|
|
106
|
+
mXML = rb_define_module("XML");
|
|
107
|
+
cXMLXPath = rb_define_class_under(mXML, "XPath", rb_cObject);
|
|
108
|
+
#endif
|
|
109
|
+
|
|
110
|
+
void
|
|
111
|
+
ruby_init_xml_xpath_context(void) {
|
|
112
|
+
cXMLXPathContext = rb_define_class_under(cXMLXPath, "Context", rb_cObject);
|
|
113
|
+
|
|
114
|
+
rb_define_method(cXMLXPathContext, "register_namespace",
|
|
115
|
+
ruby_xml_xpath_context_register_namespace, 2);
|
|
116
|
+
rb_define_method(cXMLXPathContext, "doc",
|
|
117
|
+
ruby_xml_xpath_context_doc_get, 0);
|
|
118
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* $Id: $ */
|
|
2
2
|
|
|
3
|
-
#include "
|
|
3
|
+
#include "ruby_libxml.h"
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
* Document-class: XML::XPath::Object
|
|
@@ -12,6 +12,27 @@
|
|
|
12
12
|
*/
|
|
13
13
|
VALUE cXMLXPathObject;
|
|
14
14
|
|
|
15
|
+
|
|
16
|
+
static VALUE
|
|
17
|
+
ruby_xml_xpath_object_tabref(xmlXPathObjectPtr xpop, int apos) {
|
|
18
|
+
|
|
19
|
+
if (apos < 0 )
|
|
20
|
+
apos=xpop->nodesetval->nodeNr+apos;
|
|
21
|
+
|
|
22
|
+
if (apos < 0 || apos+1 > xpop->nodesetval->nodeNr )
|
|
23
|
+
return Qnil;
|
|
24
|
+
|
|
25
|
+
switch(xpop->nodesetval->nodeTab[apos]->type) {
|
|
26
|
+
case XML_ATTRIBUTE_NODE:
|
|
27
|
+
return ruby_xml_attr_wrap(cXMLAttr,
|
|
28
|
+
(xmlAttrPtr)xpop->nodesetval->nodeTab[apos]);
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
return ruby_xml_node2_wrap(cXMLNode,
|
|
32
|
+
xpop->nodesetval->nodeTab[apos]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
15
36
|
void
|
|
16
37
|
ruby_xml_xpath_object_mark(xmlXPathObjectPtr xpop)
|
|
17
38
|
{
|
|
@@ -43,30 +64,44 @@ ruby_xml_xpath_object_wrap(xmlXPathObjectPtr xpop)
|
|
|
43
64
|
|
|
44
65
|
switch(xpop->type) {
|
|
45
66
|
case XPATH_NODESET:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
67
|
+
rval = Data_Wrap_Struct(cXMLXPathObject,
|
|
68
|
+
ruby_xml_xpath_object_mark,
|
|
69
|
+
ruby_xml_xpath_object_free,
|
|
70
|
+
xpop);
|
|
71
|
+
|
|
72
|
+
if (xpop->type == XPATH_NODESET && !((xpop->nodesetval == NULL) || (xpop->nodesetval->nodeNr == 0))) {
|
|
73
|
+
int i;
|
|
74
|
+
for (i = 0; i < xpop->nodesetval->nodeNr; i++) {
|
|
75
|
+
ruby_xml_xpath_object_tabref(xpop, i);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
50
78
|
break;
|
|
51
79
|
case XPATH_BOOLEAN:
|
|
52
80
|
if (xpop->boolval != 0)
|
|
53
81
|
rval=Qtrue;
|
|
54
82
|
else
|
|
55
83
|
rval=Qfalse;
|
|
84
|
+
|
|
85
|
+
xmlXPathFreeObject(xpop);
|
|
56
86
|
break;
|
|
57
87
|
case XPATH_NUMBER:
|
|
58
88
|
rval=rb_float_new(xpop->floatval);
|
|
89
|
+
|
|
90
|
+
xmlXPathFreeObject(xpop);
|
|
59
91
|
break;
|
|
60
92
|
case XPATH_STRING:
|
|
61
93
|
rval=rb_str_new2(xpop->stringval);
|
|
94
|
+
|
|
95
|
+
xmlXPathFreeObject(xpop);
|
|
62
96
|
break;
|
|
63
97
|
default:
|
|
98
|
+
xmlXPathFreeObject(xpop);
|
|
64
99
|
rval=Qnil;
|
|
65
100
|
}
|
|
66
|
-
xmlXPathFreeObject(xpop);
|
|
67
101
|
return rval;
|
|
68
102
|
}
|
|
69
103
|
|
|
104
|
+
|
|
70
105
|
/*
|
|
71
106
|
* call-seq:
|
|
72
107
|
* xpath_object.to_a => [node, ..., node]
|
|
@@ -85,7 +120,7 @@ ruby_xml_xpath_object_to_a(VALUE self)
|
|
|
85
120
|
set_ary = rb_ary_new();
|
|
86
121
|
if (!((xpop->nodesetval == NULL) || (xpop->nodesetval->nodeNr == 0))) {
|
|
87
122
|
for (i = 0; i < xpop->nodesetval->nodeNr; i++) {
|
|
88
|
-
nodeobj =
|
|
123
|
+
nodeobj = ruby_xml_xpath_object_tabref(xpop, i);
|
|
89
124
|
rb_ary_push(set_ary, nodeobj);
|
|
90
125
|
}
|
|
91
126
|
}
|
|
@@ -134,26 +169,6 @@ ruby_xml_xpath_object_empty_q(VALUE self) {
|
|
|
134
169
|
return ( xpop->nodesetval == NULL || xpop->nodesetval->nodeNr <= 0 ) ? Qtrue : Qfalse;
|
|
135
170
|
}
|
|
136
171
|
|
|
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
|
-
|
|
157
172
|
/*
|
|
158
173
|
* call-seq:
|
|
159
174
|
* xpath_object.each { |node| ... } => self
|
|
@@ -202,8 +217,7 @@ ruby_xml_xpath_object_aref(VALUE self, VALUE aref) {
|
|
|
202
217
|
if ( ruby_xml_xpath_object_empty_q(self) == Qtrue )
|
|
203
218
|
return Qnil;
|
|
204
219
|
|
|
205
|
-
return ruby_xml_xpath_object_tabref(
|
|
206
|
-
(xmlXPathObjectPtr)DATA_PTR(self),
|
|
220
|
+
return ruby_xml_xpath_object_tabref((xmlXPathObjectPtr)DATA_PTR(self),
|
|
207
221
|
NUM2INT(aref));
|
|
208
222
|
}
|
|
209
223
|
|
|
@@ -10,7 +10,6 @@ typedef struct ruby_xml_xpath_object_s {
|
|
|
10
10
|
} ruby_xml_xpath_object;
|
|
11
11
|
|
|
12
12
|
VALUE ruby_xml_xpath_object_wrap(xmlXPathObjectPtr xpop);
|
|
13
|
-
|
|
14
13
|
VALUE ruby_xml_xpath_object_to_a(VALUE self);
|
|
15
14
|
VALUE ruby_xml_xpath_object_first(VALUE self);
|
|
16
15
|
VALUE ruby_xml_xpath_object_set(VALUE self);
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
/* $Id: ruby_xml_xpointer.c
|
|
2
|
-
|
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
|
-
|
|
5
|
-
#include "
|
|
6
|
-
#include "ruby_xml_xpointer.h"
|
|
7
|
-
|
|
8
|
-
VALUE cXMLXPointer;
|
|
9
|
-
VALUE eXMLXPointerInvalidExpression;
|
|
10
|
-
|
|
11
|
-
VALUE
|
|
12
|
-
ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
|
|
13
|
-
#ifdef LIBXML_XPTR_ENABLED
|
|
14
|
-
ruby_xml_node *node;
|
|
15
|
-
xmlXPathContextPtr ctxt;
|
|
16
|
-
VALUE rxptr_xpth_ctxt, rxxp;
|
|
17
|
-
xmlXPathObjectPtr xpath;
|
|
18
|
-
|
|
19
|
-
Check_Type(xptr_str, T_STRING);
|
|
20
|
-
if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
|
|
21
|
-
rb_raise(rb_eTypeError, "require an XML::Node object");
|
|
22
|
-
|
|
23
|
-
Data_Get_Struct(rnode, ruby_xml_node, node);
|
|
24
|
-
|
|
25
|
-
rxptr_xpth_ctxt =
|
|
26
|
-
ruby_xml_xpath_context_wrap(ctxt=xmlXPtrNewContext(node->node->doc, node->node, NULL));
|
|
27
|
-
|
|
28
|
-
if (NIL_P(rxptr_xpth_ctxt))
|
|
29
|
-
return(Qnil);
|
|
30
|
-
|
|
31
|
-
xpath = xmlXPtrEval((xmlChar*)StringValuePtr(xptr_str), ctxt);
|
|
32
|
-
if (xpath == NULL)
|
|
33
|
-
rb_raise(eXMLXPointerInvalidExpression, "invalid xpointer expression");
|
|
34
|
-
|
|
35
|
-
rxxp = ruby_xml_xpath_object_wrap(xpath);
|
|
36
|
-
return(rxxp);
|
|
37
|
-
#else
|
|
38
|
-
rb_warn("libxml was compiled without XPointer support");
|
|
39
|
-
return(Qfalse);
|
|
40
|
-
#endif
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
VALUE
|
|
45
|
-
ruby_xml_xpointer_point2(VALUE node, VALUE xptr_str) {
|
|
46
|
-
return(ruby_xml_xpointer_point(cXMLXPointer, node, xptr_str));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/*
|
|
51
|
-
* call-seq:
|
|
52
|
-
* XML::XPointer.range(start_node, end_node) => xpath
|
|
53
|
-
*
|
|
54
|
-
* Create an xpath representing the range between the supplied
|
|
55
|
-
* start and end node.
|
|
56
|
-
*/
|
|
57
|
-
VALUE
|
|
58
|
-
ruby_xml_xpointer_range(VALUE class, VALUE rstart, VALUE rend) {
|
|
59
|
-
#ifdef LIBXML_XPTR_ENABLED
|
|
60
|
-
ruby_xml_node *start, *end;
|
|
61
|
-
VALUE rxxp;
|
|
62
|
-
xmlXPathObjectPtr xpath;
|
|
63
|
-
|
|
64
|
-
if (rb_obj_is_kind_of(rstart, cXMLNode) == Qfalse)
|
|
65
|
-
rb_raise(rb_eTypeError, "require an XML::Node object as a starting point");
|
|
66
|
-
if (rb_obj_is_kind_of(rend, cXMLNode) == Qfalse)
|
|
67
|
-
rb_raise(rb_eTypeError, "require an XML::Node object as an ending point");
|
|
68
|
-
|
|
69
|
-
Data_Get_Struct(rstart, ruby_xml_node, start);
|
|
70
|
-
if (start->node == NULL)
|
|
71
|
-
return(Qnil);
|
|
72
|
-
|
|
73
|
-
Data_Get_Struct(rend, ruby_xml_node, end);
|
|
74
|
-
if (end->node == NULL)
|
|
75
|
-
return(Qnil);
|
|
76
|
-
|
|
77
|
-
xpath = xmlXPtrNewRangeNodes(start->node, end->node);
|
|
78
|
-
if (xpath == NULL)
|
|
79
|
-
rb_fatal("You shouldn't be able to have this happen");
|
|
80
|
-
|
|
81
|
-
rxxp = ruby_xml_xpath_object_wrap(xpath);
|
|
82
|
-
return(rxxp);
|
|
83
|
-
#else
|
|
84
|
-
rb_warn("libxml was compiled without XPointer support");
|
|
85
|
-
return(Qfalse);
|
|
86
|
-
#endif
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Rdoc needs to know
|
|
90
|
-
#ifdef RDOC_NEVER_DEFINED
|
|
91
|
-
mXML = rb_define_module("XML");
|
|
92
|
-
#endif
|
|
93
|
-
|
|
94
|
-
void
|
|
95
|
-
ruby_init_xml_xpointer(void) {
|
|
96
|
-
cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
|
|
97
|
-
eXMLXPointerInvalidExpression = rb_define_class_under(cXMLXPointer, "InvalidExpression", eXMLError);
|
|
98
|
-
|
|
99
|
-
rb_define_singleton_method(cXMLXPointer, "range", ruby_xml_xpointer_range, 2);
|
|
100
|
-
}
|
|
1
|
+
/* $Id: ruby_xml_xpointer.c 300 2008-07-01 19:14:15Z cfis $ */
|
|
2
|
+
|
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
|
+
|
|
5
|
+
#include "ruby_libxml.h"
|
|
6
|
+
#include "ruby_xml_xpointer.h"
|
|
7
|
+
|
|
8
|
+
VALUE cXMLXPointer;
|
|
9
|
+
VALUE eXMLXPointerInvalidExpression;
|
|
10
|
+
|
|
11
|
+
VALUE
|
|
12
|
+
ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
|
|
13
|
+
#ifdef LIBXML_XPTR_ENABLED
|
|
14
|
+
ruby_xml_node *node;
|
|
15
|
+
xmlXPathContextPtr ctxt;
|
|
16
|
+
VALUE rxptr_xpth_ctxt, rxxp;
|
|
17
|
+
xmlXPathObjectPtr xpath;
|
|
18
|
+
|
|
19
|
+
Check_Type(xptr_str, T_STRING);
|
|
20
|
+
if (rb_obj_is_kind_of(rnode, cXMLNode) == Qfalse)
|
|
21
|
+
rb_raise(rb_eTypeError, "require an XML::Node object");
|
|
22
|
+
|
|
23
|
+
Data_Get_Struct(rnode, ruby_xml_node, node);
|
|
24
|
+
|
|
25
|
+
rxptr_xpth_ctxt =
|
|
26
|
+
ruby_xml_xpath_context_wrap(ctxt=xmlXPtrNewContext(node->node->doc, node->node, NULL));
|
|
27
|
+
|
|
28
|
+
if (NIL_P(rxptr_xpth_ctxt))
|
|
29
|
+
return(Qnil);
|
|
30
|
+
|
|
31
|
+
xpath = xmlXPtrEval((xmlChar*)StringValuePtr(xptr_str), ctxt);
|
|
32
|
+
if (xpath == NULL)
|
|
33
|
+
rb_raise(eXMLXPointerInvalidExpression, "invalid xpointer expression");
|
|
34
|
+
|
|
35
|
+
rxxp = ruby_xml_xpath_object_wrap(xpath);
|
|
36
|
+
return(rxxp);
|
|
37
|
+
#else
|
|
38
|
+
rb_warn("libxml was compiled without XPointer support");
|
|
39
|
+
return(Qfalse);
|
|
40
|
+
#endif
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
VALUE
|
|
45
|
+
ruby_xml_xpointer_point2(VALUE node, VALUE xptr_str) {
|
|
46
|
+
return(ruby_xml_xpointer_point(cXMLXPointer, node, xptr_str));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
* call-seq:
|
|
52
|
+
* XML::XPointer.range(start_node, end_node) => xpath
|
|
53
|
+
*
|
|
54
|
+
* Create an xpath representing the range between the supplied
|
|
55
|
+
* start and end node.
|
|
56
|
+
*/
|
|
57
|
+
VALUE
|
|
58
|
+
ruby_xml_xpointer_range(VALUE class, VALUE rstart, VALUE rend) {
|
|
59
|
+
#ifdef LIBXML_XPTR_ENABLED
|
|
60
|
+
ruby_xml_node *start, *end;
|
|
61
|
+
VALUE rxxp;
|
|
62
|
+
xmlXPathObjectPtr xpath;
|
|
63
|
+
|
|
64
|
+
if (rb_obj_is_kind_of(rstart, cXMLNode) == Qfalse)
|
|
65
|
+
rb_raise(rb_eTypeError, "require an XML::Node object as a starting point");
|
|
66
|
+
if (rb_obj_is_kind_of(rend, cXMLNode) == Qfalse)
|
|
67
|
+
rb_raise(rb_eTypeError, "require an XML::Node object as an ending point");
|
|
68
|
+
|
|
69
|
+
Data_Get_Struct(rstart, ruby_xml_node, start);
|
|
70
|
+
if (start->node == NULL)
|
|
71
|
+
return(Qnil);
|
|
72
|
+
|
|
73
|
+
Data_Get_Struct(rend, ruby_xml_node, end);
|
|
74
|
+
if (end->node == NULL)
|
|
75
|
+
return(Qnil);
|
|
76
|
+
|
|
77
|
+
xpath = xmlXPtrNewRangeNodes(start->node, end->node);
|
|
78
|
+
if (xpath == NULL)
|
|
79
|
+
rb_fatal("You shouldn't be able to have this happen");
|
|
80
|
+
|
|
81
|
+
rxxp = ruby_xml_xpath_object_wrap(xpath);
|
|
82
|
+
return(rxxp);
|
|
83
|
+
#else
|
|
84
|
+
rb_warn("libxml was compiled without XPointer support");
|
|
85
|
+
return(Qfalse);
|
|
86
|
+
#endif
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Rdoc needs to know
|
|
90
|
+
#ifdef RDOC_NEVER_DEFINED
|
|
91
|
+
mXML = rb_define_module("XML");
|
|
92
|
+
#endif
|
|
93
|
+
|
|
94
|
+
void
|
|
95
|
+
ruby_init_xml_xpointer(void) {
|
|
96
|
+
cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
|
|
97
|
+
eXMLXPointerInvalidExpression = rb_define_class_under(cXMLXPointer, "InvalidExpression", eXMLError);
|
|
98
|
+
|
|
99
|
+
rb_define_singleton_method(cXMLXPointer, "range", ruby_xml_xpointer_range, 2);
|
|
100
|
+
}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/* $Id: ruby_xml_xpointer_context.c
|
|
2
|
-
|
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
|
-
|
|
5
|
-
#include "
|
|
6
|
-
#include "ruby_xml_xpointer_context.h"
|
|
7
|
-
|
|
8
|
-
VALUE cXMLXPointerContext;
|
|
9
|
-
VALUE eXMLXPointerContextInvalidPath;
|
|
10
|
-
|
|
11
|
-
// Rdoc needs to know
|
|
12
|
-
#ifdef RDOC_NEVER_DEFINED
|
|
13
|
-
mXML = rb_define_module("XML");
|
|
14
|
-
cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
|
|
15
|
-
#endif
|
|
16
|
-
|
|
17
|
-
void
|
|
18
|
-
ruby_init_xml_xpointer_context(void) {
|
|
19
|
-
cXMLXPointerContext = rb_define_class_under(cXMLXPointer, "Context", cXMLXPathContext);
|
|
20
|
-
eXMLXPointerContextInvalidPath = rb_define_class_under(cXMLXPointerContext, "InvalidPath", eXMLError);
|
|
21
|
-
}
|
|
1
|
+
/* $Id: ruby_xml_xpointer_context.c 300 2008-07-01 19:14:15Z cfis $ */
|
|
2
|
+
|
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
|
+
|
|
5
|
+
#include "ruby_libxml.h"
|
|
6
|
+
#include "ruby_xml_xpointer_context.h"
|
|
7
|
+
|
|
8
|
+
VALUE cXMLXPointerContext;
|
|
9
|
+
VALUE eXMLXPointerContextInvalidPath;
|
|
10
|
+
|
|
11
|
+
// Rdoc needs to know
|
|
12
|
+
#ifdef RDOC_NEVER_DEFINED
|
|
13
|
+
mXML = rb_define_module("XML");
|
|
14
|
+
cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
void
|
|
18
|
+
ruby_init_xml_xpointer_context(void) {
|
|
19
|
+
cXMLXPointerContext = rb_define_class_under(cXMLXPointer, "Context", cXMLXPathContext);
|
|
20
|
+
eXMLXPointerContextInvalidPath = rb_define_class_under(cXMLXPointerContext, "InvalidPath", eXMLError);
|
|
21
|
+
}
|