libxml-ruby 0.9.7-x86-mswin32-60 → 0.9.8-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +53 -0
- data/Rakefile +1 -0
- data/ext/libxml/build.log +4 -0
- data/ext/libxml/cbg.c +86 -86
- data/ext/libxml/libxml.c +878 -876
- data/ext/libxml/ruby_libxml.h +8 -4
- data/ext/libxml/ruby_xml_attr.c +36 -168
- data/ext/libxml/ruby_xml_attr.h +2 -4
- data/ext/libxml/ruby_xml_attr_decl.c +177 -0
- data/ext/libxml/ruby_xml_attr_decl.h +13 -0
- data/ext/libxml/ruby_xml_attributes.c +29 -20
- data/ext/libxml/ruby_xml_document.c +895 -898
- data/ext/libxml/ruby_xml_dtd.c +18 -1
- data/ext/libxml/ruby_xml_dtd.h +1 -0
- data/ext/libxml/ruby_xml_encoding.c +116 -0
- data/ext/libxml/ruby_xml_encoding.h +12 -0
- data/ext/libxml/ruby_xml_error.c +8 -2
- data/ext/libxml/ruby_xml_html_parser.c +53 -74
- data/ext/libxml/ruby_xml_html_parser.h +2 -3
- data/ext/libxml/ruby_xml_html_parser_context.c +145 -0
- data/ext/libxml/ruby_xml_html_parser_context.h +12 -0
- data/ext/libxml/ruby_xml_html_parser_options.c +48 -0
- data/ext/libxml/ruby_xml_html_parser_options.h +12 -0
- data/ext/libxml/ruby_xml_input_cbg.c +1 -1
- data/ext/libxml/ruby_xml_io.c +30 -0
- data/ext/libxml/ruby_xml_io.h +9 -0
- data/ext/libxml/ruby_xml_namespace.c +34 -16
- data/ext/libxml/ruby_xml_namespace.h +2 -2
- data/ext/libxml/ruby_xml_namespaces.c +6 -6
- data/ext/libxml/ruby_xml_node.c +1367 -1324
- data/ext/libxml/ruby_xml_node.h +2 -2
- data/ext/libxml/ruby_xml_parser.c +26 -78
- data/ext/libxml/ruby_xml_parser.h +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +284 -13
- data/ext/libxml/ruby_xml_parser_context.h +1 -2
- data/ext/libxml/ruby_xml_parser_options.c +75 -0
- data/ext/libxml/ruby_xml_parser_options.h +14 -0
- data/ext/libxml/ruby_xml_reader.c +277 -183
- data/ext/libxml/ruby_xml_sax_parser.c +60 -57
- data/ext/libxml/ruby_xml_xpath_context.c +43 -8
- data/ext/libxml/ruby_xml_xpath_expression.c +6 -0
- data/ext/libxml/ruby_xml_xpath_object.c +107 -95
- data/ext/libxml/ruby_xml_xpath_object.h +9 -1
- data/ext/libxml/ruby_xml_xpointer.c +107 -107
- data/ext/libxml/version.h +2 -2
- data/ext/mingw/libxml_ruby.dll.a +0 -0
- data/ext/mingw/libxml_ruby.so +0 -0
- data/ext/vc/libxml_ruby.vcproj +43 -3
- data/lib/libxml.rb +2 -3
- data/lib/libxml/attr.rb +71 -2
- data/lib/libxml/attr_decl.rb +81 -0
- data/lib/libxml/document.rb +78 -14
- data/lib/libxml/html_parser.rb +75 -42
- data/lib/libxml/node.rb +11 -0
- data/lib/libxml/parser.rb +106 -62
- data/lib/libxml/reader.rb +12 -0
- data/lib/libxml/sax_parser.rb +42 -52
- data/lib/libxml/xpath_object.rb +15 -0
- data/test/model/atom.xml +12 -12
- data/test/model/bands.xml +4 -4
- data/test/model/books.xml +146 -147
- data/test/model/merge_bug_data.xml +1 -1
- data/test/model/rubynet.xml +1 -0
- data/test/model/shiporder.rng +1 -1
- data/test/model/shiporder.xml +22 -22
- data/test/model/shiporder.xsd +30 -30
- data/test/model/xinclude.xml +1 -1
- data/test/{tc_node_attr.rb → tc_attr.rb} +1 -1
- data/test/tc_attr_decl.rb +131 -0
- data/test/tc_deprecated_require.rb +1 -3
- data/test/tc_document.rb +13 -3
- data/test/tc_document_write.rb +5 -5
- data/test/tc_dtd.rb +13 -5
- data/test/tc_html_parser.rb +14 -26
- data/test/tc_node_cdata.rb +1 -3
- data/test/tc_node_comment.rb +2 -4
- data/test/tc_node_edit.rb +2 -3
- data/test/tc_node_text.rb +35 -1
- data/test/tc_node_write.rb +3 -3
- data/test/tc_node_xlink.rb +2 -4
- data/test/tc_parser.rb +163 -70
- data/test/tc_parser_context.rb +103 -42
- data/test/tc_reader.rb +173 -45
- data/test/tc_relaxng.rb +2 -2
- data/test/tc_sax_parser.rb +48 -52
- data/test/tc_schema.rb +2 -2
- data/test/tc_xpath.rb +37 -6
- data/test/tc_xpath_context.rb +7 -1
- data/test/tc_xpath_expression.rb +1 -3
- data/test/tc_xpointer.rb +1 -3
- data/test/test_suite.rb +2 -3
- metadata +20 -13
- data/ext/libxml/ruby_xml_input.c +0 -329
- data/ext/libxml/ruby_xml_input.h +0 -20
- data/lib/libxml/parser_context.rb +0 -17
- data/lib/libxml/parser_options.rb +0 -25
- data/test/model/simple.xml +0 -7
- data/test/tc_input.rb +0 -13
- data/test/tc_well_formed.rb +0 -11
data/CHANGES
CHANGED
@@ -1,3 +1,54 @@
|
|
1
|
+
== 0.9.8 / 2009-1-24 Charlie Savage
|
2
|
+
|
3
|
+
* Refactored XML::Parser, XML::HTMLParser, XML::SaxParser and
|
4
|
+
XML::Reader to have consistent APIs. All the parsers
|
5
|
+
now take a context object in their constructors, allowing fine
|
6
|
+
grained control over the parsers for advanced use cases. These
|
7
|
+
API changes are backwards compatible except
|
8
|
+
for XML::Reader, which now takes an optional hash table as a
|
9
|
+
second parameter in its various constructors versus an optional
|
10
|
+
boolean value.
|
11
|
+
|
12
|
+
* Updated all APIs to use the encoding constants defined
|
13
|
+
in XML::Encoding versus string valus. This API change
|
14
|
+
is not backwards compatible.
|
15
|
+
|
16
|
+
* Added support for attribute declarations in DTD's via the new
|
17
|
+
XML::AttrDecl class (Len Lattanzi)
|
18
|
+
|
19
|
+
* Support libxml's content escaping capabilities for text nodes by
|
20
|
+
wrapping libxml's "xmlStringText" and "xmlStringTextNoenc"
|
21
|
+
(Joe Khoobyar).
|
22
|
+
|
23
|
+
* Updated XML::Reader#read API to return true if a node was read,
|
24
|
+
false if node was not read and raises an exception on an error.
|
25
|
+
Previously #read returned 1 if a node was read, 0 if a node was
|
26
|
+
not read and -1 for an error. This change is not backwards
|
27
|
+
compatible, but provides a more natural interface for Ruby by
|
28
|
+
allowing code like this:
|
29
|
+
|
30
|
+
while reader.read
|
31
|
+
# do stuff
|
32
|
+
end
|
33
|
+
|
34
|
+
* Changed XML::Error exception objects to return copies of nodes that
|
35
|
+
cause parse errors instead of the original node. This prevents
|
36
|
+
segmentation faults when the error is reraised.
|
37
|
+
|
38
|
+
* Added XML::Reader#node method.
|
39
|
+
|
40
|
+
* Fixed compile errors on OS X which uses an older version of libxml.
|
41
|
+
|
42
|
+
* Fixed memory leak when performing XPath searches.
|
43
|
+
|
44
|
+
* Fixed rdocs.
|
45
|
+
|
46
|
+
* Don't override libxml's default settings for entity substitution and
|
47
|
+
loading external DTDs. This may break some code - you may need to
|
48
|
+
add in a call to XML.default_substitute_entities = true or
|
49
|
+
XML.default_load_external_dtd = true.
|
50
|
+
|
51
|
+
|
1
52
|
== 0.9.7 / 2008-12-08 Charlie Savage
|
2
53
|
|
3
54
|
* Added SAX2 support. SAX handlers now define two new callbacks,
|
@@ -21,6 +72,8 @@
|
|
21
72
|
|
22
73
|
* Fix compilation bugs on Solaris.
|
23
74
|
|
75
|
+
* Fix Rdoc compilation bug.
|
76
|
+
|
24
77
|
|
25
78
|
== 0.9.6 / 2008-12-08 Charlie Savage
|
26
79
|
|
data/Rakefile
CHANGED
data/ext/libxml/cbg.c
CHANGED
@@ -1,86 +1,86 @@
|
|
1
|
-
#include "ruby_libxml.h"
|
2
|
-
#include <string.h>
|
3
|
-
#include <libxml/xmlIO.h>
|
4
|
-
|
5
|
-
/*
|
6
|
-
int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
|
7
|
-
xmlInputOpenCallback openFunc,
|
8
|
-
xmlInputReadCallback readFunc,
|
9
|
-
xmlInputCloseCallback closeFunc);
|
10
|
-
|
11
|
-
|
12
|
-
int (*xmlInputMatchCallback) (char const *filename);
|
13
|
-
void* (*xmlInputOpenCallback) (char const *filename);
|
14
|
-
int (*xmlInputReadCallback) (void *context,
|
15
|
-
char *buffer,
|
16
|
-
int len);
|
17
|
-
int (*xmlInputCloseCallback) (void *context);
|
18
|
-
*/
|
19
|
-
|
20
|
-
typedef struct deb_doc_context
|
21
|
-
{
|
22
|
-
char *buffer;
|
23
|
-
char *bpos;
|
24
|
-
int remaining;
|
25
|
-
} deb_doc_context;
|
26
|
-
|
27
|
-
int deb_Match(char const *filename)
|
28
|
-
{
|
29
|
-
fprintf(stderr, "deb_Match: %s\n", filename);
|
30
|
-
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "deb://", 6))
|
31
|
-
{
|
32
|
-
return (1);
|
33
|
-
}
|
34
|
-
return (0);
|
35
|
-
}
|
36
|
-
|
37
|
-
void* deb_Open(char const *filename)
|
38
|
-
{
|
39
|
-
deb_doc_context *deb_doc;
|
40
|
-
VALUE res;
|
41
|
-
|
42
|
-
deb_doc = (deb_doc_context*) malloc(sizeof(deb_doc_context));
|
43
|
-
|
44
|
-
res = rb_funcall(rb_funcall(rb_mKernel, rb_intern("const_get"), 1,
|
45
|
-
rb_str_new2("DEBSystem")), rb_intern("document_query"), 1, rb_str_new2(
|
46
|
-
filename));
|
47
|
-
deb_doc->buffer = strdup(StringValuePtr(res));
|
48
|
-
//deb_doc->buffer = strdup("<serepes>serepes</serepes>");
|
49
|
-
|
50
|
-
deb_doc->bpos = deb_doc->buffer;
|
51
|
-
deb_doc->remaining = strlen(deb_doc->buffer);
|
52
|
-
return deb_doc;
|
53
|
-
}
|
54
|
-
|
55
|
-
int deb_Read(void *context, char *buffer, int len)
|
56
|
-
{
|
57
|
-
deb_doc_context *deb_doc;
|
58
|
-
int ret_len;
|
59
|
-
deb_doc = (deb_doc_context*) context;
|
60
|
-
|
61
|
-
if (len >= deb_doc->remaining)
|
62
|
-
{
|
63
|
-
ret_len = deb_doc->remaining;
|
64
|
-
}
|
65
|
-
else
|
66
|
-
{
|
67
|
-
ret_len = len;
|
68
|
-
}
|
69
|
-
deb_doc->remaining -= ret_len;
|
70
|
-
strncpy(buffer, deb_doc->bpos, ret_len);
|
71
|
-
deb_doc->bpos += ret_len;
|
72
|
-
|
73
|
-
return ret_len;
|
74
|
-
}
|
75
|
-
|
76
|
-
int deb_Close(void *context)
|
77
|
-
{
|
78
|
-
free(((deb_doc_context*) context)->buffer);
|
79
|
-
free(context);
|
80
|
-
return 1;
|
81
|
-
}
|
82
|
-
|
83
|
-
void deb_register_cbg()
|
84
|
-
{
|
85
|
-
xmlRegisterInputCallbacks(deb_Match, deb_Open, deb_Read, deb_Close);
|
86
|
-
}
|
1
|
+
#include "ruby_libxml.h"
|
2
|
+
#include <string.h>
|
3
|
+
#include <libxml/xmlIO.h>
|
4
|
+
|
5
|
+
/*
|
6
|
+
int xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
|
7
|
+
xmlInputOpenCallback openFunc,
|
8
|
+
xmlInputReadCallback readFunc,
|
9
|
+
xmlInputCloseCallback closeFunc);
|
10
|
+
|
11
|
+
|
12
|
+
int (*xmlInputMatchCallback) (char const *filename);
|
13
|
+
void* (*xmlInputOpenCallback) (char const *filename);
|
14
|
+
int (*xmlInputReadCallback) (void *context,
|
15
|
+
char *buffer,
|
16
|
+
int len);
|
17
|
+
int (*xmlInputCloseCallback) (void *context);
|
18
|
+
*/
|
19
|
+
|
20
|
+
typedef struct deb_doc_context
|
21
|
+
{
|
22
|
+
char *buffer;
|
23
|
+
char *bpos;
|
24
|
+
int remaining;
|
25
|
+
} deb_doc_context;
|
26
|
+
|
27
|
+
int deb_Match(char const *filename)
|
28
|
+
{
|
29
|
+
fprintf(stderr, "deb_Match: %s\n", filename);
|
30
|
+
if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "deb://", 6))
|
31
|
+
{
|
32
|
+
return (1);
|
33
|
+
}
|
34
|
+
return (0);
|
35
|
+
}
|
36
|
+
|
37
|
+
void* deb_Open(char const *filename)
|
38
|
+
{
|
39
|
+
deb_doc_context *deb_doc;
|
40
|
+
VALUE res;
|
41
|
+
|
42
|
+
deb_doc = (deb_doc_context*) malloc(sizeof(deb_doc_context));
|
43
|
+
|
44
|
+
res = rb_funcall(rb_funcall(rb_mKernel, rb_intern("const_get"), 1,
|
45
|
+
rb_str_new2("DEBSystem")), rb_intern("document_query"), 1, rb_str_new2(
|
46
|
+
filename));
|
47
|
+
deb_doc->buffer = strdup(StringValuePtr(res));
|
48
|
+
//deb_doc->buffer = strdup("<serepes>serepes</serepes>");
|
49
|
+
|
50
|
+
deb_doc->bpos = deb_doc->buffer;
|
51
|
+
deb_doc->remaining = strlen(deb_doc->buffer);
|
52
|
+
return deb_doc;
|
53
|
+
}
|
54
|
+
|
55
|
+
int deb_Read(void *context, char *buffer, int len)
|
56
|
+
{
|
57
|
+
deb_doc_context *deb_doc;
|
58
|
+
int ret_len;
|
59
|
+
deb_doc = (deb_doc_context*) context;
|
60
|
+
|
61
|
+
if (len >= deb_doc->remaining)
|
62
|
+
{
|
63
|
+
ret_len = deb_doc->remaining;
|
64
|
+
}
|
65
|
+
else
|
66
|
+
{
|
67
|
+
ret_len = len;
|
68
|
+
}
|
69
|
+
deb_doc->remaining -= ret_len;
|
70
|
+
strncpy(buffer, deb_doc->bpos, ret_len);
|
71
|
+
deb_doc->bpos += ret_len;
|
72
|
+
|
73
|
+
return ret_len;
|
74
|
+
}
|
75
|
+
|
76
|
+
int deb_Close(void *context)
|
77
|
+
{
|
78
|
+
free(((deb_doc_context*) context)->buffer);
|
79
|
+
free(context);
|
80
|
+
return 1;
|
81
|
+
}
|
82
|
+
|
83
|
+
void deb_register_cbg()
|
84
|
+
{
|
85
|
+
xmlRegisterInputCallbacks(deb_Match, deb_Open, deb_Read, deb_Close);
|
86
|
+
}
|
data/ext/libxml/libxml.c
CHANGED
@@ -1,876 +1,878 @@
|
|
1
|
-
/* $Id: libxml.c
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#include "ruby_libxml.h"
|
6
|
-
|
7
|
-
VALUE mLibXML;
|
8
|
-
VALUE mXML;
|
9
|
-
|
10
|
-
/*
|
11
|
-
* call-seq:
|
12
|
-
* XML.catalog_dump -> true
|
13
|
-
*
|
14
|
-
* Dump all the global catalog content stdout.
|
15
|
-
*/
|
16
|
-
static VALUE rxml_catalog_dump(VALUE self)
|
17
|
-
{
|
18
|
-
xmlCatalogDump(stdout);
|
19
|
-
return (Qtrue);
|
20
|
-
}
|
21
|
-
|
22
|
-
/*
|
23
|
-
* call-seq:
|
24
|
-
* XML.catalog_remove(catalog) -> true
|
25
|
-
*
|
26
|
-
* Remove the specified resource catalog.
|
27
|
-
*/
|
28
|
-
static VALUE rxml_catalog_remove(VALUE self, VALUE cat)
|
29
|
-
{
|
30
|
-
Check_Type(cat, T_STRING);
|
31
|
-
xmlCatalogRemove((xmlChar *) StringValuePtr(cat));
|
32
|
-
return (Qtrue);
|
33
|
-
}
|
34
|
-
|
35
|
-
/*
|
36
|
-
* call-seq:
|
37
|
-
* XML.check_lib_versions -> true
|
38
|
-
*
|
39
|
-
* Check LIBXML version matches version the bindings
|
40
|
-
* were compiled to. Throws an exception if not.
|
41
|
-
*/
|
42
|
-
static VALUE rxml_check_lib_versions(VALUE class)
|
43
|
-
{
|
44
|
-
xmlCheckVersion(LIBXML_VERSION);
|
45
|
-
return (Qtrue);
|
46
|
-
}
|
47
|
-
|
48
|
-
/*
|
49
|
-
* call-seq:
|
50
|
-
* XML.enabled_automata? -> (true|false)
|
51
|
-
*
|
52
|
-
* Determine whether libxml regexp automata support is enabled.
|
53
|
-
*/
|
54
|
-
static VALUE rxml_enabled_automata_q(VALUE class)
|
55
|
-
{
|
56
|
-
#ifdef LIBXML_AUTOMATA_ENABLED
|
57
|
-
return(Qtrue);
|
58
|
-
#else
|
59
|
-
return (Qfalse);
|
60
|
-
#endif
|
61
|
-
}
|
62
|
-
|
63
|
-
/*
|
64
|
-
* call-seq:
|
65
|
-
* XML.enabled_c14n? -> (true|false)
|
66
|
-
*
|
67
|
-
* Determine whether libxml 'canonical XML' support is enabled.
|
68
|
-
* See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
|
69
|
-
*/
|
70
|
-
static VALUE rxml_enabled_c14n_q(VALUE class)
|
71
|
-
{
|
72
|
-
#ifdef LIBXML_C14N_ENABLED
|
73
|
-
return(Qtrue);
|
74
|
-
#else
|
75
|
-
return (Qfalse);
|
76
|
-
#endif
|
77
|
-
}
|
78
|
-
|
79
|
-
/*
|
80
|
-
* call-seq:
|
81
|
-
* XML.enabled_catalog? -> (true|false)
|
82
|
-
*
|
83
|
-
* Determine whether libxml resource catalog support is enabled.
|
84
|
-
*/
|
85
|
-
static VALUE rxml_enabled_catalog_q(VALUE class)
|
86
|
-
{
|
87
|
-
#ifdef LIBXML_CATALOG_ENABLED
|
88
|
-
return(Qtrue);
|
89
|
-
#else
|
90
|
-
return (Qfalse);
|
91
|
-
#endif
|
92
|
-
}
|
93
|
-
|
94
|
-
/*
|
95
|
-
* call-seq:
|
96
|
-
* XML.enabled_debug? -> (true|false)
|
97
|
-
*
|
98
|
-
* Determine whether libxml debugging support is enabled.
|
99
|
-
*/
|
100
|
-
static VALUE rxml_enabled_debug_q(VALUE class)
|
101
|
-
{
|
102
|
-
#ifdef LIBXML_DEBUG_ENABLED
|
103
|
-
return(Qtrue);
|
104
|
-
#else
|
105
|
-
return (Qfalse);
|
106
|
-
#endif
|
107
|
-
}
|
108
|
-
|
109
|
-
/*
|
110
|
-
* call-seq:
|
111
|
-
* XML.enabled_docbook? -> (true|false)
|
112
|
-
*
|
113
|
-
* Determine whether libxml docbook support is enabled.
|
114
|
-
*/
|
115
|
-
static VALUE rxml_enabled_docbook_q(VALUE class)
|
116
|
-
{
|
117
|
-
#ifdef LIBXML_DOCB_ENABLED
|
118
|
-
return(Qtrue);
|
119
|
-
#else
|
120
|
-
return (Qfalse);
|
121
|
-
#endif
|
122
|
-
}
|
123
|
-
|
124
|
-
/*
|
125
|
-
* call-seq:
|
126
|
-
* XML.enabled_ftp? -> (true|false)
|
127
|
-
*
|
128
|
-
* Determine whether libxml ftp client support is enabled.
|
129
|
-
*/
|
130
|
-
static VALUE rxml_enabled_ftp_q(VALUE class)
|
131
|
-
{
|
132
|
-
#ifdef LIBXML_FTP_ENABLED
|
133
|
-
return(Qtrue);
|
134
|
-
#else
|
135
|
-
return (Qfalse);
|
136
|
-
#endif
|
137
|
-
}
|
138
|
-
|
139
|
-
/*
|
140
|
-
* call-seq:
|
141
|
-
* XML.enabled_http? -> (true|false)
|
142
|
-
*
|
143
|
-
* Determine whether libxml http client support is enabled.
|
144
|
-
*/
|
145
|
-
static VALUE rxml_enabled_http_q(VALUE class)
|
146
|
-
{
|
147
|
-
#ifdef LIBXML_HTTP_ENABLED
|
148
|
-
return(Qtrue);
|
149
|
-
#else
|
150
|
-
return (Qfalse);
|
151
|
-
#endif
|
152
|
-
}
|
153
|
-
|
154
|
-
/*
|
155
|
-
* call-seq:
|
156
|
-
* XML.enabled_html? -> (true|false)
|
157
|
-
*
|
158
|
-
* Determine whether libxml html support is enabled.
|
159
|
-
*/
|
160
|
-
static VALUE rxml_enabled_html_q(VALUE class)
|
161
|
-
{
|
162
|
-
#ifdef LIBXML_HTML_ENABLED
|
163
|
-
return(Qtrue);
|
164
|
-
#else
|
165
|
-
return (Qfalse);
|
166
|
-
#endif
|
167
|
-
}
|
168
|
-
|
169
|
-
/*
|
170
|
-
* call-seq:
|
171
|
-
* XML.enabled_iconv? -> (true|false)
|
172
|
-
*
|
173
|
-
* Determine whether libxml iconv support is enabled.
|
174
|
-
*/
|
175
|
-
static VALUE rxml_enabled_iconv_q(VALUE class)
|
176
|
-
{
|
177
|
-
#ifdef LIBXML_ICONV_ENABLED
|
178
|
-
return(Qtrue);
|
179
|
-
#else
|
180
|
-
return (Qfalse);
|
181
|
-
#endif
|
182
|
-
}
|
183
|
-
|
184
|
-
/*
|
185
|
-
* call-seq:
|
186
|
-
* XML.enabled_memory_debug? -> (true|false)
|
187
|
-
*
|
188
|
-
* Determine whether libxml memory location debugging support
|
189
|
-
* is enabled.
|
190
|
-
*/
|
191
|
-
static VALUE rxml_enabled_memory_debug_location_q(VALUE class)
|
192
|
-
{
|
193
|
-
#ifdef DEBUG_MEMORY_LOCATION
|
194
|
-
return(Qtrue);
|
195
|
-
#else
|
196
|
-
return (Qfalse);
|
197
|
-
#endif
|
198
|
-
}
|
199
|
-
|
200
|
-
/*
|
201
|
-
* call-seq:
|
202
|
-
* XML.enabled_regexp? -> (true|false)
|
203
|
-
*
|
204
|
-
* Determine whether libxml regular expression support is enabled.
|
205
|
-
*/
|
206
|
-
static VALUE rxml_enabled_regexp_q(VALUE class)
|
207
|
-
{
|
208
|
-
#ifdef LIBXML_REGEXP_ENABLED
|
209
|
-
return(Qtrue);
|
210
|
-
#else
|
211
|
-
return (Qfalse);
|
212
|
-
#endif
|
213
|
-
}
|
214
|
-
|
215
|
-
/*
|
216
|
-
* call-seq:
|
217
|
-
* XML.enabled_schemas? -> (true|false)
|
218
|
-
*
|
219
|
-
* Determine whether libxml schema support is enabled.
|
220
|
-
*/
|
221
|
-
static VALUE rxml_enabled_schemas_q(VALUE class)
|
222
|
-
{
|
223
|
-
#ifdef LIBXML_SCHEMAS_ENABLED
|
224
|
-
return(Qtrue);
|
225
|
-
#else
|
226
|
-
return (Qfalse);
|
227
|
-
#endif
|
228
|
-
}
|
229
|
-
|
230
|
-
/*
|
231
|
-
* call-seq:
|
232
|
-
* XML.enabled_thread? -> (true|false)
|
233
|
-
*
|
234
|
-
* Determine whether libxml thread-safe semantics support
|
235
|
-
* is enabled (I think?).
|
236
|
-
*/
|
237
|
-
static VALUE rxml_enabled_thread_q(VALUE class)
|
238
|
-
{
|
239
|
-
#ifdef LIBXML_THREAD_ENABLED
|
240
|
-
return(Qtrue);
|
241
|
-
#else
|
242
|
-
return (Qfalse);
|
243
|
-
#endif
|
244
|
-
}
|
245
|
-
|
246
|
-
/*
|
247
|
-
* call-seq:
|
248
|
-
* XML.enabled_unicode? -> (true|false)
|
249
|
-
*
|
250
|
-
* Determine whether libxml unicode support is enabled.
|
251
|
-
*/
|
252
|
-
static VALUE rxml_enabled_unicode_q(VALUE class)
|
253
|
-
{
|
254
|
-
#ifdef LIBXML_UNICODE_ENABLED
|
255
|
-
return(Qtrue);
|
256
|
-
#else
|
257
|
-
return (Qfalse);
|
258
|
-
#endif
|
259
|
-
}
|
260
|
-
|
261
|
-
/*
|
262
|
-
* call-seq:
|
263
|
-
* XML.enabled_xinclude? -> (true|false)
|
264
|
-
*
|
265
|
-
* Determine whether libxml xinclude support is enabled.
|
266
|
-
*/
|
267
|
-
static VALUE rxml_enabled_xinclude_q(VALUE class)
|
268
|
-
{
|
269
|
-
#ifdef LIBXML_XINCLUDE_ENABLED
|
270
|
-
return(Qtrue);
|
271
|
-
#else
|
272
|
-
return (Qfalse);
|
273
|
-
#endif
|
274
|
-
}
|
275
|
-
|
276
|
-
/*
|
277
|
-
* call-seq:
|
278
|
-
* XML.enabled_xpath? -> (true|false)
|
279
|
-
*
|
280
|
-
* Determine whether libxml xpath support is enabled.
|
281
|
-
*/
|
282
|
-
static VALUE rxml_enabled_xpath_q(VALUE class)
|
283
|
-
{
|
284
|
-
#ifdef LIBXML_XPATH_ENABLED
|
285
|
-
return(Qtrue);
|
286
|
-
#else
|
287
|
-
return (Qfalse);
|
288
|
-
#endif
|
289
|
-
}
|
290
|
-
|
291
|
-
/*
|
292
|
-
* call-seq:
|
293
|
-
* XML.enabled_xpointer? -> (true|false)
|
294
|
-
*
|
295
|
-
* Determine whether libxml xpointer support is enabled.
|
296
|
-
*/
|
297
|
-
static VALUE rxml_enabled_xpointer_q(VALUE class)
|
298
|
-
{
|
299
|
-
#ifdef LIBXML_XPTR_ENABLED
|
300
|
-
return(Qtrue);
|
301
|
-
#else
|
302
|
-
return (Qfalse);
|
303
|
-
#endif
|
304
|
-
}
|
305
|
-
|
306
|
-
/*
|
307
|
-
* call-seq:
|
308
|
-
* XML.enabled_zlib? -> (true|false)
|
309
|
-
*
|
310
|
-
* Determine whether libxml zlib support is enabled.
|
311
|
-
*/
|
312
|
-
static VALUE rxml_enabled_zlib_q(VALUE class)
|
313
|
-
{
|
314
|
-
#ifdef HAVE_ZLIB_H
|
315
|
-
return(Qtrue);
|
316
|
-
#else
|
317
|
-
return (Qfalse);
|
318
|
-
#endif
|
319
|
-
}
|
320
|
-
|
321
|
-
/*
|
322
|
-
* call-seq:
|
323
|
-
* XML.debug_entities -> (true|false)
|
324
|
-
*
|
325
|
-
* Determine whether included-entity debugging is enabled.
|
326
|
-
* (Requires Libxml to be compiled with debugging support)
|
327
|
-
*/
|
328
|
-
static VALUE rxml_debug_entities_get(VALUE class)
|
329
|
-
{
|
330
|
-
#ifdef LIBXML_DEBUG_ENABLED
|
331
|
-
if (xmlParserDebugEntities)
|
332
|
-
return(Qtrue);
|
333
|
-
else
|
334
|
-
return(Qfalse);
|
335
|
-
#else
|
336
|
-
rb_warn("libxml was compiled with debugging turned off");
|
337
|
-
return (Qfalse);
|
338
|
-
#endif
|
339
|
-
}
|
340
|
-
|
341
|
-
/*
|
342
|
-
* call-seq:
|
343
|
-
* XML.debug_entities = true|false
|
344
|
-
*
|
345
|
-
* Enable or disable included-entity debugging.
|
346
|
-
* (Requires Libxml to be compiled with debugging support)
|
347
|
-
*/
|
348
|
-
static VALUE rxml_debug_entities_set(VALUE class, VALUE bool)
|
349
|
-
{
|
350
|
-
#ifdef LIBXML_DEBUG_ENABLED
|
351
|
-
if (TYPE(bool) == T_FALSE)
|
352
|
-
{
|
353
|
-
xmlParserDebugEntities = 0;
|
354
|
-
return(Qfalse);
|
355
|
-
}
|
356
|
-
else
|
357
|
-
{
|
358
|
-
xmlParserDebugEntities = 1;
|
359
|
-
return(Qtrue);
|
360
|
-
}
|
361
|
-
#else
|
362
|
-
rb_warn("libxml was compiled with debugging turned off");
|
363
|
-
#endif
|
364
|
-
}
|
365
|
-
|
366
|
-
/*
|
367
|
-
* call-seq:
|
368
|
-
* XML.default_keep_blanks -> (true|false)
|
369
|
-
*
|
370
|
-
* Determine whether parsers retain whitespace by default.
|
371
|
-
*/
|
372
|
-
static VALUE rxml_default_keep_blanks_get(VALUE class)
|
373
|
-
{
|
374
|
-
if (xmlKeepBlanksDefaultValue)
|
375
|
-
return (Qtrue);
|
376
|
-
else
|
377
|
-
return (Qfalse);
|
378
|
-
}
|
379
|
-
|
380
|
-
/*
|
381
|
-
* call-seq:
|
382
|
-
* XML.default_keep_blanks = true|false
|
383
|
-
*
|
384
|
-
* Controls whether parsers retain whitespace by default.
|
385
|
-
*/
|
386
|
-
static VALUE rxml_default_keep_blanks_set(VALUE class, VALUE bool)
|
387
|
-
{
|
388
|
-
if (TYPE(bool) == T_FALSE)
|
389
|
-
{
|
390
|
-
xmlKeepBlanksDefaultValue = 0;
|
391
|
-
return (Qfalse);
|
392
|
-
}
|
393
|
-
else if (TYPE(bool) == T_TRUE)
|
394
|
-
{
|
395
|
-
xmlKeepBlanksDefaultValue = 1;
|
396
|
-
return (Qtrue);
|
397
|
-
}
|
398
|
-
else
|
399
|
-
{
|
400
|
-
rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
|
401
|
-
}
|
402
|
-
}
|
403
|
-
|
404
|
-
/*
|
405
|
-
* call-seq:
|
406
|
-
* XML.default_load_external_dtd -> (true|false)
|
407
|
-
*
|
408
|
-
* Determine whether parsers load external DTDs by default.
|
409
|
-
*/
|
410
|
-
static VALUE rxml_default_load_external_dtd_get(VALUE class)
|
411
|
-
{
|
412
|
-
if (xmlLoadExtDtdDefaultValue)
|
413
|
-
return (Qtrue);
|
414
|
-
else
|
415
|
-
return (Qfalse);
|
416
|
-
}
|
417
|
-
|
418
|
-
/*
|
419
|
-
* call-seq:
|
420
|
-
* XML.default_load_external_dtd = true|false
|
421
|
-
*
|
422
|
-
* Controls whether parsers load external DTDs by default.
|
423
|
-
*/
|
424
|
-
static VALUE rxml_default_load_external_dtd_set(VALUE class, VALUE bool)
|
425
|
-
{
|
426
|
-
if (
|
427
|
-
{
|
428
|
-
xmlLoadExtDtdDefaultValue = 0;
|
429
|
-
return (Qfalse);
|
430
|
-
}
|
431
|
-
else
|
432
|
-
{
|
433
|
-
xmlLoadExtDtdDefaultValue = 1;
|
434
|
-
return (Qtrue);
|
435
|
-
}
|
436
|
-
}
|
437
|
-
|
438
|
-
/*
|
439
|
-
* call-seq:
|
440
|
-
* XML.default_line_numbers -> (true|false)
|
441
|
-
*
|
442
|
-
* Determine whether parsers retain line-numbers by default.
|
443
|
-
*/
|
444
|
-
static VALUE rxml_default_line_numbers_get(VALUE class)
|
445
|
-
{
|
446
|
-
if (xmlLineNumbersDefaultValue)
|
447
|
-
return (Qtrue);
|
448
|
-
else
|
449
|
-
return (Qfalse);
|
450
|
-
}
|
451
|
-
|
452
|
-
/*
|
453
|
-
* call-seq:
|
454
|
-
* XML.default_line_numbers = true|false
|
455
|
-
*
|
456
|
-
* Controls whether parsers retain line-numbers by default.
|
457
|
-
*/
|
458
|
-
static VALUE rxml_default_line_numbers_set(VALUE class, VALUE bool)
|
459
|
-
{
|
460
|
-
if (TYPE(bool) == T_FALSE)
|
461
|
-
{
|
462
|
-
xmlLineNumbersDefault(0);
|
463
|
-
return (Qfalse);
|
464
|
-
}
|
465
|
-
else
|
466
|
-
{
|
467
|
-
xmlLineNumbersDefault(1);
|
468
|
-
return (Qtrue);
|
469
|
-
}
|
470
|
-
}
|
471
|
-
|
472
|
-
/*
|
473
|
-
* call-seq:
|
474
|
-
* XML.default_pedantic_parser -> (true|false)
|
475
|
-
*
|
476
|
-
* Determine whether parsers are pedantic by default.
|
477
|
-
*/
|
478
|
-
static VALUE rxml_default_pedantic_parser_get(VALUE class)
|
479
|
-
{
|
480
|
-
if (xmlPedanticParserDefaultValue)
|
481
|
-
return (Qtrue);
|
482
|
-
else
|
483
|
-
return (Qfalse);
|
484
|
-
}
|
485
|
-
|
486
|
-
/*
|
487
|
-
* call-seq:
|
488
|
-
* XML.default_pedantic_parser = true|false
|
489
|
-
*
|
490
|
-
* Controls whether parsers are pedantic by default.
|
491
|
-
*/
|
492
|
-
static VALUE rxml_default_pedantic_parser_set(VALUE class, VALUE bool)
|
493
|
-
{
|
494
|
-
if (TYPE(bool) == T_FALSE)
|
495
|
-
{
|
496
|
-
xmlPedanticParserDefault(0);
|
497
|
-
return (Qfalse);
|
498
|
-
}
|
499
|
-
else
|
500
|
-
{
|
501
|
-
xmlPedanticParserDefault(1);
|
502
|
-
return (Qtrue);
|
503
|
-
}
|
504
|
-
}
|
505
|
-
|
506
|
-
/*
|
507
|
-
* call-seq:
|
508
|
-
* XML.default_substitute_entities -> (true|false)
|
509
|
-
*
|
510
|
-
* Determine whether parsers perform inline entity substitution
|
511
|
-
* (for external entities) by default.
|
512
|
-
*/
|
513
|
-
static VALUE rxml_default_substitute_entities_get(VALUE class)
|
514
|
-
{
|
515
|
-
if (xmlSubstituteEntitiesDefaultValue)
|
516
|
-
return (Qtrue);
|
517
|
-
else
|
518
|
-
return (Qfalse);
|
519
|
-
}
|
520
|
-
|
521
|
-
/*
|
522
|
-
* call-seq:
|
523
|
-
* XML.default_substitute_entities = true|false
|
524
|
-
*
|
525
|
-
* Controls whether parsers perform inline entity substitution
|
526
|
-
* (for external entities) by default.
|
527
|
-
*/
|
528
|
-
static VALUE rxml_default_substitute_entities_set(VALUE class, VALUE bool)
|
529
|
-
{
|
530
|
-
if (
|
531
|
-
{
|
532
|
-
xmlSubstituteEntitiesDefault(0);
|
533
|
-
return (Qfalse);
|
534
|
-
}
|
535
|
-
else
|
536
|
-
{
|
537
|
-
xmlSubstituteEntitiesDefault(1);
|
538
|
-
return (Qtrue);
|
539
|
-
}
|
540
|
-
}
|
541
|
-
|
542
|
-
/*
|
543
|
-
* call-seq:
|
544
|
-
* XML.default_tree_indent_string -> "string"
|
545
|
-
*
|
546
|
-
* Obtain the default string used by parsers to indent the XML tree
|
547
|
-
* for output.
|
548
|
-
*/
|
549
|
-
static VALUE rxml_default_tree_indent_string_get(VALUE class)
|
550
|
-
{
|
551
|
-
if (xmlTreeIndentString == NULL)
|
552
|
-
return (Qnil);
|
553
|
-
else
|
554
|
-
return (rb_str_new2(xmlTreeIndentString));
|
555
|
-
}
|
556
|
-
|
557
|
-
/*
|
558
|
-
* call-seq:
|
559
|
-
* XML.default_tree_indent_string = "string"
|
560
|
-
*
|
561
|
-
* Set the default string used by parsers to indent the XML tree
|
562
|
-
* for output.
|
563
|
-
*/
|
564
|
-
static VALUE rxml_default_tree_indent_string_set(VALUE class, VALUE string)
|
565
|
-
{
|
566
|
-
Check_Type(string, T_STRING);
|
567
|
-
xmlTreeIndentString = xmlStrdup((xmlChar *)StringValuePtr(string));
|
568
|
-
return (string);
|
569
|
-
}
|
570
|
-
|
571
|
-
/*
|
572
|
-
* call-seq:
|
573
|
-
* XML.default_validity_checking -> (true|false)
|
574
|
-
*
|
575
|
-
* Determine whether parsers perform XML validation by default.
|
576
|
-
*/
|
577
|
-
static VALUE rxml_default_validity_checking_get(VALUE class)
|
578
|
-
{
|
579
|
-
if (xmlDoValidityCheckingDefaultValue)
|
580
|
-
return (Qtrue);
|
581
|
-
else
|
582
|
-
return (Qfalse);
|
583
|
-
}
|
584
|
-
|
585
|
-
/*
|
586
|
-
* call-seq:
|
587
|
-
* XML.default_validity_checking = true|false
|
588
|
-
*
|
589
|
-
* Controls whether parsers perform XML validation by default.
|
590
|
-
*/
|
591
|
-
static VALUE rxml_default_validity_checking_set(VALUE class, VALUE bool)
|
592
|
-
{
|
593
|
-
if (TYPE(bool) == T_FALSE)
|
594
|
-
{
|
595
|
-
xmlDoValidityCheckingDefaultValue = 0;
|
596
|
-
return (Qfalse);
|
597
|
-
}
|
598
|
-
else
|
599
|
-
{
|
600
|
-
xmlDoValidityCheckingDefaultValue = 1;
|
601
|
-
return (Qtrue);
|
602
|
-
}
|
603
|
-
}
|
604
|
-
|
605
|
-
/*
|
606
|
-
* call-seq:
|
607
|
-
* XML.default_warnings -> (true|false)
|
608
|
-
*
|
609
|
-
* Determine whether parsers output warnings by default.
|
610
|
-
*/
|
611
|
-
static VALUE rxml_default_warnings_get(VALUE class)
|
612
|
-
{
|
613
|
-
if (xmlGetWarningsDefaultValue)
|
614
|
-
return (Qtrue);
|
615
|
-
else
|
616
|
-
return (Qfalse);
|
617
|
-
}
|
618
|
-
|
619
|
-
/*
|
620
|
-
* call-seq:
|
621
|
-
* XML.default_warnings = true|false
|
622
|
-
*
|
623
|
-
* Controls whether parsers output warnings by default.
|
624
|
-
*/
|
625
|
-
static VALUE rxml_default_warnings_set(VALUE class, VALUE bool)
|
626
|
-
{
|
627
|
-
if (TYPE(bool) == T_FALSE)
|
628
|
-
{
|
629
|
-
xmlGetWarningsDefaultValue = 0;
|
630
|
-
return (Qfalse);
|
631
|
-
}
|
632
|
-
else
|
633
|
-
{
|
634
|
-
xmlGetWarningsDefaultValue = 1;
|
635
|
-
return (Qtrue);
|
636
|
-
}
|
637
|
-
}
|
638
|
-
|
639
|
-
/*
|
640
|
-
* call-seq:
|
641
|
-
* XML.default_compression -> (true|false)
|
642
|
-
*
|
643
|
-
* Determine whether parsers use Zlib compression by default
|
644
|
-
* (requires libxml to be compiled with Zlib support).
|
645
|
-
*/
|
646
|
-
static VALUE rxml_default_compression_get(VALUE class)
|
647
|
-
{
|
648
|
-
#ifdef HAVE_ZLIB_H
|
649
|
-
return(INT2FIX(xmlGetCompressMode()));
|
650
|
-
#else
|
651
|
-
rb_warn("libxml was compiled without zlib support");
|
652
|
-
return (Qfalse);
|
653
|
-
#endif
|
654
|
-
}
|
655
|
-
|
656
|
-
/*
|
657
|
-
* call-seq:
|
658
|
-
* XML.default_compression = true|false
|
659
|
-
*
|
660
|
-
* Controls whether parsers use Zlib compression by default
|
661
|
-
* (requires libxml to be compiled with Zlib support).
|
662
|
-
*/
|
663
|
-
static VALUE rxml_default_compression_set(VALUE class, VALUE num)
|
664
|
-
{
|
665
|
-
#ifdef HAVE_ZLIB_H
|
666
|
-
Check_Type(num, T_FIXNUM);
|
667
|
-
xmlSetCompressMode(FIX2INT(num));
|
668
|
-
return(num);
|
669
|
-
#else
|
670
|
-
rb_warn("libxml was compiled without zlib support");
|
671
|
-
return (Qfalse);
|
672
|
-
#endif
|
673
|
-
}
|
674
|
-
|
675
|
-
/*
|
676
|
-
* call-seq:
|
677
|
-
* XML.features -> ["feature", ..., "feature"]
|
678
|
-
*
|
679
|
-
* Obtains an array of strings representing features supported
|
680
|
-
* (and enabled) by the installed libxml.
|
681
|
-
*/
|
682
|
-
static VALUE rxml_features(VALUE class)
|
683
|
-
{
|
684
|
-
VALUE arr, str;
|
685
|
-
int i, len = MAX_LIBXML_FEATURES_LEN;
|
686
|
-
char **list = NULL;
|
687
|
-
|
688
|
-
list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
|
689
|
-
MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
|
690
|
-
|
691
|
-
arr = rb_ary_new();
|
692
|
-
if (xmlGetFeaturesList(&len, (const char **) list) == -1)
|
693
|
-
return Qnil;
|
694
|
-
|
695
|
-
for (i = 0; i < len; i++)
|
696
|
-
{
|
697
|
-
str = rb_str_new2((const char *) list[i]);
|
698
|
-
rb_gc_unregister_address(&str);
|
699
|
-
rb_ary_push(arr, str);
|
700
|
-
}
|
701
|
-
|
702
|
-
if (len == MAX_LIBXML_FEATURES_LEN)
|
703
|
-
rb_warn(
|
704
|
-
"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");
|
705
|
-
|
706
|
-
ruby_xfree(list);
|
707
|
-
return (arr);
|
708
|
-
}
|
709
|
-
|
710
|
-
/*
|
711
|
-
* call-seq:
|
712
|
-
* XML.indent_tree_output -> (true|false)
|
713
|
-
*
|
714
|
-
* Determines whether XML output will be indented
|
715
|
-
* (using the string supplied to +default_indent_tree_string+)
|
716
|
-
*/
|
717
|
-
static VALUE rxml_indent_tree_output_get(VALUE class)
|
718
|
-
{
|
719
|
-
if (xmlIndentTreeOutput)
|
720
|
-
return (Qtrue);
|
721
|
-
else
|
722
|
-
return (Qfalse);
|
723
|
-
}
|
724
|
-
|
725
|
-
/*
|
726
|
-
* call-seq:
|
727
|
-
* XML.indent_tree_output = true|false
|
728
|
-
*
|
729
|
-
* Controls whether XML output will be indented
|
730
|
-
* (using the string supplied to +default_indent_tree_string+)
|
731
|
-
*/
|
732
|
-
static VALUE rxml_indent_tree_output_set(VALUE class, VALUE bool)
|
733
|
-
{
|
734
|
-
if (TYPE(bool) == T_TRUE)
|
735
|
-
{
|
736
|
-
xmlIndentTreeOutput = 1;
|
737
|
-
return (Qtrue);
|
738
|
-
}
|
739
|
-
else if (TYPE(bool) == T_FALSE)
|
740
|
-
{
|
741
|
-
xmlIndentTreeOutput = 0;
|
742
|
-
return (Qfalse);
|
743
|
-
}
|
744
|
-
else
|
745
|
-
{
|
746
|
-
rb_raise(rb_eArgError, "Invalid argument, must be boolean");
|
747
|
-
}
|
748
|
-
}
|
749
|
-
|
750
|
-
/*
|
751
|
-
* call-seq:
|
752
|
-
* XML.memory_dump -> (true|false)
|
753
|
-
*
|
754
|
-
* Perform a parser memory dump (requires memory debugging
|
755
|
-
* support in libxml).
|
756
|
-
*/
|
757
|
-
static VALUE rxml_memory_dump(VALUE self)
|
758
|
-
{
|
759
|
-
#ifdef DEBUG_MEMORY_LOCATION
|
760
|
-
xmlMemoryDump();
|
761
|
-
return(Qtrue);
|
762
|
-
#else
|
763
|
-
rb_warn("libxml was compiled without memory debugging support");
|
764
|
-
return (Qfalse);
|
765
|
-
#endif
|
766
|
-
}
|
767
|
-
|
768
|
-
/*
|
769
|
-
* call-seq:
|
770
|
-
* XML.memory_used -> num_bytes
|
771
|
-
*
|
772
|
-
* Perform a parser memory dump (requires memory debugging
|
773
|
-
* support in libxml).
|
774
|
-
*/
|
775
|
-
static VALUE rxml_memory_used(VALUE self)
|
776
|
-
{
|
777
|
-
#ifdef DEBUG_MEMORY_LOCATION
|
778
|
-
return(INT2NUM(xmlMemUsed()));
|
779
|
-
#else
|
780
|
-
rb_warn("libxml was compiled without memory debugging support");
|
781
|
-
return (Qfalse);
|
782
|
-
#endif
|
783
|
-
}
|
784
|
-
|
785
|
-
#if defined(_WIN32)
|
786
|
-
__declspec(dllexport)
|
787
|
-
#endif
|
788
|
-
void Init_libxml_ruby(void)
|
789
|
-
{
|
790
|
-
mLibXML = rb_define_module("LibXML");
|
791
|
-
mXML = rb_define_module_under(mLibXML, "XML");
|
792
|
-
|
793
|
-
/* Constants */
|
794
|
-
rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
|
795
|
-
rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
|
796
|
-
rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
|
797
|
-
rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2(
|
798
|
-
(const char*) XML_XML_NAMESPACE));
|
799
|
-
|
800
|
-
rb_define_module_function(mXML, "enabled_automata?", rxml_enabled_automata_q, 0);
|
801
|
-
rb_define_module_function(mXML, "enabled_c14n?", rxml_enabled_c14n_q, 0);
|
802
|
-
rb_define_module_function(mXML, "enabled_catalog?", rxml_enabled_catalog_q, 0);
|
803
|
-
rb_define_module_function(mXML, "enabled_debug?", rxml_enabled_debug_q, 0);
|
804
|
-
rb_define_module_function(mXML, "enabled_docbook?", rxml_enabled_docbook_q, 0);
|
805
|
-
rb_define_module_function(mXML, "enabled_ftp?", rxml_enabled_ftp_q, 0);
|
806
|
-
rb_define_module_function(mXML, "enabled_http?", rxml_enabled_http_q, 0);
|
807
|
-
rb_define_module_function(mXML, "enabled_html?", rxml_enabled_html_q, 0);
|
808
|
-
rb_define_module_function(mXML, "enabled_iconv?", rxml_enabled_iconv_q, 0);
|
809
|
-
rb_define_module_function(mXML, "enabled_memory_debug?", rxml_enabled_memory_debug_location_q, 0);
|
810
|
-
rb_define_module_function(mXML, "enabled_regexp?", rxml_enabled_regexp_q, 0);
|
811
|
-
rb_define_module_function(mXML, "enabled_schemas?", rxml_enabled_schemas_q, 0);
|
812
|
-
rb_define_module_function(mXML, "enabled_thread?", rxml_enabled_thread_q, 0);
|
813
|
-
rb_define_module_function(mXML, "enabled_unicode?", rxml_enabled_unicode_q, 0);
|
814
|
-
rb_define_module_function(mXML, "enabled_xinclude?", rxml_enabled_xinclude_q, 0);
|
815
|
-
rb_define_module_function(mXML, "enabled_xpath?", rxml_enabled_xpath_q, 0);
|
816
|
-
rb_define_module_function(mXML, "enabled_xpointer?", rxml_enabled_xpointer_q, 0);
|
817
|
-
rb_define_module_function(mXML, "enabled_zlib?", rxml_enabled_zlib_q, 0);
|
818
|
-
|
819
|
-
rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
|
820
|
-
rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
|
821
|
-
rb_define_module_function(mXML, "check_lib_versions", rxml_check_lib_versions, 0);
|
822
|
-
rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
|
823
|
-
rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
|
824
|
-
rb_define_module_function(mXML, "default_compression", rxml_default_compression_get, 0);
|
825
|
-
rb_define_module_function(mXML, "default_compression=", rxml_default_compression_set, 1);
|
826
|
-
rb_define_module_function(mXML, "default_keep_blanks", rxml_default_keep_blanks_get, 0);
|
827
|
-
rb_define_module_function(mXML, "default_keep_blanks=", rxml_default_keep_blanks_set, 1);
|
828
|
-
rb_define_module_function(mXML, "default_load_external_dtd", rxml_default_load_external_dtd_get, 0);
|
829
|
-
rb_define_module_function(mXML, "default_load_external_dtd=", rxml_default_load_external_dtd_set, 1);
|
830
|
-
rb_define_module_function(mXML, "default_line_numbers", rxml_default_line_numbers_get, 0);
|
831
|
-
rb_define_module_function(mXML, "default_line_numbers=", rxml_default_line_numbers_set, 1);
|
832
|
-
rb_define_module_function(mXML, "default_pedantic_parser", rxml_default_pedantic_parser_get, 0);
|
833
|
-
rb_define_module_function(mXML, "default_pedantic_parser=", rxml_default_pedantic_parser_set, 1);
|
834
|
-
rb_define_module_function(mXML, "default_substitute_entities", rxml_default_substitute_entities_get, 0);
|
835
|
-
rb_define_module_function(mXML, "default_substitute_entities=", rxml_default_substitute_entities_set, 1);
|
836
|
-
rb_define_module_function(mXML, "default_tree_indent_string", rxml_default_tree_indent_string_get, 0);
|
837
|
-
rb_define_module_function(mXML, "default_tree_indent_string=", rxml_default_tree_indent_string_set, 1);
|
838
|
-
rb_define_module_function(mXML, "default_validity_checking", rxml_default_validity_checking_get, 0);
|
839
|
-
rb_define_module_function(mXML, "default_validity_checking=", rxml_default_validity_checking_set, 1);
|
840
|
-
rb_define_module_function(mXML, "default_warnings", rxml_default_warnings_get, 0);
|
841
|
-
rb_define_module_function(mXML, "default_warnings=", rxml_default_warnings_set, 1);
|
842
|
-
rb_define_module_function(mXML, "features", rxml_features, 0);
|
843
|
-
rb_define_module_function(mXML, "indent_tree_output", rxml_indent_tree_output_get, 0);
|
844
|
-
rb_define_module_function(mXML, "indent_tree_output=", rxml_indent_tree_output_set, 1);
|
845
|
-
rb_define_module_function(mXML, "memory_dump", rxml_memory_dump, 0);
|
846
|
-
rb_define_module_function(mXML, "memory_used", rxml_memory_used, 0);
|
847
|
-
|
848
|
-
/* Now initialize all the other modules */
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
1
|
+
/* $Id: libxml.c 756 2009-01-24 22:56:05Z cfis $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "ruby_libxml.h"
|
6
|
+
|
7
|
+
VALUE mLibXML;
|
8
|
+
VALUE mXML;
|
9
|
+
|
10
|
+
/*
|
11
|
+
* call-seq:
|
12
|
+
* XML.catalog_dump -> true
|
13
|
+
*
|
14
|
+
* Dump all the global catalog content stdout.
|
15
|
+
*/
|
16
|
+
static VALUE rxml_catalog_dump(VALUE self)
|
17
|
+
{
|
18
|
+
xmlCatalogDump(stdout);
|
19
|
+
return (Qtrue);
|
20
|
+
}
|
21
|
+
|
22
|
+
/*
|
23
|
+
* call-seq:
|
24
|
+
* XML.catalog_remove(catalog) -> true
|
25
|
+
*
|
26
|
+
* Remove the specified resource catalog.
|
27
|
+
*/
|
28
|
+
static VALUE rxml_catalog_remove(VALUE self, VALUE cat)
|
29
|
+
{
|
30
|
+
Check_Type(cat, T_STRING);
|
31
|
+
xmlCatalogRemove((xmlChar *) StringValuePtr(cat));
|
32
|
+
return (Qtrue);
|
33
|
+
}
|
34
|
+
|
35
|
+
/*
|
36
|
+
* call-seq:
|
37
|
+
* XML.check_lib_versions -> true
|
38
|
+
*
|
39
|
+
* Check LIBXML version matches version the bindings
|
40
|
+
* were compiled to. Throws an exception if not.
|
41
|
+
*/
|
42
|
+
static VALUE rxml_check_lib_versions(VALUE class)
|
43
|
+
{
|
44
|
+
xmlCheckVersion(LIBXML_VERSION);
|
45
|
+
return (Qtrue);
|
46
|
+
}
|
47
|
+
|
48
|
+
/*
|
49
|
+
* call-seq:
|
50
|
+
* XML.enabled_automata? -> (true|false)
|
51
|
+
*
|
52
|
+
* Determine whether libxml regexp automata support is enabled.
|
53
|
+
*/
|
54
|
+
static VALUE rxml_enabled_automata_q(VALUE class)
|
55
|
+
{
|
56
|
+
#ifdef LIBXML_AUTOMATA_ENABLED
|
57
|
+
return(Qtrue);
|
58
|
+
#else
|
59
|
+
return (Qfalse);
|
60
|
+
#endif
|
61
|
+
}
|
62
|
+
|
63
|
+
/*
|
64
|
+
* call-seq:
|
65
|
+
* XML.enabled_c14n? -> (true|false)
|
66
|
+
*
|
67
|
+
* Determine whether libxml 'canonical XML' support is enabled.
|
68
|
+
* See "Canonical XML" (http://www.w3.org/TR/xml-c14n)
|
69
|
+
*/
|
70
|
+
static VALUE rxml_enabled_c14n_q(VALUE class)
|
71
|
+
{
|
72
|
+
#ifdef LIBXML_C14N_ENABLED
|
73
|
+
return(Qtrue);
|
74
|
+
#else
|
75
|
+
return (Qfalse);
|
76
|
+
#endif
|
77
|
+
}
|
78
|
+
|
79
|
+
/*
|
80
|
+
* call-seq:
|
81
|
+
* XML.enabled_catalog? -> (true|false)
|
82
|
+
*
|
83
|
+
* Determine whether libxml resource catalog support is enabled.
|
84
|
+
*/
|
85
|
+
static VALUE rxml_enabled_catalog_q(VALUE class)
|
86
|
+
{
|
87
|
+
#ifdef LIBXML_CATALOG_ENABLED
|
88
|
+
return(Qtrue);
|
89
|
+
#else
|
90
|
+
return (Qfalse);
|
91
|
+
#endif
|
92
|
+
}
|
93
|
+
|
94
|
+
/*
|
95
|
+
* call-seq:
|
96
|
+
* XML.enabled_debug? -> (true|false)
|
97
|
+
*
|
98
|
+
* Determine whether libxml debugging support is enabled.
|
99
|
+
*/
|
100
|
+
static VALUE rxml_enabled_debug_q(VALUE class)
|
101
|
+
{
|
102
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
103
|
+
return(Qtrue);
|
104
|
+
#else
|
105
|
+
return (Qfalse);
|
106
|
+
#endif
|
107
|
+
}
|
108
|
+
|
109
|
+
/*
|
110
|
+
* call-seq:
|
111
|
+
* XML.enabled_docbook? -> (true|false)
|
112
|
+
*
|
113
|
+
* Determine whether libxml docbook support is enabled.
|
114
|
+
*/
|
115
|
+
static VALUE rxml_enabled_docbook_q(VALUE class)
|
116
|
+
{
|
117
|
+
#ifdef LIBXML_DOCB_ENABLED
|
118
|
+
return(Qtrue);
|
119
|
+
#else
|
120
|
+
return (Qfalse);
|
121
|
+
#endif
|
122
|
+
}
|
123
|
+
|
124
|
+
/*
|
125
|
+
* call-seq:
|
126
|
+
* XML.enabled_ftp? -> (true|false)
|
127
|
+
*
|
128
|
+
* Determine whether libxml ftp client support is enabled.
|
129
|
+
*/
|
130
|
+
static VALUE rxml_enabled_ftp_q(VALUE class)
|
131
|
+
{
|
132
|
+
#ifdef LIBXML_FTP_ENABLED
|
133
|
+
return(Qtrue);
|
134
|
+
#else
|
135
|
+
return (Qfalse);
|
136
|
+
#endif
|
137
|
+
}
|
138
|
+
|
139
|
+
/*
|
140
|
+
* call-seq:
|
141
|
+
* XML.enabled_http? -> (true|false)
|
142
|
+
*
|
143
|
+
* Determine whether libxml http client support is enabled.
|
144
|
+
*/
|
145
|
+
static VALUE rxml_enabled_http_q(VALUE class)
|
146
|
+
{
|
147
|
+
#ifdef LIBXML_HTTP_ENABLED
|
148
|
+
return(Qtrue);
|
149
|
+
#else
|
150
|
+
return (Qfalse);
|
151
|
+
#endif
|
152
|
+
}
|
153
|
+
|
154
|
+
/*
|
155
|
+
* call-seq:
|
156
|
+
* XML.enabled_html? -> (true|false)
|
157
|
+
*
|
158
|
+
* Determine whether libxml html support is enabled.
|
159
|
+
*/
|
160
|
+
static VALUE rxml_enabled_html_q(VALUE class)
|
161
|
+
{
|
162
|
+
#ifdef LIBXML_HTML_ENABLED
|
163
|
+
return(Qtrue);
|
164
|
+
#else
|
165
|
+
return (Qfalse);
|
166
|
+
#endif
|
167
|
+
}
|
168
|
+
|
169
|
+
/*
|
170
|
+
* call-seq:
|
171
|
+
* XML.enabled_iconv? -> (true|false)
|
172
|
+
*
|
173
|
+
* Determine whether libxml iconv support is enabled.
|
174
|
+
*/
|
175
|
+
static VALUE rxml_enabled_iconv_q(VALUE class)
|
176
|
+
{
|
177
|
+
#ifdef LIBXML_ICONV_ENABLED
|
178
|
+
return(Qtrue);
|
179
|
+
#else
|
180
|
+
return (Qfalse);
|
181
|
+
#endif
|
182
|
+
}
|
183
|
+
|
184
|
+
/*
|
185
|
+
* call-seq:
|
186
|
+
* XML.enabled_memory_debug? -> (true|false)
|
187
|
+
*
|
188
|
+
* Determine whether libxml memory location debugging support
|
189
|
+
* is enabled.
|
190
|
+
*/
|
191
|
+
static VALUE rxml_enabled_memory_debug_location_q(VALUE class)
|
192
|
+
{
|
193
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
194
|
+
return(Qtrue);
|
195
|
+
#else
|
196
|
+
return (Qfalse);
|
197
|
+
#endif
|
198
|
+
}
|
199
|
+
|
200
|
+
/*
|
201
|
+
* call-seq:
|
202
|
+
* XML.enabled_regexp? -> (true|false)
|
203
|
+
*
|
204
|
+
* Determine whether libxml regular expression support is enabled.
|
205
|
+
*/
|
206
|
+
static VALUE rxml_enabled_regexp_q(VALUE class)
|
207
|
+
{
|
208
|
+
#ifdef LIBXML_REGEXP_ENABLED
|
209
|
+
return(Qtrue);
|
210
|
+
#else
|
211
|
+
return (Qfalse);
|
212
|
+
#endif
|
213
|
+
}
|
214
|
+
|
215
|
+
/*
|
216
|
+
* call-seq:
|
217
|
+
* XML.enabled_schemas? -> (true|false)
|
218
|
+
*
|
219
|
+
* Determine whether libxml schema support is enabled.
|
220
|
+
*/
|
221
|
+
static VALUE rxml_enabled_schemas_q(VALUE class)
|
222
|
+
{
|
223
|
+
#ifdef LIBXML_SCHEMAS_ENABLED
|
224
|
+
return(Qtrue);
|
225
|
+
#else
|
226
|
+
return (Qfalse);
|
227
|
+
#endif
|
228
|
+
}
|
229
|
+
|
230
|
+
/*
|
231
|
+
* call-seq:
|
232
|
+
* XML.enabled_thread? -> (true|false)
|
233
|
+
*
|
234
|
+
* Determine whether libxml thread-safe semantics support
|
235
|
+
* is enabled (I think?).
|
236
|
+
*/
|
237
|
+
static VALUE rxml_enabled_thread_q(VALUE class)
|
238
|
+
{
|
239
|
+
#ifdef LIBXML_THREAD_ENABLED
|
240
|
+
return(Qtrue);
|
241
|
+
#else
|
242
|
+
return (Qfalse);
|
243
|
+
#endif
|
244
|
+
}
|
245
|
+
|
246
|
+
/*
|
247
|
+
* call-seq:
|
248
|
+
* XML.enabled_unicode? -> (true|false)
|
249
|
+
*
|
250
|
+
* Determine whether libxml unicode support is enabled.
|
251
|
+
*/
|
252
|
+
static VALUE rxml_enabled_unicode_q(VALUE class)
|
253
|
+
{
|
254
|
+
#ifdef LIBXML_UNICODE_ENABLED
|
255
|
+
return(Qtrue);
|
256
|
+
#else
|
257
|
+
return (Qfalse);
|
258
|
+
#endif
|
259
|
+
}
|
260
|
+
|
261
|
+
/*
|
262
|
+
* call-seq:
|
263
|
+
* XML.enabled_xinclude? -> (true|false)
|
264
|
+
*
|
265
|
+
* Determine whether libxml xinclude support is enabled.
|
266
|
+
*/
|
267
|
+
static VALUE rxml_enabled_xinclude_q(VALUE class)
|
268
|
+
{
|
269
|
+
#ifdef LIBXML_XINCLUDE_ENABLED
|
270
|
+
return(Qtrue);
|
271
|
+
#else
|
272
|
+
return (Qfalse);
|
273
|
+
#endif
|
274
|
+
}
|
275
|
+
|
276
|
+
/*
|
277
|
+
* call-seq:
|
278
|
+
* XML.enabled_xpath? -> (true|false)
|
279
|
+
*
|
280
|
+
* Determine whether libxml xpath support is enabled.
|
281
|
+
*/
|
282
|
+
static VALUE rxml_enabled_xpath_q(VALUE class)
|
283
|
+
{
|
284
|
+
#ifdef LIBXML_XPATH_ENABLED
|
285
|
+
return(Qtrue);
|
286
|
+
#else
|
287
|
+
return (Qfalse);
|
288
|
+
#endif
|
289
|
+
}
|
290
|
+
|
291
|
+
/*
|
292
|
+
* call-seq:
|
293
|
+
* XML.enabled_xpointer? -> (true|false)
|
294
|
+
*
|
295
|
+
* Determine whether libxml xpointer support is enabled.
|
296
|
+
*/
|
297
|
+
static VALUE rxml_enabled_xpointer_q(VALUE class)
|
298
|
+
{
|
299
|
+
#ifdef LIBXML_XPTR_ENABLED
|
300
|
+
return(Qtrue);
|
301
|
+
#else
|
302
|
+
return (Qfalse);
|
303
|
+
#endif
|
304
|
+
}
|
305
|
+
|
306
|
+
/*
|
307
|
+
* call-seq:
|
308
|
+
* XML.enabled_zlib? -> (true|false)
|
309
|
+
*
|
310
|
+
* Determine whether libxml zlib support is enabled.
|
311
|
+
*/
|
312
|
+
static VALUE rxml_enabled_zlib_q(VALUE class)
|
313
|
+
{
|
314
|
+
#ifdef HAVE_ZLIB_H
|
315
|
+
return(Qtrue);
|
316
|
+
#else
|
317
|
+
return (Qfalse);
|
318
|
+
#endif
|
319
|
+
}
|
320
|
+
|
321
|
+
/*
|
322
|
+
* call-seq:
|
323
|
+
* XML.debug_entities -> (true|false)
|
324
|
+
*
|
325
|
+
* Determine whether included-entity debugging is enabled.
|
326
|
+
* (Requires Libxml to be compiled with debugging support)
|
327
|
+
*/
|
328
|
+
static VALUE rxml_debug_entities_get(VALUE class)
|
329
|
+
{
|
330
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
331
|
+
if (xmlParserDebugEntities)
|
332
|
+
return(Qtrue);
|
333
|
+
else
|
334
|
+
return(Qfalse);
|
335
|
+
#else
|
336
|
+
rb_warn("libxml was compiled with debugging turned off");
|
337
|
+
return (Qfalse);
|
338
|
+
#endif
|
339
|
+
}
|
340
|
+
|
341
|
+
/*
|
342
|
+
* call-seq:
|
343
|
+
* XML.debug_entities = true|false
|
344
|
+
*
|
345
|
+
* Enable or disable included-entity debugging.
|
346
|
+
* (Requires Libxml to be compiled with debugging support)
|
347
|
+
*/
|
348
|
+
static VALUE rxml_debug_entities_set(VALUE class, VALUE bool)
|
349
|
+
{
|
350
|
+
#ifdef LIBXML_DEBUG_ENABLED
|
351
|
+
if (TYPE(bool) == T_FALSE)
|
352
|
+
{
|
353
|
+
xmlParserDebugEntities = 0;
|
354
|
+
return(Qfalse);
|
355
|
+
}
|
356
|
+
else
|
357
|
+
{
|
358
|
+
xmlParserDebugEntities = 1;
|
359
|
+
return(Qtrue);
|
360
|
+
}
|
361
|
+
#else
|
362
|
+
rb_warn("libxml was compiled with debugging turned off");
|
363
|
+
#endif
|
364
|
+
}
|
365
|
+
|
366
|
+
/*
|
367
|
+
* call-seq:
|
368
|
+
* XML.default_keep_blanks -> (true|false)
|
369
|
+
*
|
370
|
+
* Determine whether parsers retain whitespace by default.
|
371
|
+
*/
|
372
|
+
static VALUE rxml_default_keep_blanks_get(VALUE class)
|
373
|
+
{
|
374
|
+
if (xmlKeepBlanksDefaultValue)
|
375
|
+
return (Qtrue);
|
376
|
+
else
|
377
|
+
return (Qfalse);
|
378
|
+
}
|
379
|
+
|
380
|
+
/*
|
381
|
+
* call-seq:
|
382
|
+
* XML.default_keep_blanks = true|false
|
383
|
+
*
|
384
|
+
* Controls whether parsers retain whitespace by default.
|
385
|
+
*/
|
386
|
+
static VALUE rxml_default_keep_blanks_set(VALUE class, VALUE bool)
|
387
|
+
{
|
388
|
+
if (TYPE(bool) == T_FALSE)
|
389
|
+
{
|
390
|
+
xmlKeepBlanksDefaultValue = 0;
|
391
|
+
return (Qfalse);
|
392
|
+
}
|
393
|
+
else if (TYPE(bool) == T_TRUE)
|
394
|
+
{
|
395
|
+
xmlKeepBlanksDefaultValue = 1;
|
396
|
+
return (Qtrue);
|
397
|
+
}
|
398
|
+
else
|
399
|
+
{
|
400
|
+
rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
|
401
|
+
}
|
402
|
+
}
|
403
|
+
|
404
|
+
/*
|
405
|
+
* call-seq:
|
406
|
+
* XML.default_load_external_dtd -> (true|false)
|
407
|
+
*
|
408
|
+
* Determine whether parsers load external DTDs by default.
|
409
|
+
*/
|
410
|
+
static VALUE rxml_default_load_external_dtd_get(VALUE class)
|
411
|
+
{
|
412
|
+
if (xmlLoadExtDtdDefaultValue)
|
413
|
+
return (Qtrue);
|
414
|
+
else
|
415
|
+
return (Qfalse);
|
416
|
+
}
|
417
|
+
|
418
|
+
/*
|
419
|
+
* call-seq:
|
420
|
+
* XML.default_load_external_dtd = true|false
|
421
|
+
*
|
422
|
+
* Controls whether parsers load external DTDs by default.
|
423
|
+
*/
|
424
|
+
static VALUE rxml_default_load_external_dtd_set(VALUE class, VALUE bool)
|
425
|
+
{
|
426
|
+
if (bool == Qfalse)
|
427
|
+
{
|
428
|
+
xmlLoadExtDtdDefaultValue = 0;
|
429
|
+
return (Qfalse);
|
430
|
+
}
|
431
|
+
else
|
432
|
+
{
|
433
|
+
xmlLoadExtDtdDefaultValue = 1;
|
434
|
+
return (Qtrue);
|
435
|
+
}
|
436
|
+
}
|
437
|
+
|
438
|
+
/*
|
439
|
+
* call-seq:
|
440
|
+
* XML.default_line_numbers -> (true|false)
|
441
|
+
*
|
442
|
+
* Determine whether parsers retain line-numbers by default.
|
443
|
+
*/
|
444
|
+
static VALUE rxml_default_line_numbers_get(VALUE class)
|
445
|
+
{
|
446
|
+
if (xmlLineNumbersDefaultValue)
|
447
|
+
return (Qtrue);
|
448
|
+
else
|
449
|
+
return (Qfalse);
|
450
|
+
}
|
451
|
+
|
452
|
+
/*
|
453
|
+
* call-seq:
|
454
|
+
* XML.default_line_numbers = true|false
|
455
|
+
*
|
456
|
+
* Controls whether parsers retain line-numbers by default.
|
457
|
+
*/
|
458
|
+
static VALUE rxml_default_line_numbers_set(VALUE class, VALUE bool)
|
459
|
+
{
|
460
|
+
if (TYPE(bool) == T_FALSE)
|
461
|
+
{
|
462
|
+
xmlLineNumbersDefault(0);
|
463
|
+
return (Qfalse);
|
464
|
+
}
|
465
|
+
else
|
466
|
+
{
|
467
|
+
xmlLineNumbersDefault(1);
|
468
|
+
return (Qtrue);
|
469
|
+
}
|
470
|
+
}
|
471
|
+
|
472
|
+
/*
|
473
|
+
* call-seq:
|
474
|
+
* XML.default_pedantic_parser -> (true|false)
|
475
|
+
*
|
476
|
+
* Determine whether parsers are pedantic by default.
|
477
|
+
*/
|
478
|
+
static VALUE rxml_default_pedantic_parser_get(VALUE class)
|
479
|
+
{
|
480
|
+
if (xmlPedanticParserDefaultValue)
|
481
|
+
return (Qtrue);
|
482
|
+
else
|
483
|
+
return (Qfalse);
|
484
|
+
}
|
485
|
+
|
486
|
+
/*
|
487
|
+
* call-seq:
|
488
|
+
* XML.default_pedantic_parser = true|false
|
489
|
+
*
|
490
|
+
* Controls whether parsers are pedantic by default.
|
491
|
+
*/
|
492
|
+
static VALUE rxml_default_pedantic_parser_set(VALUE class, VALUE bool)
|
493
|
+
{
|
494
|
+
if (TYPE(bool) == T_FALSE)
|
495
|
+
{
|
496
|
+
xmlPedanticParserDefault(0);
|
497
|
+
return (Qfalse);
|
498
|
+
}
|
499
|
+
else
|
500
|
+
{
|
501
|
+
xmlPedanticParserDefault(1);
|
502
|
+
return (Qtrue);
|
503
|
+
}
|
504
|
+
}
|
505
|
+
|
506
|
+
/*
|
507
|
+
* call-seq:
|
508
|
+
* XML.default_substitute_entities -> (true|false)
|
509
|
+
*
|
510
|
+
* Determine whether parsers perform inline entity substitution
|
511
|
+
* (for external entities) by default.
|
512
|
+
*/
|
513
|
+
static VALUE rxml_default_substitute_entities_get(VALUE class)
|
514
|
+
{
|
515
|
+
if (xmlSubstituteEntitiesDefaultValue)
|
516
|
+
return (Qtrue);
|
517
|
+
else
|
518
|
+
return (Qfalse);
|
519
|
+
}
|
520
|
+
|
521
|
+
/*
|
522
|
+
* call-seq:
|
523
|
+
* XML.default_substitute_entities = true|false
|
524
|
+
*
|
525
|
+
* Controls whether parsers perform inline entity substitution
|
526
|
+
* (for external entities) by default.
|
527
|
+
*/
|
528
|
+
static VALUE rxml_default_substitute_entities_set(VALUE class, VALUE bool)
|
529
|
+
{
|
530
|
+
if (bool == Qfalse)
|
531
|
+
{
|
532
|
+
xmlSubstituteEntitiesDefault(0);
|
533
|
+
return (Qfalse);
|
534
|
+
}
|
535
|
+
else
|
536
|
+
{
|
537
|
+
xmlSubstituteEntitiesDefault(1);
|
538
|
+
return (Qtrue);
|
539
|
+
}
|
540
|
+
}
|
541
|
+
|
542
|
+
/*
|
543
|
+
* call-seq:
|
544
|
+
* XML.default_tree_indent_string -> "string"
|
545
|
+
*
|
546
|
+
* Obtain the default string used by parsers to indent the XML tree
|
547
|
+
* for output.
|
548
|
+
*/
|
549
|
+
static VALUE rxml_default_tree_indent_string_get(VALUE class)
|
550
|
+
{
|
551
|
+
if (xmlTreeIndentString == NULL)
|
552
|
+
return (Qnil);
|
553
|
+
else
|
554
|
+
return (rb_str_new2(xmlTreeIndentString));
|
555
|
+
}
|
556
|
+
|
557
|
+
/*
|
558
|
+
* call-seq:
|
559
|
+
* XML.default_tree_indent_string = "string"
|
560
|
+
*
|
561
|
+
* Set the default string used by parsers to indent the XML tree
|
562
|
+
* for output.
|
563
|
+
*/
|
564
|
+
static VALUE rxml_default_tree_indent_string_set(VALUE class, VALUE string)
|
565
|
+
{
|
566
|
+
Check_Type(string, T_STRING);
|
567
|
+
xmlTreeIndentString = xmlStrdup((xmlChar *)StringValuePtr(string));
|
568
|
+
return (string);
|
569
|
+
}
|
570
|
+
|
571
|
+
/*
|
572
|
+
* call-seq:
|
573
|
+
* XML.default_validity_checking -> (true|false)
|
574
|
+
*
|
575
|
+
* Determine whether parsers perform XML validation by default.
|
576
|
+
*/
|
577
|
+
static VALUE rxml_default_validity_checking_get(VALUE class)
|
578
|
+
{
|
579
|
+
if (xmlDoValidityCheckingDefaultValue)
|
580
|
+
return (Qtrue);
|
581
|
+
else
|
582
|
+
return (Qfalse);
|
583
|
+
}
|
584
|
+
|
585
|
+
/*
|
586
|
+
* call-seq:
|
587
|
+
* XML.default_validity_checking = true|false
|
588
|
+
*
|
589
|
+
* Controls whether parsers perform XML validation by default.
|
590
|
+
*/
|
591
|
+
static VALUE rxml_default_validity_checking_set(VALUE class, VALUE bool)
|
592
|
+
{
|
593
|
+
if (TYPE(bool) == T_FALSE)
|
594
|
+
{
|
595
|
+
xmlDoValidityCheckingDefaultValue = 0;
|
596
|
+
return (Qfalse);
|
597
|
+
}
|
598
|
+
else
|
599
|
+
{
|
600
|
+
xmlDoValidityCheckingDefaultValue = 1;
|
601
|
+
return (Qtrue);
|
602
|
+
}
|
603
|
+
}
|
604
|
+
|
605
|
+
/*
|
606
|
+
* call-seq:
|
607
|
+
* XML.default_warnings -> (true|false)
|
608
|
+
*
|
609
|
+
* Determine whether parsers output warnings by default.
|
610
|
+
*/
|
611
|
+
static VALUE rxml_default_warnings_get(VALUE class)
|
612
|
+
{
|
613
|
+
if (xmlGetWarningsDefaultValue)
|
614
|
+
return (Qtrue);
|
615
|
+
else
|
616
|
+
return (Qfalse);
|
617
|
+
}
|
618
|
+
|
619
|
+
/*
|
620
|
+
* call-seq:
|
621
|
+
* XML.default_warnings = true|false
|
622
|
+
*
|
623
|
+
* Controls whether parsers output warnings by default.
|
624
|
+
*/
|
625
|
+
static VALUE rxml_default_warnings_set(VALUE class, VALUE bool)
|
626
|
+
{
|
627
|
+
if (TYPE(bool) == T_FALSE)
|
628
|
+
{
|
629
|
+
xmlGetWarningsDefaultValue = 0;
|
630
|
+
return (Qfalse);
|
631
|
+
}
|
632
|
+
else
|
633
|
+
{
|
634
|
+
xmlGetWarningsDefaultValue = 1;
|
635
|
+
return (Qtrue);
|
636
|
+
}
|
637
|
+
}
|
638
|
+
|
639
|
+
/*
|
640
|
+
* call-seq:
|
641
|
+
* XML.default_compression -> (true|false)
|
642
|
+
*
|
643
|
+
* Determine whether parsers use Zlib compression by default
|
644
|
+
* (requires libxml to be compiled with Zlib support).
|
645
|
+
*/
|
646
|
+
static VALUE rxml_default_compression_get(VALUE class)
|
647
|
+
{
|
648
|
+
#ifdef HAVE_ZLIB_H
|
649
|
+
return(INT2FIX(xmlGetCompressMode()));
|
650
|
+
#else
|
651
|
+
rb_warn("libxml was compiled without zlib support");
|
652
|
+
return (Qfalse);
|
653
|
+
#endif
|
654
|
+
}
|
655
|
+
|
656
|
+
/*
|
657
|
+
* call-seq:
|
658
|
+
* XML.default_compression = true|false
|
659
|
+
*
|
660
|
+
* Controls whether parsers use Zlib compression by default
|
661
|
+
* (requires libxml to be compiled with Zlib support).
|
662
|
+
*/
|
663
|
+
static VALUE rxml_default_compression_set(VALUE class, VALUE num)
|
664
|
+
{
|
665
|
+
#ifdef HAVE_ZLIB_H
|
666
|
+
Check_Type(num, T_FIXNUM);
|
667
|
+
xmlSetCompressMode(FIX2INT(num));
|
668
|
+
return(num);
|
669
|
+
#else
|
670
|
+
rb_warn("libxml was compiled without zlib support");
|
671
|
+
return (Qfalse);
|
672
|
+
#endif
|
673
|
+
}
|
674
|
+
|
675
|
+
/*
|
676
|
+
* call-seq:
|
677
|
+
* XML.features -> ["feature", ..., "feature"]
|
678
|
+
*
|
679
|
+
* Obtains an array of strings representing features supported
|
680
|
+
* (and enabled) by the installed libxml.
|
681
|
+
*/
|
682
|
+
static VALUE rxml_features(VALUE class)
|
683
|
+
{
|
684
|
+
VALUE arr, str;
|
685
|
+
int i, len = MAX_LIBXML_FEATURES_LEN;
|
686
|
+
char **list = NULL;
|
687
|
+
|
688
|
+
list = ALLOC_N(char *,MAX_LIBXML_FEATURES_LEN);
|
689
|
+
MEMZERO(list, char *, MAX_LIBXML_FEATURES_LEN);
|
690
|
+
|
691
|
+
arr = rb_ary_new();
|
692
|
+
if (xmlGetFeaturesList(&len, (const char **) list) == -1)
|
693
|
+
return Qnil;
|
694
|
+
|
695
|
+
for (i = 0; i < len; i++)
|
696
|
+
{
|
697
|
+
str = rb_str_new2((const char *) list[i]);
|
698
|
+
rb_gc_unregister_address(&str);
|
699
|
+
rb_ary_push(arr, str);
|
700
|
+
}
|
701
|
+
|
702
|
+
if (len == MAX_LIBXML_FEATURES_LEN)
|
703
|
+
rb_warn(
|
704
|
+
"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");
|
705
|
+
|
706
|
+
ruby_xfree(list);
|
707
|
+
return (arr);
|
708
|
+
}
|
709
|
+
|
710
|
+
/*
|
711
|
+
* call-seq:
|
712
|
+
* XML.indent_tree_output -> (true|false)
|
713
|
+
*
|
714
|
+
* Determines whether XML output will be indented
|
715
|
+
* (using the string supplied to +default_indent_tree_string+)
|
716
|
+
*/
|
717
|
+
static VALUE rxml_indent_tree_output_get(VALUE class)
|
718
|
+
{
|
719
|
+
if (xmlIndentTreeOutput)
|
720
|
+
return (Qtrue);
|
721
|
+
else
|
722
|
+
return (Qfalse);
|
723
|
+
}
|
724
|
+
|
725
|
+
/*
|
726
|
+
* call-seq:
|
727
|
+
* XML.indent_tree_output = true|false
|
728
|
+
*
|
729
|
+
* Controls whether XML output will be indented
|
730
|
+
* (using the string supplied to +default_indent_tree_string+)
|
731
|
+
*/
|
732
|
+
static VALUE rxml_indent_tree_output_set(VALUE class, VALUE bool)
|
733
|
+
{
|
734
|
+
if (TYPE(bool) == T_TRUE)
|
735
|
+
{
|
736
|
+
xmlIndentTreeOutput = 1;
|
737
|
+
return (Qtrue);
|
738
|
+
}
|
739
|
+
else if (TYPE(bool) == T_FALSE)
|
740
|
+
{
|
741
|
+
xmlIndentTreeOutput = 0;
|
742
|
+
return (Qfalse);
|
743
|
+
}
|
744
|
+
else
|
745
|
+
{
|
746
|
+
rb_raise(rb_eArgError, "Invalid argument, must be boolean");
|
747
|
+
}
|
748
|
+
}
|
749
|
+
|
750
|
+
/*
|
751
|
+
* call-seq:
|
752
|
+
* XML.memory_dump -> (true|false)
|
753
|
+
*
|
754
|
+
* Perform a parser memory dump (requires memory debugging
|
755
|
+
* support in libxml).
|
756
|
+
*/
|
757
|
+
static VALUE rxml_memory_dump(VALUE self)
|
758
|
+
{
|
759
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
760
|
+
xmlMemoryDump();
|
761
|
+
return(Qtrue);
|
762
|
+
#else
|
763
|
+
rb_warn("libxml was compiled without memory debugging support");
|
764
|
+
return (Qfalse);
|
765
|
+
#endif
|
766
|
+
}
|
767
|
+
|
768
|
+
/*
|
769
|
+
* call-seq:
|
770
|
+
* XML.memory_used -> num_bytes
|
771
|
+
*
|
772
|
+
* Perform a parser memory dump (requires memory debugging
|
773
|
+
* support in libxml).
|
774
|
+
*/
|
775
|
+
static VALUE rxml_memory_used(VALUE self)
|
776
|
+
{
|
777
|
+
#ifdef DEBUG_MEMORY_LOCATION
|
778
|
+
return(INT2NUM(xmlMemUsed()));
|
779
|
+
#else
|
780
|
+
rb_warn("libxml was compiled without memory debugging support");
|
781
|
+
return (Qfalse);
|
782
|
+
#endif
|
783
|
+
}
|
784
|
+
|
785
|
+
#if defined(_WIN32)
|
786
|
+
__declspec(dllexport)
|
787
|
+
#endif
|
788
|
+
void Init_libxml_ruby(void)
|
789
|
+
{
|
790
|
+
mLibXML = rb_define_module("LibXML");
|
791
|
+
mXML = rb_define_module_under(mLibXML, "XML");
|
792
|
+
|
793
|
+
/* Constants */
|
794
|
+
rb_define_const(mXML, "LIBXML_VERSION", rb_str_new2(LIBXML_DOTTED_VERSION));
|
795
|
+
rb_define_const(mXML, "VERSION", rb_str_new2(RUBY_LIBXML_VERSION));
|
796
|
+
rb_define_const(mXML, "VERNUM", INT2NUM(RUBY_LIBXML_VERNUM));
|
797
|
+
rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2(
|
798
|
+
(const char*) XML_XML_NAMESPACE));
|
799
|
+
|
800
|
+
rb_define_module_function(mXML, "enabled_automata?", rxml_enabled_automata_q, 0);
|
801
|
+
rb_define_module_function(mXML, "enabled_c14n?", rxml_enabled_c14n_q, 0);
|
802
|
+
rb_define_module_function(mXML, "enabled_catalog?", rxml_enabled_catalog_q, 0);
|
803
|
+
rb_define_module_function(mXML, "enabled_debug?", rxml_enabled_debug_q, 0);
|
804
|
+
rb_define_module_function(mXML, "enabled_docbook?", rxml_enabled_docbook_q, 0);
|
805
|
+
rb_define_module_function(mXML, "enabled_ftp?", rxml_enabled_ftp_q, 0);
|
806
|
+
rb_define_module_function(mXML, "enabled_http?", rxml_enabled_http_q, 0);
|
807
|
+
rb_define_module_function(mXML, "enabled_html?", rxml_enabled_html_q, 0);
|
808
|
+
rb_define_module_function(mXML, "enabled_iconv?", rxml_enabled_iconv_q, 0);
|
809
|
+
rb_define_module_function(mXML, "enabled_memory_debug?", rxml_enabled_memory_debug_location_q, 0);
|
810
|
+
rb_define_module_function(mXML, "enabled_regexp?", rxml_enabled_regexp_q, 0);
|
811
|
+
rb_define_module_function(mXML, "enabled_schemas?", rxml_enabled_schemas_q, 0);
|
812
|
+
rb_define_module_function(mXML, "enabled_thread?", rxml_enabled_thread_q, 0);
|
813
|
+
rb_define_module_function(mXML, "enabled_unicode?", rxml_enabled_unicode_q, 0);
|
814
|
+
rb_define_module_function(mXML, "enabled_xinclude?", rxml_enabled_xinclude_q, 0);
|
815
|
+
rb_define_module_function(mXML, "enabled_xpath?", rxml_enabled_xpath_q, 0);
|
816
|
+
rb_define_module_function(mXML, "enabled_xpointer?", rxml_enabled_xpointer_q, 0);
|
817
|
+
rb_define_module_function(mXML, "enabled_zlib?", rxml_enabled_zlib_q, 0);
|
818
|
+
|
819
|
+
rb_define_module_function(mXML, "catalog_dump", rxml_catalog_dump, 0);
|
820
|
+
rb_define_module_function(mXML, "catalog_remove", rxml_catalog_remove, 1);
|
821
|
+
rb_define_module_function(mXML, "check_lib_versions", rxml_check_lib_versions, 0);
|
822
|
+
rb_define_module_function(mXML, "debug_entities", rxml_debug_entities_get, 0);
|
823
|
+
rb_define_module_function(mXML, "debug_entities=", rxml_debug_entities_set, 1);
|
824
|
+
rb_define_module_function(mXML, "default_compression", rxml_default_compression_get, 0);
|
825
|
+
rb_define_module_function(mXML, "default_compression=", rxml_default_compression_set, 1);
|
826
|
+
rb_define_module_function(mXML, "default_keep_blanks", rxml_default_keep_blanks_get, 0);
|
827
|
+
rb_define_module_function(mXML, "default_keep_blanks=", rxml_default_keep_blanks_set, 1);
|
828
|
+
rb_define_module_function(mXML, "default_load_external_dtd", rxml_default_load_external_dtd_get, 0);
|
829
|
+
rb_define_module_function(mXML, "default_load_external_dtd=", rxml_default_load_external_dtd_set, 1);
|
830
|
+
rb_define_module_function(mXML, "default_line_numbers", rxml_default_line_numbers_get, 0);
|
831
|
+
rb_define_module_function(mXML, "default_line_numbers=", rxml_default_line_numbers_set, 1);
|
832
|
+
rb_define_module_function(mXML, "default_pedantic_parser", rxml_default_pedantic_parser_get, 0);
|
833
|
+
rb_define_module_function(mXML, "default_pedantic_parser=", rxml_default_pedantic_parser_set, 1);
|
834
|
+
rb_define_module_function(mXML, "default_substitute_entities", rxml_default_substitute_entities_get, 0);
|
835
|
+
rb_define_module_function(mXML, "default_substitute_entities=", rxml_default_substitute_entities_set, 1);
|
836
|
+
rb_define_module_function(mXML, "default_tree_indent_string", rxml_default_tree_indent_string_get, 0);
|
837
|
+
rb_define_module_function(mXML, "default_tree_indent_string=", rxml_default_tree_indent_string_set, 1);
|
838
|
+
rb_define_module_function(mXML, "default_validity_checking", rxml_default_validity_checking_get, 0);
|
839
|
+
rb_define_module_function(mXML, "default_validity_checking=", rxml_default_validity_checking_set, 1);
|
840
|
+
rb_define_module_function(mXML, "default_warnings", rxml_default_warnings_get, 0);
|
841
|
+
rb_define_module_function(mXML, "default_warnings=", rxml_default_warnings_set, 1);
|
842
|
+
rb_define_module_function(mXML, "features", rxml_features, 0);
|
843
|
+
rb_define_module_function(mXML, "indent_tree_output", rxml_indent_tree_output_get, 0);
|
844
|
+
rb_define_module_function(mXML, "indent_tree_output=", rxml_indent_tree_output_set, 1);
|
845
|
+
rb_define_module_function(mXML, "memory_dump", rxml_memory_dump, 0);
|
846
|
+
rb_define_module_function(mXML, "memory_used", rxml_memory_used, 0);
|
847
|
+
|
848
|
+
/* Now initialize all the other modules */
|
849
|
+
rxml_init_io();
|
850
|
+
ruby_init_xml_error();
|
851
|
+
ruby_init_xml_encoding();
|
852
|
+
ruby_init_state();
|
853
|
+
ruby_init_parser();
|
854
|
+
ruby_init_xml_parser_context();
|
855
|
+
ruby_init_parser_options();
|
856
|
+
ruby_init_xml_node();
|
857
|
+
ruby_init_xml_attributes();
|
858
|
+
ruby_init_xml_attr();
|
859
|
+
ruby_init_xml_attr_decl();
|
860
|
+
ruby_init_xml_document();
|
861
|
+
ruby_init_xml_namespaces();
|
862
|
+
ruby_init_xml_namespace();
|
863
|
+
ruby_init_xml_sax_parser();
|
864
|
+
ruby_init_xml_sax2_handler();
|
865
|
+
ruby_init_xml_xinclude();
|
866
|
+
ruby_init_xml_xpath();
|
867
|
+
ruby_init_xml_xpath_context();
|
868
|
+
ruby_init_xml_xpath_expression();
|
869
|
+
ruby_init_xml_xpointer();
|
870
|
+
ruby_init_html_parser();
|
871
|
+
ruby_init_html_parser_options();
|
872
|
+
ruby_init_html_parser_context();
|
873
|
+
ruby_init_input_callbacks();
|
874
|
+
ruby_init_xml_dtd();
|
875
|
+
ruby_init_xml_schema();
|
876
|
+
ruby_init_xml_relaxng();
|
877
|
+
ruby_init_xml_reader();
|
878
|
+
}
|