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,40 @@
|
|
1
|
+
/* $Id: ruby_xml_html_parser.c 710 2009-01-20 05:30:51Z cfis $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "ruby_libxml.h"
|
6
|
+
|
7
|
+
/* Document-class: LibXML::XML::HTMLParser::Options
|
8
|
+
*
|
9
|
+
* Options to control the operation of the HTMLParser. The easiest
|
10
|
+
* way to set a parser's options is via the methods
|
11
|
+
* XML::HTMLParser.file, XML::HTMLParser.io or XML::HTMLParser.string.
|
12
|
+
* For additional control, see XML::HTMLParser::Context#options=.
|
13
|
+
*/
|
14
|
+
|
15
|
+
VALUE mXMLHtmlParserOptions;
|
16
|
+
|
17
|
+
void rxml_init_html_parser_options(void)
|
18
|
+
{
|
19
|
+
mXMLHtmlParserOptions = rb_define_module_under(cXMLHtmlParser, "Options");
|
20
|
+
|
21
|
+
|
22
|
+
#if LIBXML_VERSION >= 20621
|
23
|
+
/* 1: Relax parsing. */
|
24
|
+
rb_define_const(mXMLHtmlParserOptions, "RECOVER", INT2NUM(HTML_PARSE_RECOVER));
|
25
|
+
#endif
|
26
|
+
/* 32: Suppress error reports. */
|
27
|
+
rb_define_const(mXMLHtmlParserOptions, "NOERROR", INT2NUM(HTML_PARSE_NOERROR));
|
28
|
+
/* 64: Suppress warning reports. */
|
29
|
+
rb_define_const(mXMLHtmlParserOptions, "NOWARNING", INT2NUM(HTML_PARSE_NOWARNING));
|
30
|
+
/* 128: Enable pedantic error reporting. */
|
31
|
+
rb_define_const(mXMLHtmlParserOptions, "PEDANTIC", INT2NUM(HTML_PARSE_PEDANTIC));
|
32
|
+
/* 256: Remove blank nodes. */
|
33
|
+
rb_define_const(mXMLHtmlParserOptions, "NOBLANKS", INT2NUM(HTML_PARSE_NOBLANKS));
|
34
|
+
#if LIBXML_VERSION >= 20621
|
35
|
+
/* 2048: Forbid network access. */
|
36
|
+
rb_define_const(mXMLHtmlParserOptions, "NONET", INT2NUM(HTML_PARSE_NONET));
|
37
|
+
/* 65536: Compact small text nodes. */
|
38
|
+
rb_define_const(mXMLHtmlParserOptions, "COMPACT", INT2NUM(HTML_PARSE_COMPACT));
|
39
|
+
#endif
|
40
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/* $Id: ruby_xml_html_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_HTML_PARSER_OPTIONS__
|
6
|
+
#define __RXML_HTML_PARSER_OPTIONS__
|
7
|
+
|
8
|
+
extern VALUE mXMLHtmlParserOptions;
|
9
|
+
|
10
|
+
void rxml_init_html_parser_options(void);
|
11
|
+
|
12
|
+
#endif
|
Binary file
|
@@ -0,0 +1,191 @@
|
|
1
|
+
/* Author: Martin Povolny (xpovolny@fi.muni.cz) */
|
2
|
+
|
3
|
+
#include "ruby_libxml.h"
|
4
|
+
#include "ruby_xml_input_cbg.h"
|
5
|
+
|
6
|
+
/* Document-class: LibXML::XML::InputCallbacks
|
7
|
+
*
|
8
|
+
* Support for adding custom scheme handlers. */
|
9
|
+
|
10
|
+
static ic_scheme *first_scheme = 0;
|
11
|
+
|
12
|
+
int ic_match(char const *filename)
|
13
|
+
{
|
14
|
+
ic_scheme *scheme;
|
15
|
+
|
16
|
+
//fprintf( stderr, "ic_match: %s\n", filename );
|
17
|
+
|
18
|
+
scheme = first_scheme;
|
19
|
+
while (0 != scheme)
|
20
|
+
{
|
21
|
+
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST scheme->scheme_name, scheme->name_len))
|
22
|
+
{
|
23
|
+
return 1;
|
24
|
+
}
|
25
|
+
scheme = scheme->next_scheme;
|
26
|
+
}
|
27
|
+
return 0;
|
28
|
+
}
|
29
|
+
|
30
|
+
void* ic_open(char const *filename)
|
31
|
+
{
|
32
|
+
ic_doc_context *ic_doc;
|
33
|
+
ic_scheme *scheme;
|
34
|
+
VALUE res;
|
35
|
+
|
36
|
+
scheme = first_scheme;
|
37
|
+
while (0 != scheme)
|
38
|
+
{
|
39
|
+
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST scheme->scheme_name, scheme->name_len))
|
40
|
+
{
|
41
|
+
ic_doc = (ic_doc_context*) malloc(sizeof(ic_doc_context));
|
42
|
+
|
43
|
+
res = rb_funcall(scheme->class, rb_intern("document_query"), 1,
|
44
|
+
rb_str_new2(filename));
|
45
|
+
|
46
|
+
ic_doc->buffer = strdup(StringValuePtr(res));
|
47
|
+
|
48
|
+
ic_doc->bpos = ic_doc->buffer;
|
49
|
+
ic_doc->remaining = strlen(ic_doc->buffer);
|
50
|
+
return ic_doc;
|
51
|
+
}
|
52
|
+
scheme = scheme->next_scheme;
|
53
|
+
}
|
54
|
+
return 0;
|
55
|
+
}
|
56
|
+
|
57
|
+
int ic_read(void *context, char *buffer, int len)
|
58
|
+
{
|
59
|
+
ic_doc_context *ic_doc;
|
60
|
+
int ret_len;
|
61
|
+
ic_doc = (ic_doc_context*) context;
|
62
|
+
|
63
|
+
if (len >= ic_doc->remaining)
|
64
|
+
{
|
65
|
+
ret_len = ic_doc->remaining;
|
66
|
+
}
|
67
|
+
else
|
68
|
+
{
|
69
|
+
ret_len = len;
|
70
|
+
}
|
71
|
+
ic_doc->remaining -= ret_len;
|
72
|
+
strncpy(buffer, ic_doc->bpos, ret_len);
|
73
|
+
ic_doc->bpos += ret_len;
|
74
|
+
|
75
|
+
return ret_len;
|
76
|
+
}
|
77
|
+
|
78
|
+
int ic_close(void *context)
|
79
|
+
{
|
80
|
+
ruby_xfree(((ic_doc_context*) context)->buffer);
|
81
|
+
ruby_xfree(context);
|
82
|
+
return 1;
|
83
|
+
}
|
84
|
+
|
85
|
+
/*
|
86
|
+
* call-seq:
|
87
|
+
* register
|
88
|
+
*
|
89
|
+
* Register a new set of I/O callback for handling parser input.
|
90
|
+
*/
|
91
|
+
static VALUE input_callbacks_register_input_callbacks()
|
92
|
+
{
|
93
|
+
xmlRegisterInputCallbacks(ic_match, ic_open, ic_read, ic_close);
|
94
|
+
return (Qtrue);
|
95
|
+
}
|
96
|
+
|
97
|
+
/*
|
98
|
+
* call-seq:
|
99
|
+
* add_scheme
|
100
|
+
*
|
101
|
+
* No documentation available.
|
102
|
+
*/
|
103
|
+
static VALUE input_callbacks_add_scheme(VALUE self, VALUE scheme_name,
|
104
|
+
VALUE class)
|
105
|
+
{
|
106
|
+
ic_scheme *scheme;
|
107
|
+
|
108
|
+
Check_Type(scheme_name, T_STRING);
|
109
|
+
|
110
|
+
scheme = (ic_scheme*) malloc(sizeof(ic_scheme));
|
111
|
+
scheme->next_scheme = 0;
|
112
|
+
scheme->scheme_name = strdup(StringValuePtr(scheme_name)); /* TODO alloc, dealloc */
|
113
|
+
scheme->name_len = strlen(scheme->scheme_name);
|
114
|
+
scheme->class = class; /* TODO alloc, dealloc */
|
115
|
+
|
116
|
+
//fprintf( stderr, "registered: %s, %d, %s\n", scheme->scheme_name, scheme->name_len, scheme->class );
|
117
|
+
|
118
|
+
if (0 == first_scheme)
|
119
|
+
first_scheme = scheme;
|
120
|
+
else
|
121
|
+
{
|
122
|
+
ic_scheme *pos;
|
123
|
+
pos = first_scheme;
|
124
|
+
while (0 != pos->next_scheme)
|
125
|
+
pos = pos->next_scheme;
|
126
|
+
pos->next_scheme = scheme;
|
127
|
+
}
|
128
|
+
|
129
|
+
return (Qtrue);
|
130
|
+
}
|
131
|
+
|
132
|
+
/*
|
133
|
+
* call-seq:
|
134
|
+
* remove_scheme
|
135
|
+
*
|
136
|
+
* No documentation available.
|
137
|
+
*/
|
138
|
+
static VALUE input_callbacks_remove_scheme(VALUE self, VALUE scheme_name)
|
139
|
+
{
|
140
|
+
char *name;
|
141
|
+
ic_scheme *save_scheme, *scheme;
|
142
|
+
|
143
|
+
Check_Type(scheme_name, T_STRING);
|
144
|
+
name = StringValuePtr(scheme_name);
|
145
|
+
|
146
|
+
if (0 == first_scheme)
|
147
|
+
return Qfalse;
|
148
|
+
|
149
|
+
if (!strncmp(name, first_scheme->scheme_name, first_scheme->name_len))
|
150
|
+
{
|
151
|
+
save_scheme = first_scheme->next_scheme;
|
152
|
+
|
153
|
+
ruby_xfree(first_scheme->scheme_name);
|
154
|
+
ruby_xfree(first_scheme);
|
155
|
+
|
156
|
+
first_scheme = save_scheme;
|
157
|
+
return Qtrue;
|
158
|
+
}
|
159
|
+
|
160
|
+
scheme = first_scheme;
|
161
|
+
while (0 != scheme->next_scheme)
|
162
|
+
{
|
163
|
+
if (!strncmp(name, scheme->next_scheme->scheme_name,
|
164
|
+
scheme->next_scheme->name_len))
|
165
|
+
{
|
166
|
+
save_scheme = scheme->next_scheme->next_scheme;
|
167
|
+
|
168
|
+
ruby_xfree(scheme->next_scheme->scheme_name);
|
169
|
+
ruby_xfree(scheme->next_scheme);
|
170
|
+
|
171
|
+
scheme->next_scheme = save_scheme;
|
172
|
+
return Qtrue;
|
173
|
+
}
|
174
|
+
scheme = scheme->next_scheme;
|
175
|
+
}
|
176
|
+
return Qfalse;
|
177
|
+
}
|
178
|
+
|
179
|
+
void rxml_init_input_callbacks(void)
|
180
|
+
{
|
181
|
+
VALUE cInputCallbacks;
|
182
|
+
cInputCallbacks = rb_define_class_under(mXML, "InputCallbacks", rb_cObject);
|
183
|
+
|
184
|
+
/* Class Methods */
|
185
|
+
rb_define_singleton_method(cInputCallbacks, "register",
|
186
|
+
input_callbacks_register_input_callbacks, 0);
|
187
|
+
rb_define_singleton_method(cInputCallbacks, "add_scheme",
|
188
|
+
input_callbacks_add_scheme, 2);
|
189
|
+
rb_define_singleton_method(cInputCallbacks, "remove_scheme",
|
190
|
+
input_callbacks_remove_scheme, 1);
|
191
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#ifndef _INPUT_CBG_
|
2
|
+
#define _INPUT_CBG_
|
3
|
+
|
4
|
+
void rxml_init_input_callbacks(void);
|
5
|
+
|
6
|
+
typedef struct ic_doc_context {
|
7
|
+
char *buffer;
|
8
|
+
char *bpos;
|
9
|
+
int remaining;
|
10
|
+
} ic_doc_context;
|
11
|
+
|
12
|
+
typedef struct ic_scheme {
|
13
|
+
char *scheme_name;
|
14
|
+
VALUE class;
|
15
|
+
int name_len;
|
16
|
+
|
17
|
+
struct ic_scheme *next_scheme;
|
18
|
+
} ic_scheme;
|
19
|
+
|
20
|
+
#endif
|
Binary file
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/* $Id: libxml.c 734 2009-01-22 04:41:07Z cfis $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "ruby_libxml.h"
|
6
|
+
|
7
|
+
static ID READ_METHOD;
|
8
|
+
|
9
|
+
/* This method is called by libxml when it wants to read
|
10
|
+
more data from a stream. We go with the duck typing
|
11
|
+
solution to support StringIO objects. */
|
12
|
+
int rxml_read_callback(void *context, char *buffer, int len)
|
13
|
+
{
|
14
|
+
VALUE io = (VALUE) context;
|
15
|
+
VALUE string = rb_funcall(io, READ_METHOD, 1, INT2NUM(len));
|
16
|
+
int size;
|
17
|
+
|
18
|
+
if (string == Qnil)
|
19
|
+
return 0;
|
20
|
+
|
21
|
+
size = RSTRING_LEN(string);
|
22
|
+
memcpy(buffer, StringValuePtr(string), size);
|
23
|
+
|
24
|
+
return size;
|
25
|
+
}
|
26
|
+
|
27
|
+
void rxml_init_io(void)
|
28
|
+
{
|
29
|
+
READ_METHOD = rb_intern("read");
|
30
|
+
}
|
Binary file
|
@@ -0,0 +1,170 @@
|
|
1
|
+
/* $Id: ruby_xml_namespace.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_namespace.h"
|
7
|
+
|
8
|
+
VALUE cXMLNamespace;
|
9
|
+
|
10
|
+
/* Document-class: LibXML::XML::Namespace
|
11
|
+
*
|
12
|
+
* The Namespace class represents an XML namespace.
|
13
|
+
* To add a namespace to a node, create a new instance
|
14
|
+
* of this class. Note that this does *not* assign the
|
15
|
+
* node to the namespace. To do that see the
|
16
|
+
* XML::Namespaces#namespace method.
|
17
|
+
*
|
18
|
+
* Usage:
|
19
|
+
*
|
20
|
+
* node = XML::Node.new('<Envelope>')
|
21
|
+
* XML::Namespace.new(node, 'soap', 'http://schemas.xmlsoap.org/soap/envelope/')
|
22
|
+
* assert_equal("<Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"/>", node.to_s)
|
23
|
+
* assert_nil(node.namespaces.namespace)
|
24
|
+
*/
|
25
|
+
|
26
|
+
static void rxml_namespace_free(xmlNsPtr xns)
|
27
|
+
{
|
28
|
+
xns->_private = NULL;
|
29
|
+
}
|
30
|
+
|
31
|
+
static VALUE rxml_namespace_alloc(VALUE klass)
|
32
|
+
{
|
33
|
+
return Data_Wrap_Struct(klass, NULL, rxml_namespace_free, NULL);
|
34
|
+
}
|
35
|
+
|
36
|
+
VALUE rxml_namespace_wrap(xmlNsPtr xns, RUBY_DATA_FUNC freeFunc)
|
37
|
+
{
|
38
|
+
if (xns->_private)
|
39
|
+
{
|
40
|
+
return (VALUE)xns->_private;
|
41
|
+
}
|
42
|
+
else
|
43
|
+
{
|
44
|
+
VALUE ns;
|
45
|
+
if (freeFunc == NULL)
|
46
|
+
freeFunc = (RUBY_DATA_FUNC)rxml_namespace_free;
|
47
|
+
|
48
|
+
ns = Data_Wrap_Struct(cXMLNamespace, NULL, freeFunc, xns);
|
49
|
+
xns->_private = (void*)ns;
|
50
|
+
return ns;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
/*
|
55
|
+
* call-seq:
|
56
|
+
* initialize(node, "prefix", "href") -> XML::Namespace
|
57
|
+
*
|
58
|
+
* Create a new namespace and adds it to the specified node.
|
59
|
+
* Note this does *not* assign the node to the namespace.
|
60
|
+
* To do that see the XML::Namespaces#namespace method.
|
61
|
+
*/
|
62
|
+
static VALUE rxml_namespace_initialize(VALUE self, VALUE node, VALUE prefix,
|
63
|
+
VALUE href)
|
64
|
+
{
|
65
|
+
xmlNodePtr xnode;
|
66
|
+
xmlChar *xmlPrefix;
|
67
|
+
xmlNsPtr xns;
|
68
|
+
|
69
|
+
Check_Type(node, T_DATA);
|
70
|
+
Data_Get_Struct(node, xmlNode, xnode);
|
71
|
+
|
72
|
+
/* Prefix can be null - that means its the default namespace */
|
73
|
+
xmlPrefix = NIL_P(prefix) ? NULL : (xmlChar *)StringValuePtr(prefix);
|
74
|
+
xns = xmlNewNs(xnode, (xmlChar*) StringValuePtr(href), xmlPrefix);
|
75
|
+
|
76
|
+
if (!xns)
|
77
|
+
rxml_raise(&xmlLastError);
|
78
|
+
|
79
|
+
xns->_private = (void*)self;
|
80
|
+
DATA_PTR(self) = xns;
|
81
|
+
return self;
|
82
|
+
}
|
83
|
+
|
84
|
+
/*
|
85
|
+
* call-seq:
|
86
|
+
* ns.href -> "href"
|
87
|
+
*
|
88
|
+
* Usage:
|
89
|
+
*
|
90
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
91
|
+
* ns = doc.root.namespaces.find_by_href('http://schemas.xmlsoap.org/soap/envelope/')
|
92
|
+
* assert_equal('http://schemas.xmlsoap.org/soap/envelope/', ns.href)
|
93
|
+
*/
|
94
|
+
static VALUE rxml_namespace_href_get(VALUE self)
|
95
|
+
{
|
96
|
+
xmlNsPtr xns;
|
97
|
+
Data_Get_Struct(self, xmlNs, xns);
|
98
|
+
if (xns->href == NULL)
|
99
|
+
return Qnil;
|
100
|
+
else
|
101
|
+
return rb_str_new2((const char*) xns->href);
|
102
|
+
}
|
103
|
+
|
104
|
+
/*
|
105
|
+
* call-seq:
|
106
|
+
* ns.node_type -> num
|
107
|
+
*
|
108
|
+
* Obtain this namespace's type identifier.
|
109
|
+
*/
|
110
|
+
static VALUE rxml_namespace_node_type(VALUE self)
|
111
|
+
{
|
112
|
+
xmlNsPtr xns;
|
113
|
+
Data_Get_Struct(self, xmlNs, xns);
|
114
|
+
return INT2NUM(xns->type);
|
115
|
+
}
|
116
|
+
|
117
|
+
/*
|
118
|
+
* call-seq:
|
119
|
+
* ns.prefix -> "prefix"
|
120
|
+
*
|
121
|
+
* Obtain the namespace's prefix.
|
122
|
+
*
|
123
|
+
* Usage:
|
124
|
+
*
|
125
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
126
|
+
* ns = doc.root.namespaces.find_by_href('http://schemas.xmlsoap.org/soap/envelope/')
|
127
|
+
* assert_equal('soap', ns.prefix)
|
128
|
+
*/
|
129
|
+
static VALUE rxml_namespace_prefix_get(VALUE self)
|
130
|
+
{
|
131
|
+
xmlNsPtr xns;
|
132
|
+
Data_Get_Struct(self, xmlNs, xns);
|
133
|
+
if (xns->prefix == NULL)
|
134
|
+
return Qnil;
|
135
|
+
else
|
136
|
+
return rb_str_new2((const char*) xns->prefix);
|
137
|
+
}
|
138
|
+
|
139
|
+
/*
|
140
|
+
* call-seq:
|
141
|
+
* ns.next -> XML::Namespace
|
142
|
+
*
|
143
|
+
* Obtain the next namespace.
|
144
|
+
*
|
145
|
+
* Usage:
|
146
|
+
*
|
147
|
+
* doc = XML::Document.string('<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"/>')
|
148
|
+
* ns = doc.root.namespaces.find_by_href('http://schemas.xmlsoap.org/soap/envelope/')
|
149
|
+
* assert_nil(ns.next)
|
150
|
+
*/
|
151
|
+
static VALUE rxml_namespace_next(VALUE self)
|
152
|
+
{
|
153
|
+
xmlNsPtr xns;
|
154
|
+
Data_Get_Struct(self, xmlNs, xns);
|
155
|
+
if (xns == NULL || xns->next == NULL)
|
156
|
+
return (Qnil);
|
157
|
+
else
|
158
|
+
return (rxml_namespace_wrap(xns->next, NULL));
|
159
|
+
}
|
160
|
+
|
161
|
+
void rxml_init_namespace(void)
|
162
|
+
{
|
163
|
+
cXMLNamespace = rb_define_class_under(mXML, "Namespace", rb_cObject);
|
164
|
+
rb_define_alloc_func(cXMLNamespace, rxml_namespace_alloc);
|
165
|
+
rb_define_method(cXMLNamespace, "initialize", rxml_namespace_initialize, 3);
|
166
|
+
rb_define_method(cXMLNamespace, "href", rxml_namespace_href_get, 0);
|
167
|
+
rb_define_method(cXMLNamespace, "next", rxml_namespace_next, 0);
|
168
|
+
rb_define_method(cXMLNamespace, "node_type", rxml_namespace_node_type, 0);
|
169
|
+
rb_define_method(cXMLNamespace, "prefix", rxml_namespace_prefix_get, 0);
|
170
|
+
}
|