libxml-ruby 0.6.0-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +122 -0
- data/LICENSE +23 -0
- data/README +144 -0
- data/ext/libxml/cbg.c +76 -0
- data/ext/libxml/extconf.rb +308 -0
- data/ext/libxml/libxml.c +62 -0
- data/ext/libxml/ruby_libxml.h +93 -0
- data/ext/libxml/ruby_xml_attr.c +405 -0
- data/ext/libxml/ruby_xml_attr.h +19 -0
- data/ext/libxml/ruby_xml_document.c +1111 -0
- data/ext/libxml/ruby_xml_document.h +27 -0
- data/ext/libxml/ruby_xml_dtd.c +168 -0
- data/ext/libxml/ruby_xml_dtd.h +17 -0
- data/ext/libxml/ruby_xml_html_parser.c +449 -0
- data/ext/libxml/ruby_xml_html_parser.h +29 -0
- data/ext/libxml/ruby_xml_input_cbg.c +158 -0
- data/ext/libxml/ruby_xml_input_cbg.h +20 -0
- data/ext/libxml/ruby_xml_node.c +2410 -0
- data/ext/libxml/ruby_xml_node.h +27 -0
- data/ext/libxml/ruby_xml_node_set.c +170 -0
- data/ext/libxml/ruby_xml_node_set.h +20 -0
- data/ext/libxml/ruby_xml_ns.c +153 -0
- data/ext/libxml/ruby_xml_ns.h +21 -0
- data/ext/libxml/ruby_xml_parser.c +1425 -0
- data/ext/libxml/ruby_xml_parser.h +31 -0
- data/ext/libxml/ruby_xml_parser_context.c +750 -0
- data/ext/libxml/ruby_xml_parser_context.h +22 -0
- data/ext/libxml/ruby_xml_reader.c +900 -0
- data/ext/libxml/ruby_xml_reader.h +14 -0
- data/ext/libxml/ruby_xml_sax_parser.c +485 -0
- data/ext/libxml/ruby_xml_sax_parser.h +56 -0
- data/ext/libxml/ruby_xml_schema.c +146 -0
- data/ext/libxml/ruby_xml_schema.h +16 -0
- data/ext/libxml/ruby_xml_state.c +113 -0
- data/ext/libxml/ruby_xml_state.h +12 -0
- data/ext/libxml/ruby_xml_tree.c +43 -0
- data/ext/libxml/ruby_xml_tree.h +12 -0
- data/ext/libxml/ruby_xml_xinclude.c +20 -0
- data/ext/libxml/ruby_xml_xinclude.h +13 -0
- data/ext/libxml/ruby_xml_xpath.c +243 -0
- data/ext/libxml/ruby_xml_xpath.h +23 -0
- data/ext/libxml/ruby_xml_xpath_context.c +118 -0
- data/ext/libxml/ruby_xml_xpath_context.h +20 -0
- data/ext/libxml/ruby_xml_xpath_object.c +293 -0
- data/ext/libxml/ruby_xml_xpath_object.h +28 -0
- data/ext/libxml/ruby_xml_xpointer.c +100 -0
- data/ext/libxml/ruby_xml_xpointer.h +27 -0
- data/ext/libxml/ruby_xml_xpointer_context.c +21 -0
- data/ext/libxml/ruby_xml_xpointer_context.h +18 -0
- data/ext/libxml/sax_parser_callbacks.inc +213 -0
- data/ext/libxml/version.h +9 -0
- data/lib/libxml.rb +125 -0
- data/lib/libxml_ruby.so +0 -0
- data/lib/xml/libxml.rb +5 -0
- 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 -0
- data/test/etc_doc_to_s.rb +19 -0
- data/test/ets_copy_bug.rb +21 -0
- data/test/ets_copy_bug2.rb +32 -0
- data/test/ets_copy_bug3.rb +38 -0
- data/test/ets_doc_file.rb +15 -0
- data/test/ets_doc_to_s.rb +21 -0
- data/test/ets_gpx.rb +26 -0
- data/test/ets_node_gc.rb +21 -0
- data/test/ets_test.xml +2 -0
- data/test/ets_tsr.rb +9 -0
- data/test/gc.log +0 -0
- data/test/merge_bug.rb +55 -0
- data/test/schema-test.rb +74 -0
- data/test/tc_well_formed.rb +11 -0
- data/test/tc_xml_document.rb +52 -0
- data/test/tc_xml_document_write.rb +24 -0
- data/test/tc_xml_document_write2.rb +54 -0
- data/test/tc_xml_document_write3.rb +96 -0
- data/test/tc_xml_html_parser.rb +63 -0
- data/test/tc_xml_node.rb +59 -0
- data/test/tc_xml_node2.rb +25 -0
- data/test/tc_xml_node3.rb +27 -0
- data/test/tc_xml_node4.rb +86 -0
- data/test/tc_xml_node5.rb +52 -0
- data/test/tc_xml_node6.rb +27 -0
- data/test/tc_xml_node7.rb +35 -0
- data/test/tc_xml_node8.rb +32 -0
- data/test/tc_xml_node9.rb +32 -0
- data/test/tc_xml_node_copy.rb +40 -0
- data/test/tc_xml_node_set.rb +24 -0
- data/test/tc_xml_node_set2.rb +37 -0
- data/test/tc_xml_node_text.rb +17 -0
- data/test/tc_xml_node_xlink.rb +28 -0
- data/test/tc_xml_parser.rb +190 -0
- data/test/tc_xml_parser2.rb +16 -0
- data/test/tc_xml_parser3.rb +23 -0
- data/test/tc_xml_parser4.rb +33 -0
- data/test/tc_xml_parser5.rb +27 -0
- data/test/tc_xml_parser6.rb +23 -0
- data/test/tc_xml_parser7.rb +28 -0
- data/test/tc_xml_parser8.rb +32 -0
- data/test/tc_xml_parser9.rb +11 -0
- data/test/tc_xml_parser_context.rb +88 -0
- data/test/tc_xml_reader.rb +112 -0
- data/test/tc_xml_sax_parser.rb +104 -0
- data/test/tc_xml_sax_parser2.rb +51 -0
- data/test/tc_xml_xinclude.rb +30 -0
- data/test/tc_xml_xpath.rb +38 -0
- data/test/tc_xml_xpath2.rb +14 -0
- data/test/tc_xml_xpointer.rb +78 -0
- 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 +224 -0
@@ -0,0 +1,31 @@
|
|
1
|
+
/* $Id: ruby_xml_parser.h 39 2006-02-21 20:40:16Z roscopeco $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_PARSER__
|
6
|
+
#define __RUBY_XML_PARSER__
|
7
|
+
|
8
|
+
#define MAX_LIBXML_FEATURES_LEN 50
|
9
|
+
|
10
|
+
extern int ruby_xml_parser_count;
|
11
|
+
extern VALUE cXMLParser;
|
12
|
+
extern VALUE eXMLParserParseError;
|
13
|
+
|
14
|
+
typedef struct ruby_xml_parser {
|
15
|
+
VALUE ctxt;
|
16
|
+
int parsed;
|
17
|
+
void *data;
|
18
|
+
int data_type;
|
19
|
+
} ruby_xml_parser;
|
20
|
+
|
21
|
+
VALUE ruby_xml_parser_default_load_external_dtd_set(VALUE class, VALUE bool);
|
22
|
+
VALUE ruby_xml_parser_default_substitute_entities_set(VALUE class, VALUE bool);
|
23
|
+
VALUE ruby_xml_parser_features(VALUE self);
|
24
|
+
VALUE ruby_xml_parser_filename_get(VALUE self);
|
25
|
+
VALUE ruby_xml_parser_filename_set(VALUE self, VALUE filename);
|
26
|
+
VALUE ruby_xml_parser_new(VALUE class);
|
27
|
+
VALUE ruby_xml_parser_parse(VALUE self);
|
28
|
+
VALUE ruby_xml_parser_str_get(VALUE self);
|
29
|
+
VALUE ruby_xml_parser_str_set(VALUE self, VALUE str);
|
30
|
+
|
31
|
+
#endif
|
@@ -0,0 +1,750 @@
|
|
1
|
+
/* $Id: ruby_xml_parser_context.c 300 2008-07-01 19:14:15Z cfis $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#include "ruby_libxml.h"
|
6
|
+
#include "ruby_xml_parser_context.h"
|
7
|
+
|
8
|
+
/* TODO:
|
9
|
+
*
|
10
|
+
* *) xmlParserInput class/structure
|
11
|
+
* *) errNo and mappings
|
12
|
+
* *) validity context
|
13
|
+
* *) record_info or stats class/structure
|
14
|
+
* *) xmlParserNodeInfoSeq
|
15
|
+
* *) xmlParserInputState
|
16
|
+
*/
|
17
|
+
VALUE cXMLParserContext;
|
18
|
+
|
19
|
+
/*
|
20
|
+
* call-seq:
|
21
|
+
* context.data_directory => "dir"
|
22
|
+
*
|
23
|
+
* Obtain the data directory associated with this context.
|
24
|
+
*/
|
25
|
+
VALUE
|
26
|
+
ruby_xml_parser_context_data_directory_get(VALUE self) {
|
27
|
+
ruby_xml_parser_context *rxpc;
|
28
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
29
|
+
|
30
|
+
if (rxpc->ctxt->directory == NULL)
|
31
|
+
return(Qnil);
|
32
|
+
else
|
33
|
+
return(rb_str_new2(rxpc->ctxt->directory));
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
/*
|
38
|
+
* call-seq:
|
39
|
+
* context.depth => num
|
40
|
+
*
|
41
|
+
* Obtain the depth of this context.
|
42
|
+
*/
|
43
|
+
VALUE
|
44
|
+
ruby_xml_parser_context_depth_get(VALUE self) {
|
45
|
+
ruby_xml_parser_context *rxpc;
|
46
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
47
|
+
|
48
|
+
return(INT2NUM(rxpc->ctxt->depth));
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
/*
|
53
|
+
* call-seq:
|
54
|
+
* context.disable_sax? => (true|false)
|
55
|
+
*
|
56
|
+
* Determine whether SAX-based processing is disabled
|
57
|
+
* in this context.
|
58
|
+
*/
|
59
|
+
VALUE
|
60
|
+
ruby_xml_parser_context_disable_sax_q(VALUE self) {
|
61
|
+
ruby_xml_parser_context *rxpc;
|
62
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
63
|
+
|
64
|
+
if (rxpc->ctxt->disableSAX)
|
65
|
+
return(Qtrue);
|
66
|
+
else
|
67
|
+
return(Qfalse);
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
/*
|
72
|
+
* call-seq:
|
73
|
+
* context.doc => document
|
74
|
+
*
|
75
|
+
* Obtain the +XML::Document+ associated with this context.
|
76
|
+
*/
|
77
|
+
VALUE
|
78
|
+
ruby_xml_parser_context_doc_get(VALUE self) {
|
79
|
+
ruby_xml_parser_context *rxpc;
|
80
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
81
|
+
|
82
|
+
if (rxpc->ctxt->myDoc == NULL)
|
83
|
+
return(Qnil);
|
84
|
+
|
85
|
+
return(ruby_xml_document_wrap(rxpc->ctxt->myDoc));
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
/*
|
90
|
+
* call-seq:
|
91
|
+
* context.docbook? => (true|false)
|
92
|
+
*
|
93
|
+
* Determine whether this is a docbook context.
|
94
|
+
*/
|
95
|
+
VALUE
|
96
|
+
ruby_xml_parser_context_docbook_q(VALUE self) {
|
97
|
+
ruby_xml_parser_context *rxpc;
|
98
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
99
|
+
|
100
|
+
if (rxpc->ctxt->html == 2) // TODO check this
|
101
|
+
return(Qtrue);
|
102
|
+
else
|
103
|
+
return(Qfalse);
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
/*
|
108
|
+
* call-seq:
|
109
|
+
* context.encoding => "encoding"
|
110
|
+
*
|
111
|
+
* Obtain the character encoding identifier used in
|
112
|
+
* this context.
|
113
|
+
*/
|
114
|
+
VALUE
|
115
|
+
ruby_xml_parser_context_encoding_get(VALUE self) {
|
116
|
+
ruby_xml_parser_context *rxpc;
|
117
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
118
|
+
|
119
|
+
if (rxpc->ctxt->encoding == NULL)
|
120
|
+
return(Qnil);
|
121
|
+
else
|
122
|
+
return(rb_str_new2((const char*)rxpc->ctxt->encoding));
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
/*
|
127
|
+
* call-seq:
|
128
|
+
* context.errno => num
|
129
|
+
*
|
130
|
+
* Obtain the last-error number in this context.
|
131
|
+
*/
|
132
|
+
VALUE
|
133
|
+
ruby_xml_parser_context_errno_get(VALUE self) {
|
134
|
+
ruby_xml_parser_context *rxpc;
|
135
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
136
|
+
|
137
|
+
return(INT2NUM(rxpc->ctxt->errNo));
|
138
|
+
}
|
139
|
+
|
140
|
+
|
141
|
+
void
|
142
|
+
ruby_xml_parser_context_free(ruby_xml_parser_context *rxpc) {
|
143
|
+
if (rxpc->ctxt != NULL) {
|
144
|
+
xmlFreeParserCtxt(rxpc->ctxt);
|
145
|
+
rxpc->ctxt = NULL;
|
146
|
+
}
|
147
|
+
|
148
|
+
ruby_xfree(rxpc);
|
149
|
+
}
|
150
|
+
|
151
|
+
void
|
152
|
+
ruby_xml_parser_context_mark(void *v) {
|
153
|
+
if ( v == NULL ) return;
|
154
|
+
ruby_xml_state_marker();
|
155
|
+
}
|
156
|
+
|
157
|
+
/*
|
158
|
+
* call-seq:
|
159
|
+
* context.html? => (true|false)
|
160
|
+
*
|
161
|
+
* Determine whether this is an html context.
|
162
|
+
*/
|
163
|
+
VALUE
|
164
|
+
ruby_xml_parser_context_html_q(VALUE self) {
|
165
|
+
ruby_xml_parser_context *rxpc;
|
166
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
167
|
+
|
168
|
+
if (rxpc->ctxt->html == 1)
|
169
|
+
return(Qtrue);
|
170
|
+
else
|
171
|
+
return(Qfalse);
|
172
|
+
}
|
173
|
+
|
174
|
+
|
175
|
+
/*
|
176
|
+
* call-seq:
|
177
|
+
* context.max_num_streams => num
|
178
|
+
*
|
179
|
+
* Obtain the limit on the number of IO streams opened in
|
180
|
+
* this context.
|
181
|
+
*/
|
182
|
+
VALUE
|
183
|
+
ruby_xml_parser_context_io_max_num_streams_get(VALUE self) {
|
184
|
+
// TODO alias to max_streams and dep this?
|
185
|
+
ruby_xml_parser_context *rxpc;
|
186
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
187
|
+
|
188
|
+
return(INT2NUM(rxpc->ctxt->inputMax));
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
/*
|
193
|
+
* call-seq:
|
194
|
+
* context.num_streams => "dir"
|
195
|
+
*
|
196
|
+
* Obtain the actual number of IO streams in this
|
197
|
+
* context.
|
198
|
+
*/
|
199
|
+
VALUE
|
200
|
+
ruby_xml_parser_context_io_num_streams_get(VALUE self) {
|
201
|
+
ruby_xml_parser_context *rxpc;
|
202
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
203
|
+
|
204
|
+
return(INT2NUM(rxpc->ctxt->inputNr));
|
205
|
+
}
|
206
|
+
|
207
|
+
|
208
|
+
/*
|
209
|
+
* call-seq:
|
210
|
+
* context.keep_blanks? => (true|false)
|
211
|
+
*
|
212
|
+
* Determine whether parsers in this context retain
|
213
|
+
* whitespace.
|
214
|
+
*/
|
215
|
+
VALUE
|
216
|
+
ruby_xml_parser_context_keep_blanks_q(VALUE self) {
|
217
|
+
ruby_xml_parser_context *rxpc;
|
218
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
219
|
+
|
220
|
+
if (rxpc->ctxt->keepBlanks)
|
221
|
+
return(Qtrue);
|
222
|
+
else
|
223
|
+
return(Qfalse);
|
224
|
+
}
|
225
|
+
|
226
|
+
|
227
|
+
/*
|
228
|
+
* call-seq:
|
229
|
+
* context.name_depth => num
|
230
|
+
*
|
231
|
+
* Obtain the name depth for this context.
|
232
|
+
*/
|
233
|
+
VALUE
|
234
|
+
ruby_xml_parser_context_name_depth_get(VALUE self) {
|
235
|
+
ruby_xml_parser_context *rxpc;
|
236
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
237
|
+
|
238
|
+
return(INT2NUM(rxpc->ctxt->nameNr));
|
239
|
+
}
|
240
|
+
|
241
|
+
|
242
|
+
/*
|
243
|
+
* call-seq:
|
244
|
+
* context.name_depth_max => num
|
245
|
+
*
|
246
|
+
* Obtain the maximum name depth for this context.
|
247
|
+
*/
|
248
|
+
VALUE
|
249
|
+
ruby_xml_parser_context_name_depth_max_get(VALUE self) {
|
250
|
+
ruby_xml_parser_context *rxpc;
|
251
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
252
|
+
|
253
|
+
return(INT2NUM(rxpc->ctxt->nameMax));
|
254
|
+
}
|
255
|
+
|
256
|
+
|
257
|
+
/*
|
258
|
+
* call-seq:
|
259
|
+
* context.name_node => "name"
|
260
|
+
*
|
261
|
+
* Obtain the name node for this context.
|
262
|
+
*/
|
263
|
+
VALUE
|
264
|
+
ruby_xml_parser_context_name_node_get(VALUE self) {
|
265
|
+
ruby_xml_parser_context *rxpc;
|
266
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
267
|
+
|
268
|
+
if (rxpc->ctxt->name == NULL)
|
269
|
+
return(Qnil);
|
270
|
+
else
|
271
|
+
return(rb_str_new2((const char*)rxpc->ctxt->name));
|
272
|
+
}
|
273
|
+
|
274
|
+
|
275
|
+
/*
|
276
|
+
* call-seq:
|
277
|
+
* context.name_tab => ["name", ..., "name"]
|
278
|
+
*
|
279
|
+
* Obtain the name table for this context.
|
280
|
+
*/
|
281
|
+
VALUE
|
282
|
+
ruby_xml_parser_context_name_tab_get(VALUE self) {
|
283
|
+
int i;
|
284
|
+
ruby_xml_parser_context *rxpc;
|
285
|
+
VALUE tab_ary;
|
286
|
+
|
287
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
288
|
+
|
289
|
+
if (rxpc->ctxt->nameTab == NULL)
|
290
|
+
return(Qnil);
|
291
|
+
|
292
|
+
tab_ary = rb_ary_new();
|
293
|
+
|
294
|
+
for (i = (rxpc->ctxt->nameNr - 1); i >= 0; i--) {
|
295
|
+
if (rxpc->ctxt->nameTab[i] == NULL)
|
296
|
+
continue;
|
297
|
+
else
|
298
|
+
rb_ary_push(tab_ary, rb_str_new2((const char*)rxpc->ctxt->nameTab[i]));
|
299
|
+
}
|
300
|
+
|
301
|
+
return(tab_ary);
|
302
|
+
}
|
303
|
+
|
304
|
+
|
305
|
+
/*
|
306
|
+
* call-seq:
|
307
|
+
* context.node_depth => num
|
308
|
+
*
|
309
|
+
* Obtain the node depth for this context.
|
310
|
+
*/
|
311
|
+
VALUE
|
312
|
+
ruby_xml_parser_context_node_depth_get(VALUE self) {
|
313
|
+
ruby_xml_parser_context *rxpc;
|
314
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
315
|
+
|
316
|
+
return(INT2NUM(rxpc->ctxt->nodeNr));
|
317
|
+
}
|
318
|
+
|
319
|
+
|
320
|
+
/*
|
321
|
+
* call-seq:
|
322
|
+
* context.node => node
|
323
|
+
*
|
324
|
+
* Obtain the root node of this context.
|
325
|
+
*/
|
326
|
+
VALUE
|
327
|
+
ruby_xml_parser_context_node_get(VALUE self) {
|
328
|
+
ruby_xml_parser_context *rxpc;
|
329
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
330
|
+
|
331
|
+
if (rxpc->ctxt->node == NULL)
|
332
|
+
return(Qnil);
|
333
|
+
else
|
334
|
+
return(ruby_xml_node2_wrap(cXMLNode,
|
335
|
+
rxpc->ctxt->node));
|
336
|
+
}
|
337
|
+
|
338
|
+
|
339
|
+
/*
|
340
|
+
* call-seq:
|
341
|
+
* context.node_depth_max => num
|
342
|
+
*
|
343
|
+
* Obtain the maximum node depth for this context.
|
344
|
+
*/
|
345
|
+
VALUE
|
346
|
+
ruby_xml_parser_context_node_depth_max_get(VALUE self) {
|
347
|
+
ruby_xml_parser_context *rxpc;
|
348
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
349
|
+
|
350
|
+
return(INT2NUM(rxpc->ctxt->nodeMax));
|
351
|
+
}
|
352
|
+
|
353
|
+
|
354
|
+
/*
|
355
|
+
* call-seq:
|
356
|
+
* context.num_chars => num
|
357
|
+
*
|
358
|
+
* Obtain the number of characters in this context.
|
359
|
+
*/
|
360
|
+
VALUE
|
361
|
+
ruby_xml_parser_context_num_chars_get(VALUE self) {
|
362
|
+
ruby_xml_parser_context *rxpc;
|
363
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
364
|
+
|
365
|
+
return(LONG2NUM(rxpc->ctxt->nbChars));
|
366
|
+
}
|
367
|
+
|
368
|
+
|
369
|
+
VALUE
|
370
|
+
ruby_xml_parser_context_new(VALUE class, xmlParserCtxtPtr ctxt) {
|
371
|
+
ruby_xml_parser_context *rxpc;
|
372
|
+
|
373
|
+
rxpc = ALLOC(ruby_xml_parser_context);
|
374
|
+
|
375
|
+
rxpc->ctxt = ctxt;
|
376
|
+
return Data_Wrap_Struct(class,
|
377
|
+
ruby_xml_parser_context_mark,
|
378
|
+
ruby_xml_parser_context_free,
|
379
|
+
rxpc);
|
380
|
+
}
|
381
|
+
|
382
|
+
|
383
|
+
VALUE
|
384
|
+
ruby_xml_parser_context_new2(VALUE class) {
|
385
|
+
return(ruby_xml_parser_context_new(class, NULL));
|
386
|
+
}
|
387
|
+
|
388
|
+
|
389
|
+
VALUE
|
390
|
+
ruby_xml_parser_context_new3() {
|
391
|
+
return(ruby_xml_parser_context_new2(cXMLParserContext));
|
392
|
+
}
|
393
|
+
|
394
|
+
|
395
|
+
VALUE
|
396
|
+
ruby_xml_parser_context_options_set(VALUE self, VALUE options) {
|
397
|
+
ruby_xml_parser_context *rxpc;
|
398
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
399
|
+
|
400
|
+
if (xmlCtxtUseOptions(rxpc->ctxt, NUM2INT(options)))
|
401
|
+
return Qfalse;
|
402
|
+
else
|
403
|
+
return Qtrue;
|
404
|
+
}
|
405
|
+
|
406
|
+
VALUE
|
407
|
+
ruby_xml_parser_context_options_get(VALUE self) {
|
408
|
+
ruby_xml_parser_context *rxpc;
|
409
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
410
|
+
return INT2NUM(rxpc->ctxt->options);
|
411
|
+
}
|
412
|
+
|
413
|
+
/*
|
414
|
+
* call-seq:
|
415
|
+
* context.replace_entities? => (true|false)
|
416
|
+
*
|
417
|
+
* Determine whether external entity replacement is enabled in this
|
418
|
+
* context.
|
419
|
+
*/
|
420
|
+
VALUE
|
421
|
+
ruby_xml_parser_context_replace_entities_q(VALUE self) {
|
422
|
+
ruby_xml_parser_context *rxpc;
|
423
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
424
|
+
|
425
|
+
if (rxpc->ctxt->replaceEntities)
|
426
|
+
return(Qtrue);
|
427
|
+
else
|
428
|
+
return(Qfalse);
|
429
|
+
}
|
430
|
+
|
431
|
+
|
432
|
+
/*
|
433
|
+
* call-seq:
|
434
|
+
* context.replace_entities = true|false
|
435
|
+
*
|
436
|
+
* Control whether external entity replacement is enabled in this
|
437
|
+
* context.
|
438
|
+
*/
|
439
|
+
VALUE
|
440
|
+
ruby_xml_parser_context_replace_entities_set(VALUE self, VALUE bool) {
|
441
|
+
ruby_xml_parser_context *rxpc;
|
442
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
443
|
+
|
444
|
+
if (TYPE(bool) == T_FALSE) {
|
445
|
+
rxpc->ctxt->replaceEntities = 0;
|
446
|
+
return(Qfalse);
|
447
|
+
} else {
|
448
|
+
rxpc->ctxt->replaceEntities = 1;
|
449
|
+
return(Qfalse);
|
450
|
+
}
|
451
|
+
}
|
452
|
+
|
453
|
+
|
454
|
+
/*
|
455
|
+
* call-seq:
|
456
|
+
* context.reset
|
457
|
+
*
|
458
|
+
* Resets the parser context.
|
459
|
+
*/
|
460
|
+
VALUE
|
461
|
+
ruby_xml_parser_context_reset(VALUE self) {
|
462
|
+
ruby_xml_parser_context *rxpc;
|
463
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
464
|
+
xmlCtxtReset(rxpc->ctxt);
|
465
|
+
}
|
466
|
+
|
467
|
+
/*
|
468
|
+
* call-seq:
|
469
|
+
* context.space_depth => num
|
470
|
+
*
|
471
|
+
* Obtain the space depth for this context.
|
472
|
+
*/
|
473
|
+
VALUE
|
474
|
+
ruby_xml_parser_context_space_depth_get(VALUE self) {
|
475
|
+
ruby_xml_parser_context *rxpc;
|
476
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
477
|
+
|
478
|
+
return(INT2NUM(rxpc->ctxt->spaceNr));
|
479
|
+
}
|
480
|
+
|
481
|
+
|
482
|
+
/*
|
483
|
+
* call-seq:
|
484
|
+
* context.space_depth => num
|
485
|
+
*
|
486
|
+
* Obtain the maximum space depth for this context.
|
487
|
+
*/
|
488
|
+
VALUE
|
489
|
+
ruby_xml_parser_context_space_depth_max_get(VALUE self) {
|
490
|
+
ruby_xml_parser_context *rxpc;
|
491
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
492
|
+
|
493
|
+
return(INT2NUM(rxpc->ctxt->spaceMax));
|
494
|
+
}
|
495
|
+
|
496
|
+
|
497
|
+
/*
|
498
|
+
* call-seq:
|
499
|
+
* context.subset_external? => (true|false)
|
500
|
+
*
|
501
|
+
* Determine whether this context is a subset of an
|
502
|
+
* external context.
|
503
|
+
*/
|
504
|
+
VALUE
|
505
|
+
ruby_xml_parser_context_subset_external_q(VALUE self) {
|
506
|
+
ruby_xml_parser_context *rxpc;
|
507
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
508
|
+
|
509
|
+
if (rxpc->ctxt->inSubset == 2)
|
510
|
+
return(Qtrue);
|
511
|
+
else
|
512
|
+
return(Qfalse);
|
513
|
+
}
|
514
|
+
|
515
|
+
|
516
|
+
/*
|
517
|
+
* call-seq:
|
518
|
+
* context.subset_internal? => (true|false)
|
519
|
+
*
|
520
|
+
* Determine whether this context is a subset of an
|
521
|
+
* internal context.
|
522
|
+
*/
|
523
|
+
VALUE
|
524
|
+
ruby_xml_parser_context_subset_internal_q(VALUE self) {
|
525
|
+
ruby_xml_parser_context *rxpc;
|
526
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
527
|
+
|
528
|
+
if (rxpc->ctxt->inSubset == 1)
|
529
|
+
return(Qtrue);
|
530
|
+
else
|
531
|
+
return(Qfalse);
|
532
|
+
}
|
533
|
+
|
534
|
+
|
535
|
+
/*
|
536
|
+
* call-seq:
|
537
|
+
* context.subset_name => "name"
|
538
|
+
*
|
539
|
+
* Obtain this context's subset name (valid only if
|
540
|
+
* either of subset_external? or subset_internal?
|
541
|
+
* is true).
|
542
|
+
*/
|
543
|
+
VALUE
|
544
|
+
ruby_xml_parser_context_subset_name_get(VALUE self) {
|
545
|
+
ruby_xml_parser_context *rxpc;
|
546
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
547
|
+
|
548
|
+
if (rxpc->ctxt->intSubName == NULL)
|
549
|
+
return(Qnil);
|
550
|
+
else
|
551
|
+
return(rb_str_new2((const char*)rxpc->ctxt->intSubName));
|
552
|
+
}
|
553
|
+
|
554
|
+
|
555
|
+
/*
|
556
|
+
* call-seq:
|
557
|
+
* context.subset_external_uri => "uri"
|
558
|
+
*
|
559
|
+
* Obtain this context's external subset URI. (valid only if
|
560
|
+
* either of subset_external? or subset_internal?
|
561
|
+
* is true).
|
562
|
+
*/
|
563
|
+
VALUE
|
564
|
+
ruby_xml_parser_context_subset_external_uri_get(VALUE self) {
|
565
|
+
ruby_xml_parser_context *rxpc;
|
566
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
567
|
+
|
568
|
+
if (rxpc->ctxt->extSubURI == NULL)
|
569
|
+
return(Qnil);
|
570
|
+
else
|
571
|
+
return(rb_str_new2((const char*)rxpc->ctxt->extSubURI));
|
572
|
+
}
|
573
|
+
|
574
|
+
|
575
|
+
/*
|
576
|
+
* call-seq:
|
577
|
+
* context.subset_external_system_id => "system_id"
|
578
|
+
*
|
579
|
+
* Obtain this context's external subset system identifier.
|
580
|
+
* (valid only if either of subset_external? or subset_internal?
|
581
|
+
* is true).
|
582
|
+
*/
|
583
|
+
VALUE
|
584
|
+
ruby_xml_parser_context_subset_external_system_id_get(VALUE self) {
|
585
|
+
ruby_xml_parser_context *rxpc;
|
586
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
587
|
+
|
588
|
+
if (rxpc->ctxt->extSubSystem == NULL)
|
589
|
+
return(Qnil);
|
590
|
+
else
|
591
|
+
return(rb_str_new2((const char*)rxpc->ctxt->extSubSystem));
|
592
|
+
}
|
593
|
+
|
594
|
+
|
595
|
+
/*
|
596
|
+
* call-seq:
|
597
|
+
* context.standalone? => (true|false)
|
598
|
+
*
|
599
|
+
* Determine whether this is a standalone context.
|
600
|
+
*/
|
601
|
+
VALUE
|
602
|
+
ruby_xml_parser_context_standalone_q(VALUE self) {
|
603
|
+
ruby_xml_parser_context *rxpc;
|
604
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
605
|
+
|
606
|
+
if (rxpc->ctxt->standalone)
|
607
|
+
return(Qtrue);
|
608
|
+
else
|
609
|
+
return(Qfalse);
|
610
|
+
}
|
611
|
+
|
612
|
+
|
613
|
+
/*
|
614
|
+
* call-seq:
|
615
|
+
* context.stats? => (true|false)
|
616
|
+
*
|
617
|
+
* Determine whether this context maintains statistics.
|
618
|
+
*/
|
619
|
+
VALUE
|
620
|
+
ruby_xml_parser_context_stats_q(VALUE self) {
|
621
|
+
ruby_xml_parser_context *rxpc;
|
622
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
623
|
+
|
624
|
+
if (rxpc->ctxt->record_info)
|
625
|
+
return(Qtrue);
|
626
|
+
else
|
627
|
+
return(Qfalse);
|
628
|
+
}
|
629
|
+
|
630
|
+
|
631
|
+
/*
|
632
|
+
* call-seq:
|
633
|
+
* context.valid? => (true|false)
|
634
|
+
*
|
635
|
+
* Determine whether this context is valid.
|
636
|
+
*/
|
637
|
+
VALUE
|
638
|
+
ruby_xml_parser_context_valid_q(VALUE self) {
|
639
|
+
ruby_xml_parser_context *rxpc;
|
640
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
641
|
+
|
642
|
+
if (rxpc->ctxt->valid)
|
643
|
+
return(Qtrue);
|
644
|
+
else
|
645
|
+
return(Qfalse);
|
646
|
+
}
|
647
|
+
|
648
|
+
|
649
|
+
/*
|
650
|
+
* call-seq:
|
651
|
+
* context.validate? => (true|false)
|
652
|
+
*
|
653
|
+
* Determine whether validation is enabled in this context.
|
654
|
+
*/
|
655
|
+
VALUE
|
656
|
+
ruby_xml_parser_context_validate_q(VALUE self) {
|
657
|
+
ruby_xml_parser_context *rxpc;
|
658
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
659
|
+
|
660
|
+
if (rxpc->ctxt->validate)
|
661
|
+
return(Qtrue);
|
662
|
+
else
|
663
|
+
return(Qfalse);
|
664
|
+
}
|
665
|
+
|
666
|
+
|
667
|
+
/*
|
668
|
+
* call-seq:
|
669
|
+
* context.version => "version"
|
670
|
+
*
|
671
|
+
* Obtain this context's version identifier.
|
672
|
+
*/
|
673
|
+
VALUE
|
674
|
+
ruby_xml_parser_context_version_get(VALUE self) {
|
675
|
+
ruby_xml_parser_context *rxpc;
|
676
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
677
|
+
|
678
|
+
if (rxpc->ctxt->version == NULL)
|
679
|
+
return(Qnil);
|
680
|
+
else
|
681
|
+
return(rb_str_new2((const char*)rxpc->ctxt->version));
|
682
|
+
}
|
683
|
+
|
684
|
+
|
685
|
+
/*
|
686
|
+
* call-seq:
|
687
|
+
* context.well_formed? => (true|false)
|
688
|
+
*
|
689
|
+
* Determine whether this context contains well-formed XML.
|
690
|
+
*/
|
691
|
+
VALUE
|
692
|
+
ruby_xml_parser_context_well_formed_q(VALUE self) {
|
693
|
+
ruby_xml_parser_context *rxpc;
|
694
|
+
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
695
|
+
|
696
|
+
if (rxpc->ctxt->wellFormed)
|
697
|
+
return(Qtrue);
|
698
|
+
else
|
699
|
+
return(Qfalse);
|
700
|
+
}
|
701
|
+
|
702
|
+
|
703
|
+
// Rdoc needs to know
|
704
|
+
#ifdef RDOC_NEVER_DEFINED
|
705
|
+
mXML = rb_define_module("XML");
|
706
|
+
cXMLParser = rb_define_class_under(mXML, "Parser", rb_cObject);
|
707
|
+
#endif
|
708
|
+
|
709
|
+
void
|
710
|
+
ruby_init_xml_parser_context(void) {
|
711
|
+
cXMLParserContext = rb_define_class_under(cXMLParser, "Context", rb_cObject);
|
712
|
+
|
713
|
+
rb_define_method(cXMLParserContext, "data_directory", ruby_xml_parser_context_data_directory_get, 0);
|
714
|
+
rb_define_method(cXMLParserContext, "depth", ruby_xml_parser_context_depth_get, 0);
|
715
|
+
rb_define_method(cXMLParserContext, "disable_sax?", ruby_xml_parser_context_disable_sax_q, 0);
|
716
|
+
rb_define_method(cXMLParserContext, "doc", ruby_xml_parser_context_doc_get, 0);
|
717
|
+
rb_define_method(cXMLParserContext, "docbook?", ruby_xml_parser_context_docbook_q, 0);
|
718
|
+
rb_define_method(cXMLParserContext, "encoding", ruby_xml_parser_context_encoding_get, 0);
|
719
|
+
rb_define_method(cXMLParserContext, "errno", ruby_xml_parser_context_errno_get, 0);
|
720
|
+
rb_define_method(cXMLParserContext, "html?", ruby_xml_parser_context_html_q, 0);
|
721
|
+
rb_define_method(cXMLParserContext, "io_max_num_streams", ruby_xml_parser_context_io_max_num_streams_get, 0);
|
722
|
+
rb_define_method(cXMLParserContext, "io_num_streams", ruby_xml_parser_context_io_num_streams_get, 0);
|
723
|
+
rb_define_method(cXMLParserContext, "keep_blanks?", ruby_xml_parser_context_keep_blanks_q, 0);
|
724
|
+
rb_define_method(cXMLParserContext, "name_node", ruby_xml_parser_context_name_node_get, 0);
|
725
|
+
rb_define_method(cXMLParserContext, "name_depth", ruby_xml_parser_context_name_depth_get, 0);
|
726
|
+
rb_define_method(cXMLParserContext, "name_depth_max", ruby_xml_parser_context_name_depth_max_get, 0);
|
727
|
+
rb_define_method(cXMLParserContext, "name_tab", ruby_xml_parser_context_name_tab_get, 0);
|
728
|
+
rb_define_method(cXMLParserContext, "node", ruby_xml_parser_context_node_get, 0);
|
729
|
+
rb_define_method(cXMLParserContext, "node_depth", ruby_xml_parser_context_node_depth_get, 0);
|
730
|
+
rb_define_method(cXMLParserContext, "node_depth_max", ruby_xml_parser_context_node_depth_max_get, 0);
|
731
|
+
rb_define_method(cXMLParserContext, "num_chars", ruby_xml_parser_context_num_chars_get, 0);
|
732
|
+
rb_define_method(cXMLParserContext, "options", ruby_xml_parser_context_options_get, 0);
|
733
|
+
rb_define_method(cXMLParserContext, "options=", ruby_xml_parser_context_options_set, 1);
|
734
|
+
rb_define_method(cXMLParserContext, "replace_entities?", ruby_xml_parser_context_replace_entities_q, 0);
|
735
|
+
rb_define_method(cXMLParserContext, "replace_entities=", ruby_xml_parser_context_replace_entities_set, 1);
|
736
|
+
rb_define_method(cXMLParserContext, "reset", ruby_xml_parser_context_reset, 0);
|
737
|
+
rb_define_method(cXMLParserContext, "space_depth", ruby_xml_parser_context_space_depth_get, 0);
|
738
|
+
rb_define_method(cXMLParserContext, "space_depth_max", ruby_xml_parser_context_space_depth_max_get, 0);
|
739
|
+
rb_define_method(cXMLParserContext, "subset_external?", ruby_xml_parser_context_subset_external_q, 0);
|
740
|
+
rb_define_method(cXMLParserContext, "subset_external_system_id", ruby_xml_parser_context_subset_external_system_id_get, 0);
|
741
|
+
rb_define_method(cXMLParserContext, "subset_external_uri", ruby_xml_parser_context_subset_name_get, 0);
|
742
|
+
rb_define_method(cXMLParserContext, "subset_internal?", ruby_xml_parser_context_subset_internal_q, 0);
|
743
|
+
rb_define_method(cXMLParserContext, "subset_internal_name", ruby_xml_parser_context_subset_name_get, 0);
|
744
|
+
rb_define_method(cXMLParserContext, "stats?", ruby_xml_parser_context_stats_q, 0);
|
745
|
+
rb_define_method(cXMLParserContext, "standalone?", ruby_xml_parser_context_standalone_q, 0);
|
746
|
+
rb_define_method(cXMLParserContext, "valid", ruby_xml_parser_context_valid_q, 0);
|
747
|
+
rb_define_method(cXMLParserContext, "validate?", ruby_xml_parser_context_validate_q, 0);
|
748
|
+
rb_define_method(cXMLParserContext, "version", ruby_xml_parser_context_version_get, 0);
|
749
|
+
rb_define_method(cXMLParserContext, "well_formed?", ruby_xml_parser_context_well_formed_q, 0);
|
750
|
+
}
|