libxml-ruby 2.9.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/HISTORY +790 -0
- data/LICENSE +21 -0
- data/MANIFEST +166 -0
- data/README.rdoc +184 -0
- data/Rakefile +81 -0
- data/ext/libxml/extconf.h +4 -0
- data/ext/libxml/extconf.rb +57 -0
- data/ext/libxml/libxml.c +80 -0
- data/ext/libxml/libxml_ruby.def +35 -0
- data/ext/libxml/ruby_libxml.h +75 -0
- data/ext/libxml/ruby_xml.c +977 -0
- data/ext/libxml/ruby_xml.h +20 -0
- data/ext/libxml/ruby_xml_attr.c +333 -0
- data/ext/libxml/ruby_xml_attr.h +12 -0
- data/ext/libxml/ruby_xml_attr_decl.c +153 -0
- data/ext/libxml/ruby_xml_attr_decl.h +11 -0
- data/ext/libxml/ruby_xml_attributes.c +275 -0
- data/ext/libxml/ruby_xml_attributes.h +15 -0
- data/ext/libxml/ruby_xml_cbg.c +85 -0
- data/ext/libxml/ruby_xml_document.c +1133 -0
- data/ext/libxml/ruby_xml_document.h +11 -0
- data/ext/libxml/ruby_xml_dtd.c +261 -0
- data/ext/libxml/ruby_xml_dtd.h +9 -0
- data/ext/libxml/ruby_xml_encoding.c +262 -0
- data/ext/libxml/ruby_xml_encoding.h +19 -0
- data/ext/libxml/ruby_xml_error.c +996 -0
- data/ext/libxml/ruby_xml_error.h +12 -0
- data/ext/libxml/ruby_xml_html_parser.c +92 -0
- data/ext/libxml/ruby_xml_html_parser.h +10 -0
- data/ext/libxml/ruby_xml_html_parser_context.c +337 -0
- data/ext/libxml/ruby_xml_html_parser_context.h +10 -0
- data/ext/libxml/ruby_xml_html_parser_options.c +46 -0
- data/ext/libxml/ruby_xml_html_parser_options.h +10 -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_io.c +52 -0
- data/ext/libxml/ruby_xml_io.h +10 -0
- data/ext/libxml/ruby_xml_namespace.c +153 -0
- data/ext/libxml/ruby_xml_namespace.h +10 -0
- data/ext/libxml/ruby_xml_namespaces.c +293 -0
- data/ext/libxml/ruby_xml_namespaces.h +9 -0
- data/ext/libxml/ruby_xml_node.c +1446 -0
- data/ext/libxml/ruby_xml_node.h +11 -0
- data/ext/libxml/ruby_xml_parser.c +94 -0
- data/ext/libxml/ruby_xml_parser.h +12 -0
- data/ext/libxml/ruby_xml_parser_context.c +999 -0
- data/ext/libxml/ruby_xml_parser_context.h +10 -0
- data/ext/libxml/ruby_xml_parser_options.c +66 -0
- data/ext/libxml/ruby_xml_parser_options.h +12 -0
- data/ext/libxml/ruby_xml_reader.c +1226 -0
- data/ext/libxml/ruby_xml_reader.h +17 -0
- data/ext/libxml/ruby_xml_relaxng.c +110 -0
- data/ext/libxml/ruby_xml_relaxng.h +10 -0
- data/ext/libxml/ruby_xml_sax2_handler.c +326 -0
- data/ext/libxml/ruby_xml_sax2_handler.h +10 -0
- data/ext/libxml/ruby_xml_sax_parser.c +120 -0
- data/ext/libxml/ruby_xml_sax_parser.h +10 -0
- data/ext/libxml/ruby_xml_schema.c +300 -0
- data/ext/libxml/ruby_xml_schema.h +809 -0
- data/ext/libxml/ruby_xml_schema_attribute.c +109 -0
- data/ext/libxml/ruby_xml_schema_attribute.h +15 -0
- data/ext/libxml/ruby_xml_schema_element.c +94 -0
- data/ext/libxml/ruby_xml_schema_element.h +14 -0
- data/ext/libxml/ruby_xml_schema_facet.c +52 -0
- data/ext/libxml/ruby_xml_schema_facet.h +13 -0
- data/ext/libxml/ruby_xml_schema_type.c +259 -0
- data/ext/libxml/ruby_xml_schema_type.h +9 -0
- data/ext/libxml/ruby_xml_version.h +9 -0
- data/ext/libxml/ruby_xml_writer.c +1136 -0
- data/ext/libxml/ruby_xml_writer.h +10 -0
- data/ext/libxml/ruby_xml_xinclude.c +16 -0
- data/ext/libxml/ruby_xml_xinclude.h +11 -0
- data/ext/libxml/ruby_xml_xpath.c +188 -0
- data/ext/libxml/ruby_xml_xpath.h +13 -0
- data/ext/libxml/ruby_xml_xpath_context.c +360 -0
- data/ext/libxml/ruby_xml_xpath_context.h +9 -0
- data/ext/libxml/ruby_xml_xpath_expression.c +81 -0
- data/ext/libxml/ruby_xml_xpath_expression.h +10 -0
- data/ext/libxml/ruby_xml_xpath_object.c +335 -0
- data/ext/libxml/ruby_xml_xpath_object.h +17 -0
- data/ext/libxml/ruby_xml_xpointer.c +99 -0
- data/ext/libxml/ruby_xml_xpointer.h +11 -0
- data/ext/vc/libxml_ruby.sln +26 -0
- data/lib/2.3/libxml_ruby.so +0 -0
- data/lib/libs/libiconv-2.dll +0 -0
- data/lib/libs/libxml2-2.dll +0 -0
- data/lib/libs/zlib1.dll +0 -0
- data/lib/libxml.rb +35 -0
- data/lib/libxml/attr.rb +123 -0
- data/lib/libxml/attr_decl.rb +80 -0
- data/lib/libxml/attributes.rb +14 -0
- data/lib/libxml/document.rb +194 -0
- data/lib/libxml/error.rb +95 -0
- data/lib/libxml/hpricot.rb +78 -0
- data/lib/libxml/html_parser.rb +96 -0
- data/lib/libxml/namespace.rb +62 -0
- data/lib/libxml/namespaces.rb +38 -0
- data/lib/libxml/node.rb +399 -0
- data/lib/libxml/ns.rb +22 -0
- data/lib/libxml/parser.rb +367 -0
- data/lib/libxml/properties.rb +23 -0
- data/lib/libxml/reader.rb +29 -0
- data/lib/libxml/sax_callbacks.rb +180 -0
- data/lib/libxml/sax_parser.rb +58 -0
- data/lib/libxml/schema.rb +67 -0
- data/lib/libxml/schema/attribute.rb +19 -0
- data/lib/libxml/schema/element.rb +27 -0
- data/lib/libxml/schema/type.rb +29 -0
- data/lib/libxml/tree.rb +29 -0
- data/lib/libxml/xpath_object.rb +16 -0
- data/lib/xml.rb +14 -0
- data/lib/xml/libxml.rb +10 -0
- data/libxml-ruby.gemspec +47 -0
- data/script/benchmark/depixelate +634 -0
- data/script/benchmark/hamlet.xml +9055 -0
- data/script/benchmark/parsecount +170 -0
- data/script/benchmark/sock_entries.xml +507 -0
- data/script/benchmark/throughput +41 -0
- data/script/test +6 -0
- data/setup.rb +1585 -0
- data/test/c14n/given/doc.dtd +1 -0
- data/test/c14n/given/example-1.xml +14 -0
- data/test/c14n/given/example-2.xml +11 -0
- data/test/c14n/given/example-3.xml +18 -0
- data/test/c14n/given/example-4.xml +9 -0
- data/test/c14n/given/example-5.xml +12 -0
- data/test/c14n/given/example-6.xml +2 -0
- data/test/c14n/given/example-7.xml +11 -0
- data/test/c14n/given/example-8.xml +11 -0
- data/test/c14n/given/example-8.xpath +10 -0
- data/test/c14n/given/world.txt +1 -0
- data/test/c14n/result/1-1-without-comments/example-1 +4 -0
- data/test/c14n/result/1-1-without-comments/example-2 +11 -0
- data/test/c14n/result/1-1-without-comments/example-3 +14 -0
- data/test/c14n/result/1-1-without-comments/example-4 +9 -0
- data/test/c14n/result/1-1-without-comments/example-5 +3 -0
- data/test/c14n/result/1-1-without-comments/example-6 +1 -0
- data/test/c14n/result/1-1-without-comments/example-7 +1 -0
- data/test/c14n/result/1-1-without-comments/example-8 +1 -0
- data/test/c14n/result/with-comments/example-1 +6 -0
- data/test/c14n/result/with-comments/example-2 +11 -0
- data/test/c14n/result/with-comments/example-3 +14 -0
- data/test/c14n/result/with-comments/example-4 +9 -0
- data/test/c14n/result/with-comments/example-5 +4 -0
- data/test/c14n/result/with-comments/example-6 +1 -0
- data/test/c14n/result/with-comments/example-7 +1 -0
- data/test/c14n/result/without-comments/example-1 +4 -0
- data/test/c14n/result/without-comments/example-2 +11 -0
- data/test/c14n/result/without-comments/example-3 +14 -0
- data/test/c14n/result/without-comments/example-4 +9 -0
- data/test/c14n/result/without-comments/example-5 +3 -0
- data/test/c14n/result/without-comments/example-6 +1 -0
- data/test/c14n/result/without-comments/example-7 +1 -0
- data/test/model/atom.xml +13 -0
- data/test/model/bands.iso-8859-1.xml +5 -0
- data/test/model/bands.utf-8.xml +5 -0
- data/test/model/bands.xml +5 -0
- data/test/model/books.xml +154 -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 +40 -0
- data/test/model/soap.xml +27 -0
- data/test/model/xinclude.xml +5 -0
- data/test/tc_attr.rb +181 -0
- data/test/tc_attr_decl.rb +132 -0
- data/test/tc_attributes.rb +142 -0
- data/test/tc_canonicalize.rb +124 -0
- data/test/tc_deprecated_require.rb +12 -0
- data/test/tc_document.rb +125 -0
- data/test/tc_document_write.rb +195 -0
- data/test/tc_dtd.rb +128 -0
- data/test/tc_encoding.rb +126 -0
- data/test/tc_encoding_sax.rb +115 -0
- data/test/tc_error.rb +179 -0
- data/test/tc_html_parser.rb +161 -0
- data/test/tc_html_parser_context.rb +23 -0
- data/test/tc_namespace.rb +61 -0
- data/test/tc_namespaces.rb +209 -0
- data/test/tc_node.rb +215 -0
- data/test/tc_node_cdata.rb +50 -0
- data/test/tc_node_comment.rb +32 -0
- data/test/tc_node_copy.rb +41 -0
- data/test/tc_node_edit.rb +174 -0
- data/test/tc_node_pi.rb +39 -0
- data/test/tc_node_text.rb +70 -0
- data/test/tc_node_write.rb +107 -0
- data/test/tc_node_xlink.rb +28 -0
- data/test/tc_parser.rb +375 -0
- data/test/tc_parser_context.rb +204 -0
- data/test/tc_properties.rb +38 -0
- data/test/tc_reader.rb +399 -0
- data/test/tc_relaxng.rb +53 -0
- data/test/tc_sax_parser.rb +319 -0
- data/test/tc_schema.rb +161 -0
- data/test/tc_traversal.rb +152 -0
- data/test/tc_writer.rb +447 -0
- data/test/tc_xinclude.rb +20 -0
- data/test/tc_xml.rb +225 -0
- data/test/tc_xpath.rb +244 -0
- data/test/tc_xpath_context.rb +88 -0
- data/test/tc_xpath_expression.rb +37 -0
- data/test/tc_xpointer.rb +72 -0
- data/test/test_helper.rb +16 -0
- data/test/test_suite.rb +49 -0
- metadata +344 -0
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'mkmf'
|
4
|
+
|
5
|
+
def crash(str)
|
6
|
+
printf(" extconf failure: %s\n", str)
|
7
|
+
exit 1
|
8
|
+
end
|
9
|
+
|
10
|
+
xc = with_config('xml2-config')
|
11
|
+
if xc
|
12
|
+
cflags = `#{xc} --cflags`.chomp
|
13
|
+
if $? != 0
|
14
|
+
cflags = nil
|
15
|
+
else
|
16
|
+
libs = `#{xc} --libs`.chomp
|
17
|
+
if $? != 0
|
18
|
+
libs = nil
|
19
|
+
else
|
20
|
+
$CFLAGS += ' ' + cflags
|
21
|
+
$libs = libs + " " + $libs
|
22
|
+
end
|
23
|
+
end
|
24
|
+
else
|
25
|
+
dir_config('xml2')
|
26
|
+
end
|
27
|
+
|
28
|
+
unless find_header('libxml/xmlversion.h',
|
29
|
+
'/opt/include/libxml2',
|
30
|
+
'/opt/local/include/libxml2',
|
31
|
+
'/usr/local/include/libxml2',
|
32
|
+
'/usr/include/libxml2') &&
|
33
|
+
find_library('xml2', 'xmlParseDoc',
|
34
|
+
'/opt/lib',
|
35
|
+
'/opt/local/lib',
|
36
|
+
'/usr/local/lib',
|
37
|
+
'/usr/lib')
|
38
|
+
crash(<<EOL)
|
39
|
+
need libxml2.
|
40
|
+
|
41
|
+
Install the library or try one of the following options to extconf.rb:
|
42
|
+
|
43
|
+
--with-xml2-config=/path/to/xml2-config
|
44
|
+
--with-xml2-dir=/path/to/libxml2
|
45
|
+
--with-xml2-lib=/path/to/libxml2/lib
|
46
|
+
--with-xml2-include=/path/to/libxml2/include
|
47
|
+
EOL
|
48
|
+
end
|
49
|
+
|
50
|
+
have_func('rb_io_bufwrite', 'ruby/io.h')
|
51
|
+
|
52
|
+
# For FreeBSD add /usr/local/include
|
53
|
+
$INCFLAGS << " -I/usr/local/include"
|
54
|
+
$CFLAGS << ' ' << $INCFLAGS
|
55
|
+
|
56
|
+
create_header()
|
57
|
+
create_makefile('libxml_ruby')
|
data/ext/libxml/libxml.c
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
#include "ruby_libxml.h"
|
2
|
+
|
3
|
+
#if RUBY_INTERN_H
|
4
|
+
#include <ruby/util.h>
|
5
|
+
#else
|
6
|
+
#include <util.h>
|
7
|
+
#endif
|
8
|
+
|
9
|
+
|
10
|
+
VALUE mLibXML;
|
11
|
+
|
12
|
+
static void rxml_init_memory(void)
|
13
|
+
{
|
14
|
+
/* Disable for now - broke attributes.
|
15
|
+
xmlGcMemSetup(
|
16
|
+
(xmlFreeFunc)ruby_xfree,
|
17
|
+
(xmlMallocFunc)ruby_xmalloc,
|
18
|
+
(xmlMallocFunc)ruby_xmalloc,
|
19
|
+
(xmlReallocFunc)ruby_xrealloc,
|
20
|
+
(xmlStrdupFunc)ruby_strdup
|
21
|
+
);*/
|
22
|
+
}
|
23
|
+
|
24
|
+
void Init_libxml_ruby(void)
|
25
|
+
{
|
26
|
+
/* The libxml gem provides Ruby language bindings for GNOME's Libxml2
|
27
|
+
* XML toolkit. To get started you may:
|
28
|
+
*
|
29
|
+
* require 'test_helper'
|
30
|
+
* document = XML::Document.new
|
31
|
+
*
|
32
|
+
* However, when creating an application or library you plan to
|
33
|
+
* redistribute, it is best to not add the LibXML module to the global
|
34
|
+
* namespace, in which case you can either write your code like this:
|
35
|
+
*
|
36
|
+
* require 'libxml'
|
37
|
+
* document = LibXML::XML::Document.new
|
38
|
+
*
|
39
|
+
* Refer to the README file to get started and the LICENSE file for
|
40
|
+
* copyright and distribution information.
|
41
|
+
*/
|
42
|
+
|
43
|
+
// Seutp for threading. http://xmlsoft.org/threads.html
|
44
|
+
xmlInitParser();
|
45
|
+
|
46
|
+
mLibXML = rb_define_module("LibXML");
|
47
|
+
|
48
|
+
rxml_init_memory();
|
49
|
+
rxml_init_xml();
|
50
|
+
rxml_init_io();
|
51
|
+
rxml_init_error();
|
52
|
+
rxml_init_encoding();
|
53
|
+
rxml_init_parser();
|
54
|
+
rxml_init_parser_context();
|
55
|
+
rxml_init_parser_options();
|
56
|
+
rxml_init_node();
|
57
|
+
rxml_init_attributes();
|
58
|
+
rxml_init_attr();
|
59
|
+
rxml_init_attr_decl();
|
60
|
+
rxml_init_document();
|
61
|
+
rxml_init_namespaces();
|
62
|
+
rxml_init_namespace();
|
63
|
+
rxml_init_sax_parser();
|
64
|
+
rxml_init_sax2_handler();
|
65
|
+
rxml_init_xinclude();
|
66
|
+
rxml_init_xpath();
|
67
|
+
rxml_init_xpath_object();
|
68
|
+
rxml_init_xpath_context();
|
69
|
+
rxml_init_xpath_expression();
|
70
|
+
rxml_init_xpointer();
|
71
|
+
rxml_init_html_parser();
|
72
|
+
rxml_init_html_parser_options();
|
73
|
+
rxml_init_html_parser_context();
|
74
|
+
rxml_init_input_callbacks();
|
75
|
+
rxml_init_dtd();
|
76
|
+
rxml_init_schema();
|
77
|
+
rxml_init_relaxng();
|
78
|
+
rxml_init_reader();
|
79
|
+
rxml_init_writer();
|
80
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
LIBRARY libxml_ruby.so
|
2
|
+
EXPORTS
|
3
|
+
Init_libxml_ruby
|
4
|
+
rxml_document_wrap
|
5
|
+
rxml_xpath_to_value
|
6
|
+
rxml_xpath_from_value
|
7
|
+
|
8
|
+
cXMLAttr DATA
|
9
|
+
cXMLAttrDecl DATA
|
10
|
+
cXMLAttributes DATA
|
11
|
+
cXMLDocument DATA
|
12
|
+
cXMLDtd DATA
|
13
|
+
cXMLHtmlParser DATA
|
14
|
+
cXMLHtmlParserContext DATA
|
15
|
+
cXMLNamespace DATA
|
16
|
+
cXMLNamespaces DATA
|
17
|
+
cXMLNode DATA
|
18
|
+
cXMLParser DATA
|
19
|
+
cXMLParserContext DATA
|
20
|
+
cXMLReader DATA
|
21
|
+
cXMLRelaxNG DATA
|
22
|
+
cXMLSaxParser DATA
|
23
|
+
cXMLSchema DATA
|
24
|
+
cXMLXInclude DATA
|
25
|
+
cXMLXPathContext DATA
|
26
|
+
cXMLXPathExpression DATA
|
27
|
+
cXMLXPathObject DATA
|
28
|
+
cXMLXPointer DATA
|
29
|
+
eXMLError DATA
|
30
|
+
mLibXML DATA
|
31
|
+
mXML DATA
|
32
|
+
mXMLEncoding DATA
|
33
|
+
mXMLHtmlParserOptions DATA
|
34
|
+
mXMLParserOptions DATA
|
35
|
+
mXPath DATA
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
2
|
+
|
3
|
+
#ifndef __RUBY_LIBXML_H__
|
4
|
+
#define __RUBY_LIBXML_H__
|
5
|
+
|
6
|
+
#include <ruby.h>
|
7
|
+
#include <libxml/parser.h>
|
8
|
+
#include <libxml/parserInternals.h>
|
9
|
+
#include <libxml/debugXML.h>
|
10
|
+
#include <libxml/xmlversion.h>
|
11
|
+
#include <libxml/xmlmemory.h>
|
12
|
+
#include <libxml/xpath.h>
|
13
|
+
#include <libxml/valid.h>
|
14
|
+
#include <libxml/catalog.h>
|
15
|
+
#include <libxml/HTMLparser.h>
|
16
|
+
#include <libxml/xmlreader.h>
|
17
|
+
#include <libxml/c14n.h>
|
18
|
+
|
19
|
+
/* Needed prior to Ruby 1.9.1 */
|
20
|
+
#ifndef RHASH_TBL
|
21
|
+
#define RHASH_TBL(s) (RHASH(s)->tbl)
|
22
|
+
#endif
|
23
|
+
|
24
|
+
// Encoding support added in Ruby 1.9.*
|
25
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
26
|
+
#include <ruby/encoding.h>
|
27
|
+
#endif
|
28
|
+
|
29
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
30
|
+
#include <libxml/xpathInternals.h>
|
31
|
+
#endif
|
32
|
+
#ifdef LIBXML_XINCLUDE_ENABLED
|
33
|
+
#include <libxml/xinclude.h>
|
34
|
+
#endif
|
35
|
+
#ifdef LIBXML_XPTR_ENABLED
|
36
|
+
#include <libxml/xpointer.h>
|
37
|
+
#endif
|
38
|
+
|
39
|
+
#include "ruby_xml_version.h"
|
40
|
+
#include "ruby_xml.h"
|
41
|
+
#include "ruby_xml_io.h"
|
42
|
+
#include "ruby_xml_error.h"
|
43
|
+
#include "ruby_xml_encoding.h"
|
44
|
+
#include "ruby_xml_attributes.h"
|
45
|
+
#include "ruby_xml_attr.h"
|
46
|
+
#include "ruby_xml_attr_decl.h"
|
47
|
+
#include "ruby_xml_document.h"
|
48
|
+
#include "ruby_xml_node.h"
|
49
|
+
#include "ruby_xml_namespace.h"
|
50
|
+
#include "ruby_xml_namespaces.h"
|
51
|
+
#include "ruby_xml_parser.h"
|
52
|
+
#include "ruby_xml_parser_options.h"
|
53
|
+
#include "ruby_xml_parser_context.h"
|
54
|
+
#include "ruby_xml_html_parser.h"
|
55
|
+
#include "ruby_xml_html_parser_options.h"
|
56
|
+
#include "ruby_xml_html_parser_context.h"
|
57
|
+
#include "ruby_xml_reader.h"
|
58
|
+
#include "ruby_xml_writer.h"
|
59
|
+
#include "ruby_xml_sax2_handler.h"
|
60
|
+
#include "ruby_xml_sax_parser.h"
|
61
|
+
#include "ruby_xml_writer.h"
|
62
|
+
#include "ruby_xml_xinclude.h"
|
63
|
+
#include "ruby_xml_xpath.h"
|
64
|
+
#include "ruby_xml_xpath_expression.h"
|
65
|
+
#include "ruby_xml_xpath_context.h"
|
66
|
+
#include "ruby_xml_xpath_object.h"
|
67
|
+
#include "ruby_xml_xpointer.h"
|
68
|
+
#include "ruby_xml_input_cbg.h"
|
69
|
+
#include "ruby_xml_dtd.h"
|
70
|
+
#include "ruby_xml_schema.h"
|
71
|
+
#include "ruby_xml_relaxng.h"
|
72
|
+
|
73
|
+
extern VALUE mLibXML;
|
74
|
+
|
75
|
+
#endif
|
@@ -0,0 +1,977 @@
|
|
1
|
+
#include "ruby_libxml.h"
|
2
|
+
#include "ruby_xml.h"
|
3
|
+
|
4
|
+
static struct st_table *private_pointers;
|
5
|
+
|
6
|
+
static int registered = 0; // Constant to track what nodes have been registered
|
7
|
+
|
8
|
+
void rxml_register(void *xnode, VALUE value) {
|
9
|
+
st_insert(private_pointers, (st_data_t)xnode, (st_data_t)value);
|
10
|
+
}
|
11
|
+
|
12
|
+
void rxml_register_node(xmlNodePtr xnode, VALUE value) {
|
13
|
+
if (rxml_lookup_node(xnode) == Qnil) {
|
14
|
+
xnode->_private = ®istered;
|
15
|
+
rxml_register(xnode, value);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
void rxml_register_doc(xmlDocPtr xdoc, VALUE value) {
|
20
|
+
if (rxml_lookup_doc(xdoc) == Qnil) {
|
21
|
+
xdoc->_private = ®istered;
|
22
|
+
rxml_register(xdoc, value);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
void rxml_register_dtd(xmlDtdPtr xdtd, VALUE value) {
|
27
|
+
if (rxml_lookup_dtd(xdtd) == Qnil) {
|
28
|
+
xdtd->_private = ®istered;
|
29
|
+
rxml_register(xdtd, value);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
void rxml_unregister(void *xnode) {
|
34
|
+
st_delete(private_pointers, (st_data_t*)&xnode, NULL);
|
35
|
+
}
|
36
|
+
|
37
|
+
void rxml_unregister_node(xmlNodePtr xnode) {
|
38
|
+
if (xnode->_private == ®istered) {
|
39
|
+
xnode->_private = NULL;
|
40
|
+
rxml_unregister(xnode);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
void rxml_unregister_doc(xmlDocPtr xdoc) {
|
45
|
+
if (xdoc->_private == ®istered) {
|
46
|
+
xdoc->_private = NULL;
|
47
|
+
rxml_unregister(xdoc);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
void rxml_unregister_dtd(xmlDtdPtr xdtd) {
|
52
|
+
if (xdtd->_private == ®istered) {
|
53
|
+
xdtd->_private = NULL;
|
54
|
+
rxml_unregister(xdtd);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
VALUE rxml_lookup(void *pointer) {
|
59
|
+
st_data_t result = 0;
|
60
|
+
int ret = st_lookup(private_pointers, (st_data_t)pointer, &result);
|
61
|
+
return ret ? (VALUE)result : Qnil;
|
62
|
+
}
|
63
|
+
|
64
|
+
VALUE rxml_lookup_node(xmlNodePtr xnode) {
|
65
|
+
if (!xnode || xnode->_private != ®istered)
|
66
|
+
return Qnil;
|
67
|
+
|
68
|
+
return rxml_lookup(xnode);
|
69
|
+
}
|
70
|
+
|
71
|
+
VALUE rxml_lookup_doc(xmlDocPtr xdoc) {
|
72
|
+
if (!xdoc || xdoc->_private != ®istered)
|
73
|
+
return Qnil;
|
74
|
+
|
75
|
+
return rxml_lookup(xdoc);
|
76
|
+
}
|
77
|
+
|
78
|
+
VALUE rxml_lookup_dtd(xmlDtdPtr xdtd) {
|
79
|
+
if (!xdtd || xdtd->_private != ®istered)
|
80
|
+
return Qnil;
|
81
|
+
|
82
|
+
return rxml_lookup(xdtd);
|
83
|
+
}
|
84
|
+
|
85
|
+
VALUE mXML;
|
86
|
+
|
87
|
+
/*
|
88
|
+
* call-seq:
|
89
|
+
* XML.catalog_dump -> true
|
90
|
+
*
|
91
|
+
* Dump all the global catalog content stdout.
|
92
|
+
*/
|
93
|
+
static VALUE rxml_catalog_dump(VALUE self)
|
94
|
+
{
|
95
|
+
xmlCatalogDump(stdout);
|
96
|
+
return (Qtrue);
|
97
|
+
}
|
98
|
+
|
99
|
+
/*
|
100
|
+
* call-seq:
|
101
|
+
* XML.catalog_remove(catalog) -> true
|
102
|
+
*
|
103
|
+
* Remove the specified resource catalog.
|
104
|
+
*/
|
105
|
+
static VALUE rxml_catalog_remove(VALUE self, VALUE cat)
|
106
|
+
{
|
107
|
+
Check_Type(cat, T_STRING);
|
108
|
+
xmlCatalogRemove((xmlChar *) StringValuePtr(cat));
|
109
|
+
return (Qtrue);
|
110
|
+
}
|
111
|
+
|
112
|
+
/*
|
113
|
+
* call-seq:
|
114
|
+
* XML.check_lib_versions -> true
|
115
|
+
*
|
116
|
+
* Check LIBXML version matches version the bindings
|
117
|
+
* were compiled to. Throws an exception if not.
|
118
|
+
*/
|
119
|
+
static VALUE rxml_check_lib_versions(VALUE klass)
|
120
|
+
{
|
121
|
+
xmlCheckVersion(LIBXML_VERSION);
|
122
|
+
return (Qtrue);
|
123
|
+
}
|
124
|
+
|
125
|
+
/*
|
126
|
+
* call-seq:
|
127
|
+
* XML.enabled_automata? -> (true|false)
|
128
|
+
*
|
129
|
+
* Determine whether libxml regexp automata support is enabled.
|
130
|
+
*/
|
131
|
+
static VALUE rxml_enabled_automata_q(VALUE klass)
|
132
|
+
{
|
133
|
+
#ifdef LIBXML_AUTOMATA_ENABLED
|
134
|
+
return(Qtrue);
|
135
|
+
#else
|
136
|
+
return (Qfalse);
|
137
|
+
#endif
|
138
|
+
}
|
139
|
+
|
140
|
+
/*
|
141
|
+
* call-seq:
|
142
|
+
* XML.enabled_c14n? -> (true|false)
|
143
|
+
*
|
144
|
+
* Determine whether libxml 'canonical XML' support is enabled.
|
145
|
+
* See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
|
146
|
+
*/
|
147
|
+
static VALUE rxml_enabled_c14n_q(VALUE klass)
|
148
|
+
{
|
149
|
+
#ifdef LIBXML_C14N_ENABLED
|
150
|
+
return(Qtrue);
|
151
|
+
#else
|
152
|
+
return (Qfalse);
|
153
|
+
#endif
|
154
|
+
}
|
155
|
+
|
156
|
+
/*
|
157
|
+
* call-seq:
|
158
|
+
* XML.enabled_catalog? -> (true|false)
|
159
|
+
*
|
160
|
+
* Determine whether libxml resource catalog support is enabled.
|
161
|
+
*/
|
162
|
+
static VALUE rxml_enabled_catalog_q(VALUE klass)
|
163
|
+
{
|
164
|
+
#ifdef LIBXML_CATALOG_ENABLED
|
165
|
+
return(Qtrue);
|
166
|
+
#else
|
167
|
+
return (Qfalse);
|
168
|
+
#endif
|
169
|
+
}
|
170
|
+
|
171
|
+
/*
|
172
|
+
* call-seq:
|
173
|
+
* XML.enabled_debug? -> (true|false)
|
174
|
+
*
|
175
|
+
* Determine whether libxml debugging support is enabled.
|
176
|
+
*/
|
177
|
+
static VALUE rxml_enabled_debug_q(VALUE klass)
|
178
|
+
{
|
179
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
180
|
+
return(Qtrue);
|
181
|
+
#else
|
182
|
+
return (Qfalse);
|
183
|
+
#endif
|
184
|
+
}
|
185
|
+
|
186
|
+
/*
|
187
|
+
* call-seq:
|
188
|
+
* XML.enabled_docbook? -> (true|false)
|
189
|
+
*
|
190
|
+
* Determine whether libxml docbook support is enabled.
|
191
|
+
*/
|
192
|
+
static VALUE rxml_enabled_docbook_q(VALUE klass)
|
193
|
+
{
|
194
|
+
#ifdef LIBXML_DOCB_ENABLED
|
195
|
+
return(Qtrue);
|
196
|
+
#else
|
197
|
+
return (Qfalse);
|
198
|
+
#endif
|
199
|
+
}
|
200
|
+
|
201
|
+
/*
|
202
|
+
* call-seq:
|
203
|
+
* XML.enabled_ftp? -> (true|false)
|
204
|
+
*
|
205
|
+
* Determine whether libxml ftp client support is enabled.
|
206
|
+
*/
|
207
|
+
static VALUE rxml_enabled_ftp_q(VALUE klass)
|
208
|
+
{
|
209
|
+
#ifdef LIBXML_FTP_ENABLED
|
210
|
+
return(Qtrue);
|
211
|
+
#else
|
212
|
+
return (Qfalse);
|
213
|
+
#endif
|
214
|
+
}
|
215
|
+
|
216
|
+
/*
|
217
|
+
* call-seq:
|
218
|
+
* XML.enabled_http? -> (true|false)
|
219
|
+
*
|
220
|
+
* Determine whether libxml http client support is enabled.
|
221
|
+
*/
|
222
|
+
static VALUE rxml_enabled_http_q(VALUE klass)
|
223
|
+
{
|
224
|
+
#ifdef LIBXML_HTTP_ENABLED
|
225
|
+
return(Qtrue);
|
226
|
+
#else
|
227
|
+
return (Qfalse);
|
228
|
+
#endif
|
229
|
+
}
|
230
|
+
|
231
|
+
/*
|
232
|
+
* call-seq:
|
233
|
+
* XML.enabled_html? -> (true|false)
|
234
|
+
*
|
235
|
+
* Determine whether libxml html support is enabled.
|
236
|
+
*/
|
237
|
+
static VALUE rxml_enabled_html_q(VALUE klass)
|
238
|
+
{
|
239
|
+
#ifdef LIBXML_HTML_ENABLED
|
240
|
+
return(Qtrue);
|
241
|
+
#else
|
242
|
+
return (Qfalse);
|
243
|
+
#endif
|
244
|
+
}
|
245
|
+
|
246
|
+
/*
|
247
|
+
* call-seq:
|
248
|
+
* XML.enabled_iconv? -> (true|false)
|
249
|
+
*
|
250
|
+
* Determine whether libxml iconv support is enabled.
|
251
|
+
*/
|
252
|
+
static VALUE rxml_enabled_iconv_q(VALUE klass)
|
253
|
+
{
|
254
|
+
#ifdef LIBXML_ICONV_ENABLED
|
255
|
+
return(Qtrue);
|
256
|
+
#else
|
257
|
+
return (Qfalse);
|
258
|
+
#endif
|
259
|
+
}
|
260
|
+
|
261
|
+
/*
|
262
|
+
* call-seq:
|
263
|
+
* XML.enabled_memory_debug? -> (true|false)
|
264
|
+
*
|
265
|
+
* Determine whether libxml memory location debugging support
|
266
|
+
* is enabled.
|
267
|
+
*/
|
268
|
+
static VALUE rxml_enabled_memory_debug_location_q(VALUE klass)
|
269
|
+
{
|
270
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
271
|
+
return(Qtrue);
|
272
|
+
#else
|
273
|
+
return (Qfalse);
|
274
|
+
#endif
|
275
|
+
}
|
276
|
+
|
277
|
+
/*
|
278
|
+
* call-seq:
|
279
|
+
* XML.enabled_regexp? -> (true|false)
|
280
|
+
*
|
281
|
+
* Determine whether libxml regular expression support is enabled.
|
282
|
+
*/
|
283
|
+
static VALUE rxml_enabled_regexp_q(VALUE klass)
|
284
|
+
{
|
285
|
+
#ifdef LIBXML_REGEXP_ENABLED
|
286
|
+
return(Qtrue);
|
287
|
+
#else
|
288
|
+
return (Qfalse);
|
289
|
+
#endif
|
290
|
+
}
|
291
|
+
|
292
|
+
/*
|
293
|
+
* call-seq:
|
294
|
+
* XML.enabled_schemas? -> (true|false)
|
295
|
+
*
|
296
|
+
* Determine whether libxml schema support is enabled.
|
297
|
+
*/
|
298
|
+
static VALUE rxml_enabled_schemas_q(VALUE klass)
|
299
|
+
{
|
300
|
+
#ifdef LIBXML_SCHEMAS_ENABLED
|
301
|
+
return(Qtrue);
|
302
|
+
#else
|
303
|
+
return (Qfalse);
|
304
|
+
#endif
|
305
|
+
}
|
306
|
+
|
307
|
+
/*
|
308
|
+
* call-seq:
|
309
|
+
* XML.enabled_thread? -> (true|false)
|
310
|
+
*
|
311
|
+
* Determine whether thread-safe semantics support for libxml is enabled and
|
312
|
+
* is used by this ruby extension. Threading support in libxml uses pthread
|
313
|
+
* on Unix-like systems and Win32 threads on Windows.
|
314
|
+
*/
|
315
|
+
static VALUE rxml_enabled_thread_q(VALUE klass)
|
316
|
+
{
|
317
|
+
/* This won't be defined unless this code is compiled with _REENTRANT or __MT__
|
318
|
+
* defined or the compiler is in C99 mode.
|
319
|
+
*
|
320
|
+
* Note the relevant portion libxml/xmlversion.h on a thread-enabled build:
|
321
|
+
*
|
322
|
+
* #if defined(_REENTRANT) || defined(__MT__) || \
|
323
|
+
* (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L))
|
324
|
+
* #define LIBXML_THREAD_ENABLED
|
325
|
+
* #endif
|
326
|
+
*
|
327
|
+
*/
|
328
|
+
#ifdef LIBXML_THREAD_ENABLED
|
329
|
+
return(Qtrue);
|
330
|
+
#else
|
331
|
+
return (Qfalse);
|
332
|
+
#endif
|
333
|
+
}
|
334
|
+
|
335
|
+
/*
|
336
|
+
* call-seq:
|
337
|
+
* XML.enabled_unicode? -> (true|false)
|
338
|
+
*
|
339
|
+
* Determine whether libxml unicode support is enabled.
|
340
|
+
*/
|
341
|
+
static VALUE rxml_enabled_unicode_q(VALUE klass)
|
342
|
+
{
|
343
|
+
#ifdef LIBXML_UNICODE_ENABLED
|
344
|
+
return(Qtrue);
|
345
|
+
#else
|
346
|
+
return (Qfalse);
|
347
|
+
#endif
|
348
|
+
}
|
349
|
+
|
350
|
+
/*
|
351
|
+
* call-seq:
|
352
|
+
* XML.enabled_xinclude? -> (true|false)
|
353
|
+
*
|
354
|
+
* Determine whether libxml xinclude support is enabled.
|
355
|
+
*/
|
356
|
+
static VALUE rxml_enabled_xinclude_q(VALUE klass)
|
357
|
+
{
|
358
|
+
#ifdef LIBXML_XINCLUDE_ENABLED
|
359
|
+
return(Qtrue);
|
360
|
+
#else
|
361
|
+
return (Qfalse);
|
362
|
+
#endif
|
363
|
+
}
|
364
|
+
|
365
|
+
/*
|
366
|
+
* call-seq:
|
367
|
+
* XML.enabled_xpath? -> (true|false)
|
368
|
+
*
|
369
|
+
* Determine whether libxml xpath support is enabled.
|
370
|
+
*/
|
371
|
+
static VALUE rxml_enabled_xpath_q(VALUE klass)
|
372
|
+
{
|
373
|
+
#ifdef LIBXML_XPATH_ENABLED
|
374
|
+
return(Qtrue);
|
375
|
+
#else
|
376
|
+
return (Qfalse);
|
377
|
+
#endif
|
378
|
+
}
|
379
|
+
|
380
|
+
/*
|
381
|
+
* call-seq:
|
382
|
+
* XML.enabled_xpointer? -> (true|false)
|
383
|
+
*
|
384
|
+
* Determine whether libxml xpointer support is enabled.
|
385
|
+
*/
|
386
|
+
static VALUE rxml_enabled_xpointer_q(VALUE klass)
|
387
|
+
{
|
388
|
+
#ifdef LIBXML_XPTR_ENABLED
|
389
|
+
return(Qtrue);
|
390
|
+
#else
|
391
|
+
return (Qfalse);
|
392
|
+
#endif
|
393
|
+
}
|
394
|
+
|
395
|
+
/*
|
396
|
+
* call-seq:
|
397
|
+
* XML.enabled_zlib? -> (true|false)
|
398
|
+
*
|
399
|
+
* Determine whether libxml zlib support is enabled.
|
400
|
+
*/
|
401
|
+
static VALUE rxml_enabled_zlib_q(VALUE klass)
|
402
|
+
{
|
403
|
+
#ifdef HAVE_ZLIB_H
|
404
|
+
return(Qtrue);
|
405
|
+
#else
|
406
|
+
return (Qfalse);
|
407
|
+
#endif
|
408
|
+
}
|
409
|
+
|
410
|
+
/*
|
411
|
+
* call-seq:
|
412
|
+
* XML.debug_entities -> (true|false)
|
413
|
+
*
|
414
|
+
* Determine whether included-entity debugging is enabled.
|
415
|
+
* (Requires Libxml to be compiled with debugging support)
|
416
|
+
*/
|
417
|
+
static VALUE rxml_debug_entities_get(VALUE klass)
|
418
|
+
{
|
419
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
420
|
+
if (xmlParserDebugEntities)
|
421
|
+
return(Qtrue);
|
422
|
+
else
|
423
|
+
return(Qfalse);
|
424
|
+
#else
|
425
|
+
rb_warn("libxml was compiled with debugging turned off");
|
426
|
+
return (Qfalse);
|
427
|
+
#endif
|
428
|
+
}
|
429
|
+
|
430
|
+
/*
|
431
|
+
* call-seq:
|
432
|
+
* XML.debug_entities = true|false
|
433
|
+
*
|
434
|
+
* Enable or disable included-entity debugging.
|
435
|
+
* (Requires Libxml to be compiled with debugging support)
|
436
|
+
*/
|
437
|
+
static VALUE rxml_debug_entities_set(VALUE klass, VALUE value)
|
438
|
+
{
|
439
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
440
|
+
if (value == Qfalse)
|
441
|
+
{
|
442
|
+
xmlParserDebugEntities = 0;
|
443
|
+
return(Qfalse);
|
444
|
+
}
|
445
|
+
else
|
446
|
+
{
|
447
|
+
xmlParserDebugEntities = 1;
|
448
|
+
return(Qtrue);
|
449
|
+
}
|
450
|
+
#else
|
451
|
+
rb_warn("libxml was compiled with debugging turned off");
|
452
|
+
#endif
|
453
|
+
}
|
454
|
+
|
455
|
+
/*
|
456
|
+
* call-seq:
|
457
|
+
* XML.default_keep_blanks -> (true|false)
|
458
|
+
*
|
459
|
+
* Determine whether parsers retain whitespace by default.
|
460
|
+
*/
|
461
|
+
static VALUE rxml_default_keep_blanks_get(VALUE klass)
|
462
|
+
{
|
463
|
+
if (xmlKeepBlanksDefaultValue)
|
464
|
+
return (Qtrue);
|
465
|
+
else
|
466
|
+
return (Qfalse);
|
467
|
+
}
|
468
|
+
|
469
|
+
/*
|
470
|
+
* call-seq:
|
471
|
+
* XML.default_keep_blanks = true|false
|
472
|
+
*
|
473
|
+
* Controls whether parsers retain whitespace by default.
|
474
|
+
*/
|
475
|
+
static VALUE rxml_default_keep_blanks_set(VALUE klass, VALUE value)
|
476
|
+
{
|
477
|
+
if (value == Qfalse)
|
478
|
+
{
|
479
|
+
xmlKeepBlanksDefaultValue = 0;
|
480
|
+
return (Qfalse);
|
481
|
+
}
|
482
|
+
else if (value == Qtrue)
|
483
|
+
{
|
484
|
+
xmlKeepBlanksDefaultValue = 1;
|
485
|
+
return (Qtrue);
|
486
|
+
}
|
487
|
+
else
|
488
|
+
{
|
489
|
+
rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
|
490
|
+
}
|
491
|
+
}
|
492
|
+
|
493
|
+
/*
|
494
|
+
* call-seq:
|
495
|
+
* XML.default_load_external_dtd -> (true|false)
|
496
|
+
*
|
497
|
+
* Determine whether parsers load external DTDs by default.
|
498
|
+
*/
|
499
|
+
static VALUE rxml_default_load_external_dtd_get(VALUE klass)
|
500
|
+
{
|
501
|
+
if (xmlLoadExtDtdDefaultValue)
|
502
|
+
return (Qtrue);
|
503
|
+
else
|
504
|
+
return (Qfalse);
|
505
|
+
}
|
506
|
+
|
507
|
+
/*
|
508
|
+
* call-seq:
|
509
|
+
* XML.default_load_external_dtd = true|false
|
510
|
+
*
|
511
|
+
* Controls whether parsers load external DTDs by default.
|
512
|
+
*/
|
513
|
+
static VALUE rxml_default_load_external_dtd_set(VALUE klass, VALUE value)
|
514
|
+
{
|
515
|
+
if (value == Qfalse)
|
516
|
+
{
|
517
|
+
xmlLoadExtDtdDefaultValue = 0;
|
518
|
+
return (Qfalse);
|
519
|
+
}
|
520
|
+
else
|
521
|
+
{
|
522
|
+
xmlLoadExtDtdDefaultValue = 1;
|
523
|
+
return (Qtrue);
|
524
|
+
}
|
525
|
+
}
|
526
|
+
|
527
|
+
/*
|
528
|
+
* call-seq:
|
529
|
+
* XML.default_line_numbers -> (true|false)
|
530
|
+
*
|
531
|
+
* Determine whether parsers retain line-numbers by default.
|
532
|
+
*/
|
533
|
+
static VALUE rxml_default_line_numbers_get(VALUE klass)
|
534
|
+
{
|
535
|
+
if (xmlLineNumbersDefaultValue)
|
536
|
+
return (Qtrue);
|
537
|
+
else
|
538
|
+
return (Qfalse);
|
539
|
+
}
|
540
|
+
|
541
|
+
/*
|
542
|
+
* call-seq:
|
543
|
+
* XML.default_line_numbers = true|false
|
544
|
+
*
|
545
|
+
* Controls whether parsers retain line-numbers by default.
|
546
|
+
*/
|
547
|
+
static VALUE rxml_default_line_numbers_set(VALUE klass, VALUE value)
|
548
|
+
{
|
549
|
+
if (value == Qfalse)
|
550
|
+
{
|
551
|
+
xmlLineNumbersDefault(0);
|
552
|
+
return (Qfalse);
|
553
|
+
}
|
554
|
+
else
|
555
|
+
{
|
556
|
+
xmlLineNumbersDefault(1);
|
557
|
+
return (Qtrue);
|
558
|
+
}
|
559
|
+
}
|
560
|
+
|
561
|
+
int rxml_libxml_default_options()
|
562
|
+
{
|
563
|
+
int options = 0;
|
564
|
+
|
565
|
+
if (xmlLoadExtDtdDefaultValue)
|
566
|
+
options |= XML_PARSE_DTDLOAD;
|
567
|
+
|
568
|
+
if (xmlDoValidityCheckingDefaultValue)
|
569
|
+
options |= XML_PARSE_DTDVALID;
|
570
|
+
|
571
|
+
if (!xmlKeepBlanksDefaultValue)
|
572
|
+
options |= XML_PARSE_NOBLANKS;
|
573
|
+
|
574
|
+
if (xmlSubstituteEntitiesDefaultValue)
|
575
|
+
options |= XML_PARSE_NOENT;
|
576
|
+
|
577
|
+
if (!xmlGetWarningsDefaultValue)
|
578
|
+
options |= XML_PARSE_NOWARNING;
|
579
|
+
|
580
|
+
if (xmlPedanticParserDefaultValue)
|
581
|
+
options |= XML_PARSE_PEDANTIC;
|
582
|
+
|
583
|
+
return options;
|
584
|
+
}
|
585
|
+
|
586
|
+
/*
|
587
|
+
* call-seq:
|
588
|
+
* XML.default_options -> int
|
589
|
+
*
|
590
|
+
* Returns an integer that summarize libxml2's default options.
|
591
|
+
*/
|
592
|
+
static VALUE rxml_default_options_get(VALUE klass)
|
593
|
+
{
|
594
|
+
int options = rxml_libxml_default_options();
|
595
|
+
return INT2NUM(options);
|
596
|
+
}
|
597
|
+
|
598
|
+
/*
|
599
|
+
* call-seq:
|
600
|
+
* XML.default_pedantic_parser -> (true|false)
|
601
|
+
*
|
602
|
+
* Determine whether parsers are pedantic by default.
|
603
|
+
*/
|
604
|
+
static VALUE rxml_default_pedantic_parser_get(VALUE klass)
|
605
|
+
{
|
606
|
+
if (xmlPedanticParserDefaultValue)
|
607
|
+
return (Qtrue);
|
608
|
+
else
|
609
|
+
return (Qfalse);
|
610
|
+
}
|
611
|
+
|
612
|
+
/*
|
613
|
+
* call-seq:
|
614
|
+
* XML.default_pedantic_parser = true|false
|
615
|
+
*
|
616
|
+
* Controls whether parsers are pedantic by default.
|
617
|
+
*/
|
618
|
+
static VALUE rxml_default_pedantic_parser_set(VALUE klass, VALUE value)
|
619
|
+
{
|
620
|
+
if (value == Qfalse)
|
621
|
+
{
|
622
|
+
xmlPedanticParserDefault(0);
|
623
|
+
return (Qfalse);
|
624
|
+
}
|
625
|
+
else
|
626
|
+
{
|
627
|
+
xmlPedanticParserDefault(1);
|
628
|
+
return (Qtrue);
|
629
|
+
}
|
630
|
+
}
|
631
|
+
|
632
|
+
/*
|
633
|
+
* call-seq:
|
634
|
+
* XML.default_substitute_entities -> (true|false)
|
635
|
+
*
|
636
|
+
* Determine whether parsers perform inline entity substitution
|
637
|
+
* (for external entities) by default.
|
638
|
+
*/
|
639
|
+
static VALUE rxml_default_substitute_entities_get(VALUE klass)
|
640
|
+
{
|
641
|
+
if (xmlSubstituteEntitiesDefaultValue)
|
642
|
+
return (Qtrue);
|
643
|
+
else
|
644
|
+
return (Qfalse);
|
645
|
+
}
|
646
|
+
|
647
|
+
/*
|
648
|
+
* call-seq:
|
649
|
+
* XML.default_substitute_entities = true|false
|
650
|
+
*
|
651
|
+
* Controls whether parsers perform inline entity substitution
|
652
|
+
* (for external entities) by default.
|
653
|
+
*/
|
654
|
+
static VALUE rxml_default_substitute_entities_set(VALUE klass, VALUE value)
|
655
|
+
{
|
656
|
+
if (value == Qfalse)
|
657
|
+
{
|
658
|
+
xmlSubstituteEntitiesDefault(0);
|
659
|
+
return (Qfalse);
|
660
|
+
}
|
661
|
+
else
|
662
|
+
{
|
663
|
+
xmlSubstituteEntitiesDefault(1);
|
664
|
+
return (Qtrue);
|
665
|
+
}
|
666
|
+
}
|
667
|
+
|
668
|
+
/*
|
669
|
+
* call-seq:
|
670
|
+
* XML.default_tree_indent_string -> "string"
|
671
|
+
*
|
672
|
+
* Obtain the default string used by parsers to indent the XML tree
|
673
|
+
* for output.
|
674
|
+
*/
|
675
|
+
static VALUE rxml_default_tree_indent_string_get(VALUE klass)
|
676
|
+
{
|
677
|
+
if (xmlTreeIndentString == NULL)
|
678
|
+
return (Qnil);
|
679
|
+
else
|
680
|
+
return (rb_str_new2(xmlTreeIndentString));
|
681
|
+
}
|
682
|
+
|
683
|
+
/*
|
684
|
+
* call-seq:
|
685
|
+
* XML.default_tree_indent_string = "string"
|
686
|
+
*
|
687
|
+
* Set the default string used by parsers to indent the XML tree
|
688
|
+
* for output.
|
689
|
+
*/
|
690
|
+
static VALUE rxml_default_tree_indent_string_set(VALUE klass, VALUE string)
|
691
|
+
{
|
692
|
+
Check_Type(string, T_STRING);
|
693
|
+
xmlTreeIndentString = (const char *)xmlStrdup((xmlChar *)StringValuePtr(string));
|
694
|
+
return (string);
|
695
|
+
}
|
696
|
+
|
697
|
+
/*
|
698
|
+
* call-seq:
|
699
|
+
* XML.default_validity_checking -> (true|false)
|
700
|
+
*
|
701
|
+
* Determine whether parsers perform XML validation by default.
|
702
|
+
*/
|
703
|
+
static VALUE rxml_default_validity_checking_get(VALUE klass)
|
704
|
+
{
|
705
|
+
if (xmlDoValidityCheckingDefaultValue)
|
706
|
+
return (Qtrue);
|
707
|
+
else
|
708
|
+
return (Qfalse);
|
709
|
+
}
|
710
|
+
|
711
|
+
/*
|
712
|
+
* call-seq:
|
713
|
+
* XML.default_validity_checking = true|false
|
714
|
+
*
|
715
|
+
* Controls whether parsers perform XML validation by default.
|
716
|
+
*/
|
717
|
+
static VALUE rxml_default_validity_checking_set(VALUE klass, VALUE value)
|
718
|
+
{
|
719
|
+
if (value == Qfalse)
|
720
|
+
{
|
721
|
+
xmlDoValidityCheckingDefaultValue = 0;
|
722
|
+
return (Qfalse);
|
723
|
+
}
|
724
|
+
else
|
725
|
+
{
|
726
|
+
xmlDoValidityCheckingDefaultValue = 1;
|
727
|
+
return (Qtrue);
|
728
|
+
}
|
729
|
+
}
|
730
|
+
|
731
|
+
/*
|
732
|
+
* call-seq:
|
733
|
+
* XML.default_warnings -> (true|false)
|
734
|
+
*
|
735
|
+
* Determine whether parsers output warnings by default.
|
736
|
+
*/
|
737
|
+
static VALUE rxml_default_warnings_get(VALUE klass)
|
738
|
+
{
|
739
|
+
if (xmlGetWarningsDefaultValue)
|
740
|
+
return (Qtrue);
|
741
|
+
else
|
742
|
+
return (Qfalse);
|
743
|
+
}
|
744
|
+
|
745
|
+
/*
|
746
|
+
* call-seq:
|
747
|
+
* XML.default_warnings = true|false
|
748
|
+
*
|
749
|
+
* Controls whether parsers output warnings by default.
|
750
|
+
*/
|
751
|
+
static VALUE rxml_default_warnings_set(VALUE klass, VALUE value)
|
752
|
+
{
|
753
|
+
if (value == Qfalse)
|
754
|
+
{
|
755
|
+
xmlGetWarningsDefaultValue = 0;
|
756
|
+
return (Qfalse);
|
757
|
+
}
|
758
|
+
else
|
759
|
+
{
|
760
|
+
xmlGetWarningsDefaultValue = 1;
|
761
|
+
return (Qtrue);
|
762
|
+
}
|
763
|
+
}
|
764
|
+
|
765
|
+
/*
|
766
|
+
* call-seq:
|
767
|
+
* XML.default_compression -> (true|false)
|
768
|
+
*
|
769
|
+
* Determine whether parsers use Zlib compression by default
|
770
|
+
* (requires libxml to be compiled with Zlib support).
|
771
|
+
*/
|
772
|
+
static VALUE rxml_default_compression_get(VALUE klass)
|
773
|
+
{
|
774
|
+
#ifdef HAVE_ZLIB_H
|
775
|
+
return(INT2FIX(xmlGetCompressMode()));
|
776
|
+
#else
|
777
|
+
rb_warn("libxml was compiled without zlib support");
|
778
|
+
return (Qfalse);
|
779
|
+
#endif
|
780
|
+
}
|
781
|
+
|
782
|
+
/*
|
783
|
+
* call-seq:
|
784
|
+
* XML.default_compression = true|false
|
785
|
+
*
|
786
|
+
* Controls whether parsers use Zlib compression by default
|
787
|
+
* (requires libxml to be compiled with Zlib support).
|
788
|
+
*/
|
789
|
+
static VALUE rxml_default_compression_set(VALUE klass, VALUE num)
|
790
|
+
{
|
791
|
+
#ifdef HAVE_ZLIB_H
|
792
|
+
Check_Type(num, T_FIXNUM);
|
793
|
+
xmlSetCompressMode(FIX2INT(num));
|
794
|
+
return(num);
|
795
|
+
#else
|
796
|
+
rb_warn("libxml was compiled without zlib support");
|
797
|
+
return (Qfalse);
|
798
|
+
#endif
|
799
|
+
}
|
800
|
+
|
801
|
+
/*
|
802
|
+
* call-seq:
|
803
|
+
* XML.features -> ["feature", ..., "feature"]
|
804
|
+
*
|
805
|
+
* Obtains an array of strings representing features supported
|
806
|
+
* (and enabled) by the installed libxml.
|
807
|
+
*/
|
808
|
+
static VALUE rxml_features(VALUE klass)
|
809
|
+
{
|
810
|
+
VALUE arr, str;
|
811
|
+
int i, len = MAX_LIBXML_FEATURES_LEN;
|
812
|
+
char **list = NULL;
|
813
|
+
|
814
|
+
list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
|
815
|
+
MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
|
816
|
+
|
817
|
+
arr = rb_ary_new();
|
818
|
+
if (xmlGetFeaturesList(&len, (const char **) list) == -1)
|
819
|
+
return Qnil;
|
820
|
+
|
821
|
+
for (i = 0; i < len; i++)
|
822
|
+
{
|
823
|
+
str = rb_str_new2((const char *) list[i]);
|
824
|
+
rb_gc_unregister_address(&str);
|
825
|
+
rb_ary_push(arr, str);
|
826
|
+
}
|
827
|
+
|
828
|
+
if (len == MAX_LIBXML_FEATURES_LEN)
|
829
|
+
rb_warn(
|
830
|
+
"Please contact libxml-devel@rubyforge.org and ask to have the \"MAX_LIBXML_FEATURES_LEN increased\" because you could possibly be seeing an incomplete list");
|
831
|
+
|
832
|
+
ruby_xfree(list);
|
833
|
+
return (arr);
|
834
|
+
}
|
835
|
+
|
836
|
+
/*
|
837
|
+
* call-seq:
|
838
|
+
* XML.indent_tree_output -> (true|false)
|
839
|
+
*
|
840
|
+
* Determines whether XML output will be indented
|
841
|
+
* (using the string supplied to +default_indent_tree_string+)
|
842
|
+
*/
|
843
|
+
static VALUE rxml_indent_tree_output_get(VALUE klass)
|
844
|
+
{
|
845
|
+
if (xmlIndentTreeOutput)
|
846
|
+
return (Qtrue);
|
847
|
+
else
|
848
|
+
return (Qfalse);
|
849
|
+
}
|
850
|
+
|
851
|
+
/*
|
852
|
+
* call-seq:
|
853
|
+
* XML.indent_tree_output = true|false
|
854
|
+
*
|
855
|
+
* Controls whether XML output will be indented
|
856
|
+
* (using the string supplied to +default_indent_tree_string+)
|
857
|
+
*/
|
858
|
+
static VALUE rxml_indent_tree_output_set(VALUE klass, VALUE value)
|
859
|
+
{
|
860
|
+
if (value == Qtrue)
|
861
|
+
{
|
862
|
+
xmlIndentTreeOutput = 1;
|
863
|
+
return (Qtrue);
|
864
|
+
}
|
865
|
+
else if (value == Qfalse)
|
866
|
+
{
|
867
|
+
xmlIndentTreeOutput = 0;
|
868
|
+
return (Qfalse);
|
869
|
+
}
|
870
|
+
else
|
871
|
+
{
|
872
|
+
rb_raise(rb_eArgError, "Invalid argument, must be boolean");
|
873
|
+
}
|
874
|
+
}
|
875
|
+
|
876
|
+
/*
|
877
|
+
* call-seq:
|
878
|
+
* XML.memory_dump -> (true|false)
|
879
|
+
*
|
880
|
+
* Perform a parser memory dump (requires memory debugging
|
881
|
+
* support in libxml).
|
882
|
+
*/
|
883
|
+
static VALUE rxml_memory_dump(VALUE self)
|
884
|
+
{
|
885
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
886
|
+
xmlMemoryDump();
|
887
|
+
return(Qtrue);
|
888
|
+
#else
|
889
|
+
rb_warn("libxml was compiled without memory debugging support");
|
890
|
+
return (Qfalse);
|
891
|
+
#endif
|
892
|
+
}
|
893
|
+
|
894
|
+
/*
|
895
|
+
* call-seq:
|
896
|
+
* XML.memory_used -> num_bytes
|
897
|
+
*
|
898
|
+
* Perform a parser memory dump (requires memory debugging
|
899
|
+
* support in libxml).
|
900
|
+
*/
|
901
|
+
static VALUE rxml_memory_used(VALUE self)
|
902
|
+
{
|
903
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
904
|
+
return(INT2NUM(xmlMemUsed()));
|
905
|
+
#else
|
906
|
+
rb_warn("libxml was compiled without memory debugging support");
|
907
|
+
return (Qfalse);
|
908
|
+
#endif
|
909
|
+
}
|
910
|
+
|
911
|
+
/* The libxml gem provides Ruby language bindings for GNOME's Libxml2
|
912
|
+
* XML toolkit. Refer to the README file to get started
|
913
|
+
* and the LICENSE file for copyright and distribution information.
|
914
|
+
*/
|
915
|
+
|
916
|
+
void rxml_init_xml(void)
|
917
|
+
{
|
918
|
+
/* Create a hashtable suitable for pointer keys */
|
919
|
+
private_pointers = st_init_numtable();
|
920
|
+
|
921
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
922
|
+
|
923
|
+
/* Constants */
|
924
|
+
rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
|
925
|
+
rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
|
926
|
+
rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
|
927
|
+
rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2((const char*) XML_XML_NAMESPACE));
|
928
|
+
|
929
|
+
rb_define_module_function(mXML, "enabled_automata?", rxml_enabled_automata_q, 0);
|
930
|
+
rb_define_module_function(mXML, "enabled_c14n?", rxml_enabled_c14n_q, 0);
|
931
|
+
rb_define_module_function(mXML, "enabled_catalog?", rxml_enabled_catalog_q, 0);
|
932
|
+
rb_define_module_function(mXML, "enabled_debug?", rxml_enabled_debug_q, 0);
|
933
|
+
rb_define_module_function(mXML, "enabled_docbook?", rxml_enabled_docbook_q, 0);
|
934
|
+
rb_define_module_function(mXML, "enabled_ftp?", rxml_enabled_ftp_q, 0);
|
935
|
+
rb_define_module_function(mXML, "enabled_http?", rxml_enabled_http_q, 0);
|
936
|
+
rb_define_module_function(mXML, "enabled_html?", rxml_enabled_html_q, 0);
|
937
|
+
rb_define_module_function(mXML, "enabled_iconv?", rxml_enabled_iconv_q, 0);
|
938
|
+
rb_define_module_function(mXML, "enabled_memory_debug?", rxml_enabled_memory_debug_location_q, 0);
|
939
|
+
rb_define_module_function(mXML, "enabled_regexp?", rxml_enabled_regexp_q, 0);
|
940
|
+
rb_define_module_function(mXML, "enabled_schemas?", rxml_enabled_schemas_q, 0);
|
941
|
+
rb_define_module_function(mXML, "enabled_thread?", rxml_enabled_thread_q, 0);
|
942
|
+
rb_define_module_function(mXML, "enabled_unicode?", rxml_enabled_unicode_q, 0);
|
943
|
+
rb_define_module_function(mXML, "enabled_xinclude?", rxml_enabled_xinclude_q, 0);
|
944
|
+
rb_define_module_function(mXML, "enabled_xpath?", rxml_enabled_xpath_q, 0);
|
945
|
+
rb_define_module_function(mXML, "enabled_xpointer?", rxml_enabled_xpointer_q, 0);
|
946
|
+
rb_define_module_function(mXML, "enabled_zlib?", rxml_enabled_zlib_q, 0);
|
947
|
+
|
948
|
+
rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
|
949
|
+
rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
|
950
|
+
rb_define_module_function(mXML, "check_lib_versions", rxml_check_lib_versions, 0);
|
951
|
+
rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
|
952
|
+
rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
|
953
|
+
rb_define_module_function(mXML, "default_compression", rxml_default_compression_get, 0);
|
954
|
+
rb_define_module_function(mXML, "default_compression=", rxml_default_compression_set, 1);
|
955
|
+
rb_define_module_function(mXML, "default_keep_blanks", rxml_default_keep_blanks_get, 0);
|
956
|
+
rb_define_module_function(mXML, "default_keep_blanks=", rxml_default_keep_blanks_set, 1);
|
957
|
+
rb_define_module_function(mXML, "default_load_external_dtd", rxml_default_load_external_dtd_get, 0);
|
958
|
+
rb_define_module_function(mXML, "default_load_external_dtd=", rxml_default_load_external_dtd_set, 1);
|
959
|
+
rb_define_module_function(mXML, "default_line_numbers", rxml_default_line_numbers_get, 0);
|
960
|
+
rb_define_module_function(mXML, "default_line_numbers=", rxml_default_line_numbers_set, 1);
|
961
|
+
rb_define_module_function(mXML, "default_options", rxml_default_options_get, 0);
|
962
|
+
rb_define_module_function(mXML, "default_pedantic_parser", rxml_default_pedantic_parser_get, 0);
|
963
|
+
rb_define_module_function(mXML, "default_pedantic_parser=", rxml_default_pedantic_parser_set, 1);
|
964
|
+
rb_define_module_function(mXML, "default_substitute_entities", rxml_default_substitute_entities_get, 0);
|
965
|
+
rb_define_module_function(mXML, "default_substitute_entities=", rxml_default_substitute_entities_set, 1);
|
966
|
+
rb_define_module_function(mXML, "default_tree_indent_string", rxml_default_tree_indent_string_get, 0);
|
967
|
+
rb_define_module_function(mXML, "default_tree_indent_string=", rxml_default_tree_indent_string_set, 1);
|
968
|
+
rb_define_module_function(mXML, "default_validity_checking", rxml_default_validity_checking_get, 0);
|
969
|
+
rb_define_module_function(mXML, "default_validity_checking=", rxml_default_validity_checking_set, 1);
|
970
|
+
rb_define_module_function(mXML, "default_warnings", rxml_default_warnings_get, 0);
|
971
|
+
rb_define_module_function(mXML, "default_warnings=", rxml_default_warnings_set, 1);
|
972
|
+
rb_define_module_function(mXML, "features", rxml_features, 0);
|
973
|
+
rb_define_module_function(mXML, "indent_tree_output", rxml_indent_tree_output_get, 0);
|
974
|
+
rb_define_module_function(mXML, "indent_tree_output=", rxml_indent_tree_output_set, 1);
|
975
|
+
rb_define_module_function(mXML, "memory_dump", rxml_memory_dump, 0);
|
976
|
+
rb_define_module_function(mXML, "memory_used", rxml_memory_used, 0);
|
977
|
+
}
|