libxml-ruby 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,716 +1,750 @@
|
|
1
|
-
/* $Id: ruby_xml_parser_context.c
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#include "
|
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(
|
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
|
-
|
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
|
-
|
396
|
-
|
397
|
-
*
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
}
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
*
|
416
|
-
*
|
417
|
-
*
|
418
|
-
*
|
419
|
-
|
420
|
-
|
421
|
-
VALUE
|
422
|
-
|
423
|
-
ruby_xml_parser_context
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
return(Qfalse);
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
*
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
*
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
*
|
469
|
-
*
|
470
|
-
*
|
471
|
-
*
|
472
|
-
*/
|
473
|
-
VALUE
|
474
|
-
|
475
|
-
ruby_xml_parser_context *rxpc;
|
476
|
-
Data_Get_Struct(self, ruby_xml_parser_context, rxpc);
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
*
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
*
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
*
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
*
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
*
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
*
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
*
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
*
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
*
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
*
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
*
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
rb_define_method(cXMLParserContext, "
|
714
|
-
rb_define_method(cXMLParserContext, "
|
715
|
-
rb_define_method(cXMLParserContext, "
|
716
|
-
|
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
|
+
}
|