libxml-ruby 0.5.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +23 -23
- data/README +144 -144
- data/ext/libxml/extconf.rb +26 -27
- data/ext/libxml/libxml.c +7 -37
- data/ext/libxml/{libxml.h → ruby_libxml.h} +93 -98
- data/ext/libxml/ruby_xml_attr.c +405 -387
- data/ext/libxml/ruby_xml_attr.h +19 -18
- data/ext/libxml/ruby_xml_document.c +1111 -1115
- data/ext/libxml/ruby_xml_document.h +27 -24
- data/ext/libxml/ruby_xml_dtd.c +168 -168
- data/ext/libxml/ruby_xml_html_parser.c +449 -450
- data/ext/libxml/ruby_xml_html_parser.h +1 -1
- data/ext/libxml/ruby_xml_input_cbg.c +158 -158
- data/ext/libxml/ruby_xml_node.c +2410 -2395
- data/ext/libxml/ruby_xml_node.h +1 -1
- data/ext/libxml/ruby_xml_node_set.c +170 -170
- data/ext/libxml/ruby_xml_node_set.h +1 -1
- data/ext/libxml/ruby_xml_ns.c +153 -153
- data/ext/libxml/ruby_xml_ns.h +1 -1
- data/ext/libxml/ruby_xml_parser.c +1425 -1422
- data/ext/libxml/ruby_xml_parser.h +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +750 -716
- data/ext/libxml/ruby_xml_parser_context.h +1 -1
- data/ext/libxml/ruby_xml_reader.c +900 -896
- data/ext/libxml/ruby_xml_sax_parser.c +485 -485
- data/ext/libxml/ruby_xml_sax_parser.h +1 -1
- data/ext/libxml/ruby_xml_schema.c +146 -142
- data/ext/libxml/ruby_xml_state.c +5 -6
- data/ext/libxml/ruby_xml_state.h +1 -0
- data/ext/libxml/ruby_xml_tree.c +43 -43
- data/ext/libxml/ruby_xml_tree.h +1 -1
- data/ext/libxml/ruby_xml_xinclude.c +20 -20
- data/ext/libxml/ruby_xml_xinclude.h +1 -1
- data/ext/libxml/ruby_xml_xpath.c +243 -252
- data/ext/libxml/ruby_xml_xpath.h +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +118 -118
- data/ext/libxml/ruby_xml_xpath_context.h +1 -1
- data/ext/libxml/ruby_xml_xpath_object.c +43 -29
- data/ext/libxml/ruby_xml_xpath_object.h +0 -1
- data/ext/libxml/ruby_xml_xpointer.c +100 -100
- data/ext/libxml/ruby_xml_xpointer.h +1 -1
- data/ext/libxml/ruby_xml_xpointer_context.c +21 -21
- data/ext/libxml/ruby_xml_xpointer_context.h +1 -1
- data/ext/libxml/sax_parser_callbacks.inc +213 -213
- data/ext/libxml/version.h +9 -9
- data/lib/libxml.rb +24 -3
- data/mingw/libiconv-2.dll +0 -0
- data/mingw/libxml2-2.dll +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/mingw/mingw.rake +36 -0
- data/test/dtd-test.rb +24 -24
- data/test/etc_doc_to_s.rb +1 -3
- data/test/ets_copy_bug.rb +21 -21
- data/test/ets_copy_bug2.rb +32 -32
- data/test/ets_copy_bug3.rb +38 -0
- data/test/ets_doc_file.rb +1 -0
- data/test/{model/default_validation_bug.rb → gc.log} +0 -0
- data/test/merge_bug.rb +55 -55
- data/test/schema-test.rb +74 -74
- data/test/tc_well_formed.rb +11 -0
- data/test/tc_xml_document.rb +52 -52
- data/test/tc_xml_document_write.rb +24 -24
- data/test/tc_xml_document_write2.rb +54 -54
- data/test/tc_xml_document_write3.rb +96 -96
- data/test/tc_xml_html_parser.rb +63 -63
- data/test/tc_xml_node.rb +59 -59
- data/test/tc_xml_node2.rb +25 -25
- data/test/tc_xml_node3.rb +27 -27
- data/test/tc_xml_node4.rb +86 -86
- data/test/tc_xml_node5.rb +52 -52
- data/test/tc_xml_node6.rb +27 -27
- data/test/tc_xml_node7.rb +35 -35
- data/test/tc_xml_node8.rb +32 -32
- data/test/tc_xml_node9.rb +32 -32
- data/test/tc_xml_node_set.rb +24 -24
- data/test/tc_xml_node_set2.rb +37 -37
- data/test/tc_xml_node_xlink.rb +28 -28
- data/test/tc_xml_parser.rb +190 -178
- data/test/tc_xml_parser2.rb +16 -17
- data/test/tc_xml_parser3.rb +23 -23
- data/test/tc_xml_parser4.rb +33 -33
- data/test/tc_xml_parser5.rb +27 -27
- data/test/tc_xml_parser6.rb +23 -23
- data/test/tc_xml_parser7.rb +28 -28
- data/test/tc_xml_parser8.rb +32 -32
- data/test/tc_xml_parser9.rb +11 -0
- data/test/tc_xml_parser_context.rb +88 -88
- data/test/tc_xml_reader.rb +112 -109
- data/test/tc_xml_sax_parser.rb +104 -94
- data/test/tc_xml_sax_parser2.rb +51 -0
- data/test/tc_xml_xinclude.rb +30 -30
- data/test/tc_xml_xpath.rb +38 -38
- data/test/tc_xml_xpath2.rb +14 -0
- data/test/tc_xml_xpointer.rb +78 -78
- data/vc/libxml.sln +20 -0
- data/vc/libxml.vcproj +389 -0
- data/work/Rakefile +247 -0
- data/work/task/make +26 -0
- data/work/task/memory +37 -0
- data/work/task/rdoc +39 -0
- data/work/task/setup +1616 -0
- data/work/task/test +29 -0
- data/work/test/ets_runner.rb +33 -0
- data/work/test/libxml_test.rb +3 -0
- data/work/test/runner.rb +0 -0
- data/work/test/runner_ets.rb +33 -0
- data/work/vc/debug/libxml.exp +0 -0
- data/work/vc/debug/libxml.ilk +0 -0
- data/work/vc/debug/libxml.lib +0 -0
- data/work/vc/debug/libxml.pdb +0 -0
- data/work/vc/debug/libxml.so +0 -0
- metadata +158 -189
- data/MANIFEST +0 -138
- data/NOTES +0 -9
- data/Rakefile +0 -38
- data/TODO +0 -75
- data/VERSION +0 -1
- data/log/Changelog-0.txt +0 -426
- data/log/Changelog.txt +0 -435
- data/meta/project.yaml +0 -27
- data/meta/unixname +0 -1
- data/setup.rb +0 -1472
- data/site/css/normal.css +0 -182
- data/site/img/raze-tiny.png +0 -0
- data/site/img/red-cube.jpg +0 -0
- data/site/img/xml-ruby.png +0 -0
- data/site/index.xml +0 -43
- data/site/install.xml +0 -77
- data/site/layout.rhtml +0 -38
- data/site/layout.xsl +0 -67
- data/site/license.xml +0 -32
- data/site/log/changelog.xml +0 -1324
- data/site/log/changelog.xsl +0 -42
- data/test/model/merge_bug_data.xml +0 -58
- data/test/model/rubynet.xml +0 -78
- data/test/model/rubynet_project +0 -13
- data/test/model/saxtest.xml +0 -5
- data/test/model/simple.xml +0 -7
- data/test/model/xinclude.xml +0 -5
|
@@ -1,213 +1,213 @@
|
|
|
1
|
-
/* $Id: sax_parser_callbacks.inc
|
|
2
|
-
|
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* SAX CALLBACK HANDLERS
|
|
7
|
-
*/
|
|
8
|
-
static void internal_subset_func(ruby_xml_sax_parser *cbp,
|
|
9
|
-
const char *name,
|
|
10
|
-
const char *extid,
|
|
11
|
-
const char *sysid) {
|
|
12
|
-
VALUE handler = cbp->callbackHandler;
|
|
13
|
-
|
|
14
|
-
if (handler && handler != Qnil) {
|
|
15
|
-
rb_funcall(handler, cbidOnInternalSubset, 3, rb_str_new2(name),
|
|
16
|
-
rb_str_new2(extid), rb_str_new2(sysid));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static void is_standalone_func(ruby_xml_sax_parser *cbp) {
|
|
21
|
-
VALUE handler = cbp->callbackHandler;
|
|
22
|
-
|
|
23
|
-
if (handler && handler != Qnil) {
|
|
24
|
-
rb_funcall(handler,cbidOnIsStandalone,0);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
static void has_internal_subset_func(ruby_xml_sax_parser *cbp) {
|
|
29
|
-
VALUE handler = cbp->callbackHandler;
|
|
30
|
-
|
|
31
|
-
if (handler && handler != Qnil) {
|
|
32
|
-
rb_funcall(handler,cbidOnHasInternalSubset,0);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
static void has_external_subset_func(ruby_xml_sax_parser *cbp) {
|
|
37
|
-
VALUE handler = cbp->callbackHandler;
|
|
38
|
-
|
|
39
|
-
if (handler && handler != Qnil) {
|
|
40
|
-
rb_funcall(handler,cbidOnHasExternalSubset,0);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
static void start_document_func(ruby_xml_sax_parser *cbp) {
|
|
45
|
-
VALUE handler = cbp->callbackHandler;
|
|
46
|
-
|
|
47
|
-
if (handler && handler != Qnil) {
|
|
48
|
-
rb_funcall(handler,cbidOnStartDocument,0);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
static void end_document_func(ruby_xml_sax_parser *cbp) {
|
|
53
|
-
VALUE handler = cbp->callbackHandler;
|
|
54
|
-
|
|
55
|
-
if (handler && handler != Qnil) {
|
|
56
|
-
rb_funcall(handler,cbidOnEndDocument,0);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
static void start_element_func(ruby_xml_sax_parser *cbp,
|
|
61
|
-
const char *name, const char **attrs) {
|
|
62
|
-
VALUE handler = cbp->callbackHandler;
|
|
63
|
-
VALUE ahsh = rb_hash_new();
|
|
64
|
-
const char *attr, *value;
|
|
65
|
-
|
|
66
|
-
if (attrs) {
|
|
67
|
-
while ((attr = *(attrs++))) {
|
|
68
|
-
value = *(attrs++);
|
|
69
|
-
rb_hash_aset(ahsh, rb_str_new2(attr), rb_str_new2(value));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (handler && handler != Qnil) {
|
|
74
|
-
rb_funcall(handler,cbidOnStartElement,2,rb_str_new2(name),ahsh);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static void end_element_func(ruby_xml_sax_parser *cbp,
|
|
79
|
-
const char *name) {
|
|
80
|
-
VALUE handler = cbp->callbackHandler;
|
|
81
|
-
|
|
82
|
-
if (handler && handler != Qnil) {
|
|
83
|
-
rb_funcall(handler,cbidOnEndElement,1,rb_str_new2(name));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static void reference_func(ruby_xml_sax_parser *cbp,
|
|
88
|
-
const char *name) {
|
|
89
|
-
VALUE handler = cbp->callbackHandler;
|
|
90
|
-
|
|
91
|
-
if (handler && handler != Qnil) {
|
|
92
|
-
rb_funcall(handler,cbidOnReference,1,rb_str_new2(name));
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
static void characters_func(ruby_xml_sax_parser *cbp,
|
|
97
|
-
const char *chars, int len) {
|
|
98
|
-
VALUE handler = cbp->callbackHandler;
|
|
99
|
-
|
|
100
|
-
if (handler && handler != Qnil) {
|
|
101
|
-
rb_funcall(handler,cbidOnCharacters,1,rb_str_new(chars, len));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
static void processing_instruction_func(ruby_xml_sax_parser *cbp,
|
|
106
|
-
const char *target, const char *data) {
|
|
107
|
-
VALUE handler = cbp->callbackHandler;
|
|
108
|
-
|
|
109
|
-
if (handler && handler != Qnil) {
|
|
110
|
-
rb_funcall(handler, cbidOnProcessingInstruction, 2,
|
|
111
|
-
rb_str_new2(target),rb_str_new2(data));
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
static void comment_func(ruby_xml_sax_parser *cbp,
|
|
116
|
-
const char *msg) {
|
|
117
|
-
VALUE handler = cbp->callbackHandler;
|
|
118
|
-
|
|
119
|
-
if (handler && handler != Qnil) {
|
|
120
|
-
rb_funcall(handler,cbidOnComment,1,rb_str_new2(msg));
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
#define FORMAT_AND_CALL(callsym) \
|
|
125
|
-
do { \
|
|
126
|
-
va_list args; \
|
|
127
|
-
char buf[1024]; \
|
|
128
|
-
va_start(args, msg); \
|
|
129
|
-
vsnprintf(buf, sizeof buf, msg, args); \
|
|
130
|
-
rb_funcall(handler,callsym,1,rb_str_new2(buf)); \
|
|
131
|
-
va_end(args); \
|
|
132
|
-
} \
|
|
133
|
-
while (0)
|
|
134
|
-
|
|
135
|
-
// TODO these next three should actually be formatting messages.
|
|
136
|
-
static void warning_func(ruby_xml_sax_parser *cbp,
|
|
137
|
-
const char *msg, ...) {
|
|
138
|
-
VALUE handler = cbp->callbackHandler;
|
|
139
|
-
|
|
140
|
-
if (handler && handler != Qnil) {
|
|
141
|
-
FORMAT_AND_CALL(cbidOnXmlParserWarning);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
static void error_func(ruby_xml_sax_parser *cbp,
|
|
146
|
-
const char *msg, ...) {
|
|
147
|
-
VALUE handler = cbp->callbackHandler;
|
|
148
|
-
|
|
149
|
-
if (handler && handler != Qnil) {
|
|
150
|
-
FORMAT_AND_CALL(cbidOnXmlParserError);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
static void fatal_error_func(ruby_xml_sax_parser *cbp,
|
|
155
|
-
const char *msg, ...) {
|
|
156
|
-
VALUE handler = cbp->callbackHandler;
|
|
157
|
-
|
|
158
|
-
if (handler && handler != Qnil) {
|
|
159
|
-
FORMAT_AND_CALL(cbidOnXmlParserFatalError);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
static void cdata_block_func(ruby_xml_sax_parser *cbp,
|
|
164
|
-
const char *value, int len) {
|
|
165
|
-
VALUE handler = cbp->callbackHandler;
|
|
166
|
-
|
|
167
|
-
if (handler && handler != Qnil) {
|
|
168
|
-
rb_funcall(handler,cbidOnCdataBlock,1,rb_str_new(value, len));
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
static void external_subset_func(ruby_xml_sax_parser *cbp,
|
|
173
|
-
const char *name,
|
|
174
|
-
const char *extid,
|
|
175
|
-
const char *sysid) {
|
|
176
|
-
VALUE handler = cbp->callbackHandler;
|
|
177
|
-
|
|
178
|
-
if (handler && handler != Qnil) {
|
|
179
|
-
rb_funcall(handler, cbidOnExternalSubset, 3, rb_str_new2(name),
|
|
180
|
-
rb_str_new2(extid), rb_str_new2(sysid));
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
static xmlSAXHandler rubySAXHandlerStruct = {
|
|
185
|
-
(internalSubsetSAXFunc)internal_subset_func,
|
|
186
|
-
(isStandaloneSAXFunc)is_standalone_func,
|
|
187
|
-
(hasInternalSubsetSAXFunc)has_internal_subset_func,
|
|
188
|
-
(hasExternalSubsetSAXFunc)has_external_subset_func,
|
|
189
|
-
0, /* resolveEntity */
|
|
190
|
-
0, /* getEntity */
|
|
191
|
-
0, /* entityDecl */
|
|
192
|
-
0, /* notationDecl */
|
|
193
|
-
0, /* attributeDecl */
|
|
194
|
-
0, /* elementDecl */
|
|
195
|
-
0, /* unparsedEntityDecl */
|
|
196
|
-
0, /* setDocumentLocator */
|
|
197
|
-
(startDocumentSAXFunc)start_document_func,
|
|
198
|
-
(endDocumentSAXFunc)end_document_func,
|
|
199
|
-
(startElementSAXFunc)start_element_func,
|
|
200
|
-
(endElementSAXFunc)end_element_func,
|
|
201
|
-
(referenceSAXFunc)reference_func,
|
|
202
|
-
(charactersSAXFunc)characters_func,
|
|
203
|
-
0, /* ignorableWhitespace */
|
|
204
|
-
(processingInstructionSAXFunc)processing_instruction_func,
|
|
205
|
-
(commentSAXFunc)comment_func,
|
|
206
|
-
(warningSAXFunc)warning_func,
|
|
207
|
-
(errorSAXFunc)error_func,
|
|
208
|
-
(fatalErrorSAXFunc)fatal_error_func,
|
|
209
|
-
0, /* xmlGetParameterEntity */
|
|
210
|
-
(cdataBlockSAXFunc)cdata_block_func,
|
|
211
|
-
(externalSubsetSAXFunc)external_subset_func,
|
|
212
|
-
1
|
|
213
|
-
};
|
|
1
|
+
/* $Id: sax_parser_callbacks.inc 120 2006-11-26 12:57:56Z roscopeco $ */
|
|
2
|
+
|
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
* SAX CALLBACK HANDLERS
|
|
7
|
+
*/
|
|
8
|
+
static void internal_subset_func(ruby_xml_sax_parser *cbp,
|
|
9
|
+
const char *name,
|
|
10
|
+
const char *extid,
|
|
11
|
+
const char *sysid) {
|
|
12
|
+
VALUE handler = cbp->callbackHandler;
|
|
13
|
+
|
|
14
|
+
if (handler && handler != Qnil) {
|
|
15
|
+
rb_funcall(handler, cbidOnInternalSubset, 3, rb_str_new2(name),
|
|
16
|
+
rb_str_new2(extid), rb_str_new2(sysid));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static void is_standalone_func(ruby_xml_sax_parser *cbp) {
|
|
21
|
+
VALUE handler = cbp->callbackHandler;
|
|
22
|
+
|
|
23
|
+
if (handler && handler != Qnil) {
|
|
24
|
+
rb_funcall(handler,cbidOnIsStandalone,0);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static void has_internal_subset_func(ruby_xml_sax_parser *cbp) {
|
|
29
|
+
VALUE handler = cbp->callbackHandler;
|
|
30
|
+
|
|
31
|
+
if (handler && handler != Qnil) {
|
|
32
|
+
rb_funcall(handler,cbidOnHasInternalSubset,0);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static void has_external_subset_func(ruby_xml_sax_parser *cbp) {
|
|
37
|
+
VALUE handler = cbp->callbackHandler;
|
|
38
|
+
|
|
39
|
+
if (handler && handler != Qnil) {
|
|
40
|
+
rb_funcall(handler,cbidOnHasExternalSubset,0);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static void start_document_func(ruby_xml_sax_parser *cbp) {
|
|
45
|
+
VALUE handler = cbp->callbackHandler;
|
|
46
|
+
|
|
47
|
+
if (handler && handler != Qnil) {
|
|
48
|
+
rb_funcall(handler,cbidOnStartDocument,0);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static void end_document_func(ruby_xml_sax_parser *cbp) {
|
|
53
|
+
VALUE handler = cbp->callbackHandler;
|
|
54
|
+
|
|
55
|
+
if (handler && handler != Qnil) {
|
|
56
|
+
rb_funcall(handler,cbidOnEndDocument,0);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static void start_element_func(ruby_xml_sax_parser *cbp,
|
|
61
|
+
const char *name, const char **attrs) {
|
|
62
|
+
VALUE handler = cbp->callbackHandler;
|
|
63
|
+
VALUE ahsh = rb_hash_new();
|
|
64
|
+
const char *attr, *value;
|
|
65
|
+
|
|
66
|
+
if (attrs) {
|
|
67
|
+
while ((attr = *(attrs++))) {
|
|
68
|
+
value = *(attrs++);
|
|
69
|
+
rb_hash_aset(ahsh, rb_str_new2(attr), rb_str_new2(value));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (handler && handler != Qnil) {
|
|
74
|
+
rb_funcall(handler,cbidOnStartElement,2,rb_str_new2(name),ahsh);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static void end_element_func(ruby_xml_sax_parser *cbp,
|
|
79
|
+
const char *name) {
|
|
80
|
+
VALUE handler = cbp->callbackHandler;
|
|
81
|
+
|
|
82
|
+
if (handler && handler != Qnil) {
|
|
83
|
+
rb_funcall(handler,cbidOnEndElement,1,rb_str_new2(name));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static void reference_func(ruby_xml_sax_parser *cbp,
|
|
88
|
+
const char *name) {
|
|
89
|
+
VALUE handler = cbp->callbackHandler;
|
|
90
|
+
|
|
91
|
+
if (handler && handler != Qnil) {
|
|
92
|
+
rb_funcall(handler,cbidOnReference,1,rb_str_new2(name));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
static void characters_func(ruby_xml_sax_parser *cbp,
|
|
97
|
+
const char *chars, int len) {
|
|
98
|
+
VALUE handler = cbp->callbackHandler;
|
|
99
|
+
|
|
100
|
+
if (handler && handler != Qnil) {
|
|
101
|
+
rb_funcall(handler,cbidOnCharacters,1,rb_str_new(chars, len));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static void processing_instruction_func(ruby_xml_sax_parser *cbp,
|
|
106
|
+
const char *target, const char *data) {
|
|
107
|
+
VALUE handler = cbp->callbackHandler;
|
|
108
|
+
|
|
109
|
+
if (handler && handler != Qnil) {
|
|
110
|
+
rb_funcall(handler, cbidOnProcessingInstruction, 2,
|
|
111
|
+
rb_str_new2(target),rb_str_new2(data));
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static void comment_func(ruby_xml_sax_parser *cbp,
|
|
116
|
+
const char *msg) {
|
|
117
|
+
VALUE handler = cbp->callbackHandler;
|
|
118
|
+
|
|
119
|
+
if (handler && handler != Qnil) {
|
|
120
|
+
rb_funcall(handler,cbidOnComment,1,rb_str_new2(msg));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
#define FORMAT_AND_CALL(callsym) \
|
|
125
|
+
do { \
|
|
126
|
+
va_list args; \
|
|
127
|
+
char buf[1024]; \
|
|
128
|
+
va_start(args, msg); \
|
|
129
|
+
vsnprintf(buf, sizeof buf, msg, args); \
|
|
130
|
+
rb_funcall(handler,callsym,1,rb_str_new2(buf)); \
|
|
131
|
+
va_end(args); \
|
|
132
|
+
} \
|
|
133
|
+
while (0)
|
|
134
|
+
|
|
135
|
+
// TODO these next three should actually be formatting messages.
|
|
136
|
+
static void warning_func(ruby_xml_sax_parser *cbp,
|
|
137
|
+
const char *msg, ...) {
|
|
138
|
+
VALUE handler = cbp->callbackHandler;
|
|
139
|
+
|
|
140
|
+
if (handler && handler != Qnil) {
|
|
141
|
+
FORMAT_AND_CALL(cbidOnXmlParserWarning);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static void error_func(ruby_xml_sax_parser *cbp,
|
|
146
|
+
const char *msg, ...) {
|
|
147
|
+
VALUE handler = cbp->callbackHandler;
|
|
148
|
+
|
|
149
|
+
if (handler && handler != Qnil) {
|
|
150
|
+
FORMAT_AND_CALL(cbidOnXmlParserError);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static void fatal_error_func(ruby_xml_sax_parser *cbp,
|
|
155
|
+
const char *msg, ...) {
|
|
156
|
+
VALUE handler = cbp->callbackHandler;
|
|
157
|
+
|
|
158
|
+
if (handler && handler != Qnil) {
|
|
159
|
+
FORMAT_AND_CALL(cbidOnXmlParserFatalError);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
static void cdata_block_func(ruby_xml_sax_parser *cbp,
|
|
164
|
+
const char *value, int len) {
|
|
165
|
+
VALUE handler = cbp->callbackHandler;
|
|
166
|
+
|
|
167
|
+
if (handler && handler != Qnil) {
|
|
168
|
+
rb_funcall(handler,cbidOnCdataBlock,1,rb_str_new(value, len));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
static void external_subset_func(ruby_xml_sax_parser *cbp,
|
|
173
|
+
const char *name,
|
|
174
|
+
const char *extid,
|
|
175
|
+
const char *sysid) {
|
|
176
|
+
VALUE handler = cbp->callbackHandler;
|
|
177
|
+
|
|
178
|
+
if (handler && handler != Qnil) {
|
|
179
|
+
rb_funcall(handler, cbidOnExternalSubset, 3, rb_str_new2(name),
|
|
180
|
+
rb_str_new2(extid), rb_str_new2(sysid));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static xmlSAXHandler rubySAXHandlerStruct = {
|
|
185
|
+
(internalSubsetSAXFunc)internal_subset_func,
|
|
186
|
+
(isStandaloneSAXFunc)is_standalone_func,
|
|
187
|
+
(hasInternalSubsetSAXFunc)has_internal_subset_func,
|
|
188
|
+
(hasExternalSubsetSAXFunc)has_external_subset_func,
|
|
189
|
+
0, /* resolveEntity */
|
|
190
|
+
0, /* getEntity */
|
|
191
|
+
0, /* entityDecl */
|
|
192
|
+
0, /* notationDecl */
|
|
193
|
+
0, /* attributeDecl */
|
|
194
|
+
0, /* elementDecl */
|
|
195
|
+
0, /* unparsedEntityDecl */
|
|
196
|
+
0, /* setDocumentLocator */
|
|
197
|
+
(startDocumentSAXFunc)start_document_func,
|
|
198
|
+
(endDocumentSAXFunc)end_document_func,
|
|
199
|
+
(startElementSAXFunc)start_element_func,
|
|
200
|
+
(endElementSAXFunc)end_element_func,
|
|
201
|
+
(referenceSAXFunc)reference_func,
|
|
202
|
+
(charactersSAXFunc)characters_func,
|
|
203
|
+
0, /* ignorableWhitespace */
|
|
204
|
+
(processingInstructionSAXFunc)processing_instruction_func,
|
|
205
|
+
(commentSAXFunc)comment_func,
|
|
206
|
+
(warningSAXFunc)warning_func,
|
|
207
|
+
(errorSAXFunc)error_func,
|
|
208
|
+
(fatalErrorSAXFunc)fatal_error_func,
|
|
209
|
+
0, /* xmlGetParameterEntity */
|
|
210
|
+
(cdataBlockSAXFunc)cdata_block_func,
|
|
211
|
+
(externalSubsetSAXFunc)external_subset_func,
|
|
212
|
+
1
|
|
213
|
+
};
|
data/ext/libxml/version.h
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/* Don't nuke this block! It is used for automatically updating the
|
|
2
|
-
* versions below. VERSION = string formatting, VERNUM = numbered
|
|
3
|
-
* version for inline testing: increment both or none at all
|
|
4
|
-
#define RUBY_LIBXML_VERSION "0.
|
|
5
|
-
#define RUBY_LIBXML_VERNUM
|
|
6
|
-
#define RUBY_LIBXML_VER_MAJ 0
|
|
7
|
-
#define RUBY_LIBXML_VER_MIN
|
|
8
|
-
#define RUBY_LIBXML_VER_MIC
|
|
9
|
-
#define RUBY_LIBXML_VER_PATCH 0
|
|
1
|
+
/* Don't nuke this block! It is used for automatically updating the
|
|
2
|
+
* versions below. VERSION = string formatting, VERNUM = numbered
|
|
3
|
+
* version for inline testing: increment both or none at all.*/
|
|
4
|
+
#define RUBY_LIBXML_VERSION "0.6.0"
|
|
5
|
+
#define RUBY_LIBXML_VERNUM 0
|
|
6
|
+
#define RUBY_LIBXML_VER_MAJ 0
|
|
7
|
+
#define RUBY_LIBXML_VER_MIN 6
|
|
8
|
+
#define RUBY_LIBXML_VER_MIC 0
|
|
9
|
+
#define RUBY_LIBXML_VER_PATCH 0
|
data/lib/libxml.rb
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
# $Id: libxml.rb
|
|
1
|
+
# $Id: libxml.rb 291 2008-07-01 08:04:25Z cfis $
|
|
2
2
|
# Please see the LICENSE file for copyright and distribution information
|
|
3
3
|
|
|
4
|
-
require '
|
|
4
|
+
require 'libxml_ruby.so'
|
|
5
|
+
|
|
6
|
+
module XML::XMLParserOptions
|
|
7
|
+
XML_PARSE_RECOVER = 1 # recover on errors
|
|
8
|
+
XML_PARSE_NOENT = 2 # substitute entities
|
|
9
|
+
XML_PARSE_DTDLOAD = 4 # load the external subset
|
|
10
|
+
XML_PARSE_DTDATTR = 8 # default DTD attributes
|
|
11
|
+
XML_PARSE_DTDVALID = 16 # validate with the DTD
|
|
12
|
+
XML_PARSE_NOERROR = 32 # suppress error reports
|
|
13
|
+
XML_PARSE_NOWARNING = 64 # suppress warning reports
|
|
14
|
+
XML_PARSE_PEDANTIC = 128 # pedantic error reporting
|
|
15
|
+
XML_PARSE_NOBLANKS = 256 # remove blank nodes
|
|
16
|
+
XML_PARSE_SAX1 = 512 # use the SAX1 interface internally
|
|
17
|
+
XML_PARSE_XINCLUDE = 1024 # Implement XInclude substitition
|
|
18
|
+
XML_PARSE_NONET = 2048 # Forbid network access
|
|
19
|
+
XML_PARSE_NODICT = 4096 # Do not reuse the context dictionnary
|
|
20
|
+
XML_PARSE_NSCLEAN = 8192 # remove redundant namespaces declarations
|
|
21
|
+
XML_PARSE_NOCDATA = 16384 # merge CDATA as text nodes
|
|
22
|
+
XML_PARSE_NOXINCNODE = 32768 # do not generate XINCLUDE START/END nodes
|
|
23
|
+
XML_PARSE_COMPACT = 65536 # compact small text nodes; no modification of the tree allowed afterwards (will possibly crash if you try to modify the tree)
|
|
24
|
+
end
|
|
5
25
|
|
|
6
26
|
class XML::Document
|
|
7
27
|
include Enumerable
|
|
@@ -91,7 +111,7 @@ class XML::Attr
|
|
|
91
111
|
alias :each :each_sibling
|
|
92
112
|
|
|
93
113
|
def to_h
|
|
94
|
-
inject({}) do |h,a| h[a.name] = a.value end
|
|
114
|
+
inject({}) do |h,a| h[a.name] = a.value; h end
|
|
95
115
|
end
|
|
96
116
|
|
|
97
117
|
def to_a
|
|
@@ -102,3 +122,4 @@ class XML::Attr
|
|
|
102
122
|
"#{name} = #{value}"
|
|
103
123
|
end
|
|
104
124
|
end
|
|
125
|
+
|
|
Binary file
|
data/mingw/libxml2-2.dll
ADDED
|
Binary file
|
|
Binary file
|
data/mingw/mingw.rake
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# We can't use Ruby's standard build procedures
|
|
2
|
+
# on Windows because the Ruby executable is
|
|
3
|
+
# built with VC++ while here we want to build
|
|
4
|
+
# with MingW. So just roll our own...
|
|
5
|
+
|
|
6
|
+
require 'rake/clean'
|
|
7
|
+
require 'rbconfig'
|
|
8
|
+
|
|
9
|
+
RUBY_INCLUDE_DIR = Config::CONFIG["archdir"]
|
|
10
|
+
RUBY_BIN_DIR = Config::CONFIG["bindir"]
|
|
11
|
+
RUBY_LIB_DIR = Config::CONFIG["libdir"]
|
|
12
|
+
RUBY_SHARED_LIB = Config::CONFIG["LIBRUBY"]
|
|
13
|
+
RUBY_SHARED_DLL = RUBY_SHARED_LIB.gsub(/lib$/, 'dll')
|
|
14
|
+
|
|
15
|
+
CLEAN.include('*.o')
|
|
16
|
+
CLOBBER.include('libxml.so')
|
|
17
|
+
|
|
18
|
+
task :default => "libxml"
|
|
19
|
+
|
|
20
|
+
SRC = FileList['../ext/libxml/*.c']
|
|
21
|
+
OBJ = SRC.collect do |file_name|
|
|
22
|
+
File.basename(file_name).ext('o')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
SRC.each do |srcfile|
|
|
26
|
+
objfile = File.basename(srcfile).ext('o')
|
|
27
|
+
file objfile => srcfile do
|
|
28
|
+
command = "gcc -c -fPIC -O2 -Wall -o #{objfile} -I/usr/local/include #{srcfile} -I#{RUBY_INCLUDE_DIR}"
|
|
29
|
+
sh "sh -c '#{command}'"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
file "libxml" => OBJ do
|
|
34
|
+
command = "libtool --mode=link gcc -shared -o libxml_ruby.so -L/usr/local/lib -lxml2 #{OBJ} #{RUBY_BIN_DIR}/#{RUBY_SHARED_DLL}"
|
|
35
|
+
sh "sh -c '#{command}'"
|
|
36
|
+
end
|
data/test/dtd-test.rb
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
require "libxml"
|
|
2
|
-
|
|
3
|
-
xp = XML::Parser.new
|
|
4
|
-
xp.string = '<?xml version="1.0" encoding="utf-8"?>
|
|
5
|
-
<root><head a="ee" id="1">ass<buzz/></head><descr>really big ass</descr></root>'
|
|
6
|
-
|
|
7
|
-
doc = xp.parse
|
|
8
|
-
|
|
9
|
-
dtd = XML::Dtd.new('
|
|
10
|
-
<!ELEMENT root (head, descr)>
|
|
11
|
-
<!ELEMENT head (#PCDATA)>
|
|
12
|
-
<!ATTLIST head
|
|
13
|
-
id NMTOKEN #REQUIRED
|
|
14
|
-
a CDATA #IMPLIED
|
|
15
|
-
>
|
|
16
|
-
<!ELEMENT descr (#PCDATA)>
|
|
17
|
-
')
|
|
18
|
-
|
|
19
|
-
if doc.validate(dtd) { |message, error| puts "#{error ? 'error' : 'warning'} : #{message}" }
|
|
20
|
-
puts "validation passed"
|
|
21
|
-
else
|
|
22
|
-
puts "validation failed"
|
|
23
|
-
end
|
|
24
|
-
|
|
1
|
+
require "libxml"
|
|
2
|
+
|
|
3
|
+
xp = XML::Parser.new
|
|
4
|
+
xp.string = '<?xml version="1.0" encoding="utf-8"?>
|
|
5
|
+
<root><head a="ee" id="1">ass<buzz/></head><descr>really big ass</descr></root>'
|
|
6
|
+
|
|
7
|
+
doc = xp.parse
|
|
8
|
+
|
|
9
|
+
dtd = XML::Dtd.new('
|
|
10
|
+
<!ELEMENT root (head, descr)>
|
|
11
|
+
<!ELEMENT head (#PCDATA)>
|
|
12
|
+
<!ATTLIST head
|
|
13
|
+
id NMTOKEN #REQUIRED
|
|
14
|
+
a CDATA #IMPLIED
|
|
15
|
+
>
|
|
16
|
+
<!ELEMENT descr (#PCDATA)>
|
|
17
|
+
')
|
|
18
|
+
|
|
19
|
+
if doc.validate(dtd) { |message, error| puts "#{error ? 'error' : 'warning'} : #{message}" }
|
|
20
|
+
puts "validation passed"
|
|
21
|
+
else
|
|
22
|
+
puts "validation failed"
|
|
23
|
+
end
|
|
24
|
+
|
data/test/etc_doc_to_s.rb
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
require 'libxml'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
1.times do |count|
|
|
4
4
|
|
|
5
5
|
xml_doc = XML::Document.new()
|
|
6
6
|
xml_doc.encoding = "UTF-8"
|
|
7
7
|
xml_doc.root = XML::Node.new("Request")
|
|
8
8
|
|
|
9
9
|
1000.times do |index|
|
|
10
|
-
|
|
11
10
|
xml_doc.root << node = XML::Node.new("row")
|
|
12
11
|
node["user_id"] = index.to_s
|
|
13
12
|
node << "600445"
|
|
14
|
-
|
|
15
13
|
end
|
|
16
14
|
|
|
17
15
|
xml_str = xml_doc.to_s
|
data/test/ets_copy_bug.rb
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
def test( doc2 )
|
|
4
|
-
doc = XML::Document.new('1.0')
|
|
5
|
-
doc.root = XML::Node.new("ccc")
|
|
6
|
-
doc.root['aaa'] = 'aaa'
|
|
7
|
-
doc.root.child_add(doc2.root) # BUG!
|
|
8
|
-
doc.root << doc2.root.copy(true)
|
|
9
|
-
return doc
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def test2
|
|
13
|
-
doc2 = XML::Document.new('1.0')
|
|
14
|
-
doc2.root = XML::Node.new("aaa")
|
|
15
|
-
test( doc2 )
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
1000.times { |i|
|
|
19
|
-
print "\r#{i}"; $stdout.flush
|
|
20
|
-
test2
|
|
21
|
-
}
|
|
1
|
+
require 'libxml'
|
|
2
|
+
|
|
3
|
+
def test( doc2 )
|
|
4
|
+
doc = XML::Document.new('1.0')
|
|
5
|
+
doc.root = XML::Node.new("ccc")
|
|
6
|
+
doc.root['aaa'] = 'aaa'
|
|
7
|
+
doc.root.child_add(doc2.root) # BUG!
|
|
8
|
+
doc.root << doc2.root.copy(true)
|
|
9
|
+
return doc
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test2
|
|
13
|
+
doc2 = XML::Document.new('1.0')
|
|
14
|
+
doc2.root = XML::Node.new("aaa")
|
|
15
|
+
test( doc2 )
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
1000.times { |i|
|
|
19
|
+
print "\r#{i}"; $stdout.flush
|
|
20
|
+
test2
|
|
21
|
+
}
|