libxml-ruby 0.6.0-x86-mswin32-60 → 0.7.0-x86-mswin32-60

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.
Files changed (171) hide show
  1. data/CHANGES +42 -0
  2. data/README +123 -117
  3. data/doc/classes/XML.html +226 -0
  4. data/doc/classes/XML/Attr.html +969 -0
  5. data/doc/classes/XML/Attributes.html +487 -0
  6. data/doc/classes/XML/Document.html +1423 -0
  7. data/doc/classes/XML/Dtd.html +159 -0
  8. data/doc/classes/XML/Error.html +111 -0
  9. data/doc/classes/XML/HTMLParser.html +330 -0
  10. data/doc/classes/XML/InputCallbacks.html +154 -0
  11. data/doc/classes/XML/NS.html +366 -0
  12. data/doc/classes/XML/Node.html +3292 -0
  13. data/doc/classes/XML/Node/FailedModify.html +111 -0
  14. data/doc/classes/XML/Node/Set.html +435 -0
  15. data/doc/classes/XML/Node/SetNamespace.html +111 -0
  16. data/doc/classes/XML/Node/UnknownType.html +111 -0
  17. data/doc/classes/XML/Parser.html +2178 -0
  18. data/doc/classes/XML/Parser/Context.html +1233 -0
  19. data/doc/classes/XML/Parser/ParseError.html +111 -0
  20. data/doc/classes/XML/Reader.html +2173 -0
  21. data/doc/classes/XML/SaxParser.html +396 -0
  22. data/doc/classes/XML/SiblingEnum.html +142 -0
  23. data/doc/classes/XML/State.html +118 -0
  24. data/doc/classes/XML/Tree.html +224 -0
  25. data/doc/classes/XML/XInclude.html +117 -0
  26. data/doc/classes/XML/XInclude/Error.html +111 -0
  27. data/doc/classes/XML/XMLParserOptions.html +198 -0
  28. data/doc/classes/XML/XPath.html +269 -0
  29. data/doc/classes/XML/XPath/Context.html +193 -0
  30. data/doc/classes/XML/XPath/InvalidPath.html +111 -0
  31. data/doc/classes/XML/XPath/Object.html +439 -0
  32. data/doc/classes/XML/XPointer.html +164 -0
  33. data/doc/classes/XML/XPointer/Context.html +117 -0
  34. data/doc/classes/XML/XPointer/Context/InvalidPath.html +111 -0
  35. data/doc/classes/XML/XPointer/InvalidExpression.html +111 -0
  36. data/doc/classes/singleton.html +114 -0
  37. data/doc/created.rid +1 -0
  38. data/doc/files/CHANGES.html +375 -0
  39. data/doc/files/LICENSE.html +133 -0
  40. data/doc/files/README.html +279 -0
  41. data/doc/files/VERSION.html +107 -0
  42. data/doc/files/ext/libxml/cbg_c.html +101 -0
  43. data/doc/files/ext/libxml/libxml_c.html +101 -0
  44. data/doc/files/ext/libxml/ruby_xml_attr_c.html +101 -0
  45. data/doc/files/ext/libxml/ruby_xml_attributes_c.html +101 -0
  46. data/doc/files/ext/libxml/ruby_xml_document_c.html +101 -0
  47. data/doc/files/ext/libxml/ruby_xml_dtd_c.html +101 -0
  48. data/doc/files/ext/libxml/ruby_xml_html_parser_c.html +101 -0
  49. data/doc/files/ext/libxml/ruby_xml_input_cbg_c.html +101 -0
  50. data/doc/files/ext/libxml/ruby_xml_node_c.html +101 -0
  51. data/doc/files/ext/libxml/ruby_xml_node_set_c.html +101 -0
  52. data/doc/files/ext/libxml/ruby_xml_ns_c.html +101 -0
  53. data/doc/files/ext/libxml/ruby_xml_parser_c.html +101 -0
  54. data/doc/files/ext/libxml/ruby_xml_parser_context_c.html +101 -0
  55. data/doc/files/ext/libxml/ruby_xml_reader_c.html +101 -0
  56. data/doc/files/ext/libxml/ruby_xml_sax_parser_c.html +101 -0
  57. data/doc/files/ext/libxml/ruby_xml_schema_c.html +101 -0
  58. data/doc/files/ext/libxml/ruby_xml_state_c.html +101 -0
  59. data/doc/files/ext/libxml/ruby_xml_tree_c.html +101 -0
  60. data/doc/files/ext/libxml/ruby_xml_xinclude_c.html +101 -0
  61. data/doc/files/ext/libxml/ruby_xml_xpath_c.html +101 -0
  62. data/doc/files/ext/libxml/ruby_xml_xpath_context_c.html +101 -0
  63. data/doc/files/ext/libxml/ruby_xml_xpath_object_c.html +101 -0
  64. data/doc/files/ext/libxml/ruby_xml_xpointer_c.html +101 -0
  65. data/doc/files/ext/libxml/ruby_xml_xpointer_context_c.html +101 -0
  66. data/doc/files/lib/libxml_rb.html +115 -0
  67. data/doc/files/lib/xml/libxml_rb.html +114 -0
  68. data/doc/fr_class_index.html +60 -0
  69. data/doc/fr_file_index.html +56 -0
  70. data/doc/fr_method_index.html +373 -0
  71. data/doc/index.html +24 -0
  72. data/doc/rdoc-style.css +208 -0
  73. data/ext/libxml/cbg.c +76 -76
  74. data/ext/libxml/extconf.rb +308 -308
  75. data/ext/libxml/libxml.c +58 -62
  76. data/ext/libxml/ruby_libxml.h +1 -0
  77. data/ext/libxml/ruby_xml_attr.c +201 -113
  78. data/ext/libxml/ruby_xml_attr.h +6 -9
  79. data/ext/libxml/ruby_xml_attributes.c +268 -0
  80. data/ext/libxml/ruby_xml_attributes.h +17 -0
  81. data/ext/libxml/ruby_xml_document.c +80 -66
  82. data/ext/libxml/ruby_xml_dtd.c +2 -2
  83. data/ext/libxml/ruby_xml_dtd.h +17 -17
  84. data/ext/libxml/ruby_xml_html_parser.c +18 -19
  85. data/ext/libxml/ruby_xml_html_parser.h +29 -29
  86. data/ext/libxml/ruby_xml_input_cbg.c +6 -0
  87. data/ext/libxml/ruby_xml_input_cbg.h +20 -20
  88. data/ext/libxml/ruby_xml_node.c +438 -536
  89. data/ext/libxml/ruby_xml_node.h +17 -27
  90. data/ext/libxml/ruby_xml_node_set.c +10 -9
  91. data/ext/libxml/ruby_xml_node_set.h +20 -20
  92. data/ext/libxml/ruby_xml_ns.c +60 -69
  93. data/ext/libxml/ruby_xml_ns.h +12 -21
  94. data/ext/libxml/ruby_xml_parser.c +54 -53
  95. data/ext/libxml/ruby_xml_parser.h +31 -31
  96. data/ext/libxml/ruby_xml_parser_context.c +37 -91
  97. data/ext/libxml/ruby_xml_parser_context.h +20 -22
  98. data/ext/libxml/ruby_xml_reader.h +14 -14
  99. data/ext/libxml/ruby_xml_sax_parser.c +55 -55
  100. data/ext/libxml/ruby_xml_sax_parser.h +56 -56
  101. data/ext/libxml/ruby_xml_schema.c +44 -51
  102. data/ext/libxml/ruby_xml_schema.h +16 -16
  103. data/ext/libxml/ruby_xml_state.c +35 -96
  104. data/ext/libxml/ruby_xml_state.h +2 -3
  105. data/ext/libxml/ruby_xml_tree.h +12 -12
  106. data/ext/libxml/ruby_xml_xinclude.h +13 -13
  107. data/ext/libxml/ruby_xml_xpath.c +57 -18
  108. data/ext/libxml/ruby_xml_xpath.h +23 -23
  109. data/ext/libxml/ruby_xml_xpath_context.c +11 -7
  110. data/ext/libxml/ruby_xml_xpath_context.h +20 -20
  111. data/ext/libxml/ruby_xml_xpath_object.c +9 -16
  112. data/ext/libxml/ruby_xml_xpath_object.h +4 -10
  113. data/ext/libxml/ruby_xml_xpointer.c +11 -11
  114. data/ext/libxml/ruby_xml_xpointer.h +27 -27
  115. data/ext/libxml/ruby_xml_xpointer_context.h +18 -18
  116. data/ext/libxml/version.h +2 -2
  117. data/lib/libxml.rb +134 -125
  118. data/lib/libxml_ruby.so +0 -0
  119. data/mingw/libiconv-2.dll +0 -0
  120. data/mingw/libxml2-2.dll +0 -0
  121. data/mingw/libxml_ruby.so +0 -0
  122. data/test/ets_copy_bug.rb +1 -1
  123. data/test/ets_copy_bug2.rb +16 -27
  124. data/test/ets_doc_to_s.rb +1 -1
  125. data/test/ets_gpx.rb +1 -1
  126. data/test/ets_node_gc.rb +1 -1
  127. data/test/ets_tsr.rb +1 -1
  128. data/test/tc_well_formed.rb +1 -1
  129. data/test/tc_xml_attributes.rb +106 -0
  130. data/test/tc_xml_document.rb +10 -10
  131. data/test/tc_xml_document_write3.rb +1 -1
  132. data/test/tc_xml_dtd.rb +49 -0
  133. data/test/tc_xml_html_parser.rb +3 -3
  134. data/test/tc_xml_node.rb +69 -33
  135. data/test/tc_xml_node_attr.rb +170 -0
  136. data/test/{tc_xml_node8.rb → tc_xml_node_cdata.rb} +2 -2
  137. data/test/{tc_xml_node9.rb → tc_xml_node_comment.rb} +3 -3
  138. data/test/tc_xml_node_edit.rb +91 -0
  139. data/test/tc_xml_parser.rb +97 -50
  140. data/test/tc_xml_parser_context.rb +61 -23
  141. data/test/tc_xml_schema.rb +39 -0
  142. data/test/tc_xml_xinclude.rb +5 -6
  143. data/test/tc_xml_xpath.rb +51 -27
  144. data/test/test_suite.rb +27 -0
  145. data/vc/{libxml.sln → libxml_ruby.sln} +5 -5
  146. data/vc/{libxml.vcproj → libxml_ruby.vcproj} +9 -1
  147. metadata +106 -54
  148. data/mingw/mingw.rake +0 -36
  149. data/test/dtd-test.rb +0 -24
  150. data/test/merge_bug.rb +0 -55
  151. data/test/schema-test.rb +0 -74
  152. data/test/tc_xml_node2.rb +0 -25
  153. data/test/tc_xml_node3.rb +0 -27
  154. data/test/tc_xml_node4.rb +0 -86
  155. data/test/tc_xml_node5.rb +0 -52
  156. data/test/tc_xml_node6.rb +0 -27
  157. data/test/tc_xml_node7.rb +0 -35
  158. data/test/tc_xml_parser2.rb +0 -16
  159. data/test/tc_xml_parser3.rb +0 -23
  160. data/test/tc_xml_parser4.rb +0 -33
  161. data/test/tc_xml_parser5.rb +0 -27
  162. data/test/tc_xml_parser6.rb +0 -23
  163. data/test/tc_xml_parser7.rb +0 -28
  164. data/test/tc_xml_parser8.rb +0 -32
  165. data/test/tc_xml_parser9.rb +0 -11
  166. data/test/tc_xml_xpath2.rb +0 -14
  167. data/work/vc/debug/libxml.exp +0 -0
  168. data/work/vc/debug/libxml.ilk +0 -0
  169. data/work/vc/debug/libxml.lib +0 -0
  170. data/work/vc/debug/libxml.pdb +0 -0
  171. 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
+
@@ -3,111 +3,50 @@
3
3
  #include "ruby_libxml.h"
4
4
 
5
5
  VALUE cXMLState;
6
- static VALUE weak_holder;
7
- static int id_inst;
6
+ VALUE LIBXML_STATE = Qnil;
8
7
 
9
- ID id_state;
10
-
11
- #undef DEBUG
8
+ static int dummy = 0;
12
9
 
13
10
  void
14
- ruby_xml_state_free(int * dummy) {
15
- if ( dummy==NULL ) return;
11
+ ruby_xml_state_free(int dummy) {
16
12
  xmlCleanupParser();
17
- ruby_xfree(dummy);
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
- ruby_xml_state_object() {
32
- VALUE obj,id;
33
- int *dummy;
34
-
35
- id=rb_ivar_get(cXMLState,id_state);
36
- if (NIL_P(id)) {
37
- obj = Data_Make_Struct(cXMLState, int,
38
- ruby_xml_state_mark,
39
- ruby_xml_state_free,
40
- dummy);
41
- rb_ivar_set(cXMLState,id_state,id=rb_obj_id(obj));
42
- *dummy=0;
43
- weak_holder=obj;
44
- return obj;
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
- rb_define_singleton_method(cXMLState, "used?",
108
- ruby_xml_state_used_p, 0);
109
- rb_define_singleton_method(cXMLState, "use",
110
- ruby_xml_state_use, 0);
111
-
112
- rb_ivar_set(cXMLState, id_state=rb_intern("@stateid"), Qnil);
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
  }
@@ -4,9 +4,8 @@
4
4
  #define __RUBY_XML_STATE__
5
5
 
6
6
  extern VALUE cXMLState;
7
+ extern VALUE LIBXML_STATE;
7
8
 
8
- void ruby_init_state(void);
9
- void ruby_xml_state_marker(void);
10
- VALUE ruby_xml_state_object_find(VALUE id);
9
+ void ruby_init_state(void);
11
10
 
12
11
  #endif
@@ -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
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpath.c 300 2008-07-01 19:14:15Z cfis $ */
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
- * Includes Enumerable.
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 => (true|false)
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
- ruby_xml_ns *rxns;
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, ruby_xml_ns, rxns);
91
- rprefix = rb_str_new2((const char*)rxns->ns->prefix);
92
- ruri = rb_str_new2((const char*)rxns->ns->href);
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]) => xpath
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
- ruby_xml_node *node;
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, ruby_xml_node, node);
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, ruby_xml_node, node);
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 = node->node;
187
+ ctxt->node = xnode;
150
188
 
151
189
  // XXX is setting ->namespaces used?
152
- if (node->node->type == XML_DOCUMENT_NODE) {
153
- ctxt->namespaces = xmlGetNsList(node->node->doc,
154
- xmlDocGetRootElement(node->node->doc));
190
+ if (xnode->type == XML_DOCUMENT_NODE) {
191
+ ctxt->namespaces = xmlGetNsList(xnode->doc,
192
+ xmlDocGetRootElement(xnode->doc));
155
193
  } else {
156
- ctxt->namespaces = xmlGetNsList(node->node->doc, node->node);
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
- return Qnil;
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
 
@@ -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 300 2008-07-01 19:14:15Z cfis $ */
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 => document
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
- ruby_xml_node *node;
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, ruby_xml_node, node);
66
- if (node->node->doc == NULL)
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(node->node->doc);
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) => (true|false)
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.