libxml-ruby 0.9.8-x86-mswin32-60 → 0.9.9-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/CHANGES +41 -1
  2. data/LICENSE +3 -4
  3. data/README +37 -24
  4. data/Rakefile +2 -2
  5. data/ext/libxml/extconf.rb +31 -12
  6. data/ext/libxml/libxml.c +56 -858
  7. data/ext/libxml/ruby_libxml.h +93 -96
  8. data/ext/libxml/ruby_xml.c +855 -0
  9. data/ext/libxml/ruby_xml.h +9 -0
  10. data/ext/libxml/ruby_xml_attr.c +3 -9
  11. data/ext/libxml/ruby_xml_attr.h +2 -2
  12. data/ext/libxml/ruby_xml_attr_decl.c +2 -8
  13. data/ext/libxml/ruby_xml_attr_decl.h +1 -1
  14. data/ext/libxml/ruby_xml_attributes.c +6 -8
  15. data/ext/libxml/ruby_xml_attributes.h +1 -1
  16. data/ext/libxml/ruby_xml_document.c +915 -895
  17. data/ext/libxml/ruby_xml_document.h +2 -2
  18. data/ext/libxml/ruby_xml_dtd.c +257 -136
  19. data/ext/libxml/ruby_xml_dtd.h +1 -1
  20. data/ext/libxml/ruby_xml_encoding.c +55 -37
  21. data/ext/libxml/ruby_xml_encoding.h +1 -1
  22. data/ext/libxml/ruby_xml_error.c +526 -1058
  23. data/ext/libxml/ruby_xml_error.h +1 -1
  24. data/ext/libxml/ruby_xml_html_parser.c +2 -8
  25. data/ext/libxml/ruby_xml_html_parser.h +2 -2
  26. data/ext/libxml/ruby_xml_html_parser_context.c +175 -145
  27. data/ext/libxml/ruby_xml_html_parser_context.h +1 -1
  28. data/ext/libxml/ruby_xml_html_parser_options.c +12 -20
  29. data/ext/libxml/ruby_xml_html_parser_options.h +1 -1
  30. data/ext/libxml/ruby_xml_input_cbg.c +2 -8
  31. data/ext/libxml/ruby_xml_input_cbg.h +1 -1
  32. data/ext/libxml/ruby_xml_namespace.c +2 -8
  33. data/ext/libxml/ruby_xml_namespace.h +2 -2
  34. data/ext/libxml/ruby_xml_namespaces.c +1 -9
  35. data/ext/libxml/ruby_xml_namespaces.h +1 -1
  36. data/ext/libxml/ruby_xml_node.c +182 -121
  37. data/ext/libxml/ruby_xml_node.h +2 -2
  38. data/ext/libxml/ruby_xml_parser.c +2 -8
  39. data/ext/libxml/ruby_xml_parser.h +2 -2
  40. data/ext/libxml/ruby_xml_parser_context.c +952 -901
  41. data/ext/libxml/ruby_xml_parser_context.h +2 -2
  42. data/ext/libxml/ruby_xml_parser_options.c +2 -9
  43. data/ext/libxml/ruby_xml_parser_options.h +1 -1
  44. data/ext/libxml/ruby_xml_reader.c +1002 -993
  45. data/ext/libxml/ruby_xml_reader.h +1 -1
  46. data/ext/libxml/ruby_xml_relaxng.c +1 -7
  47. data/ext/libxml/ruby_xml_relaxng.h +1 -1
  48. data/ext/libxml/ruby_xml_sax2_handler.c +2 -2
  49. data/ext/libxml/ruby_xml_sax2_handler.h +1 -1
  50. data/ext/libxml/ruby_xml_sax_parser.c +2 -8
  51. data/ext/libxml/ruby_xml_sax_parser.h +2 -2
  52. data/ext/libxml/ruby_xml_schema.c +1 -7
  53. data/ext/libxml/ruby_xml_schema.h +1 -1
  54. data/ext/libxml/{version.h → ruby_xml_version.h} +2 -2
  55. data/ext/libxml/ruby_xml_xinclude.c +2 -8
  56. data/ext/libxml/ruby_xml_xinclude.h +2 -2
  57. data/ext/libxml/ruby_xml_xpath.c +17 -18
  58. data/ext/libxml/ruby_xml_xpath.h +2 -2
  59. data/ext/libxml/ruby_xml_xpath_context.c +387 -389
  60. data/ext/libxml/ruby_xml_xpath_context.h +2 -2
  61. data/ext/libxml/ruby_xml_xpath_expression.c +18 -8
  62. data/ext/libxml/ruby_xml_xpath_expression.h +1 -1
  63. data/ext/libxml/ruby_xml_xpath_object.c +19 -8
  64. data/ext/libxml/ruby_xml_xpath_object.h +1 -1
  65. data/ext/libxml/ruby_xml_xpointer.c +2 -8
  66. data/ext/libxml/ruby_xml_xpointer.h +2 -2
  67. data/ext/mingw/libxml_ruby.dll.a +0 -0
  68. data/ext/mingw/libxml_ruby.so +0 -0
  69. data/ext/vc/libxml_ruby.sln +7 -1
  70. data/lib/libxml.rb +1 -12
  71. data/lib/libxml/attr.rb +0 -3
  72. data/lib/libxml/attr_decl.rb +0 -3
  73. data/lib/libxml/attributes.rb +0 -3
  74. data/lib/libxml/document.rb +31 -5
  75. data/lib/libxml/error.rb +8 -4
  76. data/lib/libxml/properties.rb +0 -5
  77. data/lib/libxml/sax_callbacks.rb +30 -19
  78. data/lib/libxml/tree.rb +0 -1
  79. data/lib/libxml/xpath_object.rb +0 -13
  80. data/test/model/definition.dtd +8 -0
  81. data/test/tc_attributes.rb +4 -1
  82. data/test/tc_document.rb +16 -0
  83. data/test/tc_dtd.rb +30 -2
  84. data/test/tc_html_parser.rb +55 -10
  85. data/test/tc_node.rb +67 -1
  86. data/test/tc_node_edit.rb +26 -6
  87. data/test/tc_node_text.rb +41 -23
  88. data/test/tc_parser.rb +50 -0
  89. data/test/tc_reader.rb +15 -0
  90. data/test/tc_relaxng.rb +1 -1
  91. data/test/tc_sax_parser.rb +37 -5
  92. data/test/tc_schema.rb +1 -1
  93. data/test/tc_xpath.rb +1 -0
  94. data/test/tc_xpath_expression.rb +4 -2
  95. metadata +6 -6
  96. data/ext/libxml/ruby_xml_state.c +0 -51
  97. data/ext/libxml/ruby_xml_state.h +0 -11
  98. data/ext/vc/libxml_ruby.vcproj +0 -460
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_node.h 693 2008-12-13 22:53:32Z cfis $ */
1
+ /* $Id: ruby_xml_node.h 758 2009-01-25 20:36:03Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -7,7 +7,7 @@
7
7
 
8
8
  extern VALUE cXMLNode;
9
9
 
10
- void ruby_init_xml_node(void);
10
+ void rxml_init_node(void);
11
11
  void rxml_node_mark_common(xmlNodePtr xnode);
12
12
  VALUE rxml_node_wrap(xmlNodePtr xnode);
13
13
  VALUE check_string_or_symbol(VALUE val);
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_parser.c 737 2009-01-23 01:23:08Z walltndr $ */
1
+ /* $Id: ruby_xml_parser.c 758 2009-01-25 20:36:03Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -79,13 +79,7 @@ static VALUE rxml_parser_parse(VALUE self)
79
79
  return rxml_document_wrap(ctxt->myDoc);
80
80
  }
81
81
 
82
- // Rdoc needs to know
83
- #ifdef RDOC_NEVER_DEFINED
84
- mLibXML = rb_define_module("LibXML");
85
- mXML = rb_define_module_under(mLibXML, "XML");
86
- #endif
87
-
88
- void ruby_init_parser(void)
82
+ void rxml_init_parser(void)
89
83
  {
90
84
  cXMLParser = rb_define_class_under(mXML, "Parser", rb_cObject);
91
85
 
@@ -1,4 +1,4 @@
1
- /* $Id: ruby_xml_parser.h 711 2009-01-20 07:17:15Z cfis $ */
1
+ /* $Id: ruby_xml_parser.h 758 2009-01-25 20:36:03Z cfis $ */
2
2
 
3
3
  /* Please see the LICENSE file for copyright and distribution information */
4
4
 
@@ -9,6 +9,6 @@
9
9
 
10
10
  extern VALUE cXMLParser;
11
11
 
12
- void ruby_init_parser();
12
+ void rxml_init_parser();
13
13
 
14
14
  #endif
@@ -1,901 +1,952 @@
1
- /* $Id: ruby_xml_parser_context.c 750 2009-01-24 21:16:41Z cfis $ */
2
-
3
- /* Please see the LICENSE file for copyright and distribution information */
4
-
5
- #include "ruby_libxml.h"
6
- #include "ruby_xml_parser_context.h"
7
-
8
- VALUE cXMLParserContext;
9
-
10
- /*
11
- * Document-class: LibXML::XML::Parser::Context
12
- *
13
- * The XML::Parser::Context class provides in-depth control over how
14
- * a document is parsed.
15
- */
16
-
17
- static void rxml_parser_context_free(xmlParserCtxtPtr ctxt)
18
- {
19
- xmlFreeParserCtxt(ctxt);
20
- }
21
-
22
- static VALUE rxml_parser_context_wrap(xmlParserCtxtPtr ctxt)
23
- {
24
- return Data_Wrap_Struct(cXMLParserContext, NULL, rxml_parser_context_free, ctxt);
25
- }
26
-
27
-
28
- static VALUE rxml_parser_context_alloc(VALUE klass)
29
- {
30
- xmlParserCtxtPtr ctxt = xmlNewParserCtxt();
31
- return Data_Wrap_Struct(klass, NULL, rxml_parser_context_free, ctxt);
32
- }
33
-
34
- /* call-seq:
35
- * XML::Parser::Context.document(document) -> XML::Parser::Context
36
- *
37
- * Creates a new parser context based on the specified document.
38
- *
39
- * Parameters:
40
- *
41
- * document - An XML::Document instance.
42
- */
43
- static VALUE rxml_parser_context_document(VALUE klass, VALUE document)
44
- {
45
- xmlParserCtxtPtr ctxt;
46
- xmlDocPtr xdoc;
47
- xmlChar *buffer;
48
- int length;
49
-
50
- if (rb_obj_is_kind_of(document, cXMLDocument) == Qfalse)
51
- rb_raise(rb_eTypeError, "Must pass an XML::Document object");
52
-
53
- Data_Get_Struct(document, xmlDoc, xdoc);
54
- xmlDocDumpFormatMemoryEnc(xdoc, &buffer, &length, xdoc->encoding, 0);
55
-
56
- ctxt = xmlCreateDocParserCtxt(buffer);
57
- return rxml_parser_context_wrap(ctxt);
58
- }
59
-
60
- /* call-seq:
61
- * XML::Parser::Context.file(file) -> XML::Parser::Context
62
- *
63
- * Creates a new parser context based on the specified file or uri.
64
- *
65
- * Parameters:
66
- *
67
- * file - A filename or uri.
68
- */
69
- static VALUE rxml_parser_context_file(VALUE klass, VALUE file)
70
- {
71
- xmlParserCtxtPtr ctxt = xmlCreateURLParserCtxt(StringValuePtr(file), 0);
72
- return rxml_parser_context_wrap(ctxt);
73
- }
74
-
75
- /* call-seq:
76
- * XML::Parser::Context.string(string) -> XML::Parser::Context
77
- *
78
- * Creates a new parser context based on the specified string.
79
- *
80
- * Parameters:
81
- *
82
- * string - A string that contains the data to parse.
83
- */
84
- static VALUE rxml_parser_context_string(VALUE klass, VALUE string)
85
- {
86
- xmlParserCtxtPtr ctxt;
87
- Check_Type(string, T_STRING);
88
-
89
- if (RSTRING_LEN(string) == 0)
90
- rb_raise(rb_eArgError, "Must specify a string with one or more characters");
91
-
92
- ctxt = xmlCreateMemoryParserCtxt(StringValuePtr(string),
93
- RSTRING_LEN(string));
94
-
95
- if (!ctxt)
96
- rxml_raise(&xmlLastError);
97
-
98
- return rxml_parser_context_wrap(ctxt);
99
- }
100
-
101
- /* call-seq:
102
- * XML::Parser::Context.io(io) -> XML::Parser::Context
103
- *
104
- * Creates a new parser context based on the specified io object.
105
- *
106
- * Parameters:
107
- *
108
- * io - A ruby IO object.
109
- */
110
- static VALUE rxml_parser_context_io(VALUE klass, VALUE io)
111
- {
112
- xmlParserCtxtPtr ctxt;
113
- xmlParserInputBufferPtr input;
114
- xmlParserInputPtr stream;
115
-
116
- input = xmlParserInputBufferCreateIO((xmlInputReadCallback) rxml_read_callback, NULL,
117
- (void*)io, XML_CHAR_ENCODING_NONE);
118
-
119
- ctxt = xmlNewParserCtxt();
120
- if (!ctxt)
121
- {
122
- xmlFreeParserInputBuffer(input);
123
- rxml_raise(&xmlLastError);
124
- }
125
-
126
- stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
127
-
128
- if (!stream)
129
- {
130
- xmlFreeParserInputBuffer(input);
131
- xmlFreeParserCtxt(ctxt);
132
- rxml_raise(&xmlLastError);
133
- }
134
- inputPush(ctxt, stream);
135
- return rxml_parser_context_wrap(ctxt);
136
- }
137
-
138
- /*
139
- * call-seq:
140
- * context.base_uri -> "http:://libxml.org"
141
- *
142
- * Obtain the base url for this parser context.
143
- */
144
- static VALUE rxml_parser_context_base_uri_get(VALUE self)
145
- {
146
- xmlParserCtxtPtr ctxt;
147
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
148
-
149
- if (ctxt->input && ctxt->input->filename)
150
- return rb_str_new2(ctxt->input->filename);
151
- else
152
- return Qnil;
153
- }
154
-
155
- /*
156
- * call-seq:
157
- * context.base_uri = "http:://libxml.org"
158
- *
159
- * Sets the base url for this parser context.
160
- */
161
- static VALUE rxml_parser_context_base_uri_set(VALUE self, VALUE url)
162
- {
163
- xmlParserCtxtPtr ctxt;
164
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
165
-
166
- Check_Type(url, T_STRING);
167
-
168
- if (ctxt->input && !ctxt->input->filename)
169
- {
170
- const xmlChar * xurl = StringValuePtr(url);
171
- ctxt->input->filename = (char *) xmlStrdup(xurl);
172
- }
173
- return self;
174
- }
175
-
176
-
177
- /*
178
- * call-seq:
179
- * context.data_directory -> "dir"
180
- *
181
- * Obtain the data directory associated with this context.
182
- */
183
- static VALUE rxml_parser_context_data_directory_get(VALUE self)
184
- {
185
- xmlParserCtxtPtr ctxt;
186
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
187
-
188
- if (ctxt->directory == NULL)
189
- return (Qnil);
190
- else
191
- return (rb_str_new2(ctxt->directory));
192
- }
193
-
194
- /*
195
- * call-seq:
196
- * context.depth -> num
197
- *
198
- * Obtain the depth of this context.
199
- */
200
- static VALUE rxml_parser_context_depth_get(VALUE self)
201
- {
202
- xmlParserCtxtPtr ctxt;
203
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
204
-
205
- return (INT2NUM(ctxt->depth));
206
- }
207
-
208
- /*
209
- * call-seq:
210
- * context.disable_sax? -> (true|false)
211
- *
212
- * Determine whether SAX-based processing is disabled
213
- * in this context.
214
- */
215
- static VALUE rxml_parser_context_disable_sax_q(VALUE self)
216
- {
217
- xmlParserCtxtPtr ctxt;
218
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
219
-
220
- if (ctxt->disableSAX)
221
- return (Qtrue);
222
- else
223
- return (Qfalse);
224
- }
225
-
226
- /*
227
- * call-seq:
228
- * context.docbook? -> (true|false)
229
- *
230
- * Determine whether this is a docbook context.
231
- */
232
- static VALUE rxml_parser_context_docbook_q(VALUE self)
233
- {
234
- xmlParserCtxtPtr ctxt;
235
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
236
-
237
- if (ctxt->html == 2) // TODO check this
238
- return (Qtrue);
239
- else
240
- return (Qfalse);
241
- }
242
-
243
- /*
244
- * call-seq:
245
- * context.encoding -> XML::Encoding::UTF_8
246
- *
247
- * Obtain the character encoding identifier used in
248
- * this context.
249
- */
250
- static VALUE rxml_parser_context_encoding_get(VALUE self)
251
- {
252
- xmlParserCtxtPtr ctxt;
253
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
254
- return INT2NUM(xmlParseCharEncoding(ctxt->encoding));
255
- }
256
-
257
- /*
258
- * call-seq:
259
- * context.encoding = XML::Encoding::UTF_8
260
- *
261
- * Sets the character encoding for this context.
262
- */
263
- static VALUE rxml_parser_context_encoding_set(VALUE self, VALUE encoding)
264
- {
265
- xmlParserCtxtPtr ctxt;
266
- int result;
267
- const char* xencoding = xmlGetCharEncodingName((xmlCharEncoding)NUM2INT(encoding));
268
- xmlCharEncodingHandlerPtr hdlr = xmlFindCharEncodingHandler(xencoding);
269
-
270
- if (!hdlr)
271
- rb_raise(rb_eRuntimeError, "Unknown encoding: %s", encoding);
272
-
273
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
274
- result = xmlSwitchToEncoding(ctxt, hdlr);
275
-
276
- if (result != 0)
277
- rxml_raise(&xmlLastError);
278
-
279
- if (ctxt->encoding != NULL)
280
- xmlFree((xmlChar *) ctxt->encoding);
281
-
282
- ctxt->encoding = xmlStrdup((const xmlChar *) xencoding);
283
- return self;
284
- }
285
-
286
- /*
287
- * call-seq:
288
- * context.errno -> num
289
- *
290
- * Obtain the last-error number in this context.
291
- */
292
- static VALUE rxml_parser_context_errno_get(VALUE self)
293
- {
294
- xmlParserCtxtPtr ctxt;
295
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
296
-
297
- return (INT2NUM(ctxt->errNo));
298
- }
299
-
300
- /*
301
- * call-seq:
302
- * context.html? -> (true|false)
303
- *
304
- * Determine whether this is an html context.
305
- */
306
- static VALUE rxml_parser_context_html_q(VALUE self)
307
- {
308
- xmlParserCtxtPtr ctxt;
309
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
310
-
311
- if (ctxt->html == 1)
312
- return (Qtrue);
313
- else
314
- return (Qfalse);
315
- }
316
-
317
- /*
318
- * call-seq:
319
- * context.max_num_streams -> num
320
- *
321
- * Obtain the limit on the number of IO streams opened in
322
- * this context.
323
- */
324
- static VALUE rxml_parser_context_io_max_num_streams_get(VALUE self)
325
- {
326
- // TODO alias to max_streams and dep this?
327
- xmlParserCtxtPtr ctxt;
328
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
329
-
330
- return (INT2NUM(ctxt->inputMax));
331
- }
332
-
333
- /*
334
- * call-seq:
335
- * context.num_streams -> "dir"
336
- *
337
- * Obtain the actual number of IO streams in this
338
- * context.
339
- */
340
- static VALUE rxml_parser_context_io_num_streams_get(VALUE self)
341
- {
342
- xmlParserCtxtPtr ctxt;
343
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
344
-
345
- return (INT2NUM(ctxt->inputNr));
346
- }
347
-
348
- /*
349
- * call-seq:
350
- * context.keep_blanks? -> (true|false)
351
- *
352
- * Determine whether parsers in this context retain
353
- * whitespace.
354
- */
355
- static VALUE rxml_parser_context_keep_blanks_q(VALUE self)
356
- {
357
- xmlParserCtxtPtr ctxt;
358
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
359
-
360
- if (ctxt->keepBlanks)
361
- return (Qtrue);
362
- else
363
- return (Qfalse);
364
- }
365
-
366
- /*
367
- * call-seq:
368
- * context.name_depth -> num
369
- *
370
- * Obtain the name depth for this context.
371
- */
372
- static VALUE rxml_parser_context_name_depth_get(VALUE self)
373
- {
374
- xmlParserCtxtPtr ctxt;
375
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
376
-
377
- return (INT2NUM(ctxt->nameNr));
378
- }
379
-
380
- /*
381
- * call-seq:
382
- * context.name_depth_max -> num
383
- *
384
- * Obtain the maximum name depth for this context.
385
- */
386
- static VALUE rxml_parser_context_name_depth_max_get(VALUE self)
387
- {
388
- xmlParserCtxtPtr ctxt;
389
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
390
-
391
- return (INT2NUM(ctxt->nameMax));
392
- }
393
-
394
- /*
395
- * call-seq:
396
- * context.name_node -> "name"
397
- *
398
- * Obtain the name node for this context.
399
- */
400
- static VALUE rxml_parser_context_name_node_get(VALUE self)
401
- {
402
- xmlParserCtxtPtr ctxt;
403
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
404
-
405
- if (ctxt->name == NULL)
406
- return (Qnil);
407
- else
408
- return (rb_str_new2((const char*) ctxt->name));
409
- }
410
-
411
- /*
412
- * call-seq:
413
- * context.name_tab -> ["name", ..., "name"]
414
- *
415
- * Obtain the name table for this context.
416
- */
417
- static VALUE rxml_parser_context_name_tab_get(VALUE self)
418
- {
419
- int i;
420
- xmlParserCtxtPtr ctxt;
421
- VALUE tab_ary;
422
-
423
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
424
-
425
- if (ctxt->nameTab == NULL)
426
- return (Qnil);
427
-
428
- tab_ary = rb_ary_new();
429
-
430
- for (i = (ctxt->nameNr - 1); i >= 0; i--)
431
- {
432
- if (ctxt->nameTab[i] == NULL)
433
- continue;
434
- else
435
- rb_ary_push(tab_ary, rb_str_new2((const char*) ctxt->nameTab[i]));
436
- }
437
-
438
- return (tab_ary);
439
- }
440
-
441
- /*
442
- * call-seq:
443
- * context.node_depth -> num
444
- *
445
- * Obtain the node depth for this context.
446
- */
447
- static VALUE rxml_parser_context_node_depth_get(VALUE self)
448
- {
449
- xmlParserCtxtPtr ctxt;
450
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
451
-
452
- return (INT2NUM(ctxt->nodeNr));
453
- }
454
-
455
- /*
456
- * call-seq:
457
- * context.node -> node
458
- *
459
- * Obtain the root node of this context.
460
- */
461
- static VALUE rxml_parser_context_node_get(VALUE self)
462
- {
463
- xmlParserCtxtPtr ctxt;
464
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
465
-
466
- if (ctxt->node == NULL)
467
- return (Qnil);
468
- else
469
- return (rxml_node_wrap(ctxt->node));
470
- }
471
-
472
- /*
473
- * call-seq:
474
- * context.node_depth_max -> num
475
- *
476
- * Obtain the maximum node depth for this context.
477
- */
478
- static VALUE rxml_parser_context_node_depth_max_get(VALUE self)
479
- {
480
- xmlParserCtxtPtr ctxt;
481
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
482
-
483
- return (INT2NUM(ctxt->nodeMax));
484
- }
485
-
486
- /*
487
- * call-seq:
488
- * context.num_chars -> num
489
- *
490
- * Obtain the number of characters in this context.
491
- */
492
- static VALUE rxml_parser_context_num_chars_get(VALUE self)
493
- {
494
- xmlParserCtxtPtr ctxt;
495
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
496
-
497
- return (LONG2NUM(ctxt->nbChars));
498
- }
499
-
500
-
501
- /*
502
- * call-seq:
503
- * context.options > XML::Parser::Options::NOENT
504
- *
505
- * Returns the parser options for this context. Multiple
506
- * options can be combined by using Bitwise OR (|).
507
- */
508
- static VALUE rxml_parser_context_options_get(VALUE self)
509
- {
510
- xmlParserCtxtPtr ctxt;
511
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
512
-
513
- return INT2NUM(ctxt->options);
514
- }
515
-
516
- /*
517
- * call-seq:
518
- * context.options = XML::Parser::Options::NOENT |
519
- XML::Parser::Options::NOCDATA
520
- *
521
- * Provides control over the execution of a parser. Valid values
522
- * are the constants defined on XML::Parser::Options. Multiple
523
- * options can be combined by using Bitwise OR (|).
524
- */
525
- static VALUE rxml_parser_context_options_set(VALUE self, VALUE options)
526
- {
527
- int result;
528
- xmlParserCtxtPtr ctxt;
529
- Check_Type(options, T_FIXNUM);
530
-
531
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
532
- result = xmlCtxtUseOptions(ctxt, NUM2INT(options));
533
-
534
- return self;
535
- }
536
-
537
- /*
538
- * call-seq:
539
- * context.recovery? -> (true|false)
540
- *
541
- * Determine whether recovery mode is enabled in this
542
- * context.
543
- */
544
- static VALUE rxml_parser_context_recovery_q(VALUE self)
545
- {
546
- xmlParserCtxtPtr ctxt;
547
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
548
-
549
- if (ctxt->recovery)
550
- return (Qtrue);
551
- else
552
- return (Qfalse);
553
- }
554
-
555
- /*
556
- * call-seq:
557
- * context.recovery = true|false
558
- *
559
- * Control whether recovery mode is enabled in this
560
- * context.
561
- */
562
- static VALUE rxml_parser_context_recovery_set(VALUE self, VALUE bool)
563
- {
564
- xmlParserCtxtPtr ctxt;
565
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
566
-
567
- if (TYPE(bool) == T_FALSE)
568
- {
569
- ctxt->recovery = 0;
570
- return (Qfalse);
571
- }
572
- else
573
- {
574
- ctxt->recovery = 1;
575
- return (Qtrue);
576
- }
577
- }
578
-
579
- /*
580
- * call-seq:
581
- * context.replace_entities? -> (true|false)
582
- *
583
- * Determine whether external entity replacement is enabled in this
584
- * context.
585
- */
586
- static VALUE rxml_parser_context_replace_entities_q(VALUE self)
587
- {
588
- xmlParserCtxtPtr ctxt;
589
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
590
-
591
- if (ctxt->replaceEntities)
592
- return (Qtrue);
593
- else
594
- return (Qfalse);
595
- }
596
-
597
- /*
598
- * call-seq:
599
- * context.replace_entities = true|false
600
- *
601
- * Control whether external entity replacement is enabled in this
602
- * context.
603
- */
604
- static VALUE rxml_parser_context_replace_entities_set(VALUE self, VALUE bool)
605
- {
606
- xmlParserCtxtPtr ctxt;
607
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
608
-
609
- if (TYPE(bool) == T_FALSE)
610
- {
611
- ctxt->replaceEntities = 0;
612
- return (Qfalse);
613
- }
614
- else
615
- {
616
- ctxt->replaceEntities = 1;
617
- return (Qtrue);
618
- }
619
- }
620
-
621
- /*
622
- * call-seq:
623
- * context.space_depth -> num
624
- *
625
- * Obtain the space depth for this context.
626
- */
627
- static VALUE rxml_parser_context_space_depth_get(VALUE self)
628
- {
629
- xmlParserCtxtPtr ctxt;
630
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
631
-
632
- return (INT2NUM(ctxt->spaceNr));
633
- }
634
-
635
- /*
636
- * call-seq:
637
- * context.space_depth -> num
638
- *
639
- * Obtain the maximum space depth for this context.
640
- */
641
- static VALUE rxml_parser_context_space_depth_max_get(VALUE self)
642
- {
643
- xmlParserCtxtPtr ctxt;
644
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
645
-
646
- return (INT2NUM(ctxt->spaceMax));
647
- }
648
-
649
- /*
650
- * call-seq:
651
- * context.subset_external? -> (true|false)
652
- *
653
- * Determine whether this context is a subset of an
654
- * external context.
655
- */
656
- static VALUE rxml_parser_context_subset_external_q(VALUE self)
657
- {
658
- xmlParserCtxtPtr ctxt;
659
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
660
-
661
- if (ctxt->inSubset == 2)
662
- return (Qtrue);
663
- else
664
- return (Qfalse);
665
- }
666
-
667
- /*
668
- * call-seq:
669
- * context.subset_internal? -> (true|false)
670
- *
671
- * Determine whether this context is a subset of an
672
- * internal context.
673
- */
674
- static VALUE rxml_parser_context_subset_internal_q(VALUE self)
675
- {
676
- xmlParserCtxtPtr ctxt;
677
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
678
-
679
- if (ctxt->inSubset == 1)
680
- return (Qtrue);
681
- else
682
- return (Qfalse);
683
- }
684
-
685
- /*
686
- * call-seq:
687
- * context.subset_internal_name -> "name"
688
- *
689
- * Obtain this context's subset name (valid only if
690
- * either of subset_external? or subset_internal?
691
- * is true).
692
- */
693
- static VALUE rxml_parser_context_subset_name_get(VALUE self)
694
- {
695
- xmlParserCtxtPtr ctxt;
696
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
697
-
698
- if (ctxt->intSubName == NULL)
699
- return (Qnil);
700
- else
701
- return (rb_str_new2((const char*) ctxt->intSubName));
702
- }
703
-
704
- /*
705
- * call-seq:
706
- * context.subset_external_uri -> "uri"
707
- *
708
- * Obtain this context's external subset URI. (valid only if
709
- * either of subset_external? or subset_internal?
710
- * is true).
711
- */
712
- static VALUE rxml_parser_context_subset_external_uri_get(VALUE self)
713
- {
714
- xmlParserCtxtPtr ctxt;
715
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
716
-
717
- if (ctxt->extSubURI == NULL)
718
- return (Qnil);
719
- else
720
- return (rb_str_new2((const char*) ctxt->extSubURI));
721
- }
722
-
723
- /*
724
- * call-seq:
725
- * context.subset_external_system_id -> "system_id"
726
- *
727
- * Obtain this context's external subset system identifier.
728
- * (valid only if either of subset_external? or subset_internal?
729
- * is true).
730
- */
731
- static VALUE rxml_parser_context_subset_external_system_id_get(VALUE self)
732
- {
733
- xmlParserCtxtPtr ctxt;
734
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
735
-
736
- if (ctxt->extSubSystem == NULL)
737
- return (Qnil);
738
- else
739
- return (rb_str_new2((const char*) ctxt->extSubSystem));
740
- }
741
-
742
- /*
743
- * call-seq:
744
- * context.standalone? -> (true|false)
745
- *
746
- * Determine whether this is a standalone context.
747
- */
748
- static VALUE rxml_parser_context_standalone_q(VALUE self)
749
- {
750
- xmlParserCtxtPtr ctxt;
751
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
752
-
753
- if (ctxt->standalone)
754
- return (Qtrue);
755
- else
756
- return (Qfalse);
757
- }
758
-
759
- /*
760
- * call-seq:
761
- * context.stats? -> (true|false)
762
- *
763
- * Determine whether this context maintains statistics.
764
- */
765
- static VALUE rxml_parser_context_stats_q(VALUE self)
766
- {
767
- xmlParserCtxtPtr ctxt;
768
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
769
-
770
- if (ctxt->record_info)
771
- return (Qtrue);
772
- else
773
- return (Qfalse);
774
- }
775
-
776
- /*
777
- * call-seq:
778
- * context.valid? -> (true|false)
779
- *
780
- * Determine whether this context is valid.
781
- */
782
- static VALUE rxml_parser_context_valid_q(VALUE self)
783
- {
784
- xmlParserCtxtPtr ctxt;
785
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
786
-
787
- if (ctxt->valid)
788
- return (Qtrue);
789
- else
790
- return (Qfalse);
791
- }
792
-
793
- /*
794
- * call-seq:
795
- * context.validate? -> (true|false)
796
- *
797
- * Determine whether validation is enabled in this context.
798
- */
799
- static VALUE rxml_parser_context_validate_q(VALUE self)
800
- {
801
- xmlParserCtxtPtr ctxt;
802
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
803
-
804
- if (ctxt->validate)
805
- return (Qtrue);
806
- else
807
- return (Qfalse);
808
- }
809
-
810
- /*
811
- * call-seq:
812
- * context.version -> "version"
813
- *
814
- * Obtain this context's version identifier.
815
- */
816
- static VALUE rxml_parser_context_version_get(VALUE self)
817
- {
818
- xmlParserCtxtPtr ctxt;
819
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
820
-
821
- if (ctxt->version == NULL)
822
- return (Qnil);
823
- else
824
- return (rb_str_new2((const char*) ctxt->version));
825
- }
826
-
827
- /*
828
- * call-seq:
829
- * context.well_formed? -> (true|false)
830
- *
831
- * Determine whether this context contains well-formed XML.
832
- */
833
- static VALUE rxml_parser_context_well_formed_q(VALUE self)
834
- {
835
- xmlParserCtxtPtr ctxt;
836
- Data_Get_Struct(self, xmlParserCtxt, ctxt);
837
-
838
- if (ctxt->wellFormed)
839
- return (Qtrue);
840
- else
841
- return (Qfalse);
842
- }
843
-
844
- // Rdoc needs to know
845
- #ifdef RDOC_NEVER_DEFINED
846
- mLibXML = rb_define_module("LibXML");
847
- mXML = rb_define_module_under(mLibXML, "XML");
848
- cXMLParser = rb_define_class_under(mXML, "Parser", rb_cObject);
849
- #endif
850
-
851
- void ruby_init_xml_parser_context(void)
852
- {
853
- cXMLParserContext = rb_define_class_under(cXMLParser, "Context", rb_cObject);
854
- rb_define_alloc_func(cXMLParserContext, rxml_parser_context_alloc);
855
-
856
- rb_define_singleton_method(cXMLParserContext, "document", rxml_parser_context_document, 1);
857
- rb_define_singleton_method(cXMLParserContext, "file", rxml_parser_context_file, 1);
858
- rb_define_singleton_method(cXMLParserContext, "io", rxml_parser_context_io, 1);
859
- rb_define_singleton_method(cXMLParserContext, "string", rxml_parser_context_string, 1);
860
-
861
- rb_define_method(cXMLParserContext, "base_uri", rxml_parser_context_base_uri_get, 0);
862
- rb_define_method(cXMLParserContext, "base_uri=", rxml_parser_context_base_uri_set, 1);
863
- rb_define_method(cXMLParserContext, "data_directory", rxml_parser_context_data_directory_get, 0);
864
- rb_define_method(cXMLParserContext, "depth", rxml_parser_context_depth_get, 0);
865
- rb_define_method(cXMLParserContext, "disable_sax?", rxml_parser_context_disable_sax_q, 0);
866
- rb_define_method(cXMLParserContext, "docbook?", rxml_parser_context_docbook_q, 0);
867
- rb_define_method(cXMLParserContext, "encoding", rxml_parser_context_encoding_get, 0);
868
- rb_define_method(cXMLParserContext, "encoding=", rxml_parser_context_encoding_set, 1);
869
- rb_define_method(cXMLParserContext, "errno", rxml_parser_context_errno_get, 0);
870
- rb_define_method(cXMLParserContext, "html?", rxml_parser_context_html_q, 0);
871
- rb_define_method(cXMLParserContext, "io_max_num_streams", rxml_parser_context_io_max_num_streams_get, 0);
872
- rb_define_method(cXMLParserContext, "io_num_streams", rxml_parser_context_io_num_streams_get, 0);
873
- rb_define_method(cXMLParserContext, "keep_blanks?", rxml_parser_context_keep_blanks_q, 0);
874
- rb_define_method(cXMLParserContext, "name_node", rxml_parser_context_name_node_get, 0);
875
- rb_define_method(cXMLParserContext, "name_depth", rxml_parser_context_name_depth_get, 0);
876
- rb_define_method(cXMLParserContext, "name_depth_max", rxml_parser_context_name_depth_max_get, 0);
877
- rb_define_method(cXMLParserContext, "name_tab", rxml_parser_context_name_tab_get, 0);
878
- rb_define_method(cXMLParserContext, "node", rxml_parser_context_node_get, 0);
879
- rb_define_method(cXMLParserContext, "node_depth", rxml_parser_context_node_depth_get, 0);
880
- rb_define_method(cXMLParserContext, "node_depth_max", rxml_parser_context_node_depth_max_get, 0);
881
- rb_define_method(cXMLParserContext, "num_chars", rxml_parser_context_num_chars_get, 0);
882
- rb_define_method(cXMLParserContext, "options", rxml_parser_context_options_get, 0);
883
- rb_define_method(cXMLParserContext, "options=", rxml_parser_context_options_set, 1);
884
- rb_define_method(cXMLParserContext, "recovery?", rxml_parser_context_recovery_q, 0);
885
- rb_define_method(cXMLParserContext, "recovery=", rxml_parser_context_recovery_set, 1);
886
- rb_define_method(cXMLParserContext, "replace_entities?", rxml_parser_context_replace_entities_q, 0);
887
- rb_define_method(cXMLParserContext, "replace_entities=", rxml_parser_context_replace_entities_set, 1);
888
- rb_define_method(cXMLParserContext, "space_depth", rxml_parser_context_space_depth_get, 0);
889
- rb_define_method(cXMLParserContext, "space_depth_max", rxml_parser_context_space_depth_max_get, 0);
890
- rb_define_method(cXMLParserContext, "subset_external?", rxml_parser_context_subset_external_q, 0);
891
- rb_define_method(cXMLParserContext, "subset_external_system_id", rxml_parser_context_subset_external_system_id_get, 0);
892
- rb_define_method(cXMLParserContext, "subset_external_uri", rxml_parser_context_subset_external_uri_get, 0);
893
- rb_define_method(cXMLParserContext, "subset_internal?", rxml_parser_context_subset_internal_q, 0);
894
- rb_define_method(cXMLParserContext, "subset_internal_name", rxml_parser_context_subset_name_get, 0);
895
- rb_define_method(cXMLParserContext, "stats?", rxml_parser_context_stats_q, 0);
896
- rb_define_method(cXMLParserContext, "standalone?", rxml_parser_context_standalone_q, 0);
897
- rb_define_method(cXMLParserContext, "valid", rxml_parser_context_valid_q, 0);
898
- rb_define_method(cXMLParserContext, "validate?", rxml_parser_context_validate_q, 0);
899
- rb_define_method(cXMLParserContext, "version", rxml_parser_context_version_get, 0);
900
- rb_define_method(cXMLParserContext, "well_formed?", rxml_parser_context_well_formed_q, 0);
901
- }
1
+ /* $Id: ruby_xml_parser_context.c 806 2009-03-05 08:31:29Z cfis $ */
2
+
3
+ /* Please see the LICENSE file for copyright and distribution information */
4
+
5
+ #include "ruby_libxml.h"
6
+ #include "ruby_xml_parser_context.h"
7
+
8
+ VALUE cXMLParserContext;
9
+ ID IO_ATTR;
10
+
11
+ /*
12
+ * Document-class: LibXML::XML::Parser::Context
13
+ *
14
+ * The XML::Parser::Context class provides in-depth control over how
15
+ * a document is parsed.
16
+ */
17
+
18
+ static void rxml_parser_context_free(xmlParserCtxtPtr ctxt)
19
+ {
20
+ xmlFreeParserCtxt(ctxt);
21
+ }
22
+
23
+ static VALUE rxml_parser_context_wrap(xmlParserCtxtPtr ctxt)
24
+ {
25
+ return Data_Wrap_Struct(cXMLParserContext, NULL, rxml_parser_context_free, ctxt);
26
+ }
27
+
28
+
29
+ static VALUE rxml_parser_context_alloc(VALUE klass)
30
+ {
31
+ xmlParserCtxtPtr ctxt = xmlNewParserCtxt();
32
+ return Data_Wrap_Struct(klass, NULL, rxml_parser_context_free, ctxt);
33
+ }
34
+
35
+ /* call-seq:
36
+ * XML::Parser::Context.document(document) -> XML::Parser::Context
37
+ *
38
+ * Creates a new parser context based on the specified document.
39
+ *
40
+ * Parameters:
41
+ *
42
+ * document - An XML::Document instance.
43
+ */
44
+ static VALUE rxml_parser_context_document(VALUE klass, VALUE document)
45
+ {
46
+ xmlParserCtxtPtr ctxt;
47
+ xmlDocPtr xdoc;
48
+ xmlChar *buffer;
49
+ int length;
50
+
51
+ if (rb_obj_is_kind_of(document, cXMLDocument) == Qfalse)
52
+ rb_raise(rb_eTypeError, "Must pass an XML::Document object");
53
+
54
+ Data_Get_Struct(document, xmlDoc, xdoc);
55
+ xmlDocDumpFormatMemoryEnc(xdoc, &buffer, &length, xdoc->encoding, 0);
56
+
57
+ ctxt = xmlCreateDocParserCtxt(buffer);
58
+ return rxml_parser_context_wrap(ctxt);
59
+ }
60
+
61
+ /* call-seq:
62
+ * XML::Parser::Context.file(file) -> XML::Parser::Context
63
+ *
64
+ * Creates a new parser context based on the specified file or uri.
65
+ *
66
+ * Parameters:
67
+ *
68
+ * file - A filename or uri.
69
+ */
70
+ static VALUE rxml_parser_context_file(VALUE klass, VALUE file)
71
+ {
72
+ xmlParserCtxtPtr ctxt = xmlCreateURLParserCtxt(StringValuePtr(file), 0);
73
+ if (!ctxt)
74
+ rxml_raise(&xmlLastError);
75
+
76
+ return rxml_parser_context_wrap(ctxt);
77
+ }
78
+
79
+ /* call-seq:
80
+ * XML::Parser::Context.string(string) -> XML::Parser::Context
81
+ *
82
+ * Creates a new parser context based on the specified string.
83
+ *
84
+ * Parameters:
85
+ *
86
+ * string - A string that contains the data to parse.
87
+ */
88
+ static VALUE rxml_parser_context_string(VALUE klass, VALUE string)
89
+ {
90
+ xmlParserCtxtPtr ctxt;
91
+ Check_Type(string, T_STRING);
92
+
93
+ if (RSTRING_LEN(string) == 0)
94
+ rb_raise(rb_eArgError, "Must specify a string with one or more characters");
95
+
96
+ ctxt = xmlCreateMemoryParserCtxt(StringValuePtr(string),
97
+ RSTRING_LEN(string));
98
+
99
+ if (!ctxt)
100
+ rxml_raise(&xmlLastError);
101
+
102
+ return rxml_parser_context_wrap(ctxt);
103
+ }
104
+
105
+ /* call-seq:
106
+ * XML::Parser::Context.io(io) -> XML::Parser::Context
107
+ *
108
+ * Creates a new parser context based on the specified io object.
109
+ *
110
+ * Parameters:
111
+ *
112
+ * io - A ruby IO object.
113
+ */
114
+ static VALUE rxml_parser_context_io(VALUE klass, VALUE io)
115
+ {
116
+ VALUE result;
117
+ xmlParserCtxtPtr ctxt;
118
+ xmlParserInputBufferPtr input;
119
+ xmlParserInputPtr stream;
120
+
121
+ if (NIL_P(io))
122
+ rb_raise(rb_eTypeError, "Must pass in an IO object");
123
+
124
+ input = xmlParserInputBufferCreateIO((xmlInputReadCallback) rxml_read_callback, NULL,
125
+ (void*)io, XML_CHAR_ENCODING_NONE);
126
+
127
+ ctxt = xmlNewParserCtxt();
128
+ if (!ctxt)
129
+ {
130
+ xmlFreeParserInputBuffer(input);
131
+ rxml_raise(&xmlLastError);
132
+ }
133
+
134
+ stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
135
+
136
+ if (!stream)
137
+ {
138
+ xmlFreeParserInputBuffer(input);
139
+ xmlFreeParserCtxt(ctxt);
140
+ rxml_raise(&xmlLastError);
141
+ }
142
+ inputPush(ctxt, stream);
143
+ result = rxml_parser_context_wrap(ctxt);
144
+
145
+ /* Attach io object to parser so it won't get freed.*/
146
+ rb_ivar_set(result, IO_ATTR, io);
147
+
148
+ return result;
149
+ }
150
+
151
+ /*
152
+ * call-seq:
153
+ * context.base_uri -> "http:://libxml.org"
154
+ *
155
+ * Obtain the base url for this parser context.
156
+ */
157
+ static VALUE rxml_parser_context_base_uri_get(VALUE self)
158
+ {
159
+ xmlParserCtxtPtr ctxt;
160
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
161
+
162
+ if (ctxt->input && ctxt->input->filename)
163
+ return rb_str_new2(ctxt->input->filename);
164
+ else
165
+ return Qnil;
166
+ }
167
+
168
+ /*
169
+ * call-seq:
170
+ * context.base_uri = "http:://libxml.org"
171
+ *
172
+ * Sets the base url for this parser context.
173
+ */
174
+ static VALUE rxml_parser_context_base_uri_set(VALUE self, VALUE url)
175
+ {
176
+ xmlParserCtxtPtr ctxt;
177
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
178
+
179
+ Check_Type(url, T_STRING);
180
+
181
+ if (ctxt->input && !ctxt->input->filename)
182
+ {
183
+ const xmlChar * xurl = StringValuePtr(url);
184
+ ctxt->input->filename = (char *) xmlStrdup(xurl);
185
+ }
186
+ return self;
187
+ }
188
+
189
+
190
+ /*
191
+ * call-seq:
192
+ * context.data_directory -> "dir"
193
+ *
194
+ * Obtain the data directory associated with this context.
195
+ */
196
+ static VALUE rxml_parser_context_data_directory_get(VALUE self)
197
+ {
198
+ xmlParserCtxtPtr ctxt;
199
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
200
+
201
+ if (ctxt->directory == NULL)
202
+ return (Qnil);
203
+ else
204
+ return (rb_str_new2(ctxt->directory));
205
+ }
206
+
207
+ /*
208
+ * call-seq:
209
+ * context.depth -> num
210
+ *
211
+ * Obtain the depth of this context.
212
+ */
213
+ static VALUE rxml_parser_context_depth_get(VALUE self)
214
+ {
215
+ xmlParserCtxtPtr ctxt;
216
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
217
+
218
+ return (INT2NUM(ctxt->depth));
219
+ }
220
+
221
+ /*
222
+ * call-seq:
223
+ * context.disable_cdata? -> (true|false)
224
+ *
225
+ * Determine whether CDATA nodes will be created in this context.
226
+ */
227
+ static VALUE rxml_parser_context_disable_cdata_q(VALUE self)
228
+ {
229
+ xmlParserCtxtPtr ctxt;
230
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
231
+
232
+ /* LibXML controls this internally with the default SAX handler. */
233
+ if (ctxt->sax && ctxt->sax->cdataBlock)
234
+ return (Qfalse);
235
+ else
236
+ return (Qtrue);
237
+ }
238
+
239
+ /*
240
+ * call-seq:
241
+ * context.disable_cdata = (true|false)
242
+ *
243
+ * Control whether CDATA nodes will be created in this context.
244
+ */
245
+ static VALUE rxml_parser_context_disable_cdata_set(VALUE self, VALUE bool)
246
+ {
247
+ xmlParserCtxtPtr ctxt;
248
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
249
+
250
+ if (ctxt->sax == NULL)
251
+ rb_raise(rb_eRuntimeError, "Sax handler is not yet set");
252
+
253
+ /* LibXML controls this internally with the default SAX handler. */
254
+ if (bool)
255
+ ctxt->sax->cdataBlock = NULL;
256
+ else
257
+ ctxt->sax->cdataBlock = xmlDefaultSAXHandler.cdataBlock;
258
+
259
+ return bool;
260
+ }
261
+
262
+ /*
263
+ * call-seq:
264
+ * context.disable_sax? -> (true|false)
265
+ *
266
+ * Determine whether SAX-based processing is disabled
267
+ * in this context.
268
+ */
269
+ static VALUE rxml_parser_context_disable_sax_q(VALUE self)
270
+ {
271
+ xmlParserCtxtPtr ctxt;
272
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
273
+
274
+ if (ctxt->disableSAX)
275
+ return (Qtrue);
276
+ else
277
+ return (Qfalse);
278
+ }
279
+
280
+ /*
281
+ * call-seq:
282
+ * context.docbook? -> (true|false)
283
+ *
284
+ * Determine whether this is a docbook context.
285
+ */
286
+ static VALUE rxml_parser_context_docbook_q(VALUE self)
287
+ {
288
+ xmlParserCtxtPtr ctxt;
289
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
290
+
291
+ if (ctxt->html == 2) // TODO check this
292
+ return (Qtrue);
293
+ else
294
+ return (Qfalse);
295
+ }
296
+
297
+ /*
298
+ * call-seq:
299
+ * context.encoding -> XML::Encoding::UTF_8
300
+ *
301
+ * Obtain the character encoding identifier used in
302
+ * this context.
303
+ */
304
+ static VALUE rxml_parser_context_encoding_get(VALUE self)
305
+ {
306
+ xmlParserCtxtPtr ctxt;
307
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
308
+ return INT2NUM(xmlParseCharEncoding(ctxt->encoding));
309
+ }
310
+
311
+ /*
312
+ * call-seq:
313
+ * context.encoding = XML::Encoding::UTF_8
314
+ *
315
+ * Sets the character encoding for this context.
316
+ */
317
+ static VALUE rxml_parser_context_encoding_set(VALUE self, VALUE encoding)
318
+ {
319
+ xmlParserCtxtPtr ctxt;
320
+ int result;
321
+ const char* xencoding = xmlGetCharEncodingName((xmlCharEncoding)NUM2INT(encoding));
322
+ xmlCharEncodingHandlerPtr hdlr = xmlFindCharEncodingHandler(xencoding);
323
+
324
+ if (!hdlr)
325
+ rb_raise(rb_eRuntimeError, "Unknown encoding: %s", encoding);
326
+
327
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
328
+ result = xmlSwitchToEncoding(ctxt, hdlr);
329
+
330
+ if (result != 0)
331
+ rxml_raise(&xmlLastError);
332
+
333
+ if (ctxt->encoding != NULL)
334
+ xmlFree((xmlChar *) ctxt->encoding);
335
+
336
+ ctxt->encoding = xmlStrdup((const xmlChar *) xencoding);
337
+ return self;
338
+ }
339
+
340
+ /*
341
+ * call-seq:
342
+ * context.errno -> num
343
+ *
344
+ * Obtain the last-error number in this context.
345
+ */
346
+ static VALUE rxml_parser_context_errno_get(VALUE self)
347
+ {
348
+ xmlParserCtxtPtr ctxt;
349
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
350
+
351
+ return (INT2NUM(ctxt->errNo));
352
+ }
353
+
354
+ /*
355
+ * call-seq:
356
+ * context.html? -> (true|false)
357
+ *
358
+ * Determine whether this is an html context.
359
+ */
360
+ static VALUE rxml_parser_context_html_q(VALUE self)
361
+ {
362
+ xmlParserCtxtPtr ctxt;
363
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
364
+
365
+ if (ctxt->html == 1)
366
+ return (Qtrue);
367
+ else
368
+ return (Qfalse);
369
+ }
370
+
371
+ /*
372
+ * call-seq:
373
+ * context.max_num_streams -> num
374
+ *
375
+ * Obtain the limit on the number of IO streams opened in
376
+ * this context.
377
+ */
378
+ static VALUE rxml_parser_context_io_max_num_streams_get(VALUE self)
379
+ {
380
+ // TODO alias to max_streams and dep this?
381
+ xmlParserCtxtPtr ctxt;
382
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
383
+
384
+ return (INT2NUM(ctxt->inputMax));
385
+ }
386
+
387
+ /*
388
+ * call-seq:
389
+ * context.num_streams -> "dir"
390
+ *
391
+ * Obtain the actual number of IO streams in this
392
+ * context.
393
+ */
394
+ static VALUE rxml_parser_context_io_num_streams_get(VALUE self)
395
+ {
396
+ xmlParserCtxtPtr ctxt;
397
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
398
+
399
+ return (INT2NUM(ctxt->inputNr));
400
+ }
401
+
402
+ /*
403
+ * call-seq:
404
+ * context.keep_blanks? -> (true|false)
405
+ *
406
+ * Determine whether parsers in this context retain
407
+ * whitespace.
408
+ */
409
+ static VALUE rxml_parser_context_keep_blanks_q(VALUE self)
410
+ {
411
+ xmlParserCtxtPtr ctxt;
412
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
413
+
414
+ if (ctxt->keepBlanks)
415
+ return (Qtrue);
416
+ else
417
+ return (Qfalse);
418
+ }
419
+
420
+ /*
421
+ * call-seq:
422
+ * context.name_depth -> num
423
+ *
424
+ * Obtain the name depth for this context.
425
+ */
426
+ static VALUE rxml_parser_context_name_depth_get(VALUE self)
427
+ {
428
+ xmlParserCtxtPtr ctxt;
429
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
430
+
431
+ return (INT2NUM(ctxt->nameNr));
432
+ }
433
+
434
+ /*
435
+ * call-seq:
436
+ * context.name_depth_max -> num
437
+ *
438
+ * Obtain the maximum name depth for this context.
439
+ */
440
+ static VALUE rxml_parser_context_name_depth_max_get(VALUE self)
441
+ {
442
+ xmlParserCtxtPtr ctxt;
443
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
444
+
445
+ return (INT2NUM(ctxt->nameMax));
446
+ }
447
+
448
+ /*
449
+ * call-seq:
450
+ * context.name_node -> "name"
451
+ *
452
+ * Obtain the name node for this context.
453
+ */
454
+ static VALUE rxml_parser_context_name_node_get(VALUE self)
455
+ {
456
+ xmlParserCtxtPtr ctxt;
457
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
458
+
459
+ if (ctxt->name == NULL)
460
+ return (Qnil);
461
+ else
462
+ return (rb_str_new2((const char*) ctxt->name));
463
+ }
464
+
465
+ /*
466
+ * call-seq:
467
+ * context.name_tab -> ["name", ..., "name"]
468
+ *
469
+ * Obtain the name table for this context.
470
+ */
471
+ static VALUE rxml_parser_context_name_tab_get(VALUE self)
472
+ {
473
+ int i;
474
+ xmlParserCtxtPtr ctxt;
475
+ VALUE tab_ary;
476
+
477
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
478
+
479
+ if (ctxt->nameTab == NULL)
480
+ return (Qnil);
481
+
482
+ tab_ary = rb_ary_new();
483
+
484
+ for (i = (ctxt->nameNr - 1); i >= 0; i--)
485
+ {
486
+ if (ctxt->nameTab[i] == NULL)
487
+ continue;
488
+ else
489
+ rb_ary_push(tab_ary, rb_str_new2((const char*) ctxt->nameTab[i]));
490
+ }
491
+
492
+ return (tab_ary);
493
+ }
494
+
495
+ /*
496
+ * call-seq:
497
+ * context.node_depth -> num
498
+ *
499
+ * Obtain the node depth for this context.
500
+ */
501
+ static VALUE rxml_parser_context_node_depth_get(VALUE self)
502
+ {
503
+ xmlParserCtxtPtr ctxt;
504
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
505
+
506
+ return (INT2NUM(ctxt->nodeNr));
507
+ }
508
+
509
+ /*
510
+ * call-seq:
511
+ * context.node -> node
512
+ *
513
+ * Obtain the root node of this context.
514
+ */
515
+ static VALUE rxml_parser_context_node_get(VALUE self)
516
+ {
517
+ xmlParserCtxtPtr ctxt;
518
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
519
+
520
+ if (ctxt->node == NULL)
521
+ return (Qnil);
522
+ else
523
+ return (rxml_node_wrap(ctxt->node));
524
+ }
525
+
526
+ /*
527
+ * call-seq:
528
+ * context.node_depth_max -> num
529
+ *
530
+ * Obtain the maximum node depth for this context.
531
+ */
532
+ static VALUE rxml_parser_context_node_depth_max_get(VALUE self)
533
+ {
534
+ xmlParserCtxtPtr ctxt;
535
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
536
+
537
+ return (INT2NUM(ctxt->nodeMax));
538
+ }
539
+
540
+ /*
541
+ * call-seq:
542
+ * context.num_chars -> num
543
+ *
544
+ * Obtain the number of characters in this context.
545
+ */
546
+ static VALUE rxml_parser_context_num_chars_get(VALUE self)
547
+ {
548
+ xmlParserCtxtPtr ctxt;
549
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
550
+
551
+ return (LONG2NUM(ctxt->nbChars));
552
+ }
553
+
554
+
555
+ /*
556
+ * call-seq:
557
+ * context.options > XML::Parser::Options::NOENT
558
+ *
559
+ * Returns the parser options for this context. Multiple
560
+ * options can be combined by using Bitwise OR (|).
561
+ */
562
+ static VALUE rxml_parser_context_options_get(VALUE self)
563
+ {
564
+ xmlParserCtxtPtr ctxt;
565
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
566
+
567
+ return INT2NUM(ctxt->options);
568
+ }
569
+
570
+ /*
571
+ * call-seq:
572
+ * context.options = XML::Parser::Options::NOENT |
573
+ XML::Parser::Options::NOCDATA
574
+ *
575
+ * Provides control over the execution of a parser. Valid values
576
+ * are the constants defined on XML::Parser::Options. Multiple
577
+ * options can be combined by using Bitwise OR (|).
578
+ */
579
+ static VALUE rxml_parser_context_options_set(VALUE self, VALUE options)
580
+ {
581
+ int result;
582
+ xmlParserCtxtPtr ctxt;
583
+ Check_Type(options, T_FIXNUM);
584
+
585
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
586
+ result = xmlCtxtUseOptions(ctxt, NUM2INT(options));
587
+
588
+ return self;
589
+ }
590
+
591
+ /*
592
+ * call-seq:
593
+ * context.recovery? -> (true|false)
594
+ *
595
+ * Determine whether recovery mode is enabled in this
596
+ * context.
597
+ */
598
+ static VALUE rxml_parser_context_recovery_q(VALUE self)
599
+ {
600
+ xmlParserCtxtPtr ctxt;
601
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
602
+
603
+ if (ctxt->recovery)
604
+ return (Qtrue);
605
+ else
606
+ return (Qfalse);
607
+ }
608
+
609
+ /*
610
+ * call-seq:
611
+ * context.recovery = true|false
612
+ *
613
+ * Control whether recovery mode is enabled in this
614
+ * context.
615
+ */
616
+ static VALUE rxml_parser_context_recovery_set(VALUE self, VALUE bool)
617
+ {
618
+ xmlParserCtxtPtr ctxt;
619
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
620
+
621
+ if (TYPE(bool) == T_FALSE)
622
+ {
623
+ ctxt->recovery = 0;
624
+ return (Qfalse);
625
+ }
626
+ else
627
+ {
628
+ ctxt->recovery = 1;
629
+ return (Qtrue);
630
+ }
631
+ }
632
+
633
+ /*
634
+ * call-seq:
635
+ * context.replace_entities? -> (true|false)
636
+ *
637
+ * Determine whether external entity replacement is enabled in this
638
+ * context.
639
+ */
640
+ static VALUE rxml_parser_context_replace_entities_q(VALUE self)
641
+ {
642
+ xmlParserCtxtPtr ctxt;
643
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
644
+
645
+ if (ctxt->replaceEntities)
646
+ return (Qtrue);
647
+ else
648
+ return (Qfalse);
649
+ }
650
+
651
+ /*
652
+ * call-seq:
653
+ * context.replace_entities = true|false
654
+ *
655
+ * Control whether external entity replacement is enabled in this
656
+ * context.
657
+ */
658
+ static VALUE rxml_parser_context_replace_entities_set(VALUE self, VALUE bool)
659
+ {
660
+ xmlParserCtxtPtr ctxt;
661
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
662
+
663
+ if (TYPE(bool) == T_FALSE)
664
+ {
665
+ ctxt->replaceEntities = 0;
666
+ return (Qfalse);
667
+ }
668
+ else
669
+ {
670
+ ctxt->replaceEntities = 1;
671
+ return (Qtrue);
672
+ }
673
+ }
674
+
675
+ /*
676
+ * call-seq:
677
+ * context.space_depth -> num
678
+ *
679
+ * Obtain the space depth for this context.
680
+ */
681
+ static VALUE rxml_parser_context_space_depth_get(VALUE self)
682
+ {
683
+ xmlParserCtxtPtr ctxt;
684
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
685
+
686
+ return (INT2NUM(ctxt->spaceNr));
687
+ }
688
+
689
+ /*
690
+ * call-seq:
691
+ * context.space_depth -> num
692
+ *
693
+ * Obtain the maximum space depth for this context.
694
+ */
695
+ static VALUE rxml_parser_context_space_depth_max_get(VALUE self)
696
+ {
697
+ xmlParserCtxtPtr ctxt;
698
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
699
+
700
+ return (INT2NUM(ctxt->spaceMax));
701
+ }
702
+
703
+ /*
704
+ * call-seq:
705
+ * context.subset_external? -> (true|false)
706
+ *
707
+ * Determine whether this context is a subset of an
708
+ * external context.
709
+ */
710
+ static VALUE rxml_parser_context_subset_external_q(VALUE self)
711
+ {
712
+ xmlParserCtxtPtr ctxt;
713
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
714
+
715
+ if (ctxt->inSubset == 2)
716
+ return (Qtrue);
717
+ else
718
+ return (Qfalse);
719
+ }
720
+
721
+ /*
722
+ * call-seq:
723
+ * context.subset_internal? -> (true|false)
724
+ *
725
+ * Determine whether this context is a subset of an
726
+ * internal context.
727
+ */
728
+ static VALUE rxml_parser_context_subset_internal_q(VALUE self)
729
+ {
730
+ xmlParserCtxtPtr ctxt;
731
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
732
+
733
+ if (ctxt->inSubset == 1)
734
+ return (Qtrue);
735
+ else
736
+ return (Qfalse);
737
+ }
738
+
739
+ /*
740
+ * call-seq:
741
+ * context.subset_internal_name -> "name"
742
+ *
743
+ * Obtain this context's subset name (valid only if
744
+ * either of subset_external? or subset_internal?
745
+ * is true).
746
+ */
747
+ static VALUE rxml_parser_context_subset_name_get(VALUE self)
748
+ {
749
+ xmlParserCtxtPtr ctxt;
750
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
751
+
752
+ if (ctxt->intSubName == NULL)
753
+ return (Qnil);
754
+ else
755
+ return (rb_str_new2((const char*) ctxt->intSubName));
756
+ }
757
+
758
+ /*
759
+ * call-seq:
760
+ * context.subset_external_uri -> "uri"
761
+ *
762
+ * Obtain this context's external subset URI. (valid only if
763
+ * either of subset_external? or subset_internal?
764
+ * is true).
765
+ */
766
+ static VALUE rxml_parser_context_subset_external_uri_get(VALUE self)
767
+ {
768
+ xmlParserCtxtPtr ctxt;
769
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
770
+
771
+ if (ctxt->extSubURI == NULL)
772
+ return (Qnil);
773
+ else
774
+ return (rb_str_new2((const char*) ctxt->extSubURI));
775
+ }
776
+
777
+ /*
778
+ * call-seq:
779
+ * context.subset_external_system_id -> "system_id"
780
+ *
781
+ * Obtain this context's external subset system identifier.
782
+ * (valid only if either of subset_external? or subset_internal?
783
+ * is true).
784
+ */
785
+ static VALUE rxml_parser_context_subset_external_system_id_get(VALUE self)
786
+ {
787
+ xmlParserCtxtPtr ctxt;
788
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
789
+
790
+ if (ctxt->extSubSystem == NULL)
791
+ return (Qnil);
792
+ else
793
+ return (rb_str_new2((const char*) ctxt->extSubSystem));
794
+ }
795
+
796
+ /*
797
+ * call-seq:
798
+ * context.standalone? -> (true|false)
799
+ *
800
+ * Determine whether this is a standalone context.
801
+ */
802
+ static VALUE rxml_parser_context_standalone_q(VALUE self)
803
+ {
804
+ xmlParserCtxtPtr ctxt;
805
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
806
+
807
+ if (ctxt->standalone)
808
+ return (Qtrue);
809
+ else
810
+ return (Qfalse);
811
+ }
812
+
813
+ /*
814
+ * call-seq:
815
+ * context.stats? -> (true|false)
816
+ *
817
+ * Determine whether this context maintains statistics.
818
+ */
819
+ static VALUE rxml_parser_context_stats_q(VALUE self)
820
+ {
821
+ xmlParserCtxtPtr ctxt;
822
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
823
+
824
+ if (ctxt->record_info)
825
+ return (Qtrue);
826
+ else
827
+ return (Qfalse);
828
+ }
829
+
830
+ /*
831
+ * call-seq:
832
+ * context.valid? -> (true|false)
833
+ *
834
+ * Determine whether this context is valid.
835
+ */
836
+ static VALUE rxml_parser_context_valid_q(VALUE self)
837
+ {
838
+ xmlParserCtxtPtr ctxt;
839
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
840
+
841
+ if (ctxt->valid)
842
+ return (Qtrue);
843
+ else
844
+ return (Qfalse);
845
+ }
846
+
847
+ /*
848
+ * call-seq:
849
+ * context.validate? -> (true|false)
850
+ *
851
+ * Determine whether validation is enabled in this context.
852
+ */
853
+ static VALUE rxml_parser_context_validate_q(VALUE self)
854
+ {
855
+ xmlParserCtxtPtr ctxt;
856
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
857
+
858
+ if (ctxt->validate)
859
+ return (Qtrue);
860
+ else
861
+ return (Qfalse);
862
+ }
863
+
864
+ /*
865
+ * call-seq:
866
+ * context.version -> "version"
867
+ *
868
+ * Obtain this context's version identifier.
869
+ */
870
+ static VALUE rxml_parser_context_version_get(VALUE self)
871
+ {
872
+ xmlParserCtxtPtr ctxt;
873
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
874
+
875
+ if (ctxt->version == NULL)
876
+ return (Qnil);
877
+ else
878
+ return (rb_str_new2((const char*) ctxt->version));
879
+ }
880
+
881
+ /*
882
+ * call-seq:
883
+ * context.well_formed? -> (true|false)
884
+ *
885
+ * Determine whether this context contains well-formed XML.
886
+ */
887
+ static VALUE rxml_parser_context_well_formed_q(VALUE self)
888
+ {
889
+ xmlParserCtxtPtr ctxt;
890
+ Data_Get_Struct(self, xmlParserCtxt, ctxt);
891
+
892
+ if (ctxt->wellFormed)
893
+ return (Qtrue);
894
+ else
895
+ return (Qfalse);
896
+ }
897
+
898
+ void rxml_init_parser_context(void)
899
+ {
900
+ IO_ATTR = ID2SYM(rb_intern("@io"));
901
+
902
+ cXMLParserContext = rb_define_class_under(cXMLParser, "Context", rb_cObject);
903
+ rb_define_alloc_func(cXMLParserContext, rxml_parser_context_alloc);
904
+
905
+ rb_define_singleton_method(cXMLParserContext, "document", rxml_parser_context_document, 1);
906
+ rb_define_singleton_method(cXMLParserContext, "file", rxml_parser_context_file, 1);
907
+ rb_define_singleton_method(cXMLParserContext, "io", rxml_parser_context_io, 1);
908
+ rb_define_singleton_method(cXMLParserContext, "string", rxml_parser_context_string, 1);
909
+
910
+ rb_define_method(cXMLParserContext, "base_uri", rxml_parser_context_base_uri_get, 0);
911
+ rb_define_method(cXMLParserContext, "base_uri=", rxml_parser_context_base_uri_set, 1);
912
+ rb_define_method(cXMLParserContext, "data_directory", rxml_parser_context_data_directory_get, 0);
913
+ rb_define_method(cXMLParserContext, "depth", rxml_parser_context_depth_get, 0);
914
+ rb_define_method(cXMLParserContext, "disable_cdata?", rxml_parser_context_disable_cdata_q, 0);
915
+ rb_define_method(cXMLParserContext, "disable_cdata=", rxml_parser_context_disable_cdata_set, 1);
916
+ rb_define_method(cXMLParserContext, "disable_sax?", rxml_parser_context_disable_sax_q, 0);
917
+ rb_define_method(cXMLParserContext, "docbook?", rxml_parser_context_docbook_q, 0);
918
+ rb_define_method(cXMLParserContext, "encoding", rxml_parser_context_encoding_get, 0);
919
+ rb_define_method(cXMLParserContext, "encoding=", rxml_parser_context_encoding_set, 1);
920
+ rb_define_method(cXMLParserContext, "errno", rxml_parser_context_errno_get, 0);
921
+ rb_define_method(cXMLParserContext, "html?", rxml_parser_context_html_q, 0);
922
+ rb_define_method(cXMLParserContext, "io_max_num_streams", rxml_parser_context_io_max_num_streams_get, 0);
923
+ rb_define_method(cXMLParserContext, "io_num_streams", rxml_parser_context_io_num_streams_get, 0);
924
+ rb_define_method(cXMLParserContext, "keep_blanks?", rxml_parser_context_keep_blanks_q, 0);
925
+ rb_define_method(cXMLParserContext, "name_node", rxml_parser_context_name_node_get, 0);
926
+ rb_define_method(cXMLParserContext, "name_depth", rxml_parser_context_name_depth_get, 0);
927
+ rb_define_method(cXMLParserContext, "name_depth_max", rxml_parser_context_name_depth_max_get, 0);
928
+ rb_define_method(cXMLParserContext, "name_tab", rxml_parser_context_name_tab_get, 0);
929
+ rb_define_method(cXMLParserContext, "node", rxml_parser_context_node_get, 0);
930
+ rb_define_method(cXMLParserContext, "node_depth", rxml_parser_context_node_depth_get, 0);
931
+ rb_define_method(cXMLParserContext, "node_depth_max", rxml_parser_context_node_depth_max_get, 0);
932
+ rb_define_method(cXMLParserContext, "num_chars", rxml_parser_context_num_chars_get, 0);
933
+ rb_define_method(cXMLParserContext, "options", rxml_parser_context_options_get, 0);
934
+ rb_define_method(cXMLParserContext, "options=", rxml_parser_context_options_set, 1);
935
+ rb_define_method(cXMLParserContext, "recovery?", rxml_parser_context_recovery_q, 0);
936
+ rb_define_method(cXMLParserContext, "recovery=", rxml_parser_context_recovery_set, 1);
937
+ rb_define_method(cXMLParserContext, "replace_entities?", rxml_parser_context_replace_entities_q, 0);
938
+ rb_define_method(cXMLParserContext, "replace_entities=", rxml_parser_context_replace_entities_set, 1);
939
+ rb_define_method(cXMLParserContext, "space_depth", rxml_parser_context_space_depth_get, 0);
940
+ rb_define_method(cXMLParserContext, "space_depth_max", rxml_parser_context_space_depth_max_get, 0);
941
+ rb_define_method(cXMLParserContext, "subset_external?", rxml_parser_context_subset_external_q, 0);
942
+ rb_define_method(cXMLParserContext, "subset_external_system_id", rxml_parser_context_subset_external_system_id_get, 0);
943
+ rb_define_method(cXMLParserContext, "subset_external_uri", rxml_parser_context_subset_external_uri_get, 0);
944
+ rb_define_method(cXMLParserContext, "subset_internal?", rxml_parser_context_subset_internal_q, 0);
945
+ rb_define_method(cXMLParserContext, "subset_internal_name", rxml_parser_context_subset_name_get, 0);
946
+ rb_define_method(cXMLParserContext, "stats?", rxml_parser_context_stats_q, 0);
947
+ rb_define_method(cXMLParserContext, "standalone?", rxml_parser_context_standalone_q, 0);
948
+ rb_define_method(cXMLParserContext, "valid", rxml_parser_context_valid_q, 0);
949
+ rb_define_method(cXMLParserContext, "validate?", rxml_parser_context_validate_q, 0);
950
+ rb_define_method(cXMLParserContext, "version", rxml_parser_context_version_get, 0);
951
+ rb_define_method(cXMLParserContext, "well_formed?", rxml_parser_context_well_formed_q, 0);
952
+ }