libxml-ruby 0.3.6

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