libxml-ruby 0.9.4-x86-mswin32-60 → 0.9.5-x86-mswin32-60
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/CHANGES +22 -0
- data/README +3 -1
- data/ext/libxml/cbg.c +86 -76
- data/ext/libxml/extconf.rb +2 -1
- data/ext/libxml/libxml.c +899 -885
- data/ext/libxml/ruby_libxml.h +65 -70
- data/ext/libxml/ruby_xml_attr.c +485 -500
- data/ext/libxml/ruby_xml_attributes.c +107 -106
- data/ext/libxml/ruby_xml_document.c +355 -356
- data/ext/libxml/ruby_xml_dtd.c +119 -117
- data/ext/libxml/ruby_xml_error.c +1112 -581
- data/ext/libxml/ruby_xml_html_parser.c +35 -34
- data/ext/libxml/ruby_xml_input.c +182 -187
- data/ext/libxml/ruby_xml_input_cbg.c +197 -179
- data/ext/libxml/ruby_xml_node.c +1529 -1566
- data/ext/libxml/ruby_xml_node.h +2 -2
- data/ext/libxml/ruby_xml_ns.c +150 -156
- data/ext/libxml/ruby_xml_parser.c +37 -36
- data/ext/libxml/ruby_xml_parser_context.c +657 -659
- data/ext/libxml/ruby_xml_reader.c +203 -209
- data/ext/libxml/ruby_xml_relaxng.c +29 -25
- data/ext/libxml/ruby_xml_sax_parser.c +33 -32
- data/ext/libxml/ruby_xml_schema.c +165 -161
- data/ext/libxml/ruby_xml_state.c +19 -21
- data/ext/libxml/ruby_xml_xinclude.c +24 -25
- data/ext/libxml/ruby_xml_xpath.c +108 -108
- data/ext/libxml/ruby_xml_xpath_context.c +305 -293
- data/ext/libxml/ruby_xml_xpath_expression.c +24 -24
- data/ext/libxml/ruby_xml_xpath_object.c +89 -96
- data/ext/libxml/ruby_xml_xpointer.c +107 -109
- data/ext/libxml/ruby_xml_xpointer.h +13 -13
- data/ext/libxml/version.h +2 -2
- data/ext/mingw/Rakefile +1 -1
- data/ext/mingw/libxml_ruby.dll.a +0 -0
- data/ext/mingw/libxml_ruby.so +0 -0
- data/ext/vc/libxml_ruby.vcproj +1 -1
- data/lib/libxml/error.rb +4 -4
- data/test/tc_node_edit.rb +14 -2
- data/test/tc_node_text.rb +9 -9
- metadata +2 -2
@@ -1,659 +1,657 @@
|
|
1
|
-
/* $Id: ruby_xml_parser_context.c
|
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
|
-
VALUE cXMLParserContext;
|
9
|
-
|
10
|
-
/*
|
11
|
-
* Document-class: LibXML::XML::Parser::Context
|
12
|
-
*
|
13
|
-
* The XML::Parser::Context class provides in-depth control over how
|
14
|
-
* a document is parsed.
|
15
|
-
*/
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
}
|
28
|
-
|
29
|
-
/*
|
30
|
-
* call-seq:
|
31
|
-
* context.data_directory -> "dir"
|
32
|
-
*
|
33
|
-
* Obtain the data directory associated with this context.
|
34
|
-
*/
|
35
|
-
static VALUE
|
36
|
-
|
37
|
-
xmlParserCtxtPtr ctxt;
|
38
|
-
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
39
|
-
|
40
|
-
if (ctxt->directory == NULL)
|
41
|
-
return(Qnil);
|
42
|
-
else
|
43
|
-
return(rb_str_new2(ctxt->directory));
|
44
|
-
}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
*
|
49
|
-
*
|
50
|
-
*
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
*
|
64
|
-
*
|
65
|
-
*
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
return(
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
*
|
209
|
-
*
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
*
|
223
|
-
*
|
224
|
-
*
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
*
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
return(
|
280
|
-
}
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
*
|
285
|
-
*
|
286
|
-
*
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
*
|
301
|
-
*
|
302
|
-
*
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
*
|
348
|
-
*
|
349
|
-
*
|
350
|
-
*
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
*
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
*
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
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
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
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
|
-
return(
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
*
|
476
|
-
*
|
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
|
-
cXMLParserContext
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
rb_define_method(cXMLParserContext, "
|
628
|
-
|
629
|
-
rb_define_method(cXMLParserContext, "
|
630
|
-
|
631
|
-
rb_define_method(cXMLParserContext, "
|
632
|
-
|
633
|
-
rb_define_method(cXMLParserContext, "
|
634
|
-
|
635
|
-
rb_define_method(cXMLParserContext, "
|
636
|
-
|
637
|
-
rb_define_method(cXMLParserContext, "
|
638
|
-
|
639
|
-
rb_define_method(cXMLParserContext, "
|
640
|
-
|
641
|
-
rb_define_method(cXMLParserContext, "
|
642
|
-
|
643
|
-
rb_define_method(cXMLParserContext, "
|
644
|
-
|
645
|
-
rb_define_method(cXMLParserContext, "
|
646
|
-
|
647
|
-
rb_define_method(cXMLParserContext, "
|
648
|
-
rb_define_method(cXMLParserContext, "
|
649
|
-
|
650
|
-
rb_define_method(cXMLParserContext, "
|
651
|
-
rb_define_method(cXMLParserContext, "
|
652
|
-
|
653
|
-
rb_define_method(cXMLParserContext, "
|
654
|
-
|
655
|
-
rb_define_method(cXMLParserContext, "
|
656
|
-
|
657
|
-
|
658
|
-
rb_define_method(cXMLParserContext, "well_formed?", rxml_parser_context_well_formed_q, 0);
|
659
|
-
}
|
1
|
+
/* $Id: ruby_xml_parser_context.c 650 2008-11-30 03:40:22Z 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
|
+
VALUE cXMLParserContext;
|
9
|
+
|
10
|
+
/*
|
11
|
+
* Document-class: LibXML::XML::Parser::Context
|
12
|
+
*
|
13
|
+
* The XML::Parser::Context class provides in-depth control over how
|
14
|
+
* a document is parsed.
|
15
|
+
*/
|
16
|
+
|
17
|
+
static void rxml_parser_context_free(xmlParserCtxtPtr ctxt)
|
18
|
+
{
|
19
|
+
if (ctxt != NULL)
|
20
|
+
xmlFreeParserCtxt(ctxt);
|
21
|
+
}
|
22
|
+
|
23
|
+
VALUE rxml_parser_context_wrap(xmlParserCtxtPtr ctxt)
|
24
|
+
{
|
25
|
+
return Data_Wrap_Struct(cXMLParserContext, NULL, rxml_parser_context_free,
|
26
|
+
ctxt);
|
27
|
+
}
|
28
|
+
|
29
|
+
/*
|
30
|
+
* call-seq:
|
31
|
+
* context.data_directory -> "dir"
|
32
|
+
*
|
33
|
+
* Obtain the data directory associated with this context.
|
34
|
+
*/
|
35
|
+
static VALUE rxml_parser_context_data_directory_get(VALUE self)
|
36
|
+
{
|
37
|
+
xmlParserCtxtPtr ctxt;
|
38
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
39
|
+
|
40
|
+
if (ctxt->directory == NULL)
|
41
|
+
return (Qnil);
|
42
|
+
else
|
43
|
+
return (rb_str_new2(ctxt->directory));
|
44
|
+
}
|
45
|
+
|
46
|
+
/*
|
47
|
+
* call-seq:
|
48
|
+
* context.depth -> num
|
49
|
+
*
|
50
|
+
* Obtain the depth of this context.
|
51
|
+
*/
|
52
|
+
static VALUE rxml_parser_context_depth_get(VALUE self)
|
53
|
+
{
|
54
|
+
xmlParserCtxtPtr ctxt;
|
55
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
56
|
+
|
57
|
+
return (INT2NUM(ctxt->depth));
|
58
|
+
}
|
59
|
+
|
60
|
+
/*
|
61
|
+
* call-seq:
|
62
|
+
* context.disable_sax? -> (true|false)
|
63
|
+
*
|
64
|
+
* Determine whether SAX-based processing is disabled
|
65
|
+
* in this context.
|
66
|
+
*/
|
67
|
+
static VALUE rxml_parser_context_disable_sax_q(VALUE self)
|
68
|
+
{
|
69
|
+
xmlParserCtxtPtr ctxt;
|
70
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
71
|
+
|
72
|
+
if (ctxt->disableSAX)
|
73
|
+
return (Qtrue);
|
74
|
+
else
|
75
|
+
return (Qfalse);
|
76
|
+
}
|
77
|
+
|
78
|
+
/*
|
79
|
+
* call-seq:
|
80
|
+
* context.docbook? -> (true|false)
|
81
|
+
*
|
82
|
+
* Determine whether this is a docbook context.
|
83
|
+
*/
|
84
|
+
static VALUE rxml_parser_context_docbook_q(VALUE self)
|
85
|
+
{
|
86
|
+
xmlParserCtxtPtr ctxt;
|
87
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
88
|
+
|
89
|
+
if (ctxt->html == 2) // TODO check this
|
90
|
+
return (Qtrue);
|
91
|
+
else
|
92
|
+
return (Qfalse);
|
93
|
+
}
|
94
|
+
|
95
|
+
/*
|
96
|
+
* call-seq:
|
97
|
+
* context.encoding -> "encoding"
|
98
|
+
*
|
99
|
+
* Obtain the character encoding identifier used in
|
100
|
+
* this context.
|
101
|
+
*/
|
102
|
+
static VALUE rxml_parser_context_encoding_get(VALUE self)
|
103
|
+
{
|
104
|
+
xmlParserCtxtPtr ctxt;
|
105
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
106
|
+
|
107
|
+
if (ctxt->encoding == NULL)
|
108
|
+
return (Qnil);
|
109
|
+
else
|
110
|
+
return (rb_str_new2((const char*) ctxt->encoding));
|
111
|
+
}
|
112
|
+
|
113
|
+
/*
|
114
|
+
* call-seq:
|
115
|
+
* context.errno -> num
|
116
|
+
*
|
117
|
+
* Obtain the last-error number in this context.
|
118
|
+
*/
|
119
|
+
static VALUE rxml_parser_context_errno_get(VALUE self)
|
120
|
+
{
|
121
|
+
xmlParserCtxtPtr ctxt;
|
122
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
123
|
+
|
124
|
+
return (INT2NUM(ctxt->errNo));
|
125
|
+
}
|
126
|
+
|
127
|
+
/*
|
128
|
+
* call-seq:
|
129
|
+
* context.html? -> (true|false)
|
130
|
+
*
|
131
|
+
* Determine whether this is an html context.
|
132
|
+
*/
|
133
|
+
static VALUE rxml_parser_context_html_q(VALUE self)
|
134
|
+
{
|
135
|
+
xmlParserCtxtPtr ctxt;
|
136
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
137
|
+
|
138
|
+
if (ctxt->html == 1)
|
139
|
+
return (Qtrue);
|
140
|
+
else
|
141
|
+
return (Qfalse);
|
142
|
+
}
|
143
|
+
|
144
|
+
/*
|
145
|
+
* call-seq:
|
146
|
+
* context.max_num_streams -> num
|
147
|
+
*
|
148
|
+
* Obtain the limit on the number of IO streams opened in
|
149
|
+
* this context.
|
150
|
+
*/
|
151
|
+
static VALUE rxml_parser_context_io_max_num_streams_get(VALUE self)
|
152
|
+
{
|
153
|
+
// TODO alias to max_streams and dep this?
|
154
|
+
xmlParserCtxtPtr ctxt;
|
155
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
156
|
+
|
157
|
+
return (INT2NUM(ctxt->inputMax));
|
158
|
+
}
|
159
|
+
|
160
|
+
/*
|
161
|
+
* call-seq:
|
162
|
+
* context.num_streams -> "dir"
|
163
|
+
*
|
164
|
+
* Obtain the actual number of IO streams in this
|
165
|
+
* context.
|
166
|
+
*/
|
167
|
+
static VALUE rxml_parser_context_io_num_streams_get(VALUE self)
|
168
|
+
{
|
169
|
+
xmlParserCtxtPtr ctxt;
|
170
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
171
|
+
|
172
|
+
return (INT2NUM(ctxt->inputNr));
|
173
|
+
}
|
174
|
+
|
175
|
+
/*
|
176
|
+
* call-seq:
|
177
|
+
* context.keep_blanks? -> (true|false)
|
178
|
+
*
|
179
|
+
* Determine whether parsers in this context retain
|
180
|
+
* whitespace.
|
181
|
+
*/
|
182
|
+
static VALUE rxml_parser_context_keep_blanks_q(VALUE self)
|
183
|
+
{
|
184
|
+
xmlParserCtxtPtr ctxt;
|
185
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
186
|
+
|
187
|
+
if (ctxt->keepBlanks)
|
188
|
+
return (Qtrue);
|
189
|
+
else
|
190
|
+
return (Qfalse);
|
191
|
+
}
|
192
|
+
|
193
|
+
/*
|
194
|
+
* call-seq:
|
195
|
+
* context.name_depth -> num
|
196
|
+
*
|
197
|
+
* Obtain the name depth for this context.
|
198
|
+
*/
|
199
|
+
static VALUE rxml_parser_context_name_depth_get(VALUE self)
|
200
|
+
{
|
201
|
+
xmlParserCtxtPtr ctxt;
|
202
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
203
|
+
|
204
|
+
return (INT2NUM(ctxt->nameNr));
|
205
|
+
}
|
206
|
+
|
207
|
+
/*
|
208
|
+
* call-seq:
|
209
|
+
* context.name_depth_max -> num
|
210
|
+
*
|
211
|
+
* Obtain the maximum name depth for this context.
|
212
|
+
*/
|
213
|
+
static VALUE rxml_parser_context_name_depth_max_get(VALUE self)
|
214
|
+
{
|
215
|
+
xmlParserCtxtPtr ctxt;
|
216
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
217
|
+
|
218
|
+
return (INT2NUM(ctxt->nameMax));
|
219
|
+
}
|
220
|
+
|
221
|
+
/*
|
222
|
+
* call-seq:
|
223
|
+
* context.name_node -> "name"
|
224
|
+
*
|
225
|
+
* Obtain the name node for this context.
|
226
|
+
*/
|
227
|
+
static VALUE rxml_parser_context_name_node_get(VALUE self)
|
228
|
+
{
|
229
|
+
xmlParserCtxtPtr ctxt;
|
230
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
231
|
+
|
232
|
+
if (ctxt->name == NULL)
|
233
|
+
return (Qnil);
|
234
|
+
else
|
235
|
+
return (rb_str_new2((const char*) ctxt->name));
|
236
|
+
}
|
237
|
+
|
238
|
+
/*
|
239
|
+
* call-seq:
|
240
|
+
* context.name_tab -> ["name", ..., "name"]
|
241
|
+
*
|
242
|
+
* Obtain the name table for this context.
|
243
|
+
*/
|
244
|
+
static VALUE rxml_parser_context_name_tab_get(VALUE self)
|
245
|
+
{
|
246
|
+
int i;
|
247
|
+
xmlParserCtxtPtr ctxt;
|
248
|
+
VALUE tab_ary;
|
249
|
+
|
250
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
251
|
+
|
252
|
+
if (ctxt->nameTab == NULL)
|
253
|
+
return (Qnil);
|
254
|
+
|
255
|
+
tab_ary = rb_ary_new();
|
256
|
+
|
257
|
+
for (i = (ctxt->nameNr - 1); i >= 0; i--)
|
258
|
+
{
|
259
|
+
if (ctxt->nameTab[i] == NULL)
|
260
|
+
continue;
|
261
|
+
else
|
262
|
+
rb_ary_push(tab_ary, rb_str_new2((const char*) ctxt->nameTab[i]));
|
263
|
+
}
|
264
|
+
|
265
|
+
return (tab_ary);
|
266
|
+
}
|
267
|
+
|
268
|
+
/*
|
269
|
+
* call-seq:
|
270
|
+
* context.node_depth -> num
|
271
|
+
*
|
272
|
+
* Obtain the node depth for this context.
|
273
|
+
*/
|
274
|
+
static VALUE rxml_parser_context_node_depth_get(VALUE self)
|
275
|
+
{
|
276
|
+
xmlParserCtxtPtr ctxt;
|
277
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
278
|
+
|
279
|
+
return (INT2NUM(ctxt->nodeNr));
|
280
|
+
}
|
281
|
+
|
282
|
+
/*
|
283
|
+
* call-seq:
|
284
|
+
* context.node -> node
|
285
|
+
*
|
286
|
+
* Obtain the root node of this context.
|
287
|
+
*/
|
288
|
+
static VALUE rxml_parser_context_node_get(VALUE self)
|
289
|
+
{
|
290
|
+
xmlParserCtxtPtr ctxt;
|
291
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
292
|
+
|
293
|
+
if (ctxt->node == NULL)
|
294
|
+
return (Qnil);
|
295
|
+
else
|
296
|
+
return (rxml_node_wrap(cXMLNode, ctxt->node));
|
297
|
+
}
|
298
|
+
|
299
|
+
/*
|
300
|
+
* call-seq:
|
301
|
+
* context.node_depth_max -> num
|
302
|
+
*
|
303
|
+
* Obtain the maximum node depth for this context.
|
304
|
+
*/
|
305
|
+
static VALUE rxml_parser_context_node_depth_max_get(VALUE self)
|
306
|
+
{
|
307
|
+
xmlParserCtxtPtr ctxt;
|
308
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
309
|
+
|
310
|
+
return (INT2NUM(ctxt->nodeMax));
|
311
|
+
}
|
312
|
+
|
313
|
+
/*
|
314
|
+
* call-seq:
|
315
|
+
* context.num_chars -> num
|
316
|
+
*
|
317
|
+
* Obtain the number of characters in this context.
|
318
|
+
*/
|
319
|
+
static VALUE rxml_parser_context_num_chars_get(VALUE self)
|
320
|
+
{
|
321
|
+
xmlParserCtxtPtr ctxt;
|
322
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
323
|
+
|
324
|
+
return (LONG2NUM(ctxt->nbChars));
|
325
|
+
}
|
326
|
+
|
327
|
+
/*
|
328
|
+
* call-seq:
|
329
|
+
* context.replace_entities? -> (true|false)
|
330
|
+
*
|
331
|
+
* Determine whether external entity replacement is enabled in this
|
332
|
+
* context.
|
333
|
+
*/
|
334
|
+
static VALUE rxml_parser_context_replace_entities_q(VALUE self)
|
335
|
+
{
|
336
|
+
xmlParserCtxtPtr ctxt;
|
337
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
338
|
+
|
339
|
+
if (ctxt->replaceEntities)
|
340
|
+
return (Qtrue);
|
341
|
+
else
|
342
|
+
return (Qfalse);
|
343
|
+
}
|
344
|
+
|
345
|
+
/*
|
346
|
+
* call-seq:
|
347
|
+
* context.replace_entities = true|false
|
348
|
+
*
|
349
|
+
* Control whether external entity replacement is enabled in this
|
350
|
+
* context.
|
351
|
+
*/
|
352
|
+
static VALUE rxml_parser_context_replace_entities_set(VALUE self, VALUE bool)
|
353
|
+
{
|
354
|
+
xmlParserCtxtPtr ctxt;
|
355
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
356
|
+
|
357
|
+
if (TYPE(bool) == T_FALSE)
|
358
|
+
{
|
359
|
+
ctxt->replaceEntities = 0;
|
360
|
+
return (Qfalse);
|
361
|
+
}
|
362
|
+
else
|
363
|
+
{
|
364
|
+
ctxt->replaceEntities = 1;
|
365
|
+
return (Qfalse);
|
366
|
+
}
|
367
|
+
}
|
368
|
+
|
369
|
+
/*
|
370
|
+
* call-seq:
|
371
|
+
* context.space_depth -> num
|
372
|
+
*
|
373
|
+
* Obtain the space depth for this context.
|
374
|
+
*/
|
375
|
+
static VALUE rxml_parser_context_space_depth_get(VALUE self)
|
376
|
+
{
|
377
|
+
xmlParserCtxtPtr ctxt;
|
378
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
379
|
+
|
380
|
+
return (INT2NUM(ctxt->spaceNr));
|
381
|
+
}
|
382
|
+
|
383
|
+
/*
|
384
|
+
* call-seq:
|
385
|
+
* context.space_depth -> num
|
386
|
+
*
|
387
|
+
* Obtain the maximum space depth for this context.
|
388
|
+
*/
|
389
|
+
static VALUE rxml_parser_context_space_depth_max_get(VALUE self)
|
390
|
+
{
|
391
|
+
xmlParserCtxtPtr ctxt;
|
392
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
393
|
+
|
394
|
+
return (INT2NUM(ctxt->spaceMax));
|
395
|
+
}
|
396
|
+
|
397
|
+
/*
|
398
|
+
* call-seq:
|
399
|
+
* context.subset_external? -> (true|false)
|
400
|
+
*
|
401
|
+
* Determine whether this context is a subset of an
|
402
|
+
* external context.
|
403
|
+
*/
|
404
|
+
static VALUE rxml_parser_context_subset_external_q(VALUE self)
|
405
|
+
{
|
406
|
+
xmlParserCtxtPtr ctxt;
|
407
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
408
|
+
|
409
|
+
if (ctxt->inSubset == 2)
|
410
|
+
return (Qtrue);
|
411
|
+
else
|
412
|
+
return (Qfalse);
|
413
|
+
}
|
414
|
+
|
415
|
+
/*
|
416
|
+
* call-seq:
|
417
|
+
* context.subset_internal? -> (true|false)
|
418
|
+
*
|
419
|
+
* Determine whether this context is a subset of an
|
420
|
+
* internal context.
|
421
|
+
*/
|
422
|
+
static VALUE rxml_parser_context_subset_internal_q(VALUE self)
|
423
|
+
{
|
424
|
+
xmlParserCtxtPtr ctxt;
|
425
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
426
|
+
|
427
|
+
if (ctxt->inSubset == 1)
|
428
|
+
return (Qtrue);
|
429
|
+
else
|
430
|
+
return (Qfalse);
|
431
|
+
}
|
432
|
+
|
433
|
+
/*
|
434
|
+
* call-seq:
|
435
|
+
* context.subset_name -> "name"
|
436
|
+
*
|
437
|
+
* Obtain this context's subset name (valid only if
|
438
|
+
* either of subset_external? or subset_internal?
|
439
|
+
* is true).
|
440
|
+
*/
|
441
|
+
static VALUE rxml_parser_context_subset_name_get(VALUE self)
|
442
|
+
{
|
443
|
+
xmlParserCtxtPtr ctxt;
|
444
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
445
|
+
|
446
|
+
if (ctxt->intSubName == NULL)
|
447
|
+
return (Qnil);
|
448
|
+
else
|
449
|
+
return (rb_str_new2((const char*) ctxt->intSubName));
|
450
|
+
}
|
451
|
+
|
452
|
+
/*
|
453
|
+
* call-seq:
|
454
|
+
* context.subset_external_uri -> "uri"
|
455
|
+
*
|
456
|
+
* Obtain this context's external subset URI. (valid only if
|
457
|
+
* either of subset_external? or subset_internal?
|
458
|
+
* is true).
|
459
|
+
*/
|
460
|
+
static VALUE rxml_parser_context_subset_external_uri_get(VALUE self)
|
461
|
+
{
|
462
|
+
xmlParserCtxtPtr ctxt;
|
463
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
464
|
+
|
465
|
+
if (ctxt->extSubURI == NULL)
|
466
|
+
return (Qnil);
|
467
|
+
else
|
468
|
+
return (rb_str_new2((const char*) ctxt->extSubURI));
|
469
|
+
}
|
470
|
+
|
471
|
+
/*
|
472
|
+
* call-seq:
|
473
|
+
* context.subset_external_system_id -> "system_id"
|
474
|
+
*
|
475
|
+
* Obtain this context's external subset system identifier.
|
476
|
+
* (valid only if either of subset_external? or subset_internal?
|
477
|
+
* is true).
|
478
|
+
*/
|
479
|
+
static VALUE rxml_parser_context_subset_external_system_id_get(VALUE self)
|
480
|
+
{
|
481
|
+
xmlParserCtxtPtr ctxt;
|
482
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
483
|
+
|
484
|
+
if (ctxt->extSubSystem == NULL)
|
485
|
+
return (Qnil);
|
486
|
+
else
|
487
|
+
return (rb_str_new2((const char*) ctxt->extSubSystem));
|
488
|
+
}
|
489
|
+
|
490
|
+
/*
|
491
|
+
* call-seq:
|
492
|
+
* context.standalone? -> (true|false)
|
493
|
+
*
|
494
|
+
* Determine whether this is a standalone context.
|
495
|
+
*/
|
496
|
+
static VALUE rxml_parser_context_standalone_q(VALUE self)
|
497
|
+
{
|
498
|
+
xmlParserCtxtPtr ctxt;
|
499
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
500
|
+
|
501
|
+
if (ctxt->standalone)
|
502
|
+
return (Qtrue);
|
503
|
+
else
|
504
|
+
return (Qfalse);
|
505
|
+
}
|
506
|
+
|
507
|
+
/*
|
508
|
+
* call-seq:
|
509
|
+
* context.stats? -> (true|false)
|
510
|
+
*
|
511
|
+
* Determine whether this context maintains statistics.
|
512
|
+
*/
|
513
|
+
static VALUE rxml_parser_context_stats_q(VALUE self)
|
514
|
+
{
|
515
|
+
xmlParserCtxtPtr ctxt;
|
516
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
517
|
+
|
518
|
+
if (ctxt->record_info)
|
519
|
+
return (Qtrue);
|
520
|
+
else
|
521
|
+
return (Qfalse);
|
522
|
+
}
|
523
|
+
|
524
|
+
/*
|
525
|
+
* call-seq:
|
526
|
+
* context.valid? -> (true|false)
|
527
|
+
*
|
528
|
+
* Determine whether this context is valid.
|
529
|
+
*/
|
530
|
+
static VALUE rxml_parser_context_valid_q(VALUE self)
|
531
|
+
{
|
532
|
+
xmlParserCtxtPtr ctxt;
|
533
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
534
|
+
|
535
|
+
if (ctxt->valid)
|
536
|
+
return (Qtrue);
|
537
|
+
else
|
538
|
+
return (Qfalse);
|
539
|
+
}
|
540
|
+
|
541
|
+
/*
|
542
|
+
* call-seq:
|
543
|
+
* context.validate? -> (true|false)
|
544
|
+
*
|
545
|
+
* Determine whether validation is enabled in this context.
|
546
|
+
*/
|
547
|
+
static VALUE rxml_parser_context_validate_q(VALUE self)
|
548
|
+
{
|
549
|
+
xmlParserCtxtPtr ctxt;
|
550
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
551
|
+
|
552
|
+
if (ctxt->validate)
|
553
|
+
return (Qtrue);
|
554
|
+
else
|
555
|
+
return (Qfalse);
|
556
|
+
}
|
557
|
+
|
558
|
+
/*
|
559
|
+
* call-seq:
|
560
|
+
* context.version -> "version"
|
561
|
+
*
|
562
|
+
* Obtain this context's version identifier.
|
563
|
+
*/
|
564
|
+
static VALUE rxml_parser_context_version_get(VALUE self)
|
565
|
+
{
|
566
|
+
xmlParserCtxtPtr ctxt;
|
567
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
568
|
+
|
569
|
+
if (ctxt->version == NULL)
|
570
|
+
return (Qnil);
|
571
|
+
else
|
572
|
+
return (rb_str_new2((const char*) ctxt->version));
|
573
|
+
}
|
574
|
+
|
575
|
+
/*
|
576
|
+
* call-seq:
|
577
|
+
* context.well_formed? -> (true|false)
|
578
|
+
*
|
579
|
+
* Determine whether this context contains well-formed XML.
|
580
|
+
*/
|
581
|
+
static VALUE rxml_parser_context_well_formed_q(VALUE self)
|
582
|
+
{
|
583
|
+
xmlParserCtxtPtr ctxt;
|
584
|
+
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
585
|
+
|
586
|
+
if (ctxt->wellFormed)
|
587
|
+
return (Qtrue);
|
588
|
+
else
|
589
|
+
return (Qfalse);
|
590
|
+
}
|
591
|
+
|
592
|
+
void ruby_init_xml_parser_context(void)
|
593
|
+
{
|
594
|
+
cXMLParserContext = rb_define_class_under(cXMLParser, "Context", rb_cObject);
|
595
|
+
rb_undef_alloc_func(cXMLParserContext);
|
596
|
+
|
597
|
+
rb_define_method(cXMLParserContext, "data_directory",
|
598
|
+
rxml_parser_context_data_directory_get, 0);
|
599
|
+
rb_define_method(cXMLParserContext, "depth", rxml_parser_context_depth_get, 0);
|
600
|
+
rb_define_method(cXMLParserContext, "disable_sax?",
|
601
|
+
rxml_parser_context_disable_sax_q, 0);
|
602
|
+
rb_define_method(cXMLParserContext, "docbook?",
|
603
|
+
rxml_parser_context_docbook_q, 0);
|
604
|
+
rb_define_method(cXMLParserContext, "encoding",
|
605
|
+
rxml_parser_context_encoding_get, 0);
|
606
|
+
rb_define_method(cXMLParserContext, "errno", rxml_parser_context_errno_get, 0);
|
607
|
+
rb_define_method(cXMLParserContext, "html?", rxml_parser_context_html_q, 0);
|
608
|
+
rb_define_method(cXMLParserContext, "io_max_num_streams",
|
609
|
+
rxml_parser_context_io_max_num_streams_get, 0);
|
610
|
+
rb_define_method(cXMLParserContext, "io_num_streams",
|
611
|
+
rxml_parser_context_io_num_streams_get, 0);
|
612
|
+
rb_define_method(cXMLParserContext, "keep_blanks?",
|
613
|
+
rxml_parser_context_keep_blanks_q, 0);
|
614
|
+
rb_define_method(cXMLParserContext, "name_node",
|
615
|
+
rxml_parser_context_name_node_get, 0);
|
616
|
+
rb_define_method(cXMLParserContext, "name_depth",
|
617
|
+
rxml_parser_context_name_depth_get, 0);
|
618
|
+
rb_define_method(cXMLParserContext, "name_depth_max",
|
619
|
+
rxml_parser_context_name_depth_max_get, 0);
|
620
|
+
rb_define_method(cXMLParserContext, "name_tab",
|
621
|
+
rxml_parser_context_name_tab_get, 0);
|
622
|
+
rb_define_method(cXMLParserContext, "node", rxml_parser_context_node_get, 0);
|
623
|
+
rb_define_method(cXMLParserContext, "node_depth",
|
624
|
+
rxml_parser_context_node_depth_get, 0);
|
625
|
+
rb_define_method(cXMLParserContext, "node_depth_max",
|
626
|
+
rxml_parser_context_node_depth_max_get, 0);
|
627
|
+
rb_define_method(cXMLParserContext, "num_chars",
|
628
|
+
rxml_parser_context_num_chars_get, 0);
|
629
|
+
rb_define_method(cXMLParserContext, "replace_entities?",
|
630
|
+
rxml_parser_context_replace_entities_q, 0);
|
631
|
+
rb_define_method(cXMLParserContext, "replace_entities=",
|
632
|
+
rxml_parser_context_replace_entities_set, 1);
|
633
|
+
rb_define_method(cXMLParserContext, "space_depth",
|
634
|
+
rxml_parser_context_space_depth_get, 0);
|
635
|
+
rb_define_method(cXMLParserContext, "space_depth_max",
|
636
|
+
rxml_parser_context_space_depth_max_get, 0);
|
637
|
+
rb_define_method(cXMLParserContext, "subset_external?",
|
638
|
+
rxml_parser_context_subset_external_q, 0);
|
639
|
+
rb_define_method(cXMLParserContext, "subset_external_system_id",
|
640
|
+
rxml_parser_context_subset_external_system_id_get, 0);
|
641
|
+
rb_define_method(cXMLParserContext, "subset_external_uri",
|
642
|
+
rxml_parser_context_subset_name_get, 0);
|
643
|
+
rb_define_method(cXMLParserContext, "subset_internal?",
|
644
|
+
rxml_parser_context_subset_internal_q, 0);
|
645
|
+
rb_define_method(cXMLParserContext, "subset_internal_name",
|
646
|
+
rxml_parser_context_subset_name_get, 0);
|
647
|
+
rb_define_method(cXMLParserContext, "stats?", rxml_parser_context_stats_q, 0);
|
648
|
+
rb_define_method(cXMLParserContext, "standalone?",
|
649
|
+
rxml_parser_context_standalone_q, 0);
|
650
|
+
rb_define_method(cXMLParserContext, "valid", rxml_parser_context_valid_q, 0);
|
651
|
+
rb_define_method(cXMLParserContext, "validate?",
|
652
|
+
rxml_parser_context_validate_q, 0);
|
653
|
+
rb_define_method(cXMLParserContext, "version",
|
654
|
+
rxml_parser_context_version_get, 0);
|
655
|
+
rb_define_method(cXMLParserContext, "well_formed?",
|
656
|
+
rxml_parser_context_well_formed_q, 0);
|
657
|
+
}
|