libxml-ruby 0.8.3-x86-mswin32-60 → 0.9.0-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. data/CHANGES +18 -0
  2. data/RAKEFILE +15 -39
  3. data/README +48 -47
  4. data/ext/libxml/libxml.c +847 -22
  5. data/ext/libxml/ruby_libxml.h +71 -95
  6. data/ext/libxml/ruby_xml_attr.c +500 -500
  7. data/ext/libxml/ruby_xml_attributes.c +1 -1
  8. data/ext/libxml/ruby_xml_document.c +1144 -1135
  9. data/ext/libxml/ruby_xml_document.h +4 -11
  10. data/ext/libxml/ruby_xml_dtd.c +27 -0
  11. data/ext/libxml/ruby_xml_encoding.c +164 -0
  12. data/ext/libxml/ruby_xml_encoding.h +13 -0
  13. data/ext/libxml/ruby_xml_error.c +941 -0
  14. data/ext/libxml/ruby_xml_error.h +13 -0
  15. data/ext/libxml/ruby_xml_html_parser.c +71 -387
  16. data/ext/libxml/ruby_xml_html_parser.h +1 -17
  17. data/ext/libxml/ruby_xml_input.c +179 -0
  18. data/ext/libxml/ruby_xml_input.h +18 -0
  19. data/ext/libxml/ruby_xml_input_cbg.c +17 -3
  20. data/ext/libxml/ruby_xml_node.c +1566 -1582
  21. data/ext/libxml/ruby_xml_node.h +1 -4
  22. data/ext/libxml/ruby_xml_ns.c +14 -3
  23. data/ext/libxml/ruby_xml_parser.c +164 -1398
  24. data/ext/libxml/ruby_xml_parser.h +5 -17
  25. data/ext/libxml/ruby_xml_parser_context.c +131 -169
  26. data/ext/libxml/ruby_xml_parser_context.h +2 -9
  27. data/ext/libxml/ruby_xml_reader.c +910 -945
  28. data/ext/libxml/ruby_xml_relaxng.c +32 -3
  29. data/ext/libxml/ruby_xml_sax_parser.c +106 -364
  30. data/ext/libxml/ruby_xml_sax_parser.h +1 -37
  31. data/ext/libxml/ruby_xml_schema.c +174 -145
  32. data/ext/libxml/ruby_xml_xinclude.c +9 -5
  33. data/ext/libxml/ruby_xml_xpath.c +25 -6
  34. data/ext/libxml/ruby_xml_xpath.h +1 -2
  35. data/ext/libxml/ruby_xml_xpath_context.c +17 -19
  36. data/ext/libxml/ruby_xml_xpath_object.c +60 -56
  37. data/ext/libxml/ruby_xml_xpointer.c +11 -5
  38. data/ext/libxml/sax_parser_callbacks.inc +42 -37
  39. data/ext/libxml/version.h +3 -3
  40. data/ext/mingw/Rakefile +20 -27
  41. data/ext/mingw/build.rake +41 -0
  42. data/{lib → ext/mingw}/libiconv-2.dll +0 -0
  43. data/ext/mingw/libxml2-2.dll +0 -0
  44. data/ext/mingw/libxml_ruby.dll.a +0 -0
  45. data/ext/mingw/libxml_ruby.so +0 -0
  46. data/ext/vc/libxml_ruby.vcproj +23 -15
  47. data/lib/libxml.rb +8 -2
  48. data/lib/libxml/document.rb +16 -4
  49. data/lib/libxml/error.rb +84 -0
  50. data/lib/libxml/hpricot.rb +76 -0
  51. data/lib/libxml/html_parser.rb +61 -0
  52. data/lib/libxml/node.rb +36 -25
  53. data/lib/libxml/parser.rb +312 -33
  54. data/lib/libxml/parser_context.rb +17 -0
  55. data/lib/libxml/properties.rb +15 -2
  56. data/lib/libxml/reader.rb +15 -0
  57. data/lib/libxml/sax_callbacks.rb +179 -0
  58. data/lib/libxml/sax_parser.rb +42 -0
  59. data/lib/libxml/tree.rb +1 -2
  60. data/lib/libxml/xpath_object.rb +12 -0
  61. data/test/model/atom.xml +4 -0
  62. data/test/tc_attributes.rb +43 -19
  63. data/test/tc_document.rb +1 -1
  64. data/test/tc_document_write.rb +15 -8
  65. data/test/tc_dtd.rb +36 -20
  66. data/test/tc_encoding.rb +13 -0
  67. data/test/tc_error.rb +136 -0
  68. data/test/tc_node.rb +2 -3
  69. data/test/tc_node_copy.rb +1 -1
  70. data/test/tc_node_edit.rb +6 -0
  71. data/test/tc_ns.rb +18 -0
  72. data/test/tc_parser.rb +113 -228
  73. data/test/tc_parser_context.rb +1 -2
  74. data/test/tc_reader.rb +24 -14
  75. data/test/tc_relaxng.rb +18 -6
  76. data/test/tc_sax_parser.rb +48 -13
  77. data/test/tc_schema.rb +20 -8
  78. data/test/tc_well_formed.rb +2 -1
  79. data/test/tc_xml.rb +212 -0
  80. data/test/tc_xpath.rb +60 -46
  81. data/test/tc_xpointer.rb +7 -11
  82. data/test/test_suite.rb +4 -3
  83. metadata +32 -115
  84. data/doc/rdoc/classes/LibXML.html +0 -241
  85. data/doc/rdoc/classes/LibXML/XML.html +0 -185
  86. data/doc/rdoc/classes/LibXML/XML/Attr.html +0 -1010
  87. data/doc/rdoc/classes/LibXML/XML/Attributes.html +0 -526
  88. data/doc/rdoc/classes/LibXML/XML/Document.html +0 -1489
  89. data/doc/rdoc/classes/LibXML/XML/Dtd.html +0 -213
  90. data/doc/rdoc/classes/LibXML/XML/Error.html +0 -117
  91. data/doc/rdoc/classes/LibXML/XML/HTMLParser.html +0 -348
  92. data/doc/rdoc/classes/LibXML/XML/InputCallbacks.html +0 -160
  93. data/doc/rdoc/classes/LibXML/XML/NS.html +0 -381
  94. data/doc/rdoc/classes/LibXML/XML/Node.html +0 -3396
  95. data/doc/rdoc/classes/LibXML/XML/Node/FailedModify.html +0 -123
  96. data/doc/rdoc/classes/LibXML/XML/Node/Set.html +0 -440
  97. data/doc/rdoc/classes/LibXML/XML/Node/SetNamespace.html +0 -123
  98. data/doc/rdoc/classes/LibXML/XML/Node/UnknownType.html +0 -123
  99. data/doc/rdoc/classes/LibXML/XML/Parser.html +0 -2239
  100. data/doc/rdoc/classes/LibXML/XML/Parser/Context.html +0 -1255
  101. data/doc/rdoc/classes/LibXML/XML/Parser/ParseError.html +0 -123
  102. data/doc/rdoc/classes/LibXML/XML/Reader.html +0 -2264
  103. data/doc/rdoc/classes/LibXML/XML/RelaxNG.html +0 -237
  104. data/doc/rdoc/classes/LibXML/XML/SaxParser.html +0 -415
  105. data/doc/rdoc/classes/LibXML/XML/Schema.html +0 -308
  106. data/doc/rdoc/classes/LibXML/XML/State.html +0 -124
  107. data/doc/rdoc/classes/LibXML/XML/Tree.html +0 -111
  108. data/doc/rdoc/classes/LibXML/XML/XInclude.html +0 -123
  109. data/doc/rdoc/classes/LibXML/XML/XInclude/Error.html +0 -117
  110. data/doc/rdoc/classes/LibXML/XML/XMLParserOptions.html +0 -198
  111. data/doc/rdoc/classes/LibXML/XML/XPath.html +0 -184
  112. data/doc/rdoc/classes/LibXML/XML/XPath/Context.html +0 -404
  113. data/doc/rdoc/classes/LibXML/XML/XPath/InvalidPath.html +0 -172
  114. data/doc/rdoc/classes/LibXML/XML/XPath/Object.html +0 -627
  115. data/doc/rdoc/classes/LibXML/XML/XPointer.html +0 -170
  116. data/doc/rdoc/classes/LibXML/XML/XPointer/Context.html +0 -123
  117. data/doc/rdoc/classes/LibXML/XML/XPointer/Context/InvalidPath.html +0 -117
  118. data/doc/rdoc/classes/LibXML/XML/XPointer/InvalidExpression.html +0 -124
  119. data/doc/rdoc/classes/singleton.html +0 -114
  120. data/doc/rdoc/created.rid +0 -1
  121. data/doc/rdoc/files/CHANGES.html +0 -442
  122. data/doc/rdoc/files/LICENSE.html +0 -133
  123. data/doc/rdoc/files/README.html +0 -388
  124. data/doc/rdoc/files/VERSION.html +0 -107
  125. data/doc/rdoc/files/ext/libxml/cbg_c.html +0 -101
  126. data/doc/rdoc/files/ext/libxml/libxml_c.html +0 -101
  127. data/doc/rdoc/files/ext/libxml/ruby_xml_attr_c.html +0 -101
  128. data/doc/rdoc/files/ext/libxml/ruby_xml_attributes_c.html +0 -101
  129. data/doc/rdoc/files/ext/libxml/ruby_xml_document_c.html +0 -101
  130. data/doc/rdoc/files/ext/libxml/ruby_xml_dtd_c.html +0 -101
  131. data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_c.html +0 -101
  132. data/doc/rdoc/files/ext/libxml/ruby_xml_input_cbg_c.html +0 -101
  133. data/doc/rdoc/files/ext/libxml/ruby_xml_node_c.html +0 -101
  134. data/doc/rdoc/files/ext/libxml/ruby_xml_node_set_c.html +0 -101
  135. data/doc/rdoc/files/ext/libxml/ruby_xml_ns_c.html +0 -101
  136. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_c.html +0 -101
  137. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_context_c.html +0 -101
  138. data/doc/rdoc/files/ext/libxml/ruby_xml_reader_c.html +0 -101
  139. data/doc/rdoc/files/ext/libxml/ruby_xml_relaxng_c.html +0 -101
  140. data/doc/rdoc/files/ext/libxml/ruby_xml_sax_parser_c.html +0 -101
  141. data/doc/rdoc/files/ext/libxml/ruby_xml_schema_c.html +0 -101
  142. data/doc/rdoc/files/ext/libxml/ruby_xml_state_c.html +0 -101
  143. data/doc/rdoc/files/ext/libxml/ruby_xml_xinclude_c.html +0 -101
  144. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_c.html +0 -101
  145. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_context_c.html +0 -101
  146. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_object_c.html +0 -101
  147. data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_c.html +0 -101
  148. data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_context_c.html +0 -101
  149. data/doc/rdoc/files/lib/libxml/attr_rb.html +0 -108
  150. data/doc/rdoc/files/lib/libxml/attributes_rb.html +0 -108
  151. data/doc/rdoc/files/lib/libxml/document_rb.html +0 -108
  152. data/doc/rdoc/files/lib/libxml/node_rb.html +0 -108
  153. data/doc/rdoc/files/lib/libxml/node_set_rb.html +0 -108
  154. data/doc/rdoc/files/lib/libxml/parser_options_rb.html +0 -107
  155. data/doc/rdoc/files/lib/libxml/parser_rb.html +0 -101
  156. data/doc/rdoc/files/lib/libxml/properties_rb.html +0 -108
  157. data/doc/rdoc/files/lib/libxml/tree_rb.html +0 -107
  158. data/doc/rdoc/files/lib/libxml_rb.html +0 -124
  159. data/doc/rdoc/files/lib/xml/libxml_rb.html +0 -124
  160. data/doc/rdoc/files/lib/xml_rb.html +0 -134
  161. data/doc/rdoc/fr_class_index.html +0 -62
  162. data/doc/rdoc/fr_file_index.html +0 -66
  163. data/doc/rdoc/fr_method_index.html +0 -392
  164. data/doc/rdoc/index.html +0 -24
  165. data/doc/rdoc/rdoc-style.css +0 -208
  166. data/ext/libxml/ruby_xml_node_set.c +0 -172
  167. data/ext/libxml/ruby_xml_node_set.h +0 -20
  168. data/ext/libxml/ruby_xml_xpointer_context.c +0 -22
  169. data/ext/libxml/ruby_xml_xpointer_context.h +0 -18
  170. data/lib/libxml/node_set.rb +0 -27
  171. data/lib/libxml2-2.dll +0 -0
  172. data/lib/libxml_ruby.dll.a +0 -0
  173. data/lib/libxml_ruby.so +0 -0
  174. data/test/tc_node_set.rb +0 -24
  175. data/test/tc_node_set2.rb +0 -37
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpath.h 418 2008-07-14 16:44:59Z cfis $ */
1
+ /* $Id: ruby_xml_xpath.h 528 2008-11-15 23:43:48Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -6,7 +6,6 @@
6
6
  #define __RUBY_XML_XPATH__
7
7
 
8
8
  extern VALUE mXPath;
9
- extern VALUE eXMLXPathInvalidPath;
10
9
 
11
10
  typedef struct ruby_xml_xpath {
12
11
  VALUE xd;
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpath_context.c 461 2008-07-15 21:35:56Z cfis $ */
1
+ /* $Id: ruby_xml_xpath_context.c 566 2008-11-18 06:53:36Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -50,7 +50,7 @@ ruby_xml_xpath_context_alloc(VALUE klass) {
50
50
  */
51
51
  VALUE
52
52
  ruby_xml_xpath_context_initialize(VALUE self, VALUE node) {
53
- ruby_xml_document_t *rxd;
53
+ xmlDocPtr xdoc;
54
54
  VALUE document;
55
55
  #ifndef LIBXML_XPATH_ENABLED
56
56
  rb_raise(rb_eTypeError, "libxml was not compiled with XPath support.");
@@ -60,7 +60,7 @@ ruby_xml_xpath_context_initialize(VALUE self, VALUE node) {
60
60
  {
61
61
  document = rb_funcall(node, rb_intern("doc"), 0);
62
62
  if NIL_P(document)
63
- rb_raise(rb_eTypeError, "Supplied node must belong to a document.");
63
+ rb_raise(rb_eTypeError, "Supplied node must belong to a document.");
64
64
  }
65
65
  else if (rb_obj_is_kind_of(node, cXMLDocument) == Qtrue)
66
66
  {
@@ -71,8 +71,8 @@ ruby_xml_xpath_context_initialize(VALUE self, VALUE node) {
71
71
  rb_raise(rb_eTypeError, "Supplied argument must be a document or node.");
72
72
  }
73
73
 
74
- Data_Get_Struct(document, ruby_xml_document_t, rxd);
75
- DATA_PTR(self) = xmlXPathNewContext(rxd->doc);
74
+ Data_Get_Struct(document, xmlDoc, xdoc);
75
+ DATA_PTR(self) = xmlXPathNewContext(xdoc);
76
76
 
77
77
  /* Save the doc as an attribute, this will expose it to Ruby's GC. */
78
78
  rb_iv_set(self, "@doc", document);
@@ -126,9 +126,9 @@ ruby_xml_xpath_context_register_namespaces_from_node(VALUE self, VALUE node) {
126
126
 
127
127
  if (rb_obj_is_kind_of(node, cXMLDocument) == Qtrue)
128
128
  {
129
- ruby_xml_document_t *rdoc;
130
- Data_Get_Struct(node, ruby_xml_document_t, rdoc);
131
- xnode = xmlDocGetRootElement(rdoc->doc);
129
+ xmlDocPtr xdoc;
130
+ Data_Get_Struct(node, xmlDoc, xdoc);
131
+ xnode = xmlDocGetRootElement(xdoc);
132
132
  }
133
133
  else if (rb_obj_is_kind_of(node, cXMLNode) == Qtrue)
134
134
  {
@@ -253,31 +253,29 @@ ruby_xml_xpath_context_find(VALUE self, VALUE xpath_expr) {
253
253
  xobject = xmlXPathEval((xmlChar*)StringValuePtr(xpath_expr), xctxt);
254
254
 
255
255
  if (xobject == NULL)
256
- rb_raise(eXMLXPathInvalidPath,
257
- "Invalid XPath expression (expr could not be evaluated)");
258
-
256
+ {
257
+ /* xmlLastError is differnet than xctxt->lastError. Use
258
+ xmlLastError since it has the message set while xctxt->lastError
259
+ does not. */
260
+ xmlErrorPtr xerror = xmlGetLastError();
261
+ ruby_xml_raise(xerror);
262
+ }
263
+
259
264
  result = ruby_xml_xpath_object_wrap(xobject);
260
265
  rb_iv_set(result, "@context", self);
261
266
  return result;
262
267
  }
263
268
 
264
269
 
265
- // Rdoc needs to know
266
- #ifdef RDOC_NEVER_DEFINED
267
- mLibXML = rb_define_module("LibXML");
268
- mXML = rb_define_module_under(mLibXML, "XML");
269
- mXPath = rb_define_module_under(mXML, "XPath");
270
- #endif
271
-
272
270
  void
273
271
  ruby_init_xml_xpath_context(void) {
274
272
  cXMLXPathContext = rb_define_class_under(mXPath, "Context", rb_cObject);
275
273
  rb_define_alloc_func(cXMLXPathContext, ruby_xml_xpath_context_alloc);
274
+ rb_define_attr(cXMLXPathContext, "doc", 1, 0);
276
275
  rb_define_method(cXMLXPathContext, "initialize", ruby_xml_xpath_context_initialize, 1);
277
276
  rb_define_method(cXMLXPathContext, "register_namespaces", ruby_xml_xpath_context_register_namespaces, 1);
278
277
  rb_define_method(cXMLXPathContext, "register_namespaces_from_node", ruby_xml_xpath_context_register_namespaces_from_node, 1);
279
278
  rb_define_method(cXMLXPathContext, "register_namespace", ruby_xml_xpath_context_register_namespace, 2);
280
279
  rb_define_method(cXMLXPathContext, "node=", ruby_xml_xpath_context_node_set, 1);
281
280
  rb_define_method(cXMLXPathContext, "find", ruby_xml_xpath_context_find, 1);
282
- rb_define_attr(cXMLXPathContext, "doc", 1, 0);
283
281
  }
@@ -12,36 +12,41 @@
12
12
  VALUE cXMLXPathObject;
13
13
 
14
14
 
15
- static VALUE
16
- ruby_xml_xpath_object_tabref(xmlXPathObjectPtr xpop, int apos) {
15
+ xmlDocPtr
16
+ ruby_xml_xpath_object_doc(xmlXPathObjectPtr xpop)
17
+ {
18
+ xmlDocPtr result = NULL;
19
+ xmlNodePtr *nodes = NULL;
17
20
 
18
- if (apos < 0 )
19
- apos=xpop->nodesetval->nodeNr+apos;
21
+ if (xpop->type != XPATH_NODESET)
22
+ return result;
20
23
 
21
- if (apos < 0 || apos+1 > xpop->nodesetval->nodeNr )
22
- return Qnil;
24
+ if (!xpop->nodesetval || !xpop->nodesetval->nodeTab)
25
+ return result;
23
26
 
24
- switch(xpop->nodesetval->nodeTab[apos]->type) {
25
- case XML_ATTRIBUTE_NODE:
26
- return ruby_xml_attr_wrap((xmlAttrPtr)xpop->nodesetval->nodeTab[apos]);
27
- break;
28
- default:
29
- return ruby_xml_node2_wrap(cXMLNode,
30
- xpop->nodesetval->nodeTab[apos]);
31
- }
27
+ nodes = xpop->nodesetval->nodeTab;
28
+
29
+ if (!(*nodes))
30
+ return result;
31
+
32
+ return (*nodes)->doc;
32
33
  }
33
34
 
34
35
  void
35
36
  ruby_xml_xpath_object_mark(xmlXPathObjectPtr xpop)
36
37
  {
37
- void * xnp;
38
38
  int i;
39
39
 
40
- if ( xpop->type == XPATH_NODESET && xpop->nodesetval != NULL ) {
41
- for (i=0; i<xpop->nodesetval->nodeNr; i++) {
42
- xnp=xpop->nodesetval->nodeTab[i]->_private;
43
- if (xnp != NULL)
44
- rb_gc_mark((VALUE)xnp);
40
+ if ( xpop->type == XPATH_NODESET && xpop->nodesetval != NULL )
41
+ {
42
+ xmlDocPtr xdoc = ruby_xml_xpath_object_doc(xpop);
43
+ if (xdoc && xdoc->_private)
44
+ rb_gc_mark((VALUE)xdoc->_private);
45
+
46
+ for (i=0; i<xpop->nodesetval->nodeNr; i++)
47
+ {
48
+ if (xpop->nodesetval->nodeTab[i]->_private)
49
+ rb_gc_mark((VALUE)xpop->nodesetval->nodeTab[i]->_private);
45
50
  }
46
51
  }
47
52
  }
@@ -49,12 +54,24 @@ ruby_xml_xpath_object_mark(xmlXPathObjectPtr xpop)
49
54
  void
50
55
  ruby_xml_xpath_object_free(xmlXPathObjectPtr xpop)
51
56
  {
57
+ /* Before freeing this xpath object, get the
58
+ document it is dependent on if its a nodeset. */
59
+ xmlDocPtr xdoc = ruby_xml_xpath_object_doc(xpop);
60
+
61
+ /* Now free the xpath result */
52
62
  xmlXPathFreeObject(xpop);
63
+
64
+ /* Now decrement the document object if this was a
65
+ XPATH_NODESET. Note this could free the document,
66
+ which is why we do it after freeing xpop.*/
67
+ if (xdoc)
68
+ ruby_xml_document_decr(xdoc);
53
69
  }
54
70
 
55
71
  VALUE
56
72
  ruby_xml_xpath_object_wrap(xmlXPathObjectPtr xpop)
57
73
  {
74
+ xmlDocPtr xdoc;
58
75
  VALUE rval;
59
76
 
60
77
  if ( xpop==NULL )
@@ -62,6 +79,10 @@ ruby_xml_xpath_object_wrap(xmlXPathObjectPtr xpop)
62
79
 
63
80
  switch(xpop->type) {
64
81
  case XPATH_NODESET:
82
+ xdoc = ruby_xml_xpath_object_doc(xpop);
83
+ if (xdoc)
84
+ ruby_xml_document_incr(xdoc);
85
+
65
86
  rval = Data_Wrap_Struct(cXMLXPathObject,
66
87
  ruby_xml_xpath_object_mark,
67
88
  ruby_xml_xpath_object_free,
@@ -93,6 +114,24 @@ ruby_xml_xpath_object_wrap(xmlXPathObjectPtr xpop)
93
114
  return rval;
94
115
  }
95
116
 
117
+ static VALUE
118
+ ruby_xml_xpath_object_tabref(xmlXPathObjectPtr xpop, int apos) {
119
+
120
+ if (apos < 0 )
121
+ apos=xpop->nodesetval->nodeNr+apos;
122
+
123
+ if (apos < 0 || apos+1 > xpop->nodesetval->nodeNr )
124
+ return Qnil;
125
+
126
+ switch(xpop->nodesetval->nodeTab[apos]->type) {
127
+ case XML_ATTRIBUTE_NODE:
128
+ return ruby_xml_attr_wrap((xmlAttrPtr)xpop->nodesetval->nodeTab[apos]);
129
+ break;
130
+ default:
131
+ return ruby_xml_node2_wrap(cXMLNode,
132
+ xpop->nodesetval->nodeTab[apos]);
133
+ }
134
+ }
96
135
 
97
136
  /*
98
137
  * call-seq:
@@ -120,29 +159,6 @@ ruby_xml_xpath_object_to_a(VALUE self)
120
159
  return(set_ary);
121
160
  }
122
161
 
123
- /*
124
- * call-seq:
125
- * xpath_object.set -> Node::Set
126
- *
127
- * Obtain the previous type object which is really
128
- * just a proxy back to this object. Unless the
129
- * type is not a NODESET, in which case it is nil.
130
- */
131
- VALUE
132
- ruby_xml_xpath_object_set(VALUE self)
133
- {
134
- xmlXPathObjectPtr xpop;
135
- VALUE r;
136
-
137
- Data_Get_Struct(self,xmlXPathObject,xpop);
138
- r=Qnil;
139
-
140
- if (xpop->type == XPATH_NODESET)
141
- r=ruby_xml_node_set_new2(self);
142
-
143
- return r;
144
- }
145
-
146
162
  /*
147
163
  * call-seq:
148
164
  * xpath_object.empty? -> (true|false)
@@ -300,19 +316,11 @@ ruby_xml_xpath_object_debug(VALUE self) {
300
316
  return Qnil;
301
317
  }
302
318
 
303
-
304
- // Rdoc needs to know
305
- #ifdef RDOC_NEVER_DEFINED
306
- mLibXML = rb_define_module("LibXML");
307
- mXML = rb_define_module_under(mLibXML, "XML");
308
- mXPath = rb_define_module_under(mXML, "XPath");
309
- #endif
310
-
311
319
  void
312
320
  ruby_init_xml_xpath_object(void) {
313
321
  cXMLXPathObject = rb_define_class_under(mXPath, "Object", rb_cObject);
314
322
  rb_include_module(cXMLXPathObject, rb_mEnumerable);
315
-
323
+ rb_define_attr(cXMLXPathObject, "context", 1, 0);
316
324
  rb_define_method(cXMLXPathObject, "each", ruby_xml_xpath_object_each, 0);
317
325
  rb_define_method(cXMLXPathObject, "xpath_type", ruby_xml_xpath_object_get_type, 0);
318
326
  rb_define_method(cXMLXPathObject, "empty?", ruby_xml_xpath_object_empty_q, 0);
@@ -322,9 +330,5 @@ ruby_init_xml_xpath_object(void) {
322
330
  rb_define_method(cXMLXPathObject, "to_a", ruby_xml_xpath_object_to_a, 0);
323
331
  rb_define_method(cXMLXPathObject, "[]", ruby_xml_xpath_object_aref, 1);
324
332
  rb_define_method(cXMLXPathObject, "string", ruby_xml_xpath_object_string, 0);
325
- rb_define_attr(cXMLXPathObject, "context", 1, 0);
326
333
  rb_define_method(cXMLXPathObject, "debug", ruby_xml_xpath_object_debug, 0);
327
-
328
- /* Give the NodeSet type, but it is pointless */
329
- rb_define_method(cXMLXPathObject, "set", ruby_xml_xpath_object_set, 0);
330
334
  }
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_xpointer.c 461 2008-07-15 21:35:56Z cfis $ */
1
+ /* $Id: ruby_xml_xpointer.c 566 2008-11-18 06:53:36Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -6,7 +6,15 @@
6
6
  #include "ruby_xml_xpointer.h"
7
7
 
8
8
  VALUE cXMLXPointer;
9
- VALUE eXMLXPointerInvalidExpression;
9
+
10
+ /*
11
+ * Document-class: LibXML::XML::XPointer
12
+ *
13
+ * The XML::Pointer class provides a standards based API for searching an xml document.
14
+ * XPointer is based on the XML Path Language (XML::XPath) and is documented
15
+ * at http://www.w3.org/TR/WD-xptr.
16
+ */
17
+
10
18
 
11
19
  VALUE
12
20
  ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
@@ -31,7 +39,7 @@ ruby_xml_xpointer_point(VALUE class, VALUE rnode, VALUE xptr_str) {
31
39
 
32
40
  xpop = xmlXPtrEval((xmlChar*)StringValuePtr(xptr_str), xctxt);
33
41
  if (!xpop)
34
- rb_raise(eXMLXPointerInvalidExpression, "Invalid xpointer expression");
42
+ ruby_xml_raise(&xmlLastError);
35
43
 
36
44
  result = ruby_xml_xpath_object_wrap(xpop);
37
45
  rb_iv_set(result, "@context", context);
@@ -98,7 +106,5 @@ ruby_xml_xpointer_range(VALUE class, VALUE rstart, VALUE rend) {
98
106
  void
99
107
  ruby_init_xml_xpointer(void) {
100
108
  cXMLXPointer = rb_define_class_under(mXML, "XPointer", rb_cObject);
101
- eXMLXPointerInvalidExpression = rb_define_class_under(cXMLXPointer, "InvalidExpression", eXMLError);
102
-
103
109
  rb_define_singleton_method(cXMLXPointer, "range", ruby_xml_xpointer_range, 2);
104
110
  }
@@ -1,4 +1,4 @@
1
- /* $Id: sax_parser_callbacks.inc 120 2006-11-26 12:57:56Z roscopeco $ */
1
+ /* $Id: sax_parser_callbacks.inc 544 2008-11-16 09:50:27Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -11,49 +11,51 @@ static void internal_subset_func(ruby_xml_sax_parser *cbp,
11
11
  const char *sysid) {
12
12
  VALUE handler = cbp->callbackHandler;
13
13
 
14
- if (handler && handler != Qnil) {
15
- rb_funcall(handler, cbidOnInternalSubset, 3, rb_str_new2(name),
16
- rb_str_new2(extid), rb_str_new2(sysid));
14
+ if (handler != Qnil) {
15
+ VALUE rname = name ? rb_str_new2(name) : Qnil;
16
+ VALUE rextid = extid ? rb_str_new2(extid) : Qnil;
17
+ VALUE rsysid = sysid ? rb_str_new2(sysid) : Qnil;
18
+ rb_funcall(handler, cbidOnInternalSubset, 3, rname, rextid, rsysid);
17
19
  }
18
20
  }
19
21
 
20
22
  static void is_standalone_func(ruby_xml_sax_parser *cbp) {
21
23
  VALUE handler = cbp->callbackHandler;
22
24
 
23
- if (handler && handler != Qnil) {
24
- rb_funcall(handler,cbidOnIsStandalone,0);
25
+ if (handler != Qnil) {
26
+ rb_funcall(handler, cbidOnIsStandalone,0);
25
27
  }
26
28
  }
27
29
 
28
30
  static void has_internal_subset_func(ruby_xml_sax_parser *cbp) {
29
31
  VALUE handler = cbp->callbackHandler;
30
32
 
31
- if (handler && handler != Qnil) {
32
- rb_funcall(handler,cbidOnHasInternalSubset,0);
33
+ if (handler != Qnil) {
34
+ rb_funcall(handler, cbidOnHasInternalSubset, 0);
33
35
  }
34
36
  }
35
37
 
36
38
  static void has_external_subset_func(ruby_xml_sax_parser *cbp) {
37
39
  VALUE handler = cbp->callbackHandler;
38
40
 
39
- if (handler && handler != Qnil) {
40
- rb_funcall(handler,cbidOnHasExternalSubset,0);
41
+ if (handler != Qnil) {
42
+ rb_funcall(handler, cbidOnHasExternalSubset, 0);
41
43
  }
42
44
  }
43
45
 
44
46
  static void start_document_func(ruby_xml_sax_parser *cbp) {
45
47
  VALUE handler = cbp->callbackHandler;
46
48
 
47
- if (handler && handler != Qnil) {
48
- rb_funcall(handler,cbidOnStartDocument,0);
49
+ if (handler != Qnil) {
50
+ rb_funcall(handler, cbidOnStartDocument, 0);
49
51
  }
50
52
  }
51
53
 
52
54
  static void end_document_func(ruby_xml_sax_parser *cbp) {
53
55
  VALUE handler = cbp->callbackHandler;
54
56
 
55
- if (handler && handler != Qnil) {
56
- rb_funcall(handler,cbidOnEndDocument,0);
57
+ if (handler != Qnil) {
58
+ rb_funcall(handler, cbidOnEndDocument, 0);
57
59
  }
58
60
  }
59
61
 
@@ -70,17 +72,16 @@ static void start_element_func(ruby_xml_sax_parser *cbp,
70
72
  }
71
73
  }
72
74
 
73
- if (handler && handler != Qnil) {
74
- rb_funcall(handler,cbidOnStartElement,2,rb_str_new2(name),ahsh);
75
+ if (handler != Qnil) {
76
+ rb_funcall(handler, cbidOnStartElement, 2, rb_str_new2(name), ahsh);
75
77
  }
76
78
  }
77
79
 
78
- static void end_element_func(ruby_xml_sax_parser *cbp,
79
- const char *name) {
80
+ static void end_element_func(ruby_xml_sax_parser *cbp, const char *name) {
80
81
  VALUE handler = cbp->callbackHandler;
81
82
 
82
- if (handler && handler != Qnil) {
83
- rb_funcall(handler,cbidOnEndElement,1,rb_str_new2(name));
83
+ if (handler != Qnil) {
84
+ rb_funcall(handler, cbidOnEndElement, 1, rb_str_new2(name));
84
85
  }
85
86
  }
86
87
 
@@ -88,8 +89,8 @@ static void reference_func(ruby_xml_sax_parser *cbp,
88
89
  const char *name) {
89
90
  VALUE handler = cbp->callbackHandler;
90
91
 
91
- if (handler && handler != Qnil) {
92
- rb_funcall(handler,cbidOnReference,1,rb_str_new2(name));
92
+ if (handler != Qnil) {
93
+ rb_funcall(handler, cbidOnReference,1,rb_str_new2(name));
93
94
  }
94
95
  }
95
96
 
@@ -97,8 +98,9 @@ static void characters_func(ruby_xml_sax_parser *cbp,
97
98
  const char *chars, int len) {
98
99
  VALUE handler = cbp->callbackHandler;
99
100
 
100
- if (handler && handler != Qnil) {
101
- rb_funcall(handler,cbidOnCharacters,1,rb_str_new(chars, len));
101
+ if (handler != Qnil) {
102
+ VALUE rchars = rb_str_new(chars, len);
103
+ rb_funcall(handler, cbidOnCharacters, 1, rchars);
102
104
  }
103
105
  }
104
106
 
@@ -106,9 +108,10 @@ static void processing_instruction_func(ruby_xml_sax_parser *cbp,
106
108
  const char *target, const char *data) {
107
109
  VALUE handler = cbp->callbackHandler;
108
110
 
109
- if (handler && handler != Qnil) {
110
- rb_funcall(handler, cbidOnProcessingInstruction, 2,
111
- rb_str_new2(target),rb_str_new2(data));
111
+ if (handler != Qnil) {
112
+ VALUE rtarget = target ? rb_str_new2(target) : Qnil;
113
+ VALUE rdata = data ? rb_str_new2(data) : Qnil;
114
+ rb_funcall(handler, cbidOnProcessingInstruction, 2, rtarget, rdata);
112
115
  }
113
116
  }
114
117
 
@@ -116,8 +119,8 @@ static void comment_func(ruby_xml_sax_parser *cbp,
116
119
  const char *msg) {
117
120
  VALUE handler = cbp->callbackHandler;
118
121
 
119
- if (handler && handler != Qnil) {
120
- rb_funcall(handler,cbidOnComment,1,rb_str_new2(msg));
122
+ if (handler != Qnil) {
123
+ rb_funcall(handler, cbidOnComment,1,rb_str_new2(msg));
121
124
  }
122
125
  }
123
126
 
@@ -137,7 +140,7 @@ static void warning_func(ruby_xml_sax_parser *cbp,
137
140
  const char *msg, ...) {
138
141
  VALUE handler = cbp->callbackHandler;
139
142
 
140
- if (handler && handler != Qnil) {
143
+ if (handler != Qnil) {
141
144
  FORMAT_AND_CALL(cbidOnXmlParserWarning);
142
145
  }
143
146
  }
@@ -146,7 +149,7 @@ static void error_func(ruby_xml_sax_parser *cbp,
146
149
  const char *msg, ...) {
147
150
  VALUE handler = cbp->callbackHandler;
148
151
 
149
- if (handler && handler != Qnil) {
152
+ if (handler != Qnil) {
150
153
  FORMAT_AND_CALL(cbidOnXmlParserError);
151
154
  }
152
155
  }
@@ -155,7 +158,7 @@ static void fatal_error_func(ruby_xml_sax_parser *cbp,
155
158
  const char *msg, ...) {
156
159
  VALUE handler = cbp->callbackHandler;
157
160
 
158
- if (handler && handler != Qnil) {
161
+ if (handler != Qnil) {
159
162
  FORMAT_AND_CALL(cbidOnXmlParserFatalError);
160
163
  }
161
164
  }
@@ -164,8 +167,8 @@ static void cdata_block_func(ruby_xml_sax_parser *cbp,
164
167
  const char *value, int len) {
165
168
  VALUE handler = cbp->callbackHandler;
166
169
 
167
- if (handler && handler != Qnil) {
168
- rb_funcall(handler,cbidOnCdataBlock,1,rb_str_new(value, len));
170
+ if (handler != Qnil) {
171
+ rb_funcall(handler, cbidOnCdataBlock,1,rb_str_new(value, len));
169
172
  }
170
173
  }
171
174
 
@@ -175,9 +178,11 @@ static void external_subset_func(ruby_xml_sax_parser *cbp,
175
178
  const char *sysid) {
176
179
  VALUE handler = cbp->callbackHandler;
177
180
 
178
- if (handler && handler != Qnil) {
179
- rb_funcall(handler, cbidOnExternalSubset, 3, rb_str_new2(name),
180
- rb_str_new2(extid), rb_str_new2(sysid));
181
+ if (handler != Qnil) {
182
+ VALUE rname = name ? rb_str_new2(name) : Qnil;
183
+ VALUE rextid = extid ? rb_str_new2(extid) : Qnil;
184
+ VALUE rsysid = sysid ? rb_str_new2(sysid) : Qnil;
185
+ rb_funcall(handler, cbidOnExternalSubset, 3, rname, rextid, rsysid);
181
186
  }
182
187
  }
183
188