libxml-ruby 0.6.0-x86-mswin32-60 → 0.7.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +42 -0
- data/README +123 -117
- data/doc/classes/XML.html +226 -0
- data/doc/classes/XML/Attr.html +969 -0
- data/doc/classes/XML/Attributes.html +487 -0
- data/doc/classes/XML/Document.html +1423 -0
- data/doc/classes/XML/Dtd.html +159 -0
- data/doc/classes/XML/Error.html +111 -0
- data/doc/classes/XML/HTMLParser.html +330 -0
- data/doc/classes/XML/InputCallbacks.html +154 -0
- data/doc/classes/XML/NS.html +366 -0
- data/doc/classes/XML/Node.html +3292 -0
- data/doc/classes/XML/Node/FailedModify.html +111 -0
- data/doc/classes/XML/Node/Set.html +435 -0
- data/doc/classes/XML/Node/SetNamespace.html +111 -0
- data/doc/classes/XML/Node/UnknownType.html +111 -0
- data/doc/classes/XML/Parser.html +2178 -0
- data/doc/classes/XML/Parser/Context.html +1233 -0
- data/doc/classes/XML/Parser/ParseError.html +111 -0
- data/doc/classes/XML/Reader.html +2173 -0
- data/doc/classes/XML/SaxParser.html +396 -0
- data/doc/classes/XML/SiblingEnum.html +142 -0
- data/doc/classes/XML/State.html +118 -0
- data/doc/classes/XML/Tree.html +224 -0
- data/doc/classes/XML/XInclude.html +117 -0
- data/doc/classes/XML/XInclude/Error.html +111 -0
- data/doc/classes/XML/XMLParserOptions.html +198 -0
- data/doc/classes/XML/XPath.html +269 -0
- data/doc/classes/XML/XPath/Context.html +193 -0
- data/doc/classes/XML/XPath/InvalidPath.html +111 -0
- data/doc/classes/XML/XPath/Object.html +439 -0
- data/doc/classes/XML/XPointer.html +164 -0
- data/doc/classes/XML/XPointer/Context.html +117 -0
- data/doc/classes/XML/XPointer/Context/InvalidPath.html +111 -0
- data/doc/classes/XML/XPointer/InvalidExpression.html +111 -0
- data/doc/classes/singleton.html +114 -0
- data/doc/created.rid +1 -0
- data/doc/files/CHANGES.html +375 -0
- data/doc/files/LICENSE.html +133 -0
- data/doc/files/README.html +279 -0
- data/doc/files/VERSION.html +107 -0
- data/doc/files/ext/libxml/cbg_c.html +101 -0
- data/doc/files/ext/libxml/libxml_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_attr_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_attributes_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_document_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_dtd_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_html_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_input_cbg_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_node_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_node_set_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_ns_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_parser_context_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_reader_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_sax_parser_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_schema_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_state_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_tree_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xinclude_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_context_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpath_object_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpointer_c.html +101 -0
- data/doc/files/ext/libxml/ruby_xml_xpointer_context_c.html +101 -0
- data/doc/files/lib/libxml_rb.html +115 -0
- data/doc/files/lib/xml/libxml_rb.html +114 -0
- data/doc/fr_class_index.html +60 -0
- data/doc/fr_file_index.html +56 -0
- data/doc/fr_method_index.html +373 -0
- data/doc/index.html +24 -0
- data/doc/rdoc-style.css +208 -0
- data/ext/libxml/cbg.c +76 -76
- data/ext/libxml/extconf.rb +308 -308
- data/ext/libxml/libxml.c +58 -62
- data/ext/libxml/ruby_libxml.h +1 -0
- data/ext/libxml/ruby_xml_attr.c +201 -113
- data/ext/libxml/ruby_xml_attr.h +6 -9
- data/ext/libxml/ruby_xml_attributes.c +268 -0
- data/ext/libxml/ruby_xml_attributes.h +17 -0
- data/ext/libxml/ruby_xml_document.c +80 -66
- data/ext/libxml/ruby_xml_dtd.c +2 -2
- data/ext/libxml/ruby_xml_dtd.h +17 -17
- data/ext/libxml/ruby_xml_html_parser.c +18 -19
- data/ext/libxml/ruby_xml_html_parser.h +29 -29
- data/ext/libxml/ruby_xml_input_cbg.c +6 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -20
- data/ext/libxml/ruby_xml_node.c +438 -536
- data/ext/libxml/ruby_xml_node.h +17 -27
- data/ext/libxml/ruby_xml_node_set.c +10 -9
- data/ext/libxml/ruby_xml_node_set.h +20 -20
- data/ext/libxml/ruby_xml_ns.c +60 -69
- data/ext/libxml/ruby_xml_ns.h +12 -21
- data/ext/libxml/ruby_xml_parser.c +54 -53
- data/ext/libxml/ruby_xml_parser.h +31 -31
- data/ext/libxml/ruby_xml_parser_context.c +37 -91
- data/ext/libxml/ruby_xml_parser_context.h +20 -22
- data/ext/libxml/ruby_xml_reader.h +14 -14
- data/ext/libxml/ruby_xml_sax_parser.c +55 -55
- data/ext/libxml/ruby_xml_sax_parser.h +56 -56
- data/ext/libxml/ruby_xml_schema.c +44 -51
- data/ext/libxml/ruby_xml_schema.h +16 -16
- data/ext/libxml/ruby_xml_state.c +35 -96
- data/ext/libxml/ruby_xml_state.h +2 -3
- data/ext/libxml/ruby_xml_tree.h +12 -12
- data/ext/libxml/ruby_xml_xinclude.h +13 -13
- data/ext/libxml/ruby_xml_xpath.c +57 -18
- data/ext/libxml/ruby_xml_xpath.h +23 -23
- data/ext/libxml/ruby_xml_xpath_context.c +11 -7
- data/ext/libxml/ruby_xml_xpath_context.h +20 -20
- data/ext/libxml/ruby_xml_xpath_object.c +9 -16
- data/ext/libxml/ruby_xml_xpath_object.h +4 -10
- data/ext/libxml/ruby_xml_xpointer.c +11 -11
- data/ext/libxml/ruby_xml_xpointer.h +27 -27
- data/ext/libxml/ruby_xml_xpointer_context.h +18 -18
- data/ext/libxml/version.h +2 -2
- data/lib/libxml.rb +134 -125
- data/lib/libxml_ruby.so +0 -0
- data/mingw/libiconv-2.dll +0 -0
- data/mingw/libxml2-2.dll +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/test/ets_copy_bug.rb +1 -1
- data/test/ets_copy_bug2.rb +16 -27
- data/test/ets_doc_to_s.rb +1 -1
- data/test/ets_gpx.rb +1 -1
- data/test/ets_node_gc.rb +1 -1
- data/test/ets_tsr.rb +1 -1
- data/test/tc_well_formed.rb +1 -1
- data/test/tc_xml_attributes.rb +106 -0
- data/test/tc_xml_document.rb +10 -10
- data/test/tc_xml_document_write3.rb +1 -1
- data/test/tc_xml_dtd.rb +49 -0
- data/test/tc_xml_html_parser.rb +3 -3
- data/test/tc_xml_node.rb +69 -33
- data/test/tc_xml_node_attr.rb +170 -0
- data/test/{tc_xml_node8.rb → tc_xml_node_cdata.rb} +2 -2
- data/test/{tc_xml_node9.rb → tc_xml_node_comment.rb} +3 -3
- data/test/tc_xml_node_edit.rb +91 -0
- data/test/tc_xml_parser.rb +97 -50
- data/test/tc_xml_parser_context.rb +61 -23
- data/test/tc_xml_schema.rb +39 -0
- data/test/tc_xml_xinclude.rb +5 -6
- data/test/tc_xml_xpath.rb +51 -27
- data/test/test_suite.rb +27 -0
- data/vc/{libxml.sln → libxml_ruby.sln} +5 -5
- data/vc/{libxml.vcproj → libxml_ruby.vcproj} +9 -1
- metadata +106 -54
- data/mingw/mingw.rake +0 -36
- data/test/dtd-test.rb +0 -24
- data/test/merge_bug.rb +0 -55
- data/test/schema-test.rb +0 -74
- data/test/tc_xml_node2.rb +0 -25
- data/test/tc_xml_node3.rb +0 -27
- data/test/tc_xml_node4.rb +0 -86
- data/test/tc_xml_node5.rb +0 -52
- data/test/tc_xml_node6.rb +0 -27
- data/test/tc_xml_node7.rb +0 -35
- data/test/tc_xml_parser2.rb +0 -16
- data/test/tc_xml_parser3.rb +0 -23
- data/test/tc_xml_parser4.rb +0 -33
- data/test/tc_xml_parser5.rb +0 -27
- data/test/tc_xml_parser6.rb +0 -23
- data/test/tc_xml_parser7.rb +0 -28
- data/test/tc_xml_parser8.rb +0 -32
- data/test/tc_xml_parser9.rb +0 -11
- data/test/tc_xml_xpath2.rb +0 -14
- 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
@@ -1,16 +1,16 @@
|
|
1
|
-
#ifndef __RUBY_XML_SCHEMA__
|
2
|
-
#define __RUBY_XML_SCHEMA__
|
3
|
-
|
4
|
-
#include <libxml/schemasInternals.h>
|
5
|
-
#include <libxml/xmlschemas.h>
|
6
|
-
|
7
|
-
extern VALUE cXMLSchema;
|
8
|
-
|
9
|
-
typedef struct rxp_schema {
|
10
|
-
xmlSchemaPtr schema; /* Schema interface */
|
11
|
-
} ruby_xml_schema;
|
12
|
-
|
13
|
-
void ruby_init_xml_schema(void);
|
14
|
-
void ruby_schema_free(ruby_xml_schema *rxs);
|
15
|
-
#endif
|
16
|
-
|
1
|
+
#ifndef __RUBY_XML_SCHEMA__
|
2
|
+
#define __RUBY_XML_SCHEMA__
|
3
|
+
|
4
|
+
#include <libxml/schemasInternals.h>
|
5
|
+
#include <libxml/xmlschemas.h>
|
6
|
+
|
7
|
+
extern VALUE cXMLSchema;
|
8
|
+
|
9
|
+
typedef struct rxp_schema {
|
10
|
+
xmlSchemaPtr schema; /* Schema interface */
|
11
|
+
} ruby_xml_schema;
|
12
|
+
|
13
|
+
void ruby_init_xml_schema(void);
|
14
|
+
void ruby_schema_free(ruby_xml_schema *rxs);
|
15
|
+
#endif
|
16
|
+
|
data/ext/libxml/ruby_xml_state.c
CHANGED
@@ -3,111 +3,50 @@
|
|
3
3
|
#include "ruby_libxml.h"
|
4
4
|
|
5
5
|
VALUE cXMLState;
|
6
|
-
|
7
|
-
static int id_inst;
|
6
|
+
VALUE LIBXML_STATE = Qnil;
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
#undef DEBUG
|
8
|
+
static int dummy = 0;
|
12
9
|
|
13
10
|
void
|
14
|
-
ruby_xml_state_free(int
|
15
|
-
if ( dummy==NULL ) return;
|
11
|
+
ruby_xml_state_free(int dummy) {
|
16
12
|
xmlCleanupParser();
|
17
|
-
|
18
|
-
dummy=NULL;
|
19
|
-
weak_holder=Qnil;
|
20
|
-
rb_ivar_set(cXMLState,id_state,Qnil);
|
21
|
-
}
|
22
|
-
|
23
|
-
void
|
24
|
-
ruby_xml_state_mark(void * a) {
|
25
|
-
#ifdef DEBUG
|
26
|
-
fprintf(stderr,"marked 0x%x\n",NUM2INT(rb_ivar_get(cXMLState,id_state)));
|
27
|
-
#endif
|
13
|
+
LIBXML_STATE = Qnil;
|
28
14
|
}
|
29
15
|
|
30
16
|
VALUE
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
#ifdef DEBUG
|
48
|
-
fprintf(stderr,"getting 0x%x\n",NUM2INT(id));
|
49
|
-
#endif
|
50
|
-
return weak_holder;
|
51
|
-
|
52
|
-
return rb_funcall(rb_const_get(rb_cModule,rb_intern("ObjectSpace")),
|
53
|
-
rb_intern("_id2ref"),
|
54
|
-
1,
|
55
|
-
id);
|
56
|
-
}
|
57
|
-
|
58
|
-
VALUE
|
59
|
-
ruby_xml_state_object_find_aux(VALUE id) {
|
60
|
-
return rb_funcall(rb_const_get(rb_cModule,rb_intern("ObjectSpace")),
|
61
|
-
rb_intern("_id2ref"),
|
62
|
-
1, id);
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
static VALUE
|
67
|
-
find_failed() {
|
68
|
-
return Qnil;
|
69
|
-
}
|
70
|
-
|
71
|
-
VALUE
|
72
|
-
ruby_xml_state_object_find(VALUE id) {
|
73
|
-
return rb_rescue(ruby_xml_state_object_find_aux, id, find_failed, 0);
|
74
|
-
}
|
75
|
-
/*
|
76
|
-
* This will establish a use and mark it or mark an existing use.
|
77
|
-
* should be called by parser.mark and document.mark
|
78
|
-
*/
|
79
|
-
void
|
80
|
-
ruby_xml_state_marker(void) {
|
81
|
-
ruby_xml_state_object();
|
82
|
-
rb_gc_mark(weak_holder);
|
83
|
-
}
|
84
|
-
|
85
|
-
VALUE
|
86
|
-
ruby_xml_state_used_p(VALUE klass)
|
87
|
-
{
|
88
|
-
return rb_ivar_get(cXMLState,id_state);
|
89
|
-
}
|
90
|
-
|
91
|
-
VALUE
|
92
|
-
ruby_xml_state_use(VALUE klass)
|
93
|
-
{
|
94
|
-
return ruby_xml_state_object();
|
95
|
-
}
|
96
|
-
|
97
|
-
// Rdoc needs to know
|
98
|
-
#ifdef RDOC_NEVER_DEFINED
|
99
|
-
mXML = rb_define_module("XML");
|
100
|
-
#endif
|
101
|
-
|
17
|
+
ruby_xml_state_alloc() {
|
18
|
+
#ifdef DEBUG
|
19
|
+
fprintf(stderr, "Allocating state");
|
20
|
+
#endif
|
21
|
+
|
22
|
+
xmlInitParser();
|
23
|
+
|
24
|
+
return Data_Wrap_Struct(cXMLState,
|
25
|
+
NULL, ruby_xml_state_free,
|
26
|
+
&dummy);
|
27
|
+
}
|
28
|
+
|
29
|
+
// Rdoc needs to know
|
30
|
+
#ifdef RDOC_NEVER_DEFINED
|
31
|
+
mXML = rb_define_module("XML");
|
32
|
+
#endif
|
102
33
|
|
103
34
|
void
|
104
35
|
ruby_init_state(void) {
|
36
|
+
VALUE rb_mSingleton;
|
105
37
|
cXMLState = rb_define_class_under(mXML, "State", rb_cObject);
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
38
|
+
|
39
|
+
/* Mixin singleton so only one xml state object can be created. */
|
40
|
+
rb_require("singleton");
|
41
|
+
rb_mSingleton = rb_const_get(rb_cObject, rb_intern("Singleton"));
|
42
|
+
rb_include_module(cXMLState, rb_mSingleton);
|
43
|
+
|
44
|
+
rb_define_alloc_func(cXMLState, ruby_xml_state_alloc);
|
45
|
+
|
46
|
+
/* Create one instance of the state object that is used
|
47
|
+
to initalize and cleanup libxml. Then register it with
|
48
|
+
the garbage collector so its not freed until the process
|
49
|
+
exists.*/
|
50
|
+
LIBXML_STATE = rb_class_new_instance(0, NULL, cXMLState);
|
51
|
+
rb_global_variable(&LIBXML_STATE);
|
113
52
|
}
|
data/ext/libxml/ruby_xml_state.h
CHANGED
data/ext/libxml/ruby_xml_tree.h
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
/* $Id: ruby_xml_tree.h 39 2006-02-21 20:40:16Z roscopeco $ */
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#ifndef __RUBY_XML_TREE__
|
6
|
-
#define __RUBY_XML_TREE__
|
7
|
-
|
8
|
-
extern VALUE cXMLTree;
|
9
|
-
|
10
|
-
void ruby_init_xml_tree(void);
|
11
|
-
|
12
|
-
#endif
|
1
|
+
/* $Id: ruby_xml_tree.h 39 2006-02-21 20:40:16Z roscopeco $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_TREE__
|
6
|
+
#define __RUBY_XML_TREE__
|
7
|
+
|
8
|
+
extern VALUE cXMLTree;
|
9
|
+
|
10
|
+
void ruby_init_xml_tree(void);
|
11
|
+
|
12
|
+
#endif
|
@@ -1,13 +1,13 @@
|
|
1
|
-
/* $Id: ruby_xml_xinclude.h 39 2006-02-21 20:40:16Z roscopeco $ */
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#ifndef __RUBY_XML_XINCLUDE__
|
6
|
-
#define __RUBY_XML_XINCLUDE__
|
7
|
-
|
8
|
-
extern VALUE cXMLXInclude;
|
9
|
-
extern VALUE eXMLXIncludeError;
|
10
|
-
|
11
|
-
void ruby_init_xml_xinclude(void);
|
12
|
-
|
13
|
-
#endif
|
1
|
+
/* $Id: ruby_xml_xinclude.h 39 2006-02-21 20:40:16Z roscopeco $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_XINCLUDE__
|
6
|
+
#define __RUBY_XML_XINCLUDE__
|
7
|
+
|
8
|
+
extern VALUE cXMLXInclude;
|
9
|
+
extern VALUE eXMLXIncludeError;
|
10
|
+
|
11
|
+
void ruby_init_xml_xinclude(void);
|
12
|
+
|
13
|
+
#endif
|
data/ext/libxml/ruby_xml_xpath.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: ruby_xml_xpath.c
|
1
|
+
/* $Id: ruby_xml_xpath.c 351 2008-07-09 19:55:21Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
@@ -8,16 +8,54 @@
|
|
8
8
|
/*
|
9
9
|
* Document-class: XML::XPath
|
10
10
|
*
|
11
|
-
*
|
12
|
-
|
11
|
+
* The XML::XPath class is used to query XML documents. It is used
|
12
|
+
* via the XML::Document#find method.
|
13
|
+
*
|
14
|
+
* document.find('/foo')
|
15
|
+
*
|
16
|
+
* === Working With Namespaces
|
17
|
+
* Finding namespaced elements and attributes can be tricky.
|
18
|
+
* Lets work through some examples using the following xml document:
|
19
|
+
*
|
20
|
+
* <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
21
|
+
* <soap:Body>
|
22
|
+
* <getManufacturerNamesResponse xmlns="http://services.somewhere.com">
|
23
|
+
* <IDAndNameList xmlns="http://services.somewhere.com">
|
24
|
+
* <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com"/>
|
25
|
+
* </IDAndNameList>
|
26
|
+
* </getManufacturerNamesResponse>
|
27
|
+
* </soap:Envelope>
|
28
|
+
*
|
29
|
+
* # Since the soap namespace is defined on the root
|
30
|
+
* # node we can directly use it.
|
31
|
+
* doc.find('/soap:Envelope')
|
32
|
+
*
|
33
|
+
* # Since the ns1 namespace is not defined on the root node
|
34
|
+
* # we have to first register it with the xpath engine.
|
35
|
+
* doc.find('//ns1:IdAndName',
|
36
|
+
'ns1:http://domain.somewhere.com')
|
37
|
+
*
|
38
|
+
* # Since the getManufacturerNamesResponse element uses a default
|
39
|
+
* # namespace we first have to give it a prefix and register
|
40
|
+
* # it with the xpath engine.
|
41
|
+
* doc.find('//ns:getManufacturerNamesResponse',
|
42
|
+
* 'ns:http://services.somewhere.com')
|
43
|
+
*
|
44
|
+
* # Here is an example showing a complex namespace aware
|
45
|
+
* # xpath expression.
|
46
|
+
* doc.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse/ns0:IDAndNameList/ns1:IdAndName',
|
47
|
+
['ns0:http://services.somewhere.com', 'ns1:http://domain.somewhere.com'])
|
48
|
+
*/
|
49
|
+
|
13
50
|
VALUE cXMLXPath;
|
14
51
|
VALUE eXMLXPathInvalidPath;
|
15
52
|
|
16
53
|
#ifdef LIBXML_XPATH_ENABLED
|
17
54
|
|
55
|
+
|
18
56
|
/*
|
19
57
|
* call-seq:
|
20
|
-
* xpath.debug
|
58
|
+
* xpath.debug -> (true|false)
|
21
59
|
*
|
22
60
|
* Dump libxml debugging information to stdout.
|
23
61
|
* Requires Libxml be compiled with debugging enabled.
|
@@ -51,7 +89,7 @@ ruby_xml_xpath_register_namespaces(VALUE nslist, VALUE xxpc, int level) {
|
|
51
89
|
char *cp;
|
52
90
|
long i;
|
53
91
|
VALUE rprefix, ruri;
|
54
|
-
|
92
|
+
xmlNsPtr xns;
|
55
93
|
|
56
94
|
/* Need to loop through the 2nd argument and iterate through the
|
57
95
|
* list of namespaces that we want to allow */
|
@@ -87,9 +125,9 @@ ruby_xml_xpath_register_namespaces(VALUE nslist, VALUE xxpc, int level) {
|
|
87
125
|
break;
|
88
126
|
default:
|
89
127
|
if (rb_obj_is_kind_of(nslist, cXMLNS) == Qtrue) {
|
90
|
-
Data_Get_Struct(nslist,
|
91
|
-
rprefix = rb_str_new2((const char*)
|
92
|
-
ruri = rb_str_new2((const char*)
|
128
|
+
Data_Get_Struct(nslist, xmlNs, xns);
|
129
|
+
rprefix = rb_str_new2((const char*)xns->prefix);
|
130
|
+
ruri = rb_str_new2((const char*)xns->href);
|
93
131
|
ruby_xml_xpath_context_register_namespace(xxpc, rprefix, ruri);
|
94
132
|
} else
|
95
133
|
rb_raise(rb_eArgError, "Invalid argument type, only accept string, array of strings, or an array of arrays");
|
@@ -97,7 +135,7 @@ ruby_xml_xpath_register_namespaces(VALUE nslist, VALUE xxpc, int level) {
|
|
97
135
|
}
|
98
136
|
/*
|
99
137
|
* call-seq:
|
100
|
-
* XML::XPath.find(path, namespaces = [any])
|
138
|
+
* XML::XPath.find(path, namespaces = [any]) -> xpath
|
101
139
|
*
|
102
140
|
* Find nodes matching the specified xpath (and optionally any of the
|
103
141
|
* supplied namespaces) and return as an XML::Node::Set.
|
@@ -118,7 +156,7 @@ ruby_xml_xpath_find(VALUE class, VALUE anode, VALUE xpath_expr, VALUE nslist) {
|
|
118
156
|
#ifdef LIBXML_XPATH_ENABLED
|
119
157
|
xmlXPathCompExprPtr comp;
|
120
158
|
xmlXPathObjectPtr xxpop;
|
121
|
-
|
159
|
+
xmlNodePtr xnode;
|
122
160
|
xmlXPathContextPtr ctxt;
|
123
161
|
ruby_xml_document_t *rdocp;
|
124
162
|
VALUE rnode, xxpc;
|
@@ -134,10 +172,10 @@ ruby_xml_xpath_find(VALUE class, VALUE anode, VALUE xpath_expr, VALUE nslist) {
|
|
134
172
|
#ifdef DEBUG
|
135
173
|
fprintf(stderr,"rnode 0x%x 0x%x\n",rnode,xmlDocGetRootElement(rdocp->doc)->_private);
|
136
174
|
#endif
|
137
|
-
Data_Get_Struct(rnode,
|
175
|
+
Data_Get_Struct(rnode, xmlNode, xnode);
|
138
176
|
} else if ( rb_obj_is_kind_of(anode, cXMLNode) == Qtrue) {
|
139
177
|
xxpc = ruby_xml_xpath_context_new(anode);
|
140
|
-
Data_Get_Struct(anode,
|
178
|
+
Data_Get_Struct(anode, xmlNode, xnode);
|
141
179
|
} else
|
142
180
|
rb_raise(rb_eTypeError, "arg 1 must be XML::Document or XML::Node within a document %s", rb_obj_as_string(anode));
|
143
181
|
|
@@ -146,14 +184,14 @@ ruby_xml_xpath_find(VALUE class, VALUE anode, VALUE xpath_expr, VALUE nslist) {
|
|
146
184
|
|
147
185
|
Data_Get_Struct(xxpc,xmlXPathContext,ctxt);
|
148
186
|
// XXX Is this legal? Set a subtree to apply xpath?
|
149
|
-
ctxt->node =
|
187
|
+
ctxt->node = xnode;
|
150
188
|
|
151
189
|
// XXX is setting ->namespaces used?
|
152
|
-
if (
|
153
|
-
ctxt->namespaces = xmlGetNsList(
|
154
|
-
xmlDocGetRootElement(
|
190
|
+
if (xnode->type == XML_DOCUMENT_NODE) {
|
191
|
+
ctxt->namespaces = xmlGetNsList(xnode->doc,
|
192
|
+
xmlDocGetRootElement(xnode->doc));
|
155
193
|
} else {
|
156
|
-
ctxt->namespaces = xmlGetNsList(
|
194
|
+
ctxt->namespaces = xmlGetNsList(xnode->doc, xnode);
|
157
195
|
}
|
158
196
|
|
159
197
|
ctxt->nsNr = 0;
|
@@ -173,7 +211,8 @@ ruby_xml_xpath_find(VALUE class, VALUE anode, VALUE xpath_expr, VALUE nslist) {
|
|
173
211
|
}
|
174
212
|
xxpop=xmlXPathCompiledEval(comp, ctxt);
|
175
213
|
if ( xxpop == NULL )
|
176
|
-
|
214
|
+
rb_raise(eXMLXPathInvalidPath,
|
215
|
+
"Invalid XPath expression (expr could not be evaluated)");
|
177
216
|
|
178
217
|
rxpop = ruby_xml_xpath_object_wrap(xxpop);
|
179
218
|
|
data/ext/libxml/ruby_xml_xpath.h
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
/* $Id: ruby_xml_xpath.h 207 2007-11-14 07:51:46Z danj $ */
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#ifndef __RUBY_XML_XPATH__
|
6
|
-
#define __RUBY_XML_XPATH__
|
7
|
-
|
8
|
-
extern VALUE cXMLXPath;
|
9
|
-
extern VALUE eXMLXPathInvalidPath;
|
10
|
-
|
11
|
-
typedef struct ruby_xml_xpath {
|
12
|
-
VALUE xd;
|
13
|
-
VALUE ctxt;
|
14
|
-
xmlXPathObjectPtr xpop;
|
15
|
-
} ruby_xml_xpath;
|
16
|
-
|
17
|
-
void ruby_xml_xpath_free(ruby_xml_xpath *rxxp);
|
18
|
-
VALUE ruby_xml_xpath_find(VALUE class, VALUE anode, VALUE xpath_expr, VALUE nslist);
|
19
|
-
VALUE ruby_xml_xpath_find2(VALUE anode, VALUE xpath_expr, VALUE nslist);
|
20
|
-
|
21
|
-
void ruby_init_xml_xpath(void);
|
22
|
-
|
23
|
-
#endif
|
1
|
+
/* $Id: ruby_xml_xpath.h 207 2007-11-14 07:51:46Z danj $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_XPATH__
|
6
|
+
#define __RUBY_XML_XPATH__
|
7
|
+
|
8
|
+
extern VALUE cXMLXPath;
|
9
|
+
extern VALUE eXMLXPathInvalidPath;
|
10
|
+
|
11
|
+
typedef struct ruby_xml_xpath {
|
12
|
+
VALUE xd;
|
13
|
+
VALUE ctxt;
|
14
|
+
xmlXPathObjectPtr xpop;
|
15
|
+
} ruby_xml_xpath;
|
16
|
+
|
17
|
+
void ruby_xml_xpath_free(ruby_xml_xpath *rxxp);
|
18
|
+
VALUE ruby_xml_xpath_find(VALUE class, VALUE anode, VALUE xpath_expr, VALUE nslist);
|
19
|
+
VALUE ruby_xml_xpath_find2(VALUE anode, VALUE xpath_expr, VALUE nslist);
|
20
|
+
|
21
|
+
void ruby_init_xml_xpath(void);
|
22
|
+
|
23
|
+
#endif
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: ruby_xml_xpath_context.c
|
1
|
+
/* $Id: ruby_xml_xpath_context.c 351 2008-07-09 19:55:21Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
@@ -9,7 +9,7 @@ VALUE cXMLXPathContext;
|
|
9
9
|
|
10
10
|
/*
|
11
11
|
* call-seq:
|
12
|
-
* context.doc
|
12
|
+
* context.doc -> document
|
13
13
|
*
|
14
14
|
* Obtain the XML::Document associated with this XPath.
|
15
15
|
*/
|
@@ -25,6 +25,10 @@ ruby_xml_xpath_context_doc_get(VALUE self) {
|
|
25
25
|
void
|
26
26
|
ruby_xml_xpath_context_free(xmlXPathContextPtr ctxt) {
|
27
27
|
if (ctxt != NULL) {
|
28
|
+
if (ctxt->namespaces != NULL) {
|
29
|
+
xmlFree(ctxt->namespaces);
|
30
|
+
ctxt->namespaces = NULL;
|
31
|
+
}
|
28
32
|
xmlXPathFreeContext(ctxt);
|
29
33
|
ctxt = NULL;
|
30
34
|
}
|
@@ -51,7 +55,7 @@ ruby_xml_xpath_context_wrap(xmlXPathContextPtr ctxt) {
|
|
51
55
|
VALUE
|
52
56
|
ruby_xml_xpath_context_new(VALUE anode) {
|
53
57
|
ruby_xml_document_t *rxd;
|
54
|
-
|
58
|
+
xmlNodePtr xnode;
|
55
59
|
xmlXPathContextPtr ctxt;
|
56
60
|
|
57
61
|
if (rb_obj_is_kind_of(anode,cXMLDocument) == Qtrue ) {
|
@@ -62,11 +66,11 @@ ruby_xml_xpath_context_new(VALUE anode) {
|
|
62
66
|
if (ctxt == NULL) return(Qnil);
|
63
67
|
|
64
68
|
} else if (rb_obj_is_kind_of(anode,cXMLNode) == Qtrue ) {
|
65
|
-
Data_Get_Struct(anode,
|
66
|
-
if (
|
69
|
+
Data_Get_Struct(anode, xmlNode, xnode);
|
70
|
+
if (xnode->doc == NULL)
|
67
71
|
rb_raise(rb_eTypeError,"Supplied node must be part of a document");
|
68
72
|
|
69
|
-
ctxt = xmlXPathNewContext(
|
73
|
+
ctxt = xmlXPathNewContext(xnode->doc);
|
70
74
|
if (ctxt == NULL) return(Qnil);
|
71
75
|
|
72
76
|
} else {
|
@@ -79,7 +83,7 @@ ruby_xml_xpath_context_new(VALUE anode) {
|
|
79
83
|
|
80
84
|
/*
|
81
85
|
* call-seq:
|
82
|
-
* context.register_namespace(prefix, uri)
|
86
|
+
* context.register_namespace(prefix, uri) -> (true|false)
|
83
87
|
*
|
84
88
|
* Register the specified namespace URI with the specified prefix
|
85
89
|
* in this context.
|