coupa-libxml-ruby 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (280) hide show
  1. data/CHANGES +488 -0
  2. data/LICENSE +22 -0
  3. data/README +161 -0
  4. data/Rakefile +188 -0
  5. data/doc/css/normal.css +182 -0
  6. data/doc/img/raze-tiny.png +0 -0
  7. data/doc/img/red-cube.jpg +0 -0
  8. data/doc/img/xml-ruby.png +0 -0
  9. data/doc/index.xml +43 -0
  10. data/doc/install.xml +77 -0
  11. data/doc/layout.rhtml +38 -0
  12. data/doc/layout.xsl +67 -0
  13. data/doc/license.xml +32 -0
  14. data/doc/log/changelog.xml +1324 -0
  15. data/doc/log/changelog.xsl +42 -0
  16. data/doc/rdoc/classes/LibXML.html +207 -0
  17. data/doc/rdoc/classes/LibXML/XML.html +407 -0
  18. data/doc/rdoc/classes/LibXML/XML/Attr.html +521 -0
  19. data/doc/rdoc/classes/LibXML/XML/AttrDecl.html +360 -0
  20. data/doc/rdoc/classes/LibXML/XML/Attributes.html +149 -0
  21. data/doc/rdoc/classes/LibXML/XML/Document.html +460 -0
  22. data/doc/rdoc/classes/LibXML/XML/Error.html +129 -0
  23. data/doc/rdoc/classes/LibXML/XML/HTMLParser.html +263 -0
  24. data/doc/rdoc/classes/LibXML/XML/Namespace.html +248 -0
  25. data/doc/rdoc/classes/LibXML/XML/Namespaces.html +200 -0
  26. data/doc/rdoc/classes/LibXML/XML/Node.html +1351 -0
  27. data/doc/rdoc/classes/LibXML/XML/Parser.html +328 -0
  28. data/doc/rdoc/classes/LibXML/XML/Reader.html +172 -0
  29. data/doc/rdoc/classes/LibXML/XML/SaxParser.html +232 -0
  30. data/doc/rdoc/classes/LibXML/XML/SaxParser/Callbacks.html +506 -0
  31. data/doc/rdoc/classes/LibXML/XML/SaxParser/VerboseCallbacks.html +555 -0
  32. data/doc/rdoc/classes/LibXML/XML/XPath.html +111 -0
  33. data/doc/rdoc/classes/LibXML/XML/XPath/Object.html +162 -0
  34. data/doc/rdoc/classes/cXMLDtd.html +114 -0
  35. data/doc/rdoc/classes/cXMLNode.html +114 -0
  36. data/doc/rdoc/created.rid +1 -0
  37. data/doc/rdoc/files/CHANGES.html +794 -0
  38. data/doc/rdoc/files/LICENSE.html +131 -0
  39. data/doc/rdoc/files/README.html +343 -0
  40. data/doc/rdoc/files/ext/libxml/libxml_c.html +101 -0
  41. data/doc/rdoc/files/ext/libxml/ruby_xml_attr_c.html +101 -0
  42. data/doc/rdoc/files/ext/libxml/ruby_xml_attr_decl_c.html +101 -0
  43. data/doc/rdoc/files/ext/libxml/ruby_xml_attributes_c.html +101 -0
  44. data/doc/rdoc/files/ext/libxml/ruby_xml_c.html +101 -0
  45. data/doc/rdoc/files/ext/libxml/ruby_xml_cbg_c.html +101 -0
  46. data/doc/rdoc/files/ext/libxml/ruby_xml_document_c.html +101 -0
  47. data/doc/rdoc/files/ext/libxml/ruby_xml_dtd_c.html +101 -0
  48. data/doc/rdoc/files/ext/libxml/ruby_xml_encoding_c.html +101 -0
  49. data/doc/rdoc/files/ext/libxml/ruby_xml_error_c.html +101 -0
  50. data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_c.html +101 -0
  51. data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_context_c.html +101 -0
  52. data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_options_c.html +101 -0
  53. data/doc/rdoc/files/ext/libxml/ruby_xml_input_cbg_c.html +101 -0
  54. data/doc/rdoc/files/ext/libxml/ruby_xml_io_c.html +101 -0
  55. data/doc/rdoc/files/ext/libxml/ruby_xml_namespace_c.html +101 -0
  56. data/doc/rdoc/files/ext/libxml/ruby_xml_namespaces_c.html +101 -0
  57. data/doc/rdoc/files/ext/libxml/ruby_xml_node_c.html +101 -0
  58. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_c.html +101 -0
  59. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_context_c.html +101 -0
  60. data/doc/rdoc/files/ext/libxml/ruby_xml_parser_options_c.html +101 -0
  61. data/doc/rdoc/files/ext/libxml/ruby_xml_reader_c.html +101 -0
  62. data/doc/rdoc/files/ext/libxml/ruby_xml_relaxng_c.html +101 -0
  63. data/doc/rdoc/files/ext/libxml/ruby_xml_sax2_handler_c.html +101 -0
  64. data/doc/rdoc/files/ext/libxml/ruby_xml_sax_parser_c.html +101 -0
  65. data/doc/rdoc/files/ext/libxml/ruby_xml_schema_c.html +101 -0
  66. data/doc/rdoc/files/ext/libxml/ruby_xml_xinclude_c.html +101 -0
  67. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_c.html +101 -0
  68. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_context_c.html +101 -0
  69. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_expression_c.html +101 -0
  70. data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_object_c.html +101 -0
  71. data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_c.html +101 -0
  72. data/doc/rdoc/files/lib/libxml/attr_decl_rb.html +101 -0
  73. data/doc/rdoc/files/lib/libxml/attr_rb.html +101 -0
  74. data/doc/rdoc/files/lib/libxml/attributes_rb.html +101 -0
  75. data/doc/rdoc/files/lib/libxml/document_rb.html +101 -0
  76. data/doc/rdoc/files/lib/libxml/error_rb.html +101 -0
  77. data/doc/rdoc/files/lib/libxml/hpricot_rb.html +192 -0
  78. data/doc/rdoc/files/lib/libxml/html_parser_rb.html +101 -0
  79. data/doc/rdoc/files/lib/libxml/namespace_rb.html +101 -0
  80. data/doc/rdoc/files/lib/libxml/namespaces_rb.html +101 -0
  81. data/doc/rdoc/files/lib/libxml/node_rb.html +108 -0
  82. data/doc/rdoc/files/lib/libxml/ns_rb.html +101 -0
  83. data/doc/rdoc/files/lib/libxml/parser_rb.html +101 -0
  84. data/doc/rdoc/files/lib/libxml/properties_rb.html +101 -0
  85. data/doc/rdoc/files/lib/libxml/reader_rb.html +101 -0
  86. data/doc/rdoc/files/lib/libxml/sax_callbacks_rb.html +101 -0
  87. data/doc/rdoc/files/lib/libxml/sax_parser_rb.html +101 -0
  88. data/doc/rdoc/files/lib/libxml/tree_rb.html +101 -0
  89. data/doc/rdoc/files/lib/libxml/xpath_object_rb.html +101 -0
  90. data/doc/rdoc/files/lib/libxml_rb.html +133 -0
  91. data/doc/rdoc/files/lib/xml/libxml_rb.html +124 -0
  92. data/doc/rdoc/files/lib/xml_rb.html +134 -0
  93. data/doc/rdoc/fr_class_index.html +46 -0
  94. data/doc/rdoc/fr_file_index.html +84 -0
  95. data/doc/rdoc/fr_method_index.html +155 -0
  96. data/doc/rdoc/index.html +24 -0
  97. data/doc/rdoc/rdoc-style.css +208 -0
  98. data/ext/libxml/Makefile +157 -0
  99. data/ext/libxml/build.log +4 -0
  100. data/ext/libxml/extconf.h +5 -0
  101. data/ext/libxml/extconf.rb +278 -0
  102. data/ext/libxml/libxml.c +77 -0
  103. data/ext/libxml/libxml.o +0 -0
  104. data/ext/libxml/libxml_ruby.bundle +0 -0
  105. data/ext/libxml/mkmf.log +228 -0
  106. data/ext/libxml/ruby_libxml.h +93 -0
  107. data/ext/libxml/ruby_xml.c +893 -0
  108. data/ext/libxml/ruby_xml.h +10 -0
  109. data/ext/libxml/ruby_xml.o +0 -0
  110. data/ext/libxml/ruby_xml_attr.c +352 -0
  111. data/ext/libxml/ruby_xml_attr.h +14 -0
  112. data/ext/libxml/ruby_xml_attr.o +0 -0
  113. data/ext/libxml/ruby_xml_attr_decl.c +171 -0
  114. data/ext/libxml/ruby_xml_attr_decl.h +13 -0
  115. data/ext/libxml/ruby_xml_attr_decl.o +0 -0
  116. data/ext/libxml/ruby_xml_attributes.c +277 -0
  117. data/ext/libxml/ruby_xml_attributes.h +17 -0
  118. data/ext/libxml/ruby_xml_attributes.o +0 -0
  119. data/ext/libxml/ruby_xml_cbg.c +86 -0
  120. data/ext/libxml/ruby_xml_cbg.o +0 -0
  121. data/ext/libxml/ruby_xml_document.c +1006 -0
  122. data/ext/libxml/ruby_xml_document.c.old +936 -0
  123. data/ext/libxml/ruby_xml_document.h +17 -0
  124. data/ext/libxml/ruby_xml_document.o +0 -0
  125. data/ext/libxml/ruby_xml_dtd.c +257 -0
  126. data/ext/libxml/ruby_xml_dtd.h +9 -0
  127. data/ext/libxml/ruby_xml_dtd.o +0 -0
  128. data/ext/libxml/ruby_xml_encoding.c +134 -0
  129. data/ext/libxml/ruby_xml_encoding.h +12 -0
  130. data/ext/libxml/ruby_xml_encoding.o +0 -0
  131. data/ext/libxml/ruby_xml_error.c +1004 -0
  132. data/ext/libxml/ruby_xml_error.h +14 -0
  133. data/ext/libxml/ruby_xml_error.o +0 -0
  134. data/ext/libxml/ruby_xml_html_parser.c +92 -0
  135. data/ext/libxml/ruby_xml_html_parser.h +12 -0
  136. data/ext/libxml/ruby_xml_html_parser.o +0 -0
  137. data/ext/libxml/ruby_xml_html_parser_context.c +308 -0
  138. data/ext/libxml/ruby_xml_html_parser_context.h +12 -0
  139. data/ext/libxml/ruby_xml_html_parser_context.o +0 -0
  140. data/ext/libxml/ruby_xml_html_parser_options.c +40 -0
  141. data/ext/libxml/ruby_xml_html_parser_options.h +12 -0
  142. data/ext/libxml/ruby_xml_html_parser_options.o +0 -0
  143. data/ext/libxml/ruby_xml_input_cbg.c +191 -0
  144. data/ext/libxml/ruby_xml_input_cbg.h +20 -0
  145. data/ext/libxml/ruby_xml_input_cbg.o +0 -0
  146. data/ext/libxml/ruby_xml_io.c +30 -0
  147. data/ext/libxml/ruby_xml_io.h +9 -0
  148. data/ext/libxml/ruby_xml_io.o +0 -0
  149. data/ext/libxml/ruby_xml_namespace.c +170 -0
  150. data/ext/libxml/ruby_xml_namespace.h +12 -0
  151. data/ext/libxml/ruby_xml_namespace.o +0 -0
  152. data/ext/libxml/ruby_xml_namespaces.c +295 -0
  153. data/ext/libxml/ruby_xml_namespaces.h +11 -0
  154. data/ext/libxml/ruby_xml_namespaces.o +0 -0
  155. data/ext/libxml/ruby_xml_node.c +1386 -0
  156. data/ext/libxml/ruby_xml_node.h +13 -0
  157. data/ext/libxml/ruby_xml_node.o +0 -0
  158. data/ext/libxml/ruby_xml_parser.c +94 -0
  159. data/ext/libxml/ruby_xml_parser.h +14 -0
  160. data/ext/libxml/ruby_xml_parser.o +0 -0
  161. data/ext/libxml/ruby_xml_parser_context.c +982 -0
  162. data/ext/libxml/ruby_xml_parser_context.h +12 -0
  163. data/ext/libxml/ruby_xml_parser_context.o +0 -0
  164. data/ext/libxml/ruby_xml_parser_options.c +68 -0
  165. data/ext/libxml/ruby_xml_parser_options.h +14 -0
  166. data/ext/libxml/ruby_xml_parser_options.o +0 -0
  167. data/ext/libxml/ruby_xml_reader.c +1002 -0
  168. data/ext/libxml/ruby_xml_reader.h +14 -0
  169. data/ext/libxml/ruby_xml_reader.o +0 -0
  170. data/ext/libxml/ruby_xml_relaxng.c +111 -0
  171. data/ext/libxml/ruby_xml_relaxng.h +10 -0
  172. data/ext/libxml/ruby_xml_relaxng.o +0 -0
  173. data/ext/libxml/ruby_xml_sax2_handler.c +322 -0
  174. data/ext/libxml/ruby_xml_sax2_handler.h +12 -0
  175. data/ext/libxml/ruby_xml_sax2_handler.o +0 -0
  176. data/ext/libxml/ruby_xml_sax_parser.c +137 -0
  177. data/ext/libxml/ruby_xml_sax_parser.h +12 -0
  178. data/ext/libxml/ruby_xml_sax_parser.o +0 -0
  179. data/ext/libxml/ruby_xml_schema.c +159 -0
  180. data/ext/libxml/ruby_xml_schema.h +11 -0
  181. data/ext/libxml/ruby_xml_schema.o +0 -0
  182. data/ext/libxml/ruby_xml_version.h +9 -0
  183. data/ext/libxml/ruby_xml_xinclude.c +18 -0
  184. data/ext/libxml/ruby_xml_xinclude.h +13 -0
  185. data/ext/libxml/ruby_xml_xinclude.o +0 -0
  186. data/ext/libxml/ruby_xml_xpath.c +107 -0
  187. data/ext/libxml/ruby_xml_xpath.h +12 -0
  188. data/ext/libxml/ruby_xml_xpath.o +0 -0
  189. data/ext/libxml/ruby_xml_xpath_context.c +387 -0
  190. data/ext/libxml/ruby_xml_xpath_context.h +11 -0
  191. data/ext/libxml/ruby_xml_xpath_context.o +0 -0
  192. data/ext/libxml/ruby_xml_xpath_expression.c +83 -0
  193. data/ext/libxml/ruby_xml_xpath_expression.h +12 -0
  194. data/ext/libxml/ruby_xml_xpath_expression.o +0 -0
  195. data/ext/libxml/ruby_xml_xpath_object.c +336 -0
  196. data/ext/libxml/ruby_xml_xpath_object.h +19 -0
  197. data/ext/libxml/ruby_xml_xpath_object.o +0 -0
  198. data/ext/libxml/ruby_xml_xpointer.c +101 -0
  199. data/ext/libxml/ruby_xml_xpointer.h +13 -0
  200. data/ext/libxml/ruby_xml_xpointer.o +0 -0
  201. data/ext/mingw/Rakefile +34 -0
  202. data/ext/mingw/build.rake +41 -0
  203. data/ext/vc/libxml_ruby.sln +26 -0
  204. data/lib/libxml.rb +30 -0
  205. data/lib/libxml/attr.rb +111 -0
  206. data/lib/libxml/attr_decl.rb +78 -0
  207. data/lib/libxml/attributes.rb +12 -0
  208. data/lib/libxml/document.rb +190 -0
  209. data/lib/libxml/error.rb +88 -0
  210. data/lib/libxml/hpricot.rb +76 -0
  211. data/lib/libxml/html_parser.rb +94 -0
  212. data/lib/libxml/namespace.rb +60 -0
  213. data/lib/libxml/namespaces.rb +36 -0
  214. data/lib/libxml/node.rb +385 -0
  215. data/lib/libxml/ns.rb +20 -0
  216. data/lib/libxml/parser.rb +365 -0
  217. data/lib/libxml/properties.rb +21 -0
  218. data/lib/libxml/reader.rb +27 -0
  219. data/lib/libxml/sax_callbacks.rb +178 -0
  220. data/lib/libxml/sax_parser.rb +56 -0
  221. data/lib/libxml/tree.rb +27 -0
  222. data/lib/libxml/xpath_object.rb +14 -0
  223. data/lib/xml.rb +14 -0
  224. data/lib/xml/libxml.rb +8 -0
  225. data/setup.rb +1585 -0
  226. data/test/etc_doc_to_s.rb +19 -0
  227. data/test/ets_doc_file.rb +15 -0
  228. data/test/ets_doc_to_s.rb +21 -0
  229. data/test/ets_gpx.rb +26 -0
  230. data/test/ets_node_gc.rb +21 -0
  231. data/test/ets_test.xml +2 -0
  232. data/test/ets_tsr.rb +9 -0
  233. data/test/model/atom.xml +13 -0
  234. data/test/model/bands.xml +5 -0
  235. data/test/model/books.xml +146 -0
  236. data/test/model/merge_bug_data.xml +58 -0
  237. data/test/model/ruby-lang.html +238 -0
  238. data/test/model/rubynet.xml +79 -0
  239. data/test/model/rubynet_project +1 -0
  240. data/test/model/shiporder.rnc +28 -0
  241. data/test/model/shiporder.rng +86 -0
  242. data/test/model/shiporder.xml +23 -0
  243. data/test/model/shiporder.xsd +31 -0
  244. data/test/model/soap.xml +27 -0
  245. data/test/model/xinclude.xml +5 -0
  246. data/test/tc_attr.rb +170 -0
  247. data/test/tc_attr_decl.rb +131 -0
  248. data/test/tc_attributes.rb +133 -0
  249. data/test/tc_deprecated_require.rb +11 -0
  250. data/test/tc_document.rb +113 -0
  251. data/test/tc_document_write.rb +118 -0
  252. data/test/tc_dtd.rb +123 -0
  253. data/test/tc_error.rb +136 -0
  254. data/test/tc_html_parser.rb +138 -0
  255. data/test/tc_namespace.rb +59 -0
  256. data/test/tc_namespaces.rb +174 -0
  257. data/test/tc_node.rb +181 -0
  258. data/test/tc_node_cdata.rb +49 -0
  259. data/test/tc_node_comment.rb +30 -0
  260. data/test/tc_node_copy.rb +40 -0
  261. data/test/tc_node_edit.rb +158 -0
  262. data/test/tc_node_text.rb +69 -0
  263. data/test/tc_node_write.rb +83 -0
  264. data/test/tc_node_xlink.rb +26 -0
  265. data/test/tc_parser.rb +330 -0
  266. data/test/tc_parser_context.rb +186 -0
  267. data/test/tc_properties.rb +36 -0
  268. data/test/tc_reader.rb +284 -0
  269. data/test/tc_relaxng.rb +51 -0
  270. data/test/tc_sax_parser.rb +274 -0
  271. data/test/tc_schema.rb +51 -0
  272. data/test/tc_traversal.rb +220 -0
  273. data/test/tc_xinclude.rb +19 -0
  274. data/test/tc_xml.rb +224 -0
  275. data/test/tc_xpath.rb +193 -0
  276. data/test/tc_xpath_context.rb +78 -0
  277. data/test/tc_xpath_expression.rb +35 -0
  278. data/test/tc_xpointer.rb +72 -0
  279. data/test/test_suite.rb +33 -0
  280. metadata +376 -0
@@ -0,0 +1,12 @@
1
+ /* $Id: ruby_xml_sax_parser.h 666 2008-12-07 00:16:50Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RXML_SAX2_HANDLER__
6
+ #define __RXML_SAX2_HANDLER__
7
+
8
+ extern xmlSAXHandler rxml_sax_handler;
9
+
10
+ void rxml_init_sax2_handler(void);
11
+
12
+ #endif
@@ -0,0 +1,137 @@
1
+ /* $Id: ruby_xml_sax_parser.c 758 2009-01-25 20:36:03Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "ruby_libxml.h"
6
+ #include "ruby_xml_sax_parser.h"
7
+
8
+ /*
9
+ * Document-class: LibXML::XML::SaxParser
10
+ *
11
+ * XML::SaxParser provides a callback based API for parsing documents,
12
+ * in contrast to XML::Parser's tree based API and XML::Reader's stream
13
+ * based API.
14
+ *
15
+ * The XML::SaxParser API is fairly complex, not well standardized,
16
+ * and does not directly support validation making entity, namespace and
17
+ * base processing relatively hard.
18
+ *
19
+ * To use the XML::SaxParser, register a callback class via the
20
+ * XML::SaxParser#callbacks=. It is easiest to include the
21
+ * XML::SaxParser::Callbacks module in your class and override
22
+ * the methods as needed.
23
+ *
24
+ * Basic example:
25
+ *
26
+ * class MyCallbacks
27
+ * include XML::SaxParser::Callbacks
28
+ * def on_start_element(element, attributes)
29
+ * puts #Element started: #{element}"
30
+ * end
31
+ * end
32
+ *
33
+ * parser = XML::SaxParser.string(my_string)
34
+ * parser.callbacks = MyCallbacks.new
35
+ * parser.parse
36
+ *
37
+ * You can also parse strings (see XML::SaxParser.string) and
38
+ * io objects (see XML::SaxParser.io).
39
+ */
40
+
41
+ VALUE cXMLSaxParser;
42
+ static ID CALLBACKS_ATTR;
43
+ static ID CONTEXT_ATTR;
44
+
45
+
46
+ /* ====== Parser =========== */
47
+
48
+ /*static int rxml_sax_parser_parse_io(VALUE self, VALUE input)
49
+ {
50
+ VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
51
+ VALUE io = rb_ivar_get(input, IO_ATTR);
52
+ VALUE encoding = rb_ivar_get(input, ENCODING_ATTR);
53
+ xmlCharEncoding xmlEncoding = NUM2INT(encoding);
54
+ xmlParserCtxtPtr ctxt =
55
+ xmlCreateIOParserCtxt((xmlSAXHandlerPtr) &rxml_sax_handler,
56
+ (void *) handler, (xmlInputReadCallback) rxml_read_callback, NULL,
57
+ (void *) io, xmlEncoding);
58
+ return xmlParseDocument(ctxt);
59
+ }*/
60
+
61
+
62
+ /*
63
+ * call-seq:
64
+ * parser.initialize(context) -> XML::Parser
65
+ *
66
+ * Creates a new XML::Parser from the specified
67
+ * XML::Parser::Context.
68
+ */
69
+ static VALUE rxml_sax_parser_initialize(int argc, VALUE *argv, VALUE self)
70
+ {
71
+ VALUE context = Qnil;
72
+
73
+ rb_scan_args(argc, argv, "01", &context);
74
+
75
+ if (context == Qnil)
76
+ {
77
+ rb_warn("Passing no parameters to XML::SaxParser.new is deprecated. Pass an instance of XML::Parser::Context instead.");
78
+ context = rb_class_new_instance(0, NULL, cXMLParserContext);
79
+ }
80
+
81
+ rb_ivar_set(self, CONTEXT_ATTR, context);
82
+ return self;
83
+ }
84
+
85
+ /*
86
+ * call-seq:
87
+ * parser.parse -> (true|false)
88
+ *
89
+ * Parse the input XML, generating callbacks to the object
90
+ * registered via the +callbacks+ attributesibute.
91
+ */
92
+ static VALUE rxml_sax_parser_parse(VALUE self)
93
+ {
94
+ int status;
95
+ VALUE context = rb_ivar_get(self, CONTEXT_ATTR);
96
+ xmlParserCtxtPtr ctxt;
97
+ Data_Get_Struct(context, xmlParserCtxt, ctxt);
98
+
99
+ ctxt->sax2 = 1;
100
+ ctxt->userData = (void*)rb_ivar_get(self, CALLBACKS_ATTR);
101
+
102
+ if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
103
+ xmlFree(ctxt->sax);
104
+
105
+ ctxt->sax = (xmlSAXHandlerPtr)&rxml_sax_handler;
106
+
107
+ status = xmlParseDocument(ctxt);
108
+
109
+ /* IMPORTANT - null the handle to our sax handler
110
+ so libxml doesn't try to free it.*/
111
+ ctxt->sax = NULL;
112
+
113
+ /* Now check the parsing result*/
114
+ if (status == -1 || !ctxt->wellFormed)
115
+ {
116
+ if (ctxt->myDoc)
117
+ xmlFreeDoc(ctxt->myDoc);
118
+
119
+ rxml_raise(&ctxt->lastError);
120
+ }
121
+ return Qtrue;
122
+ }
123
+
124
+ void rxml_init_sax_parser(void)
125
+ {
126
+ /* SaxParser */
127
+ cXMLSaxParser = rb_define_class_under(mXML, "SaxParser", rb_cObject);
128
+
129
+ /* Atributes */
130
+ CALLBACKS_ATTR = rb_intern("@callbacks");
131
+ CONTEXT_ATTR = rb_intern("@context");
132
+ rb_define_attr(cXMLSaxParser, "callbacks", 1, 1);
133
+
134
+ /* Instance Methods */
135
+ rb_define_method(cXMLSaxParser, "initialize", rxml_sax_parser_initialize, -1);
136
+ rb_define_method(cXMLSaxParser, "parse", rxml_sax_parser_parse, 0);
137
+ }
@@ -0,0 +1,12 @@
1
+ /* $Id: ruby_xml_sax_parser.h 758 2009-01-25 20:36:03Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RXML_SAX_PARSER__
6
+ #define __RXML_SAX_PARSER__
7
+
8
+ extern VALUE cXMLSaxParser;
9
+
10
+ void rxml_init_sax_parser(void);
11
+
12
+ #endif
@@ -0,0 +1,159 @@
1
+ #include "ruby_libxml.h"
2
+ #include "ruby_xml_schema.h"
3
+
4
+ /*
5
+ * Document-class: LibXML::XML::Schema
6
+ *
7
+ * The XML::Schema class is used to prepare XML Schemas for validation of xml
8
+ * documents.
9
+ *
10
+ * Schemas can be created from XML documents, strings or URIs using the
11
+ * corresponding methods (new for URIs).
12
+ *
13
+ * Once a schema is prepared, an XML document can be validated by the
14
+ * XML::Document#validate_schema method providing the XML::Schema object
15
+ * as parameter. The method return true if the document validates, false
16
+ * otherwise.
17
+ *
18
+ * Basic usage:
19
+ *
20
+ * # parse schema as xml document
21
+ * schema_document = XML::Document.file('schema.rng')
22
+ *
23
+ * # prepare schema for validation
24
+ * schema = XML::Schema.document(schema_document)
25
+ *
26
+ * # parse xml document to be validated
27
+ * instance = XML::Document.file('instance.xml')
28
+ *
29
+ * # validate
30
+ * instance.validate_schema(schema)
31
+ */
32
+
33
+ VALUE cXMLSchema;
34
+
35
+ static void rxml_schema_free(xmlSchemaPtr xschema)
36
+ {
37
+ xmlSchemaFree(xschema);
38
+ }
39
+
40
+ /*
41
+ * call-seq:
42
+ * XML::Schema.initialize(schema_uri) -> schema
43
+ *
44
+ * Create a new schema from the specified URI.
45
+ */
46
+ static VALUE rxml_schema_init_from_uri(VALUE class, VALUE uri)
47
+ {
48
+ xmlSchemaParserCtxtPtr xparser;
49
+ xmlSchemaPtr xschema;
50
+
51
+ Check_Type(uri, T_STRING);
52
+
53
+ xparser = xmlSchemaNewParserCtxt(StringValuePtr(uri));
54
+ xschema = xmlSchemaParse(xparser);
55
+ xmlSchemaFreeParserCtxt(xparser);
56
+
57
+ return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
58
+ }
59
+
60
+ /*
61
+ * call-seq:
62
+ * XML::Schema.document(document) -> schema
63
+ *
64
+ * Create a new schema from the specified document.
65
+ */
66
+ static VALUE rxml_schema_init_from_document(VALUE class, VALUE document)
67
+ {
68
+ xmlDocPtr xdoc;
69
+ xmlSchemaPtr xschema;
70
+ xmlSchemaParserCtxtPtr xparser;
71
+
72
+ Data_Get_Struct(document, xmlDoc, xdoc);
73
+
74
+ xparser = xmlSchemaNewDocParserCtxt(xdoc);
75
+ xschema = xmlSchemaParse(xparser);
76
+ xmlSchemaFreeParserCtxt(xparser);
77
+
78
+ return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
79
+ }
80
+
81
+ /*
82
+ * call-seq:
83
+ * XML::Schema.string("schema_data") -> "value"
84
+ *
85
+ * Create a new schema using the specified string.
86
+ */
87
+ static VALUE rxml_schema_init_from_string(VALUE self, VALUE schema_str)
88
+ {
89
+ xmlSchemaParserCtxtPtr xparser;
90
+ xmlSchemaPtr xschema;
91
+
92
+ Check_Type(schema_str, T_STRING);
93
+
94
+ xparser = xmlSchemaNewMemParserCtxt(StringValuePtr(schema_str), strlen(
95
+ StringValuePtr(schema_str)));
96
+ xschema = xmlSchemaParse(xparser);
97
+ xmlSchemaFreeParserCtxt(xparser);
98
+
99
+ return Data_Wrap_Struct(cXMLSchema, NULL, rxml_schema_free, xschema);
100
+ }
101
+
102
+ /* TODO what is this patch doing here?
103
+
104
+ xmlSchemaParserCtxtPtr parser;
105
+ xmlSchemaPtr sptr;
106
+ xmlSchemaValidCtxtPtr vptr;
107
+ + int is_invalid;
108
+
109
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &source) == FAILURE) {
110
+ return;
111
+ @@ -598,26 +598,24 @@
112
+ convert_to_string_ex(&source);
113
+ parser = xmlSchemaNewParserCtxt(Z_STRVAL_P(source));
114
+ sptr = xmlSchemaParse(parser);
115
+ break;
116
+ case SCHEMA_BLOB:
117
+ convert_to_string_ex(&source);
118
+ parser = xmlSchemaNewMemParserCtxt(Z_STRVAL_P(source), Z_STRLEN_P(source));
119
+ sptr = xmlSchemaParse(parser);
120
+ break;
121
+ }
122
+
123
+ vptr = xmlSchemaNewValidCtxt(sptr);
124
+ + is_invalid = xmlSchemaValidateDoc(vptr, (xmlDocPtr) sxe->document->ptr);
125
+ xmlSchemaFree(sptr);
126
+ xmlSchemaFreeValidCtxt(vptr);
127
+ xmlSchemaFreeParserCtxt(parser);
128
+
129
+ - if (is_valid) {
130
+ - RETURN_TRUE;
131
+ - } else {
132
+ + if (is_invalid) {
133
+ RETURN_FALSE;
134
+ + } else {
135
+ + RETURN_TRUE;
136
+ }
137
+ }
138
+ }}}
139
+ @@ -695,7 +693,7 @@
140
+ {
141
+ if (!strcmp(method, "xsearch")) {
142
+ simplexml_ce_xpath_search(INTERNAL_FUNCTION_PARAM_PASSTHRU);
143
+ -#ifdef xmlSchemaParserCtxtPtr
144
+ +#ifdef LIBXML_SCHEMAS_ENABLED
145
+ } else if (!strcmp(method, "validate_schema_file")) {
146
+ simplexml_ce_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, SCHEMA_FILE);
147
+ } else if (!strcmp(method, "validate_schema_buffer")) {
148
+ */
149
+
150
+ void rxml_init_schema(void)
151
+ {
152
+ cXMLSchema = rb_define_class_under(mXML, "Schema", rb_cObject);
153
+ rb_define_singleton_method(cXMLSchema, "new", rxml_schema_init_from_uri, 1);
154
+ rb_define_singleton_method(cXMLSchema, "from_string",
155
+ rxml_schema_init_from_string, 1);
156
+ rb_define_singleton_method(cXMLSchema, "document",
157
+ rxml_schema_init_from_document, 1);
158
+ }
159
+
@@ -0,0 +1,11 @@
1
+ #ifndef __RXML_SCHEMA__
2
+ #define __RXML_SCHEMA__
3
+
4
+ #include <libxml/schemasInternals.h>
5
+ #include <libxml/xmlschemas.h>
6
+
7
+ extern VALUE cXMLSchema;
8
+
9
+ void rxml_init_schema(void);
10
+ #endif
11
+
@@ -0,0 +1,9 @@
1
+ /* Don't nuke this block! It is used for automatically updating the
2
+ * versions below. VERSION = string formatting, VERNUM = numbered
3
+ * version for inline testing: increment both or none at all.*/
4
+ #define RUBY_LIBXML_VERSION "1.1.4"
5
+ #define RUBY_LIBXML_VERNUM 114
6
+ #define RUBY_LIBXML_VER_MAJ 1
7
+ #define RUBY_LIBXML_VER_MIN 1
8
+ #define RUBY_LIBXML_VER_MIC 4
9
+ #define RUBY_LIBXML_VER_PATCH 1
@@ -0,0 +1,18 @@
1
+ /* $Id: ruby_xml_xinclude.c 758 2009-01-25 20:36:03Z cfis $ */
2
+
3
+ #include "ruby_libxml.h"
4
+ #include "ruby_xml_xinclude.h"
5
+
6
+ VALUE cXMLXInclude;
7
+
8
+ /*
9
+ * Document-class: LibXML::XML::XInclude
10
+ *
11
+ * The ruby bindings do not currently expose libxml's
12
+ * XInclude fuctionality.
13
+ */
14
+
15
+ void rxml_init_xinclude(void)
16
+ {
17
+ cXMLXInclude = rb_define_class_under(mXML, "XInclude", rb_cObject);
18
+ }
@@ -0,0 +1,13 @@
1
+ /* $Id: ruby_xml_xinclude.h 758 2009-01-25 20:36:03Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #ifndef __RXML_XINCLUDE__
6
+ #define __RXML_XINCLUDE__
7
+
8
+ extern VALUE cXMLXInclude;
9
+ extern VALUE eXMLXIncludeError;
10
+
11
+ void rxml_init_xinclude(void);
12
+
13
+ #endif
@@ -0,0 +1,107 @@
1
+ /* $Id: ruby_xml_xpath.c 759 2009-01-26 00:15:49Z cfis $ */
2
+
3
+ /*
4
+ * Document-class: LibXML::XML::XPath
5
+ *
6
+ * The XML::XPath module is used to query XML documents. It is
7
+ * usually accessed via the XML::Document#find or
8
+ * XML::Node#find methods. For example:
9
+ *
10
+ * document.find('/foo', namespaces) -> XML::XPath::Object
11
+ *
12
+ * The optional namespaces parameter can be a string, array or
13
+ * hash table.
14
+ *
15
+ * document.find('/foo', 'xlink:http://www.w3.org/1999/xlink')
16
+ * document.find('/foo', ['xlink:http://www.w3.org/1999/xlink',
17
+ * 'xi:http://www.w3.org/2001/XInclude')
18
+ * document.find('/foo', 'xlink' => 'http://www.w3.org/1999/xlink',
19
+ * 'xi' => 'http://www.w3.org/2001/XInclude')
20
+ *
21
+ *
22
+ * === Working With Default Namespaces
23
+ *
24
+ * Finding namespaced elements and attributes can be tricky.
25
+ * Lets work through an example of a document with a default
26
+ * namespace:
27
+ *
28
+ * <?xml version="1.0" encoding="utf-8"?>
29
+ * <feed xmlns="http://www.w3.org/2005/Atom">
30
+ * <title type="text">Phil Bogle's Contacts</title>
31
+ * </feed>
32
+ *
33
+ * To find nodes you must define the atom namespace for
34
+ * libxml. One way to do this is:
35
+ *
36
+ * node = doc.find('atom:title', 'atom:http://www.w3.org/2005/Atom')
37
+ *
38
+ * Alternatively, you can register the default namespace like this:
39
+ *
40
+ * doc.root.namespaces.default_prefix = 'atom'
41
+ * node = doc.find('atom:title')
42
+ *
43
+ * === More Complex Namespace Examples
44
+ *
45
+ * Lets work through some more complex examples using the
46
+ * following xml document:
47
+ *
48
+ * <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
49
+ * <soap:Body>
50
+ * <getManufacturerNamesResponse xmlns="http://services.somewhere.com">
51
+ * <IDAndNameList xmlns="http://services.somewhere.com">
52
+ * <ns1:IdAndName xmlns:ns1="http://domain.somewhere.com"/>
53
+ * </IDAndNameList>
54
+ * </getManufacturerNamesResponse>
55
+ * </soap:Envelope>
56
+ *
57
+ * # Since the soap namespace is defined on the root
58
+ * # node we can directly use it.
59
+ * doc.find('/soap:Envelope')
60
+ *
61
+ * # Since the ns1 namespace is not defined on the root node
62
+ * # we have to first register it with the xpath engine.
63
+ * doc.find('//ns1:IdAndName',
64
+ * 'ns1:http://domain.somewhere.com')
65
+ *
66
+ * # Since the getManufacturerNamesResponse element uses a default
67
+ * # namespace we first have to give it a prefix and register
68
+ * # it with the xpath engine.
69
+ * doc.find('//ns:getManufacturerNamesResponse',
70
+ * 'ns:http://services.somewhere.com')
71
+ *
72
+ * # Here is an example showing a complex namespace aware
73
+ * # xpath expression.
74
+ * doc.find('/soap:Envelope/soap:Body/ns0:getManufacturerNamesResponse/ns0:IDAndNameList/ns1:IdAndName',
75
+ * ['ns0:http://services.somewhere.com', 'ns1:http://domain.somewhere.com'])
76
+ */
77
+
78
+
79
+ #include "ruby_libxml.h"
80
+
81
+ VALUE mXPath;
82
+
83
+ void rxml_init_xpath(void)
84
+ {
85
+ mXPath = rb_define_module_under(mXML, "XPath");
86
+
87
+ /* 0: Undefined value. */
88
+ rb_define_const(mXPath, "UNDEFINED", INT2NUM(XPATH_UNDEFINED));
89
+ /* 1: A nodeset, will be wrapped by XPath Object. */
90
+ rb_define_const(mXPath, "NODESET", INT2NUM(XPATH_NODESET));
91
+ /* 2: A boolean value. */
92
+ rb_define_const(mXPath, "BOOLEAN", INT2NUM(XPATH_BOOLEAN));
93
+ /* 3: A numeric value. */
94
+ rb_define_const(mXPath, "NUMBER", INT2NUM(XPATH_NUMBER));
95
+ /* 4: A string value. */
96
+ rb_define_const(mXPath, "STRING", INT2NUM(XPATH_STRING));
97
+ /* 5: An xpointer point */
98
+ rb_define_const(mXPath, "POINT", INT2NUM(XPATH_POINT));
99
+ /* 6: An xpointer range */
100
+ rb_define_const(mXPath, "RANGE", INT2NUM(XPATH_RANGE));
101
+ /* 7: An xpointer location set */
102
+ rb_define_const(mXPath, "LOCATIONSET", INT2NUM(XPATH_LOCATIONSET));
103
+ /* 8: XPath user type */
104
+ rb_define_const(mXPath, "USERS", INT2NUM(XPATH_USERS));
105
+ /* 9: An XSLT value tree, non modifiable */
106
+ rb_define_const(mXPath, "XSLT_TREE", INT2NUM(XPATH_XSLT_TREE));
107
+ }