coupa-libxml-ruby 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +488 -0
- data/LICENSE +22 -0
- data/README +161 -0
- data/Rakefile +188 -0
- data/doc/css/normal.css +182 -0
- data/doc/img/raze-tiny.png +0 -0
- data/doc/img/red-cube.jpg +0 -0
- data/doc/img/xml-ruby.png +0 -0
- data/doc/index.xml +43 -0
- data/doc/install.xml +77 -0
- data/doc/layout.rhtml +38 -0
- data/doc/layout.xsl +67 -0
- data/doc/license.xml +32 -0
- data/doc/log/changelog.xml +1324 -0
- data/doc/log/changelog.xsl +42 -0
- data/doc/rdoc/classes/LibXML.html +207 -0
- data/doc/rdoc/classes/LibXML/XML.html +407 -0
- data/doc/rdoc/classes/LibXML/XML/Attr.html +521 -0
- data/doc/rdoc/classes/LibXML/XML/AttrDecl.html +360 -0
- data/doc/rdoc/classes/LibXML/XML/Attributes.html +149 -0
- data/doc/rdoc/classes/LibXML/XML/Document.html +460 -0
- data/doc/rdoc/classes/LibXML/XML/Error.html +129 -0
- data/doc/rdoc/classes/LibXML/XML/HTMLParser.html +263 -0
- data/doc/rdoc/classes/LibXML/XML/Namespace.html +248 -0
- data/doc/rdoc/classes/LibXML/XML/Namespaces.html +200 -0
- data/doc/rdoc/classes/LibXML/XML/Node.html +1351 -0
- data/doc/rdoc/classes/LibXML/XML/Parser.html +328 -0
- data/doc/rdoc/classes/LibXML/XML/Reader.html +172 -0
- data/doc/rdoc/classes/LibXML/XML/SaxParser.html +232 -0
- data/doc/rdoc/classes/LibXML/XML/SaxParser/Callbacks.html +506 -0
- data/doc/rdoc/classes/LibXML/XML/SaxParser/VerboseCallbacks.html +555 -0
- data/doc/rdoc/classes/LibXML/XML/XPath.html +111 -0
- data/doc/rdoc/classes/LibXML/XML/XPath/Object.html +162 -0
- data/doc/rdoc/classes/cXMLDtd.html +114 -0
- data/doc/rdoc/classes/cXMLNode.html +114 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/CHANGES.html +794 -0
- data/doc/rdoc/files/LICENSE.html +131 -0
- data/doc/rdoc/files/README.html +343 -0
- data/doc/rdoc/files/ext/libxml/libxml_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_attr_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_attr_decl_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_attributes_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_cbg_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_document_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_dtd_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_encoding_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_error_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_context_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_html_parser_options_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_input_cbg_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_io_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_namespace_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_namespaces_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_node_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_context_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_parser_options_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_reader_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_relaxng_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_sax2_handler_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_sax_parser_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_schema_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xinclude_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_context_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_expression_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpath_object_c.html +101 -0
- data/doc/rdoc/files/ext/libxml/ruby_xml_xpointer_c.html +101 -0
- data/doc/rdoc/files/lib/libxml/attr_decl_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/attr_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/attributes_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/document_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/error_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/hpricot_rb.html +192 -0
- data/doc/rdoc/files/lib/libxml/html_parser_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/namespace_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/namespaces_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/node_rb.html +108 -0
- data/doc/rdoc/files/lib/libxml/ns_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/parser_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/properties_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/reader_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/sax_callbacks_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/sax_parser_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/tree_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml/xpath_object_rb.html +101 -0
- data/doc/rdoc/files/lib/libxml_rb.html +133 -0
- data/doc/rdoc/files/lib/xml/libxml_rb.html +124 -0
- data/doc/rdoc/files/lib/xml_rb.html +134 -0
- data/doc/rdoc/fr_class_index.html +46 -0
- data/doc/rdoc/fr_file_index.html +84 -0
- data/doc/rdoc/fr_method_index.html +155 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/ext/libxml/Makefile +157 -0
- data/ext/libxml/build.log +4 -0
- data/ext/libxml/extconf.h +5 -0
- data/ext/libxml/extconf.rb +278 -0
- data/ext/libxml/libxml.c +77 -0
- data/ext/libxml/libxml.o +0 -0
- data/ext/libxml/libxml_ruby.bundle +0 -0
- data/ext/libxml/mkmf.log +228 -0
- data/ext/libxml/ruby_libxml.h +93 -0
- data/ext/libxml/ruby_xml.c +893 -0
- data/ext/libxml/ruby_xml.h +10 -0
- data/ext/libxml/ruby_xml.o +0 -0
- data/ext/libxml/ruby_xml_attr.c +352 -0
- data/ext/libxml/ruby_xml_attr.h +14 -0
- data/ext/libxml/ruby_xml_attr.o +0 -0
- data/ext/libxml/ruby_xml_attr_decl.c +171 -0
- data/ext/libxml/ruby_xml_attr_decl.h +13 -0
- data/ext/libxml/ruby_xml_attr_decl.o +0 -0
- data/ext/libxml/ruby_xml_attributes.c +277 -0
- data/ext/libxml/ruby_xml_attributes.h +17 -0
- data/ext/libxml/ruby_xml_attributes.o +0 -0
- data/ext/libxml/ruby_xml_cbg.c +86 -0
- data/ext/libxml/ruby_xml_cbg.o +0 -0
- data/ext/libxml/ruby_xml_document.c +1006 -0
- data/ext/libxml/ruby_xml_document.c.old +936 -0
- data/ext/libxml/ruby_xml_document.h +17 -0
- data/ext/libxml/ruby_xml_document.o +0 -0
- data/ext/libxml/ruby_xml_dtd.c +257 -0
- data/ext/libxml/ruby_xml_dtd.h +9 -0
- data/ext/libxml/ruby_xml_dtd.o +0 -0
- data/ext/libxml/ruby_xml_encoding.c +134 -0
- data/ext/libxml/ruby_xml_encoding.h +12 -0
- data/ext/libxml/ruby_xml_encoding.o +0 -0
- data/ext/libxml/ruby_xml_error.c +1004 -0
- data/ext/libxml/ruby_xml_error.h +14 -0
- data/ext/libxml/ruby_xml_error.o +0 -0
- data/ext/libxml/ruby_xml_html_parser.c +92 -0
- data/ext/libxml/ruby_xml_html_parser.h +12 -0
- data/ext/libxml/ruby_xml_html_parser.o +0 -0
- data/ext/libxml/ruby_xml_html_parser_context.c +308 -0
- data/ext/libxml/ruby_xml_html_parser_context.h +12 -0
- data/ext/libxml/ruby_xml_html_parser_context.o +0 -0
- data/ext/libxml/ruby_xml_html_parser_options.c +40 -0
- data/ext/libxml/ruby_xml_html_parser_options.h +12 -0
- data/ext/libxml/ruby_xml_html_parser_options.o +0 -0
- data/ext/libxml/ruby_xml_input_cbg.c +191 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -0
- data/ext/libxml/ruby_xml_input_cbg.o +0 -0
- data/ext/libxml/ruby_xml_io.c +30 -0
- data/ext/libxml/ruby_xml_io.h +9 -0
- data/ext/libxml/ruby_xml_io.o +0 -0
- data/ext/libxml/ruby_xml_namespace.c +170 -0
- data/ext/libxml/ruby_xml_namespace.h +12 -0
- data/ext/libxml/ruby_xml_namespace.o +0 -0
- data/ext/libxml/ruby_xml_namespaces.c +295 -0
- data/ext/libxml/ruby_xml_namespaces.h +11 -0
- data/ext/libxml/ruby_xml_namespaces.o +0 -0
- data/ext/libxml/ruby_xml_node.c +1386 -0
- data/ext/libxml/ruby_xml_node.h +13 -0
- data/ext/libxml/ruby_xml_node.o +0 -0
- data/ext/libxml/ruby_xml_parser.c +94 -0
- data/ext/libxml/ruby_xml_parser.h +14 -0
- data/ext/libxml/ruby_xml_parser.o +0 -0
- data/ext/libxml/ruby_xml_parser_context.c +982 -0
- data/ext/libxml/ruby_xml_parser_context.h +12 -0
- data/ext/libxml/ruby_xml_parser_context.o +0 -0
- data/ext/libxml/ruby_xml_parser_options.c +68 -0
- data/ext/libxml/ruby_xml_parser_options.h +14 -0
- data/ext/libxml/ruby_xml_parser_options.o +0 -0
- data/ext/libxml/ruby_xml_reader.c +1002 -0
- data/ext/libxml/ruby_xml_reader.h +14 -0
- data/ext/libxml/ruby_xml_reader.o +0 -0
- data/ext/libxml/ruby_xml_relaxng.c +111 -0
- data/ext/libxml/ruby_xml_relaxng.h +10 -0
- data/ext/libxml/ruby_xml_relaxng.o +0 -0
- data/ext/libxml/ruby_xml_sax2_handler.c +322 -0
- data/ext/libxml/ruby_xml_sax2_handler.h +12 -0
- data/ext/libxml/ruby_xml_sax2_handler.o +0 -0
- data/ext/libxml/ruby_xml_sax_parser.c +137 -0
- data/ext/libxml/ruby_xml_sax_parser.h +12 -0
- data/ext/libxml/ruby_xml_sax_parser.o +0 -0
- data/ext/libxml/ruby_xml_schema.c +159 -0
- data/ext/libxml/ruby_xml_schema.h +11 -0
- data/ext/libxml/ruby_xml_schema.o +0 -0
- data/ext/libxml/ruby_xml_version.h +9 -0
- data/ext/libxml/ruby_xml_xinclude.c +18 -0
- data/ext/libxml/ruby_xml_xinclude.h +13 -0
- data/ext/libxml/ruby_xml_xinclude.o +0 -0
- data/ext/libxml/ruby_xml_xpath.c +107 -0
- data/ext/libxml/ruby_xml_xpath.h +12 -0
- data/ext/libxml/ruby_xml_xpath.o +0 -0
- data/ext/libxml/ruby_xml_xpath_context.c +387 -0
- data/ext/libxml/ruby_xml_xpath_context.h +11 -0
- data/ext/libxml/ruby_xml_xpath_context.o +0 -0
- data/ext/libxml/ruby_xml_xpath_expression.c +83 -0
- data/ext/libxml/ruby_xml_xpath_expression.h +12 -0
- data/ext/libxml/ruby_xml_xpath_expression.o +0 -0
- data/ext/libxml/ruby_xml_xpath_object.c +336 -0
- data/ext/libxml/ruby_xml_xpath_object.h +19 -0
- data/ext/libxml/ruby_xml_xpath_object.o +0 -0
- data/ext/libxml/ruby_xml_xpointer.c +101 -0
- data/ext/libxml/ruby_xml_xpointer.h +13 -0
- data/ext/libxml/ruby_xml_xpointer.o +0 -0
- data/ext/mingw/Rakefile +34 -0
- data/ext/mingw/build.rake +41 -0
- data/ext/vc/libxml_ruby.sln +26 -0
- data/lib/libxml.rb +30 -0
- data/lib/libxml/attr.rb +111 -0
- data/lib/libxml/attr_decl.rb +78 -0
- data/lib/libxml/attributes.rb +12 -0
- data/lib/libxml/document.rb +190 -0
- data/lib/libxml/error.rb +88 -0
- data/lib/libxml/hpricot.rb +76 -0
- data/lib/libxml/html_parser.rb +94 -0
- data/lib/libxml/namespace.rb +60 -0
- data/lib/libxml/namespaces.rb +36 -0
- data/lib/libxml/node.rb +385 -0
- data/lib/libxml/ns.rb +20 -0
- data/lib/libxml/parser.rb +365 -0
- data/lib/libxml/properties.rb +21 -0
- data/lib/libxml/reader.rb +27 -0
- data/lib/libxml/sax_callbacks.rb +178 -0
- data/lib/libxml/sax_parser.rb +56 -0
- data/lib/libxml/tree.rb +27 -0
- data/lib/libxml/xpath_object.rb +14 -0
- data/lib/xml.rb +14 -0
- data/lib/xml/libxml.rb +8 -0
- data/setup.rb +1585 -0
- data/test/etc_doc_to_s.rb +19 -0
- data/test/ets_doc_file.rb +15 -0
- data/test/ets_doc_to_s.rb +21 -0
- data/test/ets_gpx.rb +26 -0
- data/test/ets_node_gc.rb +21 -0
- data/test/ets_test.xml +2 -0
- data/test/ets_tsr.rb +9 -0
- data/test/model/atom.xml +13 -0
- data/test/model/bands.xml +5 -0
- data/test/model/books.xml +146 -0
- data/test/model/merge_bug_data.xml +58 -0
- data/test/model/ruby-lang.html +238 -0
- data/test/model/rubynet.xml +79 -0
- data/test/model/rubynet_project +1 -0
- data/test/model/shiporder.rnc +28 -0
- data/test/model/shiporder.rng +86 -0
- data/test/model/shiporder.xml +23 -0
- data/test/model/shiporder.xsd +31 -0
- data/test/model/soap.xml +27 -0
- data/test/model/xinclude.xml +5 -0
- data/test/tc_attr.rb +170 -0
- data/test/tc_attr_decl.rb +131 -0
- data/test/tc_attributes.rb +133 -0
- data/test/tc_deprecated_require.rb +11 -0
- data/test/tc_document.rb +113 -0
- data/test/tc_document_write.rb +118 -0
- data/test/tc_dtd.rb +123 -0
- data/test/tc_error.rb +136 -0
- data/test/tc_html_parser.rb +138 -0
- data/test/tc_namespace.rb +59 -0
- data/test/tc_namespaces.rb +174 -0
- data/test/tc_node.rb +181 -0
- data/test/tc_node_cdata.rb +49 -0
- data/test/tc_node_comment.rb +30 -0
- data/test/tc_node_copy.rb +40 -0
- data/test/tc_node_edit.rb +158 -0
- data/test/tc_node_text.rb +69 -0
- data/test/tc_node_write.rb +83 -0
- data/test/tc_node_xlink.rb +26 -0
- data/test/tc_parser.rb +330 -0
- data/test/tc_parser_context.rb +186 -0
- data/test/tc_properties.rb +36 -0
- data/test/tc_reader.rb +284 -0
- data/test/tc_relaxng.rb +51 -0
- data/test/tc_sax_parser.rb +274 -0
- data/test/tc_schema.rb +51 -0
- data/test/tc_traversal.rb +220 -0
- data/test/tc_xinclude.rb +19 -0
- data/test/tc_xml.rb +224 -0
- data/test/tc_xpath.rb +193 -0
- data/test/tc_xpath_context.rb +78 -0
- data/test/tc_xpath_expression.rb +35 -0
- data/test/tc_xpointer.rb +72 -0
- data/test/test_suite.rb +33 -0
- metadata +376 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
/* Copyright (c) 2006 Apple Computer Inc.
|
2
|
+
* Please see the LICENSE file for copyright and distribution information. */
|
3
|
+
|
4
|
+
#ifndef __RXML_READER__
|
5
|
+
#define __RXML_READER__
|
6
|
+
|
7
|
+
extern VALUE cXMLReader;
|
8
|
+
|
9
|
+
void rxml_init_reader(void);
|
10
|
+
|
11
|
+
/* Exported to be used by XML::Document#reader */
|
12
|
+
VALUE rxml_reader_new_walker(VALUE self, VALUE doc);
|
13
|
+
|
14
|
+
#endif /* __rxml_READER__ */
|
Binary file
|
@@ -0,0 +1,111 @@
|
|
1
|
+
#include "ruby_libxml.h"
|
2
|
+
#include "ruby_xml_relaxng.h"
|
3
|
+
|
4
|
+
/*
|
5
|
+
* Document-class: LibXML::XML::RelaxNG
|
6
|
+
*
|
7
|
+
* The XML::RelaxNG class is used to prepare RelaxNG schemas for validation
|
8
|
+
* of xml 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_relaxng method providing the XML::RelaxNG object
|
15
|
+
* as parameter. The method will raise an exception if the document is
|
16
|
+
* not valid.
|
17
|
+
*
|
18
|
+
* Basic Usage:
|
19
|
+
*
|
20
|
+
* # parse schema as xml document
|
21
|
+
* relaxng_document = XML::Document.file('schema.rng')
|
22
|
+
*
|
23
|
+
* # prepare schema for validation
|
24
|
+
* relaxng_schema = XML::RelaxNG.document(relaxng_document)
|
25
|
+
*
|
26
|
+
* # parse xml document to be validated
|
27
|
+
* instance = XML::Document.file('instance.xml')
|
28
|
+
*
|
29
|
+
* # validate
|
30
|
+
* instance.validate_relaxng(relaxng_schema)
|
31
|
+
*/
|
32
|
+
|
33
|
+
VALUE cXMLRelaxNG;
|
34
|
+
|
35
|
+
static void rxml_relaxng_free(xmlRelaxNGPtr xrelaxng)
|
36
|
+
{
|
37
|
+
xmlRelaxNGFree(xrelaxng);
|
38
|
+
}
|
39
|
+
|
40
|
+
/*
|
41
|
+
* call-seq:
|
42
|
+
* XML::Relaxng.new(relaxng_uri) -> relaxng
|
43
|
+
*
|
44
|
+
* Create a new relaxng from the specified URI.
|
45
|
+
*/
|
46
|
+
static VALUE rxml_relaxng_init_from_uri(VALUE class, VALUE uri)
|
47
|
+
{
|
48
|
+
xmlRelaxNGParserCtxtPtr xparser;
|
49
|
+
xmlRelaxNGPtr xrelaxng;
|
50
|
+
|
51
|
+
Check_Type(uri, T_STRING);
|
52
|
+
|
53
|
+
xparser = xmlRelaxNGNewParserCtxt(StringValuePtr(uri));
|
54
|
+
xrelaxng = xmlRelaxNGParse(xparser);
|
55
|
+
xmlRelaxNGFreeParserCtxt(xparser);
|
56
|
+
|
57
|
+
return Data_Wrap_Struct(cXMLRelaxNG, NULL, rxml_relaxng_free, xrelaxng);
|
58
|
+
}
|
59
|
+
|
60
|
+
/*
|
61
|
+
* call-seq:
|
62
|
+
* XML::RelaxNG.document(document) -> relaxng
|
63
|
+
*
|
64
|
+
* Create a new relaxng from the specified document.
|
65
|
+
*/
|
66
|
+
static VALUE rxml_relaxng_init_from_document(VALUE class, VALUE document)
|
67
|
+
{
|
68
|
+
xmlDocPtr xdoc;
|
69
|
+
xmlRelaxNGPtr xrelaxng;
|
70
|
+
xmlRelaxNGParserCtxtPtr xparser;
|
71
|
+
|
72
|
+
Data_Get_Struct(document, xmlDoc, xdoc);
|
73
|
+
|
74
|
+
xparser = xmlRelaxNGNewDocParserCtxt(xdoc);
|
75
|
+
xrelaxng = xmlRelaxNGParse(xparser);
|
76
|
+
xmlRelaxNGFreeParserCtxt(xparser);
|
77
|
+
|
78
|
+
return Data_Wrap_Struct(cXMLRelaxNG, NULL, rxml_relaxng_free, xrelaxng);
|
79
|
+
}
|
80
|
+
|
81
|
+
/*
|
82
|
+
* call-seq:
|
83
|
+
* XML::RelaxNG.string("relaxng_data") -> "value"
|
84
|
+
*
|
85
|
+
* Create a new relaxng using the specified string.
|
86
|
+
*/
|
87
|
+
static VALUE rxml_relaxng_init_from_string(VALUE self, VALUE relaxng_str)
|
88
|
+
{
|
89
|
+
xmlRelaxNGParserCtxtPtr xparser;
|
90
|
+
xmlRelaxNGPtr xrelaxng;
|
91
|
+
|
92
|
+
Check_Type(relaxng_str, T_STRING);
|
93
|
+
|
94
|
+
xparser = xmlRelaxNGNewMemParserCtxt(StringValuePtr(relaxng_str), strlen(
|
95
|
+
StringValuePtr(relaxng_str)));
|
96
|
+
xrelaxng = xmlRelaxNGParse(xparser);
|
97
|
+
xmlRelaxNGFreeParserCtxt(xparser);
|
98
|
+
|
99
|
+
return Data_Wrap_Struct(cXMLRelaxNG, NULL, rxml_relaxng_free, xrelaxng);
|
100
|
+
}
|
101
|
+
|
102
|
+
void rxml_init_relaxng(void)
|
103
|
+
{
|
104
|
+
cXMLRelaxNG = rb_define_class_under(mXML, "RelaxNG", rb_cObject);
|
105
|
+
rb_define_singleton_method(cXMLRelaxNG, "new", rxml_relaxng_init_from_uri, 1);
|
106
|
+
rb_define_singleton_method(cXMLRelaxNG, "from_string",
|
107
|
+
rxml_relaxng_init_from_string, 1);
|
108
|
+
rb_define_singleton_method(cXMLRelaxNG, "document",
|
109
|
+
rxml_relaxng_init_from_document, 1);
|
110
|
+
}
|
111
|
+
|
Binary file
|
@@ -0,0 +1,322 @@
|
|
1
|
+
/* $Id: ruby_xml_sax_parser.c 682 2008-12-09 05:31:13Z cfis $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "ruby_libxml.h"
|
6
|
+
#include "ruby_xml_sax2_handler.h"
|
7
|
+
|
8
|
+
|
9
|
+
VALUE cbidOnCdataBlock;
|
10
|
+
VALUE cbidOnCharacters;
|
11
|
+
VALUE cbidOnComment;
|
12
|
+
VALUE cbidOnEndDocument;
|
13
|
+
VALUE cbidOnEndElement;
|
14
|
+
VALUE cbidOnEndElementNs;
|
15
|
+
VALUE cbidOnExternalSubset;
|
16
|
+
VALUE cbidOnHasExternalSubset;
|
17
|
+
VALUE cbidOnHasInternalSubset;
|
18
|
+
VALUE cbidOnInternalSubset;
|
19
|
+
VALUE cbidOnIsStandalone;
|
20
|
+
VALUE cbidOnError;
|
21
|
+
VALUE cbidOnProcessingInstruction;
|
22
|
+
VALUE cbidOnReference;
|
23
|
+
VALUE cbidOnStartElement;
|
24
|
+
VALUE cbidOnStartElementNs;
|
25
|
+
VALUE cbidOnStartDocument;
|
26
|
+
|
27
|
+
/* ====== Callbacks =========== */
|
28
|
+
static void cdata_block_callback(void *ctx,
|
29
|
+
const char *value, int len)
|
30
|
+
{
|
31
|
+
VALUE handler = (VALUE) ctx;
|
32
|
+
|
33
|
+
if (handler != Qnil)
|
34
|
+
{
|
35
|
+
rb_funcall(handler, cbidOnCdataBlock,1,rb_str_new(value, len));
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
static void characters_callback(void *ctx,
|
40
|
+
const char *chars, int len)
|
41
|
+
{
|
42
|
+
VALUE handler = (VALUE) ctx;
|
43
|
+
|
44
|
+
if (handler != Qnil)
|
45
|
+
{
|
46
|
+
VALUE rchars = rb_str_new(chars, len);
|
47
|
+
rb_funcall(handler, cbidOnCharacters, 1, rchars);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
static void comment_callback(void *ctx,
|
52
|
+
const char *msg)
|
53
|
+
{
|
54
|
+
VALUE handler = (VALUE) ctx;
|
55
|
+
|
56
|
+
if (handler != Qnil)
|
57
|
+
{
|
58
|
+
rb_funcall(handler, cbidOnComment,1,rb_str_new2(msg));
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
static void end_document_callback(void *ctx)
|
63
|
+
{
|
64
|
+
VALUE handler = (VALUE) ctx;
|
65
|
+
|
66
|
+
if (handler != Qnil)
|
67
|
+
{
|
68
|
+
rb_funcall(handler, cbidOnEndDocument, 0);
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
static void end_element_ns_callback(void *ctx,
|
73
|
+
const xmlChar *xlocalname, const xmlChar *xprefix, const xmlChar *xURI)
|
74
|
+
{
|
75
|
+
VALUE handler = (VALUE) ctx;
|
76
|
+
|
77
|
+
if (handler == Qnil)
|
78
|
+
return;
|
79
|
+
|
80
|
+
/* Call end element for old-times sake */
|
81
|
+
if (rb_respond_to(handler, cbidOnEndElement))
|
82
|
+
{
|
83
|
+
VALUE name;
|
84
|
+
if (xprefix)
|
85
|
+
{
|
86
|
+
name = rb_str_new2(xprefix);
|
87
|
+
rb_str_cat2(name, ":");
|
88
|
+
rb_str_cat2(name, xlocalname);
|
89
|
+
}
|
90
|
+
else
|
91
|
+
{
|
92
|
+
name = rb_str_new2(xlocalname);
|
93
|
+
}
|
94
|
+
rb_funcall(handler, cbidOnEndElement, 1, name);
|
95
|
+
}
|
96
|
+
|
97
|
+
rb_funcall(handler, cbidOnEndElementNs, 3,
|
98
|
+
rb_str_new2(xlocalname),
|
99
|
+
xprefix ? rb_str_new2(xprefix) : Qnil,
|
100
|
+
xURI ? rb_str_new2(xURI) : Qnil);
|
101
|
+
}
|
102
|
+
|
103
|
+
static void external_subset_callback(void *ctx, const char *name, const char *extid, const char *sysid)
|
104
|
+
{
|
105
|
+
VALUE handler = (VALUE) ctx;
|
106
|
+
|
107
|
+
if (handler != Qnil)
|
108
|
+
{
|
109
|
+
VALUE rname = name ? rb_str_new2(name) : Qnil;
|
110
|
+
VALUE rextid = extid ? rb_str_new2(extid) : Qnil;
|
111
|
+
VALUE rsysid = sysid ? rb_str_new2(sysid) : Qnil;
|
112
|
+
rb_funcall(handler, cbidOnExternalSubset, 3, rname, rextid, rsysid);
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
static void has_external_subset_callback(void *ctx)
|
117
|
+
{
|
118
|
+
VALUE handler = (VALUE) ctx;
|
119
|
+
|
120
|
+
if (handler != Qnil)
|
121
|
+
{
|
122
|
+
rb_funcall(handler, cbidOnHasExternalSubset, 0);
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
static void has_internal_subset_callback(void *ctx)
|
127
|
+
{
|
128
|
+
VALUE handler = (VALUE) ctx;
|
129
|
+
|
130
|
+
if (handler != Qnil)
|
131
|
+
{
|
132
|
+
rb_funcall(handler, cbidOnHasInternalSubset, 0);
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
static void internal_subset_callback(void *ctx, const char *name, const char *extid, const char *sysid)
|
137
|
+
{
|
138
|
+
VALUE handler = (VALUE) ctx;
|
139
|
+
|
140
|
+
if (handler != Qnil)
|
141
|
+
{
|
142
|
+
VALUE rname = name ? rb_str_new2(name) : Qnil;
|
143
|
+
VALUE rextid = extid ? rb_str_new2(extid) : Qnil;
|
144
|
+
VALUE rsysid = sysid ? rb_str_new2(sysid) : Qnil;
|
145
|
+
rb_funcall(handler, cbidOnInternalSubset, 3, rname, rextid, rsysid);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
static void is_standalone_callback(void *ctx)
|
150
|
+
{
|
151
|
+
VALUE handler = (VALUE) ctx;
|
152
|
+
|
153
|
+
if (handler != Qnil)
|
154
|
+
{
|
155
|
+
rb_funcall(handler, cbidOnIsStandalone,0);
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
static void processing_instruction_callback(void *ctx, const char *target, const char *data)
|
160
|
+
{
|
161
|
+
VALUE handler = (VALUE) ctx;
|
162
|
+
|
163
|
+
if (handler != Qnil)
|
164
|
+
{
|
165
|
+
VALUE rtarget = target ? rb_str_new2(target) : Qnil;
|
166
|
+
VALUE rdata = data ? rb_str_new2(data) : Qnil;
|
167
|
+
rb_funcall(handler, cbidOnProcessingInstruction, 2, rtarget, rdata);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
static void reference_callback(void *ctx, const char *name)
|
172
|
+
{
|
173
|
+
VALUE handler = (VALUE) ctx;
|
174
|
+
|
175
|
+
if (handler != Qnil)
|
176
|
+
{
|
177
|
+
rb_funcall(handler, cbidOnReference,1,rb_str_new2(name));
|
178
|
+
}
|
179
|
+
}
|
180
|
+
|
181
|
+
static void start_document_callback(void *ctx)
|
182
|
+
{
|
183
|
+
VALUE handler = (VALUE) ctx;
|
184
|
+
|
185
|
+
if (handler != Qnil)
|
186
|
+
{
|
187
|
+
rb_funcall(handler, cbidOnStartDocument, 0);
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
static void start_element_ns_callback(void *ctx,
|
192
|
+
const xmlChar *xlocalname, const xmlChar *xprefix, const xmlChar *xURI,
|
193
|
+
int nb_namespaces, const xmlChar **xnamespaces,
|
194
|
+
int nb_attributes, int nb_defaulted, const xmlChar **xattributes)
|
195
|
+
{
|
196
|
+
VALUE handler = (VALUE) ctx;
|
197
|
+
VALUE attributes = rb_hash_new();
|
198
|
+
VALUE namespaces = rb_hash_new();
|
199
|
+
|
200
|
+
if (handler == Qnil)
|
201
|
+
return;
|
202
|
+
|
203
|
+
if (xattributes)
|
204
|
+
{
|
205
|
+
/* Each attribute is an array of [localname, prefix, URI, value, end] */
|
206
|
+
int i;
|
207
|
+
for (i = 0;i < nb_attributes * 5; i+=5)
|
208
|
+
{
|
209
|
+
VALUE attrName = rb_str_new2(xattributes[i+0]);
|
210
|
+
VALUE attrValue = rb_str_new(xattributes[i+3], xattributes[i+4] - xattributes[i+3]);
|
211
|
+
/* VALUE attrPrefix = xattributes[i+1] ? rb_str_new2(xattributes[i+1]) : Qnil;
|
212
|
+
VALUE attrURI = xattributes[i+2] ? rb_str_new2(xattributes[i+2]) : Qnil; */
|
213
|
+
|
214
|
+
rb_hash_aset(attributes, attrName, attrValue);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
if (xnamespaces)
|
219
|
+
{
|
220
|
+
int i;
|
221
|
+
for (i = 0;i < nb_namespaces * 2; i+=2)
|
222
|
+
{
|
223
|
+
VALUE nsPrefix = xnamespaces[i+0] ? rb_str_new2(xnamespaces[i+0]) : Qnil;
|
224
|
+
VALUE nsURI = xnamespaces[i+1] ? rb_str_new2(xnamespaces[i+1]) : Qnil;
|
225
|
+
rb_hash_aset(namespaces, nsPrefix, nsURI);
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
/* Call start element for old-times sake */
|
230
|
+
if (rb_respond_to(handler, cbidOnStartElement))
|
231
|
+
{
|
232
|
+
VALUE name;
|
233
|
+
if (xprefix)
|
234
|
+
{
|
235
|
+
name = rb_str_new2(xprefix);
|
236
|
+
rb_str_cat2(name, ":");
|
237
|
+
rb_str_cat2(name, xlocalname);
|
238
|
+
}
|
239
|
+
else
|
240
|
+
{
|
241
|
+
name = rb_str_new2(xlocalname);
|
242
|
+
}
|
243
|
+
rb_funcall(handler, cbidOnStartElement, 2, name, attributes);
|
244
|
+
}
|
245
|
+
|
246
|
+
rb_funcall(handler, cbidOnStartElementNs, 5,
|
247
|
+
rb_str_new2(xlocalname),
|
248
|
+
attributes,
|
249
|
+
xprefix ? rb_str_new2(xprefix) : Qnil,
|
250
|
+
xURI ? rb_str_new2(xURI) : Qnil,
|
251
|
+
namespaces);
|
252
|
+
}
|
253
|
+
|
254
|
+
static void structured_error_callback(void *ctx, xmlErrorPtr xerror)
|
255
|
+
{
|
256
|
+
VALUE handler = (VALUE) ctx;
|
257
|
+
|
258
|
+
if (handler != Qnil)
|
259
|
+
{
|
260
|
+
VALUE error = rxml_error_wrap(xerror);
|
261
|
+
rb_funcall(handler, cbidOnError, 1, error);
|
262
|
+
}
|
263
|
+
}
|
264
|
+
|
265
|
+
/* ====== Handler =========== */
|
266
|
+
xmlSAXHandler rxml_sax_handler = {
|
267
|
+
(internalSubsetSAXFunc) internal_subset_callback,
|
268
|
+
(isStandaloneSAXFunc) is_standalone_callback,
|
269
|
+
(hasInternalSubsetSAXFunc) has_internal_subset_callback,
|
270
|
+
(hasExternalSubsetSAXFunc) has_external_subset_callback,
|
271
|
+
0, /* resolveEntity */
|
272
|
+
0, /* getEntity */
|
273
|
+
0, /* entityDecl */
|
274
|
+
0, /* notationDecl */
|
275
|
+
0, /* attributeDecl */
|
276
|
+
0, /* elementDecl */
|
277
|
+
0, /* unparsedEntityDecl */
|
278
|
+
0, /* setDocumentLocator */
|
279
|
+
(startDocumentSAXFunc) start_document_callback,
|
280
|
+
(endDocumentSAXFunc) end_document_callback,
|
281
|
+
0, /* Use start_element_ns_callback instead */
|
282
|
+
0, /* Use end_element_ns_callback instead */
|
283
|
+
(referenceSAXFunc) reference_callback,
|
284
|
+
(charactersSAXFunc) characters_callback,
|
285
|
+
0, /* ignorableWhitespace */
|
286
|
+
(processingInstructionSAXFunc) processing_instruction_callback,
|
287
|
+
(commentSAXFunc) comment_callback,
|
288
|
+
0, /* xmlStructuredErrorFunc is used instead */
|
289
|
+
0, /* xmlStructuredErrorFunc is used instead */
|
290
|
+
0, /* xmlStructuredErrorFunc is used instead */
|
291
|
+
0, /* xmlGetParameterEntity */
|
292
|
+
(cdataBlockSAXFunc) cdata_block_callback,
|
293
|
+
(externalSubsetSAXFunc) external_subset_callback,
|
294
|
+
XML_SAX2_MAGIC, /* force SAX2 */
|
295
|
+
0, /* _private */
|
296
|
+
(startElementNsSAX2Func) start_element_ns_callback,
|
297
|
+
(endElementNsSAX2Func) end_element_ns_callback,
|
298
|
+
(xmlStructuredErrorFunc) structured_error_callback
|
299
|
+
};
|
300
|
+
|
301
|
+
void rxml_init_sax2_handler(void)
|
302
|
+
{
|
303
|
+
|
304
|
+
/* SaxCallbacks */
|
305
|
+
cbidOnCdataBlock = rb_intern("on_cdata_block");
|
306
|
+
cbidOnCharacters = rb_intern("on_characters");
|
307
|
+
cbidOnComment = rb_intern("on_comment");
|
308
|
+
cbidOnEndDocument = rb_intern("on_end_document");
|
309
|
+
cbidOnEndElement = rb_intern("on_end_element");
|
310
|
+
cbidOnEndElementNs = rb_intern("on_end_element_ns");
|
311
|
+
cbidOnError = rb_intern("on_error");
|
312
|
+
cbidOnExternalSubset = rb_intern("on_external_subset");
|
313
|
+
cbidOnHasExternalSubset = rb_intern("on_has_external_subset");
|
314
|
+
cbidOnHasInternalSubset = rb_intern("on_has_internal_subset");
|
315
|
+
cbidOnInternalSubset = rb_intern("on_internal_subset");
|
316
|
+
cbidOnIsStandalone = rb_intern("on_is_standalone");
|
317
|
+
cbidOnProcessingInstruction = rb_intern("on_processing_instruction");
|
318
|
+
cbidOnReference = rb_intern("on_reference");
|
319
|
+
cbidOnStartElement = rb_intern("on_start_element");
|
320
|
+
cbidOnStartElementNs = rb_intern("on_start_element_ns");
|
321
|
+
cbidOnStartDocument = rb_intern("on_start_document");
|
322
|
+
}
|