libxml-ruby 4.1.1 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY +22 -0
- data/ext/libxml/extconf.rb +67 -61
- data/ext/libxml/ruby_libxml.h +43 -44
- data/ext/libxml/ruby_xml.c +0 -343
- data/ext/libxml/ruby_xml.h +9 -10
- data/ext/libxml/ruby_xml_attr_decl.c +154 -153
- data/ext/libxml/ruby_xml_attributes.c +276 -275
- data/ext/libxml/ruby_xml_attributes.h +2 -0
- data/ext/libxml/ruby_xml_document.c +6 -6
- data/ext/libxml/ruby_xml_document.h +11 -11
- data/ext/libxml/ruby_xml_dtd.c +3 -3
- data/ext/libxml/ruby_xml_encoding.h +20 -18
- data/ext/libxml/ruby_xml_error.c +9 -6
- data/ext/libxml/ruby_xml_error.h +2 -2
- data/ext/libxml/ruby_xml_html_parser_context.c +35 -21
- data/ext/libxml/ruby_xml_namespace.c +0 -3
- data/ext/libxml/ruby_xml_node.c +1394 -1398
- data/ext/libxml/ruby_xml_parser.h +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +47 -39
- data/ext/libxml/ruby_xml_parser_options.c +9 -1
- data/ext/libxml/ruby_xml_parser_options.h +1 -1
- data/ext/libxml/ruby_xml_reader.c +1244 -1242
- data/ext/libxml/ruby_xml_relaxng.c +113 -112
- data/ext/libxml/ruby_xml_sax2_handler.c +1 -1
- data/ext/libxml/ruby_xml_sax_parser.c +1 -9
- data/ext/libxml/ruby_xml_schema.c +422 -420
- data/ext/libxml/ruby_xml_schema_attribute.c +108 -107
- data/ext/libxml/ruby_xml_schema_element.c +70 -69
- data/ext/libxml/ruby_xml_schema_type.c +252 -251
- data/ext/libxml/ruby_xml_version.h +5 -5
- data/ext/libxml/ruby_xml_writer.c +1138 -1137
- data/ext/libxml/ruby_xml_xpath.c +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +2 -2
- data/ext/libxml/ruby_xml_xpath_expression.c +81 -81
- data/ext/libxml/ruby_xml_xpath_object.c +340 -339
- data/lib/libxml/document.rb +13 -13
- data/lib/libxml/html_parser.rb +23 -23
- data/lib/libxml/parser.rb +26 -24
- data/lib/libxml/schema/element.rb +27 -19
- data/test/test.rb +5 -0
- data/test/test_document_write.rb +1 -4
- data/test/test_dtd.rb +1 -4
- data/test/test_encoding.rb +1 -4
- data/test/test_helper.rb +9 -2
- data/test/test_html_parser.rb +162 -162
- data/test/test_namespace.rb +1 -3
- data/test/test_node.rb +1 -3
- data/test/test_node_write.rb +1 -4
- data/test/test_parser.rb +26 -17
- data/test/test_reader.rb +4 -4
- data/test/test_sax_parser.rb +1 -1
- data/test/test_schema.rb +237 -231
- data/test/test_xml.rb +0 -99
- metadata +4 -3
@@ -1,1242 +1,1244 @@
|
|
1
|
-
/* Copyright (c) 2006-2007 Apple Inc.
|
2
|
-
* Please see the LICENSE file for copyright and distribution information. */
|
3
|
-
|
4
|
-
#include "ruby_libxml.h"
|
5
|
-
#include "ruby_xml_reader.h"
|
6
|
-
|
7
|
-
#include <
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
23
|
-
*
|
24
|
-
*
|
25
|
-
*
|
26
|
-
*
|
27
|
-
*
|
28
|
-
*
|
29
|
-
*
|
30
|
-
*
|
31
|
-
*
|
32
|
-
*
|
33
|
-
*
|
34
|
-
*
|
35
|
-
* reader.
|
36
|
-
* assert_equal(
|
37
|
-
*
|
38
|
-
* reader.
|
39
|
-
* assert_equal(
|
40
|
-
*
|
41
|
-
*
|
42
|
-
*
|
43
|
-
*
|
44
|
-
* XML::
|
45
|
-
*
|
46
|
-
*
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
static ID
|
58
|
-
static ID
|
59
|
-
|
60
|
-
static
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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
|
-
VALUE
|
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
|
-
* XML::Reader.io(io
|
159
|
-
*
|
160
|
-
*
|
161
|
-
*
|
162
|
-
*
|
163
|
-
*
|
164
|
-
*
|
165
|
-
*
|
166
|
-
*
|
167
|
-
*
|
168
|
-
*
|
169
|
-
*
|
170
|
-
*
|
171
|
-
*
|
172
|
-
*
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
VALUE
|
179
|
-
VALUE
|
180
|
-
|
181
|
-
char *
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
VALUE
|
190
|
-
VALUE
|
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
|
-
* XML::Reader.string(io
|
222
|
-
*
|
223
|
-
*
|
224
|
-
*
|
225
|
-
*
|
226
|
-
*
|
227
|
-
*
|
228
|
-
*
|
229
|
-
*
|
230
|
-
*
|
231
|
-
*
|
232
|
-
*
|
233
|
-
*
|
234
|
-
*
|
235
|
-
*
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
VALUE
|
242
|
-
|
243
|
-
char *
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
VALUE
|
253
|
-
VALUE
|
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
|
-
*
|
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
|
-
(const xmlChar *) StringValueCStr(
|
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
|
-
|
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
|
-
status
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
*
|
619
|
-
*
|
620
|
-
*
|
621
|
-
*
|
622
|
-
* is
|
623
|
-
*
|
624
|
-
*
|
625
|
-
*
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
status
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
*
|
643
|
-
*
|
644
|
-
*
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
const xmlChar *
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
*
|
658
|
-
*
|
659
|
-
*
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
const xmlChar *
|
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
|
-
* reader
|
692
|
-
*
|
693
|
-
* reader.
|
694
|
-
*
|
695
|
-
*
|
696
|
-
*
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
*
|
711
|
-
*
|
712
|
-
*
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
const xmlChar *
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
*
|
726
|
-
*
|
727
|
-
*
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
const xmlChar *
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
*
|
741
|
-
*
|
742
|
-
*
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
const xmlChar *
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
*
|
756
|
-
*
|
757
|
-
*
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
const xmlChar *
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
*
|
771
|
-
*
|
772
|
-
*
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
*
|
783
|
-
*
|
784
|
-
*
|
785
|
-
*
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
*
|
796
|
-
*
|
797
|
-
*
|
798
|
-
*
|
799
|
-
*
|
800
|
-
*
|
801
|
-
*
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
*
|
812
|
-
*
|
813
|
-
*
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
const xmlChar *
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
*
|
827
|
-
*
|
828
|
-
*
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
const xmlChar *
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
*
|
842
|
-
*
|
843
|
-
*
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
*
|
854
|
-
*
|
855
|
-
*
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
*
|
866
|
-
*
|
867
|
-
*
|
868
|
-
*
|
869
|
-
*
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
*
|
898
|
-
*
|
899
|
-
*
|
900
|
-
*
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
*
|
921
|
-
*
|
922
|
-
*
|
923
|
-
*
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
(const xmlChar *) StringValueCStr(
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
*
|
962
|
-
*
|
963
|
-
*
|
964
|
-
*
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
const xmlChar *
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
*
|
984
|
-
*
|
985
|
-
*
|
986
|
-
*
|
987
|
-
*
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
*
|
1012
|
-
*
|
1013
|
-
*
|
1014
|
-
*
|
1015
|
-
*
|
1016
|
-
*
|
1017
|
-
*
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
*
|
1042
|
-
*
|
1043
|
-
*
|
1044
|
-
*
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
*
|
1058
|
-
*
|
1059
|
-
*
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
*
|
1071
|
-
*
|
1072
|
-
*
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
*
|
1085
|
-
*
|
1086
|
-
*
|
1087
|
-
*
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
*
|
1098
|
-
*
|
1099
|
-
*
|
1100
|
-
*
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
*
|
1111
|
-
*
|
1112
|
-
*
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
*
|
1123
|
-
*
|
1124
|
-
*
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1140
|
-
cXMLReader
|
1141
|
-
|
1142
|
-
rb_define_singleton_method(cXMLReader, "document", rxml_reader_document, 1);
|
1143
|
-
rb_define_singleton_method(cXMLReader, "file", rxml_reader_file, -1);
|
1144
|
-
rb_define_singleton_method(cXMLReader, "io", rxml_reader_io, -1);
|
1145
|
-
rb_define_singleton_method(cXMLReader, "string", rxml_reader_string, -1);
|
1146
|
-
|
1147
|
-
rb_define_method(cXMLReader, "[]", rxml_reader_attribute, 1);
|
1148
|
-
rb_define_method(cXMLReader, "attribute_count", rxml_reader_attr_count, 0);
|
1149
|
-
rb_define_method(cXMLReader, "base_uri", rxml_reader_base_uri, 0);
|
1150
|
-
#if LIBXML_VERSION >= 20618
|
1151
|
-
rb_define_method(cXMLReader, "byte_consumed", rxml_reader_byte_consumed, 0);
|
1152
|
-
#endif
|
1153
|
-
rb_define_method(cXMLReader, "close", rxml_reader_close, 0);
|
1154
|
-
#if LIBXML_VERSION >= 20617
|
1155
|
-
rb_define_method(cXMLReader, "column_number", rxml_reader_column_number, 0);
|
1156
|
-
#endif
|
1157
|
-
rb_define_method(cXMLReader, "depth", rxml_reader_depth, 0);
|
1158
|
-
rb_define_method(cXMLReader, "doc", rxml_reader_doc, 0);
|
1159
|
-
rb_define_method(cXMLReader, "encoding", rxml_reader_encoding, 0);
|
1160
|
-
rb_define_method(cXMLReader, "expand", rxml_reader_expand, 0);
|
1161
|
-
rb_define_method(cXMLReader, "get_attribute", rxml_reader_get_attribute, 1);
|
1162
|
-
rb_define_method(cXMLReader, "get_attribute_no", rxml_reader_get_attribute_no, 1);
|
1163
|
-
rb_define_method(cXMLReader, "get_attribute_ns", rxml_reader_get_attribute_ns, 2);
|
1164
|
-
rb_define_method(cXMLReader, "has_attributes?", rxml_reader_has_attributes, 0);
|
1165
|
-
rb_define_method(cXMLReader, "has_value?", rxml_reader_has_value, 0);
|
1166
|
-
#if LIBXML_VERSION >= 20617
|
1167
|
-
rb_define_method(cXMLReader, "line_number", rxml_reader_line_number, 0);
|
1168
|
-
#endif
|
1169
|
-
rb_define_method(cXMLReader, "local_name", rxml_reader_local_name, 0);
|
1170
|
-
rb_define_method(cXMLReader, "lookup_namespace", rxml_reader_lookup_namespace, 1);
|
1171
|
-
rb_define_method(cXMLReader, "move_to_attribute", rxml_reader_move_to_attr, 1);
|
1172
|
-
rb_define_method(cXMLReader, "move_to_attribute_no", rxml_reader_move_to_attr_no, 1);
|
1173
|
-
rb_define_method(cXMLReader, "move_to_attribute_ns", rxml_reader_move_to_attr_ns, 2);
|
1174
|
-
rb_define_method(cXMLReader, "move_to_first_attribute", rxml_reader_move_to_first_attr, 0);
|
1175
|
-
rb_define_method(cXMLReader, "move_to_next_attribute", rxml_reader_move_to_next_attr, 0);
|
1176
|
-
rb_define_method(cXMLReader, "move_to_element", rxml_reader_move_to_element, 0);
|
1177
|
-
rb_define_method(cXMLReader, "name", rxml_reader_name, 0);
|
1178
|
-
rb_define_method(cXMLReader, "namespace_uri", rxml_reader_namespace_uri, 0);
|
1179
|
-
rb_define_method(cXMLReader, "next", rxml_reader_next, 0);
|
1180
|
-
rb_define_method(cXMLReader, "next_sibling", rxml_reader_next_sibling, 0);
|
1181
|
-
rb_define_method(cXMLReader, "node", rxml_reader_node, 0);
|
1182
|
-
rb_define_method(cXMLReader, "node_type", rxml_reader_node_type, 0);
|
1183
|
-
rb_define_method(cXMLReader, "normalization", rxml_reader_normalization, 0);
|
1184
|
-
rb_define_method(cXMLReader, "prefix", rxml_reader_prefix, 0);
|
1185
|
-
rb_define_method(cXMLReader, "quote_char", rxml_reader_quote_char, 0);
|
1186
|
-
rb_define_method(cXMLReader, "read", rxml_reader_read, 0);
|
1187
|
-
rb_define_method(cXMLReader, "read_attribute_value", rxml_reader_read_attr_value, 0);
|
1188
|
-
rb_define_method(cXMLReader, "read_inner_xml", rxml_reader_read_inner_xml, 0);
|
1189
|
-
rb_define_method(cXMLReader, "read_outer_xml", rxml_reader_read_outer_xml, 0);
|
1190
|
-
rb_define_method(cXMLReader, "read_state", rxml_reader_read_state, 0);
|
1191
|
-
rb_define_method(cXMLReader, "read_string", rxml_reader_read_string, 0);
|
1192
|
-
rb_define_method(cXMLReader, "relax_ng_validate", rxml_reader_relax_ng_validate, 1);
|
1193
|
-
rb_define_method(cXMLReader, "standalone", rxml_reader_standalone, 0);
|
1194
|
-
#if LIBXML_VERSION >= 20620
|
1195
|
-
rb_define_method(cXMLReader, "schema_validate", rxml_reader_schema_validate, 1);
|
1196
|
-
#endif
|
1197
|
-
rb_define_method(cXMLReader, "value", rxml_reader_value, 0);
|
1198
|
-
rb_define_method(cXMLReader, "xml_lang", rxml_reader_xml_lang, 0);
|
1199
|
-
rb_define_method(cXMLReader, "xml_version", rxml_reader_xml_version, 0);
|
1200
|
-
rb_define_method(cXMLReader, "default?", rxml_reader_default, 0);
|
1201
|
-
rb_define_method(cXMLReader, "empty_element?", rxml_reader_empty_element, 0);
|
1202
|
-
rb_define_method(cXMLReader, "namespace_declaration?", rxml_reader_namespace_declaration, 0);
|
1203
|
-
rb_define_method(cXMLReader, "valid?", rxml_reader_valid, 0);
|
1204
|
-
|
1205
|
-
/* Constants */
|
1206
|
-
rb_define_const(cXMLReader, "LOADDTD", INT2FIX(XML_PARSER_LOADDTD));
|
1207
|
-
rb_define_const(cXMLReader, "DEFAULTATTRS", INT2FIX(XML_PARSER_DEFAULTATTRS));
|
1208
|
-
rb_define_const(cXMLReader, "VALIDATE", INT2FIX(XML_PARSER_VALIDATE));
|
1209
|
-
rb_define_const(cXMLReader, "SUBST_ENTITIES", INT2FIX(XML_PARSER_SUBST_ENTITIES));
|
1210
|
-
|
1211
|
-
rb_define_const(cXMLReader, "SEVERITY_VALIDITY_WARNING", INT2FIX(XML_PARSER_SEVERITY_VALIDITY_WARNING));
|
1212
|
-
rb_define_const(cXMLReader, "SEVERITY_VALIDITY_ERROR", INT2FIX(XML_PARSER_SEVERITY_VALIDITY_ERROR));
|
1213
|
-
rb_define_const(cXMLReader, "SEVERITY_WARNING", INT2FIX(XML_PARSER_SEVERITY_WARNING));
|
1214
|
-
rb_define_const(cXMLReader, "SEVERITY_ERROR", INT2FIX(XML_PARSER_SEVERITY_ERROR));
|
1215
|
-
|
1216
|
-
rb_define_const(cXMLReader, "TYPE_NONE", INT2FIX(XML_READER_TYPE_NONE));
|
1217
|
-
rb_define_const(cXMLReader, "TYPE_ELEMENT", INT2FIX(XML_READER_TYPE_ELEMENT));
|
1218
|
-
rb_define_const(cXMLReader, "TYPE_ATTRIBUTE", INT2FIX(XML_READER_TYPE_ATTRIBUTE));
|
1219
|
-
rb_define_const(cXMLReader, "TYPE_TEXT", INT2FIX(XML_READER_TYPE_TEXT));
|
1220
|
-
rb_define_const(cXMLReader, "TYPE_CDATA", INT2FIX(XML_READER_TYPE_CDATA));
|
1221
|
-
rb_define_const(cXMLReader, "TYPE_ENTITY_REFERENCE", INT2FIX(XML_READER_TYPE_ENTITY_REFERENCE));
|
1222
|
-
rb_define_const(cXMLReader, "TYPE_ENTITY", INT2FIX(XML_READER_TYPE_ENTITY));
|
1223
|
-
rb_define_const(cXMLReader, "TYPE_PROCESSING_INSTRUCTION", INT2FIX(XML_READER_TYPE_PROCESSING_INSTRUCTION));
|
1224
|
-
rb_define_const(cXMLReader, "TYPE_COMMENT", INT2FIX(XML_READER_TYPE_COMMENT));
|
1225
|
-
rb_define_const(cXMLReader, "TYPE_DOCUMENT", INT2FIX(XML_READER_TYPE_DOCUMENT));
|
1226
|
-
rb_define_const(cXMLReader, "TYPE_DOCUMENT_TYPE", INT2FIX(XML_READER_TYPE_DOCUMENT_TYPE));
|
1227
|
-
rb_define_const(cXMLReader, "TYPE_DOCUMENT_FRAGMENT", INT2FIX(XML_READER_TYPE_DOCUMENT_FRAGMENT));
|
1228
|
-
rb_define_const(cXMLReader, "TYPE_NOTATION", INT2FIX(XML_READER_TYPE_NOTATION));
|
1229
|
-
rb_define_const(cXMLReader, "TYPE_WHITESPACE", INT2FIX(XML_READER_TYPE_WHITESPACE));
|
1230
|
-
rb_define_const(cXMLReader, "TYPE_SIGNIFICANT_WHITESPACE", INT2FIX(XML_READER_TYPE_SIGNIFICANT_WHITESPACE));
|
1231
|
-
rb_define_const(cXMLReader, "TYPE_END_ELEMENT", INT2FIX(XML_READER_TYPE_END_ELEMENT));
|
1232
|
-
rb_define_const(cXMLReader, "TYPE_END_ENTITY", INT2FIX(XML_READER_TYPE_END_ENTITY));
|
1233
|
-
rb_define_const(cXMLReader, "TYPE_XML_DECLARATION", INT2FIX(XML_READER_TYPE_XML_DECLARATION));
|
1234
|
-
|
1235
|
-
/* Read states */
|
1236
|
-
rb_define_const(cXMLReader, "MODE_INITIAL", INT2FIX(XML_TEXTREADER_MODE_INITIAL));
|
1237
|
-
rb_define_const(cXMLReader, "MODE_INTERACTIVE", INT2FIX(XML_TEXTREADER_MODE_INTERACTIVE));
|
1238
|
-
rb_define_const(cXMLReader, "MODE_ERROR", INT2FIX(XML_TEXTREADER_MODE_ERROR));
|
1239
|
-
rb_define_const(cXMLReader, "MODE_EOF", INT2FIX(XML_TEXTREADER_MODE_EOF));
|
1240
|
-
rb_define_const(cXMLReader, "MODE_CLOSED", INT2FIX(XML_TEXTREADER_MODE_CLOSED));
|
1241
|
-
rb_define_const(cXMLReader, "MODE_READING", INT2FIX(XML_TEXTREADER_MODE_READING));
|
1242
|
-
|
1
|
+
/* Copyright (c) 2006-2007 Apple Inc.
|
2
|
+
* Please see the LICENSE file for copyright and distribution information. */
|
3
|
+
|
4
|
+
#include "ruby_libxml.h"
|
5
|
+
#include "ruby_xml_reader.h"
|
6
|
+
|
7
|
+
#include <errno.h>
|
8
|
+
|
9
|
+
#include <libxml/xmlreader.h>
|
10
|
+
#include <libxml/xmlschemas.h>
|
11
|
+
|
12
|
+
/*
|
13
|
+
* Document-class: LibXML::XML::Reader
|
14
|
+
*
|
15
|
+
* The XML::Reader class provides a simpler, alternative way of parsing an XML
|
16
|
+
* document in contrast to XML::Parser or XML::SaxParser. A XML::Reader instance
|
17
|
+
* acts like a cursor going forward in a document stream, stopping at each node
|
18
|
+
* it encounters. To advance to the next node, simply cadd XML::Reader#read.
|
19
|
+
*
|
20
|
+
* The XML::Reader API closely matches the DOM Core specification and supports
|
21
|
+
* namespaces, xml:base, entity handling and DTDs.
|
22
|
+
*
|
23
|
+
* To summarize, XML::Reader provides a far simpler API to use versus XML::SaxParser
|
24
|
+
* and is more memory efficient than using XML::Parser to create a DOM tree.
|
25
|
+
*
|
26
|
+
* Example:
|
27
|
+
*
|
28
|
+
* reader = XML::Reader.string("<foo><bar>1</bar><bar>2</bar><bar>3</bar></foo>")
|
29
|
+
* reader.read
|
30
|
+
* assert_equal('foo', reader.name)
|
31
|
+
* assert_nil(reader.value)
|
32
|
+
*
|
33
|
+
* 3.times do |i|
|
34
|
+
* reader.read
|
35
|
+
* assert_equal(XML::Reader::TYPE_ELEMENT, reader.node_type)
|
36
|
+
* assert_equal('bar', reader.name)
|
37
|
+
* reader.read
|
38
|
+
* assert_equal(XML::Reader::TYPE_TEXT, reader.node_type)
|
39
|
+
* assert_equal((i + 1).to_s, reader.value)
|
40
|
+
* reader.read
|
41
|
+
* assert_equal(XML::Reader::TYPE_END_ELEMENT, reader.node_type)
|
42
|
+
* end
|
43
|
+
*
|
44
|
+
* You can also parse documents (see XML::Reader.document),
|
45
|
+
* strings (see XML::Parser.string) and io objects (see
|
46
|
+
* XML::Parser.io).
|
47
|
+
*
|
48
|
+
* For a more in depth tutorial, albeit in C, see http://xmlsoft.org/xmlreader.html.*/
|
49
|
+
|
50
|
+
|
51
|
+
/* NOTE - We need to wrap the readers document to support Reader.read.node.find('/').
|
52
|
+
To do this we need to use xmlTextReaderCurrentDoc which means we have to free the
|
53
|
+
document ourselves. Annoying... */
|
54
|
+
|
55
|
+
VALUE cXMLReader;
|
56
|
+
|
57
|
+
static ID BASE_URI_SYMBOL;
|
58
|
+
static ID ENCODING_SYMBOL;
|
59
|
+
static ID IO_ATTR;
|
60
|
+
static ID OPTIONS_SYMBOL;
|
61
|
+
|
62
|
+
static void rxml_reader_free(xmlTextReaderPtr xreader)
|
63
|
+
{
|
64
|
+
xmlFreeTextReader(xreader);
|
65
|
+
}
|
66
|
+
|
67
|
+
static void rxml_reader_mark(xmlTextReaderPtr xreader)
|
68
|
+
{
|
69
|
+
xmlDocPtr xdoc = xmlTextReaderCurrentDoc(xreader);
|
70
|
+
VALUE doc = (VALUE)xdoc->_private;
|
71
|
+
rb_gc_mark(doc);
|
72
|
+
}
|
73
|
+
|
74
|
+
static VALUE rxml_reader_wrap(xmlTextReaderPtr xreader)
|
75
|
+
{
|
76
|
+
return Data_Wrap_Struct(cXMLReader, NULL, rxml_reader_free, xreader);
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
static xmlTextReaderPtr rxml_text_reader_get(VALUE obj)
|
81
|
+
{
|
82
|
+
xmlTextReaderPtr xreader;
|
83
|
+
Data_Get_Struct(obj, xmlTextReader, xreader);
|
84
|
+
return xreader;
|
85
|
+
}
|
86
|
+
|
87
|
+
/*
|
88
|
+
* call-seq:
|
89
|
+
* XML::Reader.document(doc) -> XML::Reader
|
90
|
+
*
|
91
|
+
* Create an new reader for the specified document.
|
92
|
+
*/
|
93
|
+
VALUE rxml_reader_document(VALUE klass, VALUE doc)
|
94
|
+
{
|
95
|
+
xmlDocPtr xdoc;
|
96
|
+
xmlTextReaderPtr xreader;
|
97
|
+
|
98
|
+
Data_Get_Struct(doc, xmlDoc, xdoc);
|
99
|
+
|
100
|
+
xreader = xmlReaderWalker(xdoc);
|
101
|
+
|
102
|
+
if (xreader == NULL)
|
103
|
+
rxml_raise(xmlGetLastError());
|
104
|
+
|
105
|
+
return rxml_reader_wrap(xreader);
|
106
|
+
}
|
107
|
+
|
108
|
+
/* call-seq:
|
109
|
+
* XML::Reader.file(path) -> XML::Reader
|
110
|
+
* XML::Reader.file(path, :encoding => XML::Encoding::UTF_8,
|
111
|
+
* :options => XML::Parser::Options::NOENT) -> XML::Parser
|
112
|
+
*
|
113
|
+
* Creates a new reader by parsing the specified file or uri.
|
114
|
+
*
|
115
|
+
* You may provide an optional hash table to control how the
|
116
|
+
* parsing is performed. Valid options are:
|
117
|
+
*
|
118
|
+
* encoding - The document encoding, defaults to nil. Valid values
|
119
|
+
* are the encoding constants defined on XML::Encoding.
|
120
|
+
* options - Controls the execution of the parser, defaults to 0.
|
121
|
+
* Valid values are the constants defined on
|
122
|
+
* XML::Parser::Options. Mutliple options can be combined
|
123
|
+
* by using Bitwise OR (|).
|
124
|
+
*/
|
125
|
+
static VALUE rxml_reader_file(int argc, VALUE *argv, VALUE klass)
|
126
|
+
{
|
127
|
+
VALUE path;
|
128
|
+
VALUE options;
|
129
|
+
|
130
|
+
rb_scan_args(argc, argv, "11", &path, &options);
|
131
|
+
Check_Type(path, T_STRING);
|
132
|
+
|
133
|
+
const char* xencoding = NULL;
|
134
|
+
int xoptions = 0;
|
135
|
+
|
136
|
+
if (!NIL_P(options))
|
137
|
+
{
|
138
|
+
Check_Type(options, T_HASH);
|
139
|
+
|
140
|
+
VALUE encoding = rb_hash_aref(options, BASE_URI_SYMBOL);
|
141
|
+
xencoding = NIL_P(encoding) ? NULL : xmlGetCharEncodingName(NUM2INT(encoding));
|
142
|
+
|
143
|
+
VALUE parserOptions = rb_hash_aref(options, OPTIONS_SYMBOL);
|
144
|
+
xoptions = NIL_P(parserOptions) ? 0 : NUM2INT(parserOptions);
|
145
|
+
}
|
146
|
+
|
147
|
+
xmlTextReaderPtr xreader = xmlReaderForFile(StringValueCStr(path), xencoding, xoptions);
|
148
|
+
|
149
|
+
// Unfortunately libxml2 does not set xmlLastError and just returns a null reader
|
150
|
+
if (xreader == NULL)
|
151
|
+
rb_syserr_fail(ENOENT, StringValueCStr(path));
|
152
|
+
|
153
|
+
return rxml_reader_wrap(xreader);
|
154
|
+
}
|
155
|
+
|
156
|
+
/* call-seq:
|
157
|
+
* XML::Reader.io(io) -> XML::Reader
|
158
|
+
* XML::Reader.io(io, :encoding => XML::Encoding::UTF_8,
|
159
|
+
* :options => XML::Parser::Options::NOENT) -> XML::Parser
|
160
|
+
*
|
161
|
+
* Creates a new reader by parsing the specified io object.
|
162
|
+
*
|
163
|
+
* You may provide an optional hash table to control how the
|
164
|
+
* parsing is performed. Valid options are:
|
165
|
+
*
|
166
|
+
* base_uri - The base url for the parsed document.
|
167
|
+
* encoding - The document encoding, defaults to nil. Valid values
|
168
|
+
* are the encoding constants defined on XML::Encoding.
|
169
|
+
* options - Controls the execution of the parser, defaults to 0.
|
170
|
+
* Valid values are the constants defined on
|
171
|
+
* XML::Parser::Options. Mutliple options can be combined
|
172
|
+
* by using Bitwise OR (|).
|
173
|
+
*/
|
174
|
+
static VALUE rxml_reader_io(int argc, VALUE *argv, VALUE klass)
|
175
|
+
{
|
176
|
+
xmlTextReaderPtr xreader;
|
177
|
+
VALUE result;
|
178
|
+
VALUE io;
|
179
|
+
VALUE options;
|
180
|
+
char *xbaseurl = NULL;
|
181
|
+
const char *xencoding = NULL;
|
182
|
+
int xoptions = 0;
|
183
|
+
|
184
|
+
rb_scan_args(argc, argv, "11", &io, &options);
|
185
|
+
|
186
|
+
if (!NIL_P(options))
|
187
|
+
{
|
188
|
+
VALUE baseurl = Qnil;
|
189
|
+
VALUE encoding = Qnil;
|
190
|
+
VALUE parserOptions = Qnil;
|
191
|
+
|
192
|
+
Check_Type(options, T_HASH);
|
193
|
+
|
194
|
+
baseurl = rb_hash_aref(options, BASE_URI_SYMBOL);
|
195
|
+
xbaseurl = NIL_P(baseurl) ? NULL : StringValueCStr(baseurl);
|
196
|
+
|
197
|
+
encoding = rb_hash_aref(options, ENCODING_SYMBOL);
|
198
|
+
xencoding = NIL_P(encoding) ? NULL : xmlGetCharEncodingName(NUM2INT(encoding));
|
199
|
+
|
200
|
+
parserOptions = rb_hash_aref(options, OPTIONS_SYMBOL);
|
201
|
+
xoptions = NIL_P(parserOptions) ? 0 : NUM2INT(parserOptions);
|
202
|
+
}
|
203
|
+
|
204
|
+
xreader = xmlReaderForIO((xmlInputReadCallback) rxml_read_callback, NULL,
|
205
|
+
(void *) io,
|
206
|
+
xbaseurl, xencoding, xoptions);
|
207
|
+
|
208
|
+
if (xreader == NULL)
|
209
|
+
rxml_raise(xmlGetLastError());
|
210
|
+
|
211
|
+
result = rxml_reader_wrap(xreader);
|
212
|
+
|
213
|
+
/* Attach io object to parser so it won't get freed.*/
|
214
|
+
rb_ivar_set(result, IO_ATTR, io);
|
215
|
+
|
216
|
+
return result;
|
217
|
+
}
|
218
|
+
|
219
|
+
/* call-seq:
|
220
|
+
* XML::Reader.string(io) -> XML::Reader
|
221
|
+
* XML::Reader.string(io, :encoding => XML::Encoding::UTF_8,
|
222
|
+
* :options => XML::Parser::Options::NOENT) -> XML::Parser
|
223
|
+
*
|
224
|
+
* Creates a new reader by parsing the specified string.
|
225
|
+
*
|
226
|
+
* You may provide an optional hash table to control how the
|
227
|
+
* parsing is performed. Valid options are:
|
228
|
+
*
|
229
|
+
* base_uri - The base url for the parsed document.
|
230
|
+
* encoding - The document encoding, defaults to nil. Valid values
|
231
|
+
* are the encoding constants defined on XML::Encoding.
|
232
|
+
* options - Controls the execution of the parser, defaults to 0.
|
233
|
+
* Valid values are the constants defined on
|
234
|
+
* XML::Parser::Options. Mutliple options can be combined
|
235
|
+
* by using Bitwise OR (|).
|
236
|
+
*/
|
237
|
+
static VALUE rxml_reader_string(int argc, VALUE *argv, VALUE klass)
|
238
|
+
{
|
239
|
+
xmlTextReaderPtr xreader;
|
240
|
+
VALUE string;
|
241
|
+
VALUE options;
|
242
|
+
char *xbaseurl = NULL;
|
243
|
+
const char *xencoding = NULL;
|
244
|
+
int xoptions = 0;
|
245
|
+
|
246
|
+
rb_scan_args(argc, argv, "11", &string, &options);
|
247
|
+
Check_Type(string, T_STRING);
|
248
|
+
|
249
|
+
if (!NIL_P(options))
|
250
|
+
{
|
251
|
+
VALUE baseurl = Qnil;
|
252
|
+
VALUE encoding = Qnil;
|
253
|
+
VALUE parserOptions = Qnil;
|
254
|
+
|
255
|
+
Check_Type(options, T_HASH);
|
256
|
+
|
257
|
+
baseurl = rb_hash_aref(options, BASE_URI_SYMBOL);
|
258
|
+
xbaseurl = NIL_P(baseurl) ? NULL : StringValueCStr(baseurl);
|
259
|
+
|
260
|
+
encoding = rb_hash_aref(options, ENCODING_SYMBOL);
|
261
|
+
xencoding = NIL_P(encoding) ? NULL : xmlGetCharEncodingName(NUM2INT(encoding));
|
262
|
+
|
263
|
+
parserOptions = rb_hash_aref(options, OPTIONS_SYMBOL);
|
264
|
+
xoptions = NIL_P(parserOptions) ? 0 : NUM2INT(parserOptions);
|
265
|
+
}
|
266
|
+
|
267
|
+
xreader = xmlReaderForMemory(StringValueCStr(string), (int)RSTRING_LEN(string),
|
268
|
+
xbaseurl, xencoding, xoptions);
|
269
|
+
|
270
|
+
if (xreader == NULL)
|
271
|
+
rxml_raise(xmlGetLastError());
|
272
|
+
|
273
|
+
return rxml_reader_wrap(xreader);
|
274
|
+
}
|
275
|
+
|
276
|
+
/*
|
277
|
+
* call-seq:
|
278
|
+
* reader.close -> code
|
279
|
+
*
|
280
|
+
* This method releases any resources allocated by the current instance
|
281
|
+
* changes the state to Closed and close any underlying input.
|
282
|
+
*/
|
283
|
+
static VALUE rxml_reader_close(VALUE self)
|
284
|
+
{
|
285
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
286
|
+
return INT2FIX(xmlTextReaderClose(xreader));
|
287
|
+
}
|
288
|
+
|
289
|
+
/*
|
290
|
+
* call-seq:
|
291
|
+
* reader.move_to_attribute_no(index) -> code
|
292
|
+
*
|
293
|
+
* Move the position of the current instance to the attribute with the
|
294
|
+
* specified index relative to the containing element.
|
295
|
+
*/
|
296
|
+
static VALUE rxml_reader_move_to_attr_no(VALUE self, VALUE index)
|
297
|
+
{
|
298
|
+
int ret;
|
299
|
+
xmlTextReaderPtr xreader;
|
300
|
+
|
301
|
+
xreader = rxml_text_reader_get(self);
|
302
|
+
ret = xmlTextReaderMoveToAttributeNo(xreader, FIX2INT(index));
|
303
|
+
|
304
|
+
return INT2FIX(ret);
|
305
|
+
}
|
306
|
+
|
307
|
+
/*
|
308
|
+
* call-seq:
|
309
|
+
* reader.move_to_attribute(localName) -> code
|
310
|
+
*
|
311
|
+
* Move the position of the current instance to the attribute with the
|
312
|
+
* specified name relative to the containing element.
|
313
|
+
*/
|
314
|
+
static VALUE rxml_reader_move_to_attr(VALUE self, VALUE val)
|
315
|
+
{
|
316
|
+
int ret;
|
317
|
+
xmlTextReaderPtr xreader;
|
318
|
+
|
319
|
+
xreader = rxml_text_reader_get(self);
|
320
|
+
ret = xmlTextReaderMoveToAttribute(xreader,
|
321
|
+
(const xmlChar *) StringValueCStr(val));
|
322
|
+
|
323
|
+
return INT2FIX(ret);
|
324
|
+
}
|
325
|
+
|
326
|
+
/*
|
327
|
+
* call-seq:
|
328
|
+
* reader.move_to_attribute_ns(localName, namespaceURI) -> code
|
329
|
+
*
|
330
|
+
* Move the position of the current instance to the attribute with the
|
331
|
+
* specified name and namespace relative to the containing element.
|
332
|
+
*/
|
333
|
+
static VALUE rxml_reader_move_to_attr_ns(VALUE self, VALUE name, VALUE ns)
|
334
|
+
{
|
335
|
+
int ret;
|
336
|
+
xmlTextReaderPtr xreader;
|
337
|
+
|
338
|
+
xreader = rxml_text_reader_get(self);
|
339
|
+
ret = xmlTextReaderMoveToAttributeNs(xreader,
|
340
|
+
(const xmlChar *) StringValueCStr(name),
|
341
|
+
(const xmlChar *) StringValueCStr(ns));
|
342
|
+
|
343
|
+
return INT2FIX(ret);
|
344
|
+
}
|
345
|
+
|
346
|
+
/*
|
347
|
+
* call-seq:
|
348
|
+
* reader.move_to_first_attribute -> code
|
349
|
+
*
|
350
|
+
* Move the position of the current instance to the first attribute associated
|
351
|
+
* with the current node.
|
352
|
+
*/
|
353
|
+
static VALUE rxml_reader_move_to_first_attr(VALUE self)
|
354
|
+
{
|
355
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
356
|
+
return INT2FIX(xmlTextReaderMoveToFirstAttribute(xreader));
|
357
|
+
}
|
358
|
+
|
359
|
+
/*
|
360
|
+
* call-seq:
|
361
|
+
* reader.move_to_next_attribute -> code
|
362
|
+
*
|
363
|
+
* Move the position of the current instance to the next attribute associated
|
364
|
+
* with the current node.
|
365
|
+
*/
|
366
|
+
static VALUE rxml_reader_move_to_next_attr(VALUE self)
|
367
|
+
{
|
368
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
369
|
+
return INT2FIX(xmlTextReaderMoveToNextAttribute(xreader));
|
370
|
+
}
|
371
|
+
|
372
|
+
/*
|
373
|
+
* call-seq:
|
374
|
+
* reader.move_to_element -> code
|
375
|
+
*
|
376
|
+
* Move the position of the current instance to the node that contains the
|
377
|
+
* current attribute node.
|
378
|
+
*/
|
379
|
+
static VALUE rxml_reader_move_to_element(VALUE self)
|
380
|
+
{
|
381
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
382
|
+
return INT2FIX(xmlTextReaderMoveToElement(xreader));
|
383
|
+
}
|
384
|
+
|
385
|
+
/*
|
386
|
+
* call-seq:
|
387
|
+
* reader.next -> code
|
388
|
+
*
|
389
|
+
* Skip to the node following the current one in document order while avoiding
|
390
|
+
* the subtree if any.
|
391
|
+
*/
|
392
|
+
static VALUE rxml_reader_next(VALUE self)
|
393
|
+
{
|
394
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
395
|
+
return INT2FIX(xmlTextReaderNext(xreader));
|
396
|
+
}
|
397
|
+
|
398
|
+
/*
|
399
|
+
* call-seq:
|
400
|
+
* reader.next_sibling -> code
|
401
|
+
*
|
402
|
+
* Skip to the node following the current one in document order while avoiding
|
403
|
+
* the subtree if any. Currently implemented only for Readers built on a
|
404
|
+
* document.
|
405
|
+
*/
|
406
|
+
static VALUE rxml_reader_next_sibling(VALUE self)
|
407
|
+
{
|
408
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
409
|
+
return INT2FIX(xmlTextReaderNextSibling(xreader));
|
410
|
+
}
|
411
|
+
|
412
|
+
/*
|
413
|
+
* call-seq:
|
414
|
+
* reader.node -> XML::Node
|
415
|
+
*
|
416
|
+
* Returns the reader's current node. It will return
|
417
|
+
* nil if Reader#read has not yet been called.
|
418
|
+
* WARNING - Using this method is dangerous because the
|
419
|
+
* the node may be destroyed on the next #read.
|
420
|
+
*/
|
421
|
+
static VALUE rxml_reader_node(VALUE self)
|
422
|
+
{
|
423
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
424
|
+
xmlNodePtr xnode = xmlTextReaderCurrentNode(xreader);
|
425
|
+
return xnode ? rxml_node_wrap(xnode) : Qnil;
|
426
|
+
}
|
427
|
+
|
428
|
+
/*
|
429
|
+
* call-seq:
|
430
|
+
* reader.node_type -> type
|
431
|
+
*
|
432
|
+
* Get the node type of the current node. Reference:
|
433
|
+
* http://dotgnu.org/pnetlib-doc/System/Xml/XmlNodeType.html
|
434
|
+
*/
|
435
|
+
static VALUE rxml_reader_node_type(VALUE self)
|
436
|
+
{
|
437
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
438
|
+
return INT2FIX(xmlTextReaderNodeType(xreader));
|
439
|
+
}
|
440
|
+
|
441
|
+
/*
|
442
|
+
* call-seq:
|
443
|
+
* reader.normalization -> value
|
444
|
+
*
|
445
|
+
* The value indicating whether to normalize white space and attribute values.
|
446
|
+
* Since attribute value and end of line normalizations are a MUST in the XML
|
447
|
+
* specification only the value true is accepted. The broken bahaviour of
|
448
|
+
* accepting out of range character entities like � is of course not
|
449
|
+
* supported either.
|
450
|
+
*
|
451
|
+
* Return 1 or -1 in case of error.
|
452
|
+
*/
|
453
|
+
static VALUE rxml_reader_normalization(VALUE self)
|
454
|
+
{
|
455
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
456
|
+
return INT2FIX(xmlTextReaderNormalization(xreader));
|
457
|
+
}
|
458
|
+
|
459
|
+
/*
|
460
|
+
* call-seq:
|
461
|
+
* reader.read -> nil|true|false
|
462
|
+
*
|
463
|
+
* Causes the reader to move to the next node in the stream, exposing its properties.
|
464
|
+
*
|
465
|
+
* Returns true if a node was successfully read or false if there are no more
|
466
|
+
* nodes to read. On errors, an exception is raised.*/
|
467
|
+
static VALUE rxml_reader_read(VALUE self)
|
468
|
+
{
|
469
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
470
|
+
int result = xmlTextReaderRead(xreader);
|
471
|
+
switch(result)
|
472
|
+
{
|
473
|
+
case -1:
|
474
|
+
rxml_raise(xmlGetLastError());
|
475
|
+
return Qnil;
|
476
|
+
break;
|
477
|
+
case 0:
|
478
|
+
return Qfalse;
|
479
|
+
case 1:
|
480
|
+
return Qtrue;
|
481
|
+
default:
|
482
|
+
rb_raise(rb_eRuntimeError,
|
483
|
+
"xmlTextReaderRead did not return -1, 0 or 1. Return value was: %d", result);
|
484
|
+
}
|
485
|
+
}
|
486
|
+
|
487
|
+
/*
|
488
|
+
* call-seq:
|
489
|
+
* reader.read_attribute_value -> code
|
490
|
+
*
|
491
|
+
* Parse an attribute value into one or more Text and EntityReference nodes.
|
492
|
+
*
|
493
|
+
* Return 1 in case of success, 0 if the reader was not positionned on an
|
494
|
+
* attribute node or all the attribute values have been read, or -1 in case of
|
495
|
+
* error.
|
496
|
+
*/
|
497
|
+
static VALUE rxml_reader_read_attr_value(VALUE self)
|
498
|
+
{
|
499
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
500
|
+
return INT2FIX(xmlTextReaderReadAttributeValue(xreader));
|
501
|
+
}
|
502
|
+
|
503
|
+
/*
|
504
|
+
* call-seq:
|
505
|
+
* reader.read_inner_xml -> data
|
506
|
+
*
|
507
|
+
* Read the contents of the current node, including child nodes and markup.
|
508
|
+
*
|
509
|
+
* Return a string containing the XML content, or nil if the current node is
|
510
|
+
* neither an element nor attribute, or has no child nodes.
|
511
|
+
*/
|
512
|
+
static VALUE rxml_reader_read_inner_xml(VALUE self)
|
513
|
+
{
|
514
|
+
VALUE result = Qnil;
|
515
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
516
|
+
|
517
|
+
xmlChar *xml = xmlTextReaderReadInnerXml(xReader);
|
518
|
+
|
519
|
+
if (xml)
|
520
|
+
{
|
521
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
522
|
+
result = rxml_new_cstr( xml, xencoding);
|
523
|
+
xmlFree(xml);
|
524
|
+
}
|
525
|
+
|
526
|
+
return result;
|
527
|
+
}
|
528
|
+
|
529
|
+
/*
|
530
|
+
* call-seq:
|
531
|
+
* reader.read_outer_xml -> data
|
532
|
+
*
|
533
|
+
* Read the contents of the current node, including child nodes and markup.
|
534
|
+
*
|
535
|
+
* Return a string containing the XML content, or nil if the current node is
|
536
|
+
* neither an element nor attribute, or has no child nodes.
|
537
|
+
*/
|
538
|
+
static VALUE rxml_reader_read_outer_xml(VALUE self)
|
539
|
+
{
|
540
|
+
VALUE result = Qnil;
|
541
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
542
|
+
|
543
|
+
xmlChar *xml = xmlTextReaderReadOuterXml(xReader);
|
544
|
+
|
545
|
+
if (xml)
|
546
|
+
{
|
547
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
548
|
+
result = rxml_new_cstr( xml, xencoding);
|
549
|
+
xmlFree(xml);
|
550
|
+
}
|
551
|
+
|
552
|
+
return result;
|
553
|
+
}
|
554
|
+
|
555
|
+
/*
|
556
|
+
* call-seq:
|
557
|
+
* reader.read_state -> state
|
558
|
+
*
|
559
|
+
* Get the read state of the reader.
|
560
|
+
*/
|
561
|
+
static VALUE rxml_reader_read_state(VALUE self)
|
562
|
+
{
|
563
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
564
|
+
return INT2FIX(xmlTextReaderReadState(xreader));
|
565
|
+
}
|
566
|
+
|
567
|
+
/*
|
568
|
+
* call-seq:
|
569
|
+
* reader.read_string -> string
|
570
|
+
*
|
571
|
+
* Read the contents of an element or a text node as a string.
|
572
|
+
*
|
573
|
+
* Return a string containing the contents of the Element or Text node, or nil
|
574
|
+
* if the reader is positioned on any other type of node.
|
575
|
+
*/
|
576
|
+
static VALUE rxml_reader_read_string(VALUE self)
|
577
|
+
{
|
578
|
+
VALUE result = Qnil;
|
579
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
580
|
+
|
581
|
+
xmlChar *xml = xmlTextReaderReadString(xReader);
|
582
|
+
|
583
|
+
if (xml)
|
584
|
+
{
|
585
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
586
|
+
result = rxml_new_cstr( xml, xencoding);
|
587
|
+
xmlFree(xml);
|
588
|
+
}
|
589
|
+
|
590
|
+
return result;
|
591
|
+
}
|
592
|
+
|
593
|
+
/*
|
594
|
+
* call-seq:
|
595
|
+
* reader.relax_ng_validate(rng) -> boolean
|
596
|
+
*
|
597
|
+
* Use RelaxNG to validate the document as it is processed. Activation is only
|
598
|
+
* possible before the first read. If +rng+ is nil, the RelaxNG validation is
|
599
|
+
* desactivated.
|
600
|
+
*
|
601
|
+
* Return true in case the RelaxNG validation could be (des)activated and false in
|
602
|
+
* case of error.
|
603
|
+
*/
|
604
|
+
static VALUE rxml_reader_relax_ng_validate(VALUE self, VALUE rng)
|
605
|
+
{
|
606
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
607
|
+
xmlRelaxNGPtr xrelax;
|
608
|
+
int status;
|
609
|
+
Data_Get_Struct(rng, xmlRelaxNG, xrelax);
|
610
|
+
|
611
|
+
status = xmlTextReaderRelaxNGSetSchema(xreader, xrelax);
|
612
|
+
return (status == 0 ? Qtrue : Qfalse);
|
613
|
+
}
|
614
|
+
|
615
|
+
#if LIBXML_VERSION >= 20620
|
616
|
+
/*
|
617
|
+
* call-seq:
|
618
|
+
* reader.schema_validate(schema) -> boolean
|
619
|
+
*
|
620
|
+
* Use W3C XSD schema to validate the document as it is processed. Activation
|
621
|
+
* is only possible before the first read. If +schema+ is nil, then XML Schema
|
622
|
+
* validation is deactivated.
|
623
|
+
*
|
624
|
+
* Return false if if the schema's validation could be (de)activated and true
|
625
|
+
* otherwise.
|
626
|
+
*/
|
627
|
+
static VALUE
|
628
|
+
rxml_reader_schema_validate(VALUE self, VALUE xsd)
|
629
|
+
{
|
630
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
631
|
+
xmlSchemaPtr xschema;
|
632
|
+
int status;
|
633
|
+
|
634
|
+
Data_Get_Struct(xsd, xmlSchema, xschema);
|
635
|
+
status = xmlTextReaderSetSchema(xreader, xschema);
|
636
|
+
return (status == 0 ? Qtrue : Qfalse);
|
637
|
+
}
|
638
|
+
#endif
|
639
|
+
|
640
|
+
/*
|
641
|
+
* call-seq:
|
642
|
+
* reader.name -> name
|
643
|
+
*
|
644
|
+
* Return the qualified name of the node.
|
645
|
+
*/
|
646
|
+
static VALUE rxml_reader_name(VALUE self)
|
647
|
+
{
|
648
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
649
|
+
const xmlChar *result = xmlTextReaderConstName(xReader);
|
650
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
651
|
+
|
652
|
+
return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
|
653
|
+
}
|
654
|
+
|
655
|
+
/*
|
656
|
+
* call-seq:
|
657
|
+
* reader.local_name -> name
|
658
|
+
*
|
659
|
+
* Return the local name of the node.
|
660
|
+
*/
|
661
|
+
static VALUE rxml_reader_local_name(VALUE self)
|
662
|
+
{
|
663
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
664
|
+
const xmlChar *result = xmlTextReaderConstLocalName(xReader);
|
665
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
666
|
+
|
667
|
+
return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
|
668
|
+
}
|
669
|
+
|
670
|
+
/*
|
671
|
+
* call-seq:
|
672
|
+
* reader.attribute_count -> count
|
673
|
+
*
|
674
|
+
* Provide the number of attributes of the current node.
|
675
|
+
*/
|
676
|
+
static VALUE rxml_reader_attr_count(VALUE self)
|
677
|
+
{
|
678
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
679
|
+
return INT2FIX(xmlTextReaderAttributeCount(xreader));
|
680
|
+
}
|
681
|
+
|
682
|
+
/*
|
683
|
+
* call-seq:
|
684
|
+
* reader.encoding -> XML::Encoding::UTF_8
|
685
|
+
*
|
686
|
+
* Returns the encoding of the document being read. Note you
|
687
|
+
* first have to read data from the reader for encoding
|
688
|
+
* to return a value
|
689
|
+
*
|
690
|
+
* reader = XML::Reader.file(XML_FILE)
|
691
|
+
* assert_nil(reader.encoding)
|
692
|
+
* reader.read
|
693
|
+
* assert_equal(XML::Encoding::UTF_8, reader.encoding)
|
694
|
+
*
|
695
|
+
* In addition, libxml always appears to return nil for the encoding
|
696
|
+
* when parsing strings.
|
697
|
+
*/
|
698
|
+
static VALUE rxml_reader_encoding(VALUE self)
|
699
|
+
{
|
700
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
701
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xreader);
|
702
|
+
if (xencoding)
|
703
|
+
return INT2NUM(xmlParseCharEncoding((const char*)xencoding));
|
704
|
+
else
|
705
|
+
return INT2NUM(XML_CHAR_ENCODING_NONE);
|
706
|
+
}
|
707
|
+
|
708
|
+
/*
|
709
|
+
* call-seq:
|
710
|
+
* reader.base_uri -> URI
|
711
|
+
*
|
712
|
+
* Determine the base URI of the node.
|
713
|
+
*/
|
714
|
+
static VALUE rxml_reader_base_uri(VALUE self)
|
715
|
+
{
|
716
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
717
|
+
const xmlChar *result = xmlTextReaderConstBaseUri(xReader);
|
718
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
719
|
+
|
720
|
+
return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
|
721
|
+
}
|
722
|
+
|
723
|
+
/*
|
724
|
+
* call-seq:
|
725
|
+
* reader.namespace_uri -> URI
|
726
|
+
*
|
727
|
+
* Determine the namespace URI of the node.
|
728
|
+
*/
|
729
|
+
static VALUE rxml_reader_namespace_uri(VALUE self)
|
730
|
+
{
|
731
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
732
|
+
const xmlChar *result = xmlTextReaderConstNamespaceUri(xReader);
|
733
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
734
|
+
|
735
|
+
return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
|
736
|
+
}
|
737
|
+
|
738
|
+
/*
|
739
|
+
* call-seq:
|
740
|
+
* reader.value -> text
|
741
|
+
*
|
742
|
+
* Provide the text value of the node if present.
|
743
|
+
*/
|
744
|
+
static VALUE rxml_reader_value(VALUE self)
|
745
|
+
{
|
746
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
747
|
+
const xmlChar *result = xmlTextReaderConstValue(xReader);
|
748
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
749
|
+
|
750
|
+
return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
|
751
|
+
}
|
752
|
+
|
753
|
+
/*
|
754
|
+
* call-seq:
|
755
|
+
* reader.prefix -> prefix
|
756
|
+
*
|
757
|
+
* Get a shorthand reference to the namespace associated with the node.
|
758
|
+
*/
|
759
|
+
static VALUE rxml_reader_prefix(VALUE self)
|
760
|
+
{
|
761
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
762
|
+
const xmlChar *result = xmlTextReaderConstPrefix(xReader);
|
763
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
764
|
+
|
765
|
+
return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
|
766
|
+
}
|
767
|
+
|
768
|
+
/*
|
769
|
+
* call-seq:
|
770
|
+
* reader.depth -> depth
|
771
|
+
*
|
772
|
+
* Get the depth of the node in the tree.
|
773
|
+
*/
|
774
|
+
static VALUE rxml_reader_depth(VALUE self)
|
775
|
+
{
|
776
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
777
|
+
return INT2FIX(xmlTextReaderDepth(xreader));
|
778
|
+
}
|
779
|
+
|
780
|
+
/*
|
781
|
+
* call-seq:
|
782
|
+
* reader.quote_char -> char
|
783
|
+
*
|
784
|
+
* Get the quotation mark character used to enclose the value of an attribute,
|
785
|
+
* as an integer value (and -1 in case of error).
|
786
|
+
*/
|
787
|
+
static VALUE rxml_reader_quote_char(VALUE self)
|
788
|
+
{
|
789
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
790
|
+
return INT2FIX(xmlTextReaderQuoteChar(xreader));
|
791
|
+
}
|
792
|
+
|
793
|
+
/*
|
794
|
+
* call-seq:
|
795
|
+
* reader.standalone -> code
|
796
|
+
*
|
797
|
+
* Determine the standalone status of the document being read.
|
798
|
+
*
|
799
|
+
* Return 1 if the document was declared to be standalone, 0 if it was
|
800
|
+
* declared to be not standalone, or -1 if the document did not specify its
|
801
|
+
* standalone status or in case of error.
|
802
|
+
*/
|
803
|
+
static VALUE rxml_reader_standalone(VALUE self)
|
804
|
+
{
|
805
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
806
|
+
return INT2FIX(xmlTextReaderStandalone(xreader));
|
807
|
+
}
|
808
|
+
|
809
|
+
/*
|
810
|
+
* call-seq:
|
811
|
+
* reader.xml_lang -> value
|
812
|
+
*
|
813
|
+
* Get the xml:lang scope within which the node resides.
|
814
|
+
*/
|
815
|
+
static VALUE rxml_reader_xml_lang(VALUE self)
|
816
|
+
{
|
817
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
818
|
+
const xmlChar *result = xmlTextReaderConstXmlLang(xReader);
|
819
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
820
|
+
|
821
|
+
return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
|
822
|
+
}
|
823
|
+
|
824
|
+
/*
|
825
|
+
* call-seq:
|
826
|
+
* reader.xml_version -> version
|
827
|
+
*
|
828
|
+
* Determine the XML version of the document being read.
|
829
|
+
*/
|
830
|
+
static VALUE rxml_reader_xml_version(VALUE self)
|
831
|
+
{
|
832
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
833
|
+
const xmlChar *result = xmlTextReaderConstXmlVersion(xReader);
|
834
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
835
|
+
|
836
|
+
return (result == NULL ? Qnil : rxml_new_cstr(result, xencoding));
|
837
|
+
}
|
838
|
+
|
839
|
+
/*
|
840
|
+
* call-seq:
|
841
|
+
* reader.has_attributes? -> bool
|
842
|
+
*
|
843
|
+
* Get whether the node has attributes.
|
844
|
+
*/
|
845
|
+
static VALUE rxml_reader_has_attributes(VALUE self)
|
846
|
+
{
|
847
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
848
|
+
return xmlTextReaderHasAttributes(xreader) ? Qtrue : Qfalse;
|
849
|
+
}
|
850
|
+
|
851
|
+
/*
|
852
|
+
* call-seq:
|
853
|
+
* reader.has_value? -> bool
|
854
|
+
*
|
855
|
+
* Get whether the node can have a text value.
|
856
|
+
*/
|
857
|
+
static VALUE rxml_reader_has_value(VALUE self)
|
858
|
+
{
|
859
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
860
|
+
return xmlTextReaderHasValue(xreader) ? Qtrue : Qfalse;
|
861
|
+
}
|
862
|
+
|
863
|
+
/*
|
864
|
+
* call-seq:
|
865
|
+
* reader[key] -> value
|
866
|
+
*
|
867
|
+
* Provide the value of the attribute with the specified index (if +key+ is an
|
868
|
+
* integer) or with the specified name (if +key+ is a string) relative to the
|
869
|
+
* containing element, as a string.
|
870
|
+
*/
|
871
|
+
static VALUE rxml_reader_attribute(VALUE self, VALUE key)
|
872
|
+
{
|
873
|
+
VALUE result = Qnil;
|
874
|
+
xmlChar *xattr;
|
875
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
876
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
877
|
+
|
878
|
+
if (TYPE(key) == T_FIXNUM)
|
879
|
+
{
|
880
|
+
xattr = xmlTextReaderGetAttributeNo(xReader, FIX2INT(key));
|
881
|
+
}
|
882
|
+
else
|
883
|
+
{
|
884
|
+
xattr = xmlTextReaderGetAttribute(xReader, (const xmlChar *) StringValueCStr(key));
|
885
|
+
}
|
886
|
+
|
887
|
+
if (xattr)
|
888
|
+
{
|
889
|
+
result = rxml_new_cstr(xattr, xencoding);
|
890
|
+
xmlFree(xattr);
|
891
|
+
}
|
892
|
+
return result;
|
893
|
+
}
|
894
|
+
|
895
|
+
/*
|
896
|
+
* call-seq:
|
897
|
+
* reader.get_attribute(localName) -> value
|
898
|
+
*
|
899
|
+
* Provide the value of the attribute with the specified name
|
900
|
+
* relative to the containing element.
|
901
|
+
*/
|
902
|
+
static VALUE rxml_reader_get_attribute(VALUE self, VALUE name)
|
903
|
+
{
|
904
|
+
VALUE result = Qnil;
|
905
|
+
xmlChar *xattr;
|
906
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
907
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
908
|
+
|
909
|
+
xattr = xmlTextReaderGetAttribute(xReader, (const xmlChar *) StringValueCStr(name));
|
910
|
+
if (xattr)
|
911
|
+
{
|
912
|
+
result = rxml_new_cstr(xattr, xencoding);
|
913
|
+
xmlFree(xattr);
|
914
|
+
}
|
915
|
+
return result;
|
916
|
+
}
|
917
|
+
|
918
|
+
/*
|
919
|
+
* call-seq:
|
920
|
+
* reader.get_attribute_no(index) -> value
|
921
|
+
*
|
922
|
+
* Provide the value of the attribute with the specified index
|
923
|
+
* relative to the containing element.
|
924
|
+
*/
|
925
|
+
static VALUE rxml_reader_get_attribute_no(VALUE self, VALUE index)
|
926
|
+
{
|
927
|
+
VALUE result = Qnil;
|
928
|
+
xmlChar *xattr;
|
929
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
930
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
931
|
+
|
932
|
+
xattr = xmlTextReaderGetAttributeNo(xReader, FIX2INT(index));
|
933
|
+
if (xattr)
|
934
|
+
{
|
935
|
+
result = rxml_new_cstr(xattr, xencoding);
|
936
|
+
xmlFree(xattr);
|
937
|
+
}
|
938
|
+
return result;
|
939
|
+
}
|
940
|
+
|
941
|
+
static VALUE rxml_reader_get_attribute_ns(VALUE self, VALUE name, VALUE ns)
|
942
|
+
{
|
943
|
+
VALUE result = Qnil;
|
944
|
+
xmlChar *xattr;
|
945
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
946
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
947
|
+
|
948
|
+
xattr = xmlTextReaderGetAttributeNs(xReader,
|
949
|
+
(const xmlChar *) StringValueCStr(name),
|
950
|
+
(const xmlChar *) StringValueCStr(ns));
|
951
|
+
if (xattr)
|
952
|
+
{
|
953
|
+
result = rxml_new_cstr(xattr, xencoding);
|
954
|
+
xmlFree(xattr);
|
955
|
+
}
|
956
|
+
return result;
|
957
|
+
}
|
958
|
+
|
959
|
+
/*
|
960
|
+
* call-seq:
|
961
|
+
* reader.lookup_namespace(prefix) -> value
|
962
|
+
*
|
963
|
+
* Resolve a namespace prefix in the scope of the current element.
|
964
|
+
* To return the default namespace, specify nil as +prefix+.
|
965
|
+
*/
|
966
|
+
static VALUE rxml_reader_lookup_namespace(VALUE self, VALUE prefix)
|
967
|
+
{
|
968
|
+
VALUE result = Qnil;
|
969
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
970
|
+
const xmlChar *xnamespace = xmlTextReaderLookupNamespace(xReader, (const xmlChar *) StringValueCStr(prefix));
|
971
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
972
|
+
|
973
|
+
if (xnamespace)
|
974
|
+
{
|
975
|
+
result = rxml_new_cstr(xnamespace, xencoding);
|
976
|
+
xmlFree((void *)xnamespace);
|
977
|
+
}
|
978
|
+
return result;
|
979
|
+
}
|
980
|
+
|
981
|
+
/*
|
982
|
+
* call-seq:
|
983
|
+
* reader.expand -> node
|
984
|
+
*
|
985
|
+
* Returns the current node and its full subtree. Note the returned node
|
986
|
+
* is valid ONLY until the next read call. If you would like to preserve
|
987
|
+
* the node, or search it via xpath, call reader.doc first.
|
988
|
+
*/
|
989
|
+
static VALUE rxml_reader_expand(VALUE self)
|
990
|
+
{
|
991
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
992
|
+
xmlNodePtr xnode = xmlTextReaderExpand(xreader);
|
993
|
+
|
994
|
+
if (!xnode)
|
995
|
+
{
|
996
|
+
return Qnil;
|
997
|
+
}
|
998
|
+
else
|
999
|
+
{
|
1000
|
+
/* We cannot call rxml_node_wrap here because its sets up a mark function
|
1001
|
+
for the node. But according to the libxml docs (http://xmlsoft.org/html/libxml-xmlreader.html#xmlTextReaderExpand)
|
1002
|
+
this is only valid until the next xmlTextReaderRead call. At that point the node is freed (from reading
|
1003
|
+
the libxml2 source code. So don't set a mark or free function, because they will get called in the next
|
1004
|
+
garbage collection run and cause a segfault.*/
|
1005
|
+
return Data_Wrap_Struct(cXMLNode, NULL, NULL, xnode);
|
1006
|
+
}
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
/*
|
1010
|
+
* call-seq:
|
1011
|
+
* reader.document -> doc
|
1012
|
+
*
|
1013
|
+
* Hacking interface that provides access to the current document being accessed by the
|
1014
|
+
* reader. NOTE: as a result of this call, the reader will not destroy the associated XML
|
1015
|
+
* document. Instead, it will be destroyed when the returned document goes out of scope.
|
1016
|
+
*
|
1017
|
+
* Returns: document
|
1018
|
+
*/
|
1019
|
+
static VALUE rxml_reader_doc(VALUE self)
|
1020
|
+
{
|
1021
|
+
VALUE result = Qnil;
|
1022
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
1023
|
+
xmlDocPtr xdoc = xmlTextReaderCurrentDoc(xreader);
|
1024
|
+
|
1025
|
+
if (!xdoc)
|
1026
|
+
rb_raise(rb_eRuntimeError, "The reader does not have a document. Did you forget to call read?");
|
1027
|
+
|
1028
|
+
result = rxml_document_wrap(xdoc);
|
1029
|
+
|
1030
|
+
// And now hook in a mark function to keep the document alive as long as the reader is valid
|
1031
|
+
RDATA(self)->dmark = (RUBY_DATA_FUNC)rxml_reader_mark;
|
1032
|
+
|
1033
|
+
return result;
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
|
1037
|
+
|
1038
|
+
#if LIBXML_VERSION >= 20618
|
1039
|
+
/*
|
1040
|
+
* call-seq:
|
1041
|
+
* reader.byte_consumed -> value
|
1042
|
+
*
|
1043
|
+
* This method provides the current index of the parser used by the reader,
|
1044
|
+
* relative to the start of the current entity.
|
1045
|
+
*/
|
1046
|
+
static VALUE
|
1047
|
+
rxml_reader_byte_consumed(VALUE self)
|
1048
|
+
{
|
1049
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
1050
|
+
return LONG2NUM(xmlTextReaderByteConsumed(xreader));
|
1051
|
+
}
|
1052
|
+
#endif
|
1053
|
+
|
1054
|
+
#if LIBXML_VERSION >= 20617
|
1055
|
+
/*
|
1056
|
+
* call-seq:
|
1057
|
+
* reader.column_number -> number
|
1058
|
+
*
|
1059
|
+
* Provide the column number of the current parsing point.
|
1060
|
+
*/
|
1061
|
+
static VALUE
|
1062
|
+
rxml_reader_column_number(VALUE self)
|
1063
|
+
{
|
1064
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
1065
|
+
return INT2NUM(xmlTextReaderGetParserColumnNumber(xreader));
|
1066
|
+
}
|
1067
|
+
|
1068
|
+
/*
|
1069
|
+
* call-seq:
|
1070
|
+
* reader.line_number -> number
|
1071
|
+
*
|
1072
|
+
* Provide the line number of the current parsing point.
|
1073
|
+
*/
|
1074
|
+
static VALUE
|
1075
|
+
rxml_reader_line_number(VALUE self)
|
1076
|
+
{
|
1077
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
1078
|
+
return INT2NUM(xmlTextReaderGetParserLineNumber(xreader));
|
1079
|
+
}
|
1080
|
+
#endif
|
1081
|
+
|
1082
|
+
/*
|
1083
|
+
* call-seq:
|
1084
|
+
* reader.default? -> bool
|
1085
|
+
*
|
1086
|
+
* Return whether an Attribute node was generated from the default value
|
1087
|
+
* defined in the DTD or schema.
|
1088
|
+
*/
|
1089
|
+
static VALUE rxml_reader_default(VALUE self)
|
1090
|
+
{
|
1091
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
1092
|
+
return xmlTextReaderIsDefault(xreader) ? Qtrue : Qfalse;
|
1093
|
+
}
|
1094
|
+
|
1095
|
+
/*
|
1096
|
+
* call-seq:
|
1097
|
+
* reader.namespace_declaration? -> bool
|
1098
|
+
*
|
1099
|
+
* Determine whether the current node is a namespace declaration rather than a
|
1100
|
+
* regular attribute.
|
1101
|
+
*/
|
1102
|
+
static VALUE rxml_reader_namespace_declaration(VALUE self)
|
1103
|
+
{
|
1104
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
1105
|
+
return xmlTextReaderIsNamespaceDecl(xreader) ? Qtrue : Qfalse;
|
1106
|
+
}
|
1107
|
+
|
1108
|
+
/*
|
1109
|
+
* call-seq:
|
1110
|
+
* reader.empty_element? -> bool
|
1111
|
+
*
|
1112
|
+
* Check if the current node is empty.
|
1113
|
+
*/
|
1114
|
+
static VALUE rxml_reader_empty_element(VALUE self)
|
1115
|
+
{
|
1116
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
1117
|
+
return xmlTextReaderIsEmptyElement(xreader) ? Qtrue : Qfalse;
|
1118
|
+
}
|
1119
|
+
|
1120
|
+
/*
|
1121
|
+
* call-seq:
|
1122
|
+
* reader.valid? -> bool
|
1123
|
+
*
|
1124
|
+
* Retrieve the validity status from the parser context.
|
1125
|
+
*/
|
1126
|
+
static VALUE rxml_reader_valid(VALUE self)
|
1127
|
+
{
|
1128
|
+
xmlTextReaderPtr xreader = rxml_text_reader_get(self);
|
1129
|
+
return xmlTextReaderIsValid(xreader) ? Qtrue : Qfalse;
|
1130
|
+
}
|
1131
|
+
|
1132
|
+
void rxml_init_reader(void)
|
1133
|
+
{
|
1134
|
+
BASE_URI_SYMBOL = ID2SYM(rb_intern("base_uri"));
|
1135
|
+
ENCODING_SYMBOL = ID2SYM(rb_intern("encoding"));
|
1136
|
+
IO_ATTR = rb_intern("@io");
|
1137
|
+
OPTIONS_SYMBOL = ID2SYM(rb_intern("options"));
|
1138
|
+
|
1139
|
+
cXMLReader = rb_define_class_under(mXML, "Reader", rb_cObject);
|
1140
|
+
rb_undef_alloc_func(cXMLReader);
|
1141
|
+
|
1142
|
+
rb_define_singleton_method(cXMLReader, "document", rxml_reader_document, 1);
|
1143
|
+
rb_define_singleton_method(cXMLReader, "file", rxml_reader_file, -1);
|
1144
|
+
rb_define_singleton_method(cXMLReader, "io", rxml_reader_io, -1);
|
1145
|
+
rb_define_singleton_method(cXMLReader, "string", rxml_reader_string, -1);
|
1146
|
+
|
1147
|
+
rb_define_method(cXMLReader, "[]", rxml_reader_attribute, 1);
|
1148
|
+
rb_define_method(cXMLReader, "attribute_count", rxml_reader_attr_count, 0);
|
1149
|
+
rb_define_method(cXMLReader, "base_uri", rxml_reader_base_uri, 0);
|
1150
|
+
#if LIBXML_VERSION >= 20618
|
1151
|
+
rb_define_method(cXMLReader, "byte_consumed", rxml_reader_byte_consumed, 0);
|
1152
|
+
#endif
|
1153
|
+
rb_define_method(cXMLReader, "close", rxml_reader_close, 0);
|
1154
|
+
#if LIBXML_VERSION >= 20617
|
1155
|
+
rb_define_method(cXMLReader, "column_number", rxml_reader_column_number, 0);
|
1156
|
+
#endif
|
1157
|
+
rb_define_method(cXMLReader, "depth", rxml_reader_depth, 0);
|
1158
|
+
rb_define_method(cXMLReader, "doc", rxml_reader_doc, 0);
|
1159
|
+
rb_define_method(cXMLReader, "encoding", rxml_reader_encoding, 0);
|
1160
|
+
rb_define_method(cXMLReader, "expand", rxml_reader_expand, 0);
|
1161
|
+
rb_define_method(cXMLReader, "get_attribute", rxml_reader_get_attribute, 1);
|
1162
|
+
rb_define_method(cXMLReader, "get_attribute_no", rxml_reader_get_attribute_no, 1);
|
1163
|
+
rb_define_method(cXMLReader, "get_attribute_ns", rxml_reader_get_attribute_ns, 2);
|
1164
|
+
rb_define_method(cXMLReader, "has_attributes?", rxml_reader_has_attributes, 0);
|
1165
|
+
rb_define_method(cXMLReader, "has_value?", rxml_reader_has_value, 0);
|
1166
|
+
#if LIBXML_VERSION >= 20617
|
1167
|
+
rb_define_method(cXMLReader, "line_number", rxml_reader_line_number, 0);
|
1168
|
+
#endif
|
1169
|
+
rb_define_method(cXMLReader, "local_name", rxml_reader_local_name, 0);
|
1170
|
+
rb_define_method(cXMLReader, "lookup_namespace", rxml_reader_lookup_namespace, 1);
|
1171
|
+
rb_define_method(cXMLReader, "move_to_attribute", rxml_reader_move_to_attr, 1);
|
1172
|
+
rb_define_method(cXMLReader, "move_to_attribute_no", rxml_reader_move_to_attr_no, 1);
|
1173
|
+
rb_define_method(cXMLReader, "move_to_attribute_ns", rxml_reader_move_to_attr_ns, 2);
|
1174
|
+
rb_define_method(cXMLReader, "move_to_first_attribute", rxml_reader_move_to_first_attr, 0);
|
1175
|
+
rb_define_method(cXMLReader, "move_to_next_attribute", rxml_reader_move_to_next_attr, 0);
|
1176
|
+
rb_define_method(cXMLReader, "move_to_element", rxml_reader_move_to_element, 0);
|
1177
|
+
rb_define_method(cXMLReader, "name", rxml_reader_name, 0);
|
1178
|
+
rb_define_method(cXMLReader, "namespace_uri", rxml_reader_namespace_uri, 0);
|
1179
|
+
rb_define_method(cXMLReader, "next", rxml_reader_next, 0);
|
1180
|
+
rb_define_method(cXMLReader, "next_sibling", rxml_reader_next_sibling, 0);
|
1181
|
+
rb_define_method(cXMLReader, "node", rxml_reader_node, 0);
|
1182
|
+
rb_define_method(cXMLReader, "node_type", rxml_reader_node_type, 0);
|
1183
|
+
rb_define_method(cXMLReader, "normalization", rxml_reader_normalization, 0);
|
1184
|
+
rb_define_method(cXMLReader, "prefix", rxml_reader_prefix, 0);
|
1185
|
+
rb_define_method(cXMLReader, "quote_char", rxml_reader_quote_char, 0);
|
1186
|
+
rb_define_method(cXMLReader, "read", rxml_reader_read, 0);
|
1187
|
+
rb_define_method(cXMLReader, "read_attribute_value", rxml_reader_read_attr_value, 0);
|
1188
|
+
rb_define_method(cXMLReader, "read_inner_xml", rxml_reader_read_inner_xml, 0);
|
1189
|
+
rb_define_method(cXMLReader, "read_outer_xml", rxml_reader_read_outer_xml, 0);
|
1190
|
+
rb_define_method(cXMLReader, "read_state", rxml_reader_read_state, 0);
|
1191
|
+
rb_define_method(cXMLReader, "read_string", rxml_reader_read_string, 0);
|
1192
|
+
rb_define_method(cXMLReader, "relax_ng_validate", rxml_reader_relax_ng_validate, 1);
|
1193
|
+
rb_define_method(cXMLReader, "standalone", rxml_reader_standalone, 0);
|
1194
|
+
#if LIBXML_VERSION >= 20620
|
1195
|
+
rb_define_method(cXMLReader, "schema_validate", rxml_reader_schema_validate, 1);
|
1196
|
+
#endif
|
1197
|
+
rb_define_method(cXMLReader, "value", rxml_reader_value, 0);
|
1198
|
+
rb_define_method(cXMLReader, "xml_lang", rxml_reader_xml_lang, 0);
|
1199
|
+
rb_define_method(cXMLReader, "xml_version", rxml_reader_xml_version, 0);
|
1200
|
+
rb_define_method(cXMLReader, "default?", rxml_reader_default, 0);
|
1201
|
+
rb_define_method(cXMLReader, "empty_element?", rxml_reader_empty_element, 0);
|
1202
|
+
rb_define_method(cXMLReader, "namespace_declaration?", rxml_reader_namespace_declaration, 0);
|
1203
|
+
rb_define_method(cXMLReader, "valid?", rxml_reader_valid, 0);
|
1204
|
+
|
1205
|
+
/* Constants */
|
1206
|
+
rb_define_const(cXMLReader, "LOADDTD", INT2FIX(XML_PARSER_LOADDTD));
|
1207
|
+
rb_define_const(cXMLReader, "DEFAULTATTRS", INT2FIX(XML_PARSER_DEFAULTATTRS));
|
1208
|
+
rb_define_const(cXMLReader, "VALIDATE", INT2FIX(XML_PARSER_VALIDATE));
|
1209
|
+
rb_define_const(cXMLReader, "SUBST_ENTITIES", INT2FIX(XML_PARSER_SUBST_ENTITIES));
|
1210
|
+
|
1211
|
+
rb_define_const(cXMLReader, "SEVERITY_VALIDITY_WARNING", INT2FIX(XML_PARSER_SEVERITY_VALIDITY_WARNING));
|
1212
|
+
rb_define_const(cXMLReader, "SEVERITY_VALIDITY_ERROR", INT2FIX(XML_PARSER_SEVERITY_VALIDITY_ERROR));
|
1213
|
+
rb_define_const(cXMLReader, "SEVERITY_WARNING", INT2FIX(XML_PARSER_SEVERITY_WARNING));
|
1214
|
+
rb_define_const(cXMLReader, "SEVERITY_ERROR", INT2FIX(XML_PARSER_SEVERITY_ERROR));
|
1215
|
+
|
1216
|
+
rb_define_const(cXMLReader, "TYPE_NONE", INT2FIX(XML_READER_TYPE_NONE));
|
1217
|
+
rb_define_const(cXMLReader, "TYPE_ELEMENT", INT2FIX(XML_READER_TYPE_ELEMENT));
|
1218
|
+
rb_define_const(cXMLReader, "TYPE_ATTRIBUTE", INT2FIX(XML_READER_TYPE_ATTRIBUTE));
|
1219
|
+
rb_define_const(cXMLReader, "TYPE_TEXT", INT2FIX(XML_READER_TYPE_TEXT));
|
1220
|
+
rb_define_const(cXMLReader, "TYPE_CDATA", INT2FIX(XML_READER_TYPE_CDATA));
|
1221
|
+
rb_define_const(cXMLReader, "TYPE_ENTITY_REFERENCE", INT2FIX(XML_READER_TYPE_ENTITY_REFERENCE));
|
1222
|
+
rb_define_const(cXMLReader, "TYPE_ENTITY", INT2FIX(XML_READER_TYPE_ENTITY));
|
1223
|
+
rb_define_const(cXMLReader, "TYPE_PROCESSING_INSTRUCTION", INT2FIX(XML_READER_TYPE_PROCESSING_INSTRUCTION));
|
1224
|
+
rb_define_const(cXMLReader, "TYPE_COMMENT", INT2FIX(XML_READER_TYPE_COMMENT));
|
1225
|
+
rb_define_const(cXMLReader, "TYPE_DOCUMENT", INT2FIX(XML_READER_TYPE_DOCUMENT));
|
1226
|
+
rb_define_const(cXMLReader, "TYPE_DOCUMENT_TYPE", INT2FIX(XML_READER_TYPE_DOCUMENT_TYPE));
|
1227
|
+
rb_define_const(cXMLReader, "TYPE_DOCUMENT_FRAGMENT", INT2FIX(XML_READER_TYPE_DOCUMENT_FRAGMENT));
|
1228
|
+
rb_define_const(cXMLReader, "TYPE_NOTATION", INT2FIX(XML_READER_TYPE_NOTATION));
|
1229
|
+
rb_define_const(cXMLReader, "TYPE_WHITESPACE", INT2FIX(XML_READER_TYPE_WHITESPACE));
|
1230
|
+
rb_define_const(cXMLReader, "TYPE_SIGNIFICANT_WHITESPACE", INT2FIX(XML_READER_TYPE_SIGNIFICANT_WHITESPACE));
|
1231
|
+
rb_define_const(cXMLReader, "TYPE_END_ELEMENT", INT2FIX(XML_READER_TYPE_END_ELEMENT));
|
1232
|
+
rb_define_const(cXMLReader, "TYPE_END_ENTITY", INT2FIX(XML_READER_TYPE_END_ENTITY));
|
1233
|
+
rb_define_const(cXMLReader, "TYPE_XML_DECLARATION", INT2FIX(XML_READER_TYPE_XML_DECLARATION));
|
1234
|
+
|
1235
|
+
/* Read states */
|
1236
|
+
rb_define_const(cXMLReader, "MODE_INITIAL", INT2FIX(XML_TEXTREADER_MODE_INITIAL));
|
1237
|
+
rb_define_const(cXMLReader, "MODE_INTERACTIVE", INT2FIX(XML_TEXTREADER_MODE_INTERACTIVE));
|
1238
|
+
rb_define_const(cXMLReader, "MODE_ERROR", INT2FIX(XML_TEXTREADER_MODE_ERROR));
|
1239
|
+
rb_define_const(cXMLReader, "MODE_EOF", INT2FIX(XML_TEXTREADER_MODE_EOF));
|
1240
|
+
rb_define_const(cXMLReader, "MODE_CLOSED", INT2FIX(XML_TEXTREADER_MODE_CLOSED));
|
1241
|
+
rb_define_const(cXMLReader, "MODE_READING", INT2FIX(XML_TEXTREADER_MODE_READING));
|
1242
|
+
|
1243
|
+
rb_undef_method(CLASS_OF(cXMLReader), "new");
|
1244
|
+
}
|