Class: LibXML::XML::Parser::Context

Inherits:
Object
  • Object
show all
Defined in:
ext/libxml/ruby_xml_parser_context.c,
ext/libxml/ruby_xml_parser_context.c

Overview

The XML::Parser::Context class provides in-depth control over how a document is parsed.

Direct Known Subclasses

HTMLParser::Context

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.XML::Parser::Context.document(document) ⇒ XML::Parser::Context

Creates a new parser context based on the specified document.

Parameters:

document - An XML::Document instance.


44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'ext/libxml/ruby_xml_parser_context.c', line 44

static VALUE rxml_parser_context_document(VALUE klass, VALUE document)
{
  xmlParserCtxtPtr ctxt;
  xmlDocPtr xdoc;
  xmlChar *buffer; 
  int length;

  if (rb_obj_is_kind_of(document, cXMLDocument) == Qfalse)
    rb_raise(rb_eTypeError, "Must pass an XML::Document object");

  Data_Get_Struct(document, xmlDoc, xdoc);
  xmlDocDumpFormatMemoryEnc(xdoc, &buffer, &length, xdoc->encoding, 0);

  ctxt = xmlCreateDocParserCtxt(buffer);

  if (!ctxt)
    rxml_raise(&xmlLastError);

  /* This is annoying, but xmlInitParserCtxt (called indirectly above) and 
     xmlCtxtUseOptionsInternal (called below) initialize slightly different
     context options, in particular XML_PARSE_NODICT which xmlInitParserCtxt
     sets to 0 and xmlCtxtUseOptionsInternal sets to 1.  So we have to call both. */
  xmlCtxtUseOptions(ctxt, rxml_libxml_default_options());

  return rxml_parser_context_wrap(ctxt);
}

.XML::Parser::Context.file(file) ⇒ XML::Parser::Context

Creates a new parser context based on the specified file or uri.

Parameters:

file - A filename or uri.


80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'ext/libxml/ruby_xml_parser_context.c', line 80

static VALUE rxml_parser_context_file(VALUE klass, VALUE file)
{
  xmlParserCtxtPtr ctxt = xmlCreateURLParserCtxt(StringValuePtr(file), 0);

  if (!ctxt)
    rxml_raise(&xmlLastError);

  /* This is annoying, but xmlInitParserCtxt (called indirectly above) and 
     xmlCtxtUseOptionsInternal (called below) initialize slightly different
     context options, in particular XML_PARSE_NODICT which xmlInitParserCtxt
     sets to 0 and xmlCtxtUseOptionsInternal sets to 1.  So we have to call both. */
  xmlCtxtUseOptions(ctxt, rxml_libxml_default_options());

  return rxml_parser_context_wrap(ctxt);
}

.XML::Parser::Context.io(io) ⇒ XML::Parser::Context

Creates a new parser context based on the specified io object.

Parameters:

io - A ruby IO object.


137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'ext/libxml/ruby_xml_parser_context.c', line 137

static VALUE rxml_parser_context_io(VALUE klass, VALUE io)
{
  VALUE result;
  xmlParserCtxtPtr ctxt;
  xmlParserInputBufferPtr input;
  xmlParserInputPtr stream;

  if (NIL_P(io))
    rb_raise(rb_eTypeError, "Must pass in an IO object");

  input = xmlParserInputBufferCreateIO((xmlInputReadCallback) rxml_read_callback, NULL,
                                       (void*)io, XML_CHAR_ENCODING_NONE);
    
  ctxt = xmlNewParserCtxt();

  if (!ctxt)
  {
    xmlFreeParserInputBuffer(input);
    rxml_raise(&xmlLastError);
  }

  /* This is annoying, but xmlInitParserCtxt (called indirectly above) and 
     xmlCtxtUseOptionsInternal (called below) initialize slightly different
     context options, in particular XML_PARSE_NODICT which xmlInitParserCtxt
     sets to 0 and xmlCtxtUseOptionsInternal sets to 1.  So we have to call both. */
  xmlCtxtUseOptions(ctxt, rxml_libxml_default_options());

  stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);

  if (!stream)
  {
    xmlFreeParserInputBuffer(input);
    xmlFreeParserCtxt(ctxt);
    rxml_raise(&xmlLastError);
  }
  inputPush(ctxt, stream);
  result = rxml_parser_context_wrap(ctxt);

  /* Attach io object to parser so it won't get freed.*/
  rb_ivar_set(result, IO_ATTR, io);

  return result;
}

.XML::Parser::Context.string(string) ⇒ XML::Parser::Context

Creates a new parser context based on the specified string.

Parameters:

string - A string that contains the data to parse.


105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'ext/libxml/ruby_xml_parser_context.c', line 105

static VALUE rxml_parser_context_string(VALUE klass, VALUE string)
{
  xmlParserCtxtPtr ctxt;
  Check_Type(string, T_STRING);

  if (RSTRING_LEN(string) == 0)
    rb_raise(rb_eArgError, "Must specify a string with one or more characters");

  ctxt = xmlCreateMemoryParserCtxt(StringValuePtr(string),
                                   RSTRING_LEN(string));
  
  if (!ctxt)
    rxml_raise(&xmlLastError);

  /* This is annoying, but xmlInitParserCtxt (called indirectly above) and 
     xmlCtxtUseOptionsInternal (called below) initialize slightly different
     context options, in particular XML_PARSE_NODICT which xmlInitParserCtxt
     sets to 0 and xmlCtxtUseOptionsInternal sets to 1.  So we have to call both. */
  xmlCtxtUseOptions(ctxt, rxml_libxml_default_options());

  return rxml_parser_context_wrap(ctxt);
}

Instance Method Details

#base_uriObject

Obtain the base url for this parser context.



187
188
189
190
191
192
193
194
195
196
# File 'ext/libxml/ruby_xml_parser_context.c', line 187

static VALUE rxml_parser_context_base_uri_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->input && ctxt->input->filename)
    return rb_str_new2(ctxt->input->filename);
  else
    return Qnil;
}

#base_uri=(url) ⇒ Object

Sets the base url for this parser context.



204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'ext/libxml/ruby_xml_parser_context.c', line 204

static VALUE rxml_parser_context_base_uri_set(VALUE self, VALUE url)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  Check_Type(url, T_STRING);

  if (ctxt->input && !ctxt->input->filename)
  {
    const xmlChar * xurl = StringValuePtr(url);
    ctxt->input->filename = (char *) xmlStrdup(xurl);
  }
  return self;
}

#data_directoryObject

Obtain the data directory associated with this context.



226
227
228
229
230
231
232
233
234
235
# File 'ext/libxml/ruby_xml_parser_context.c', line 226

static VALUE rxml_parser_context_data_directory_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->directory == NULL)
    return (Qnil);
  else
    return (rb_str_new2(ctxt->directory));
}

#depthNumeric

Obtain the depth of this context.

Returns:

  • (Numeric)


243
244
245
246
247
248
249
# File 'ext/libxml/ruby_xml_parser_context.c', line 243

static VALUE rxml_parser_context_depth_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return (INT2NUM(ctxt->depth));
}

#disable_cdata=(bool) ⇒ Object

Control whether CDATA nodes will be created in this context.



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'ext/libxml/ruby_xml_parser_context.c', line 275

static VALUE rxml_parser_context_disable_cdata_set(VALUE self, VALUE bool)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->sax == NULL)
    rb_raise(rb_eRuntimeError, "Sax handler is not yet set");

  /* LibXML controls this internally with the default SAX handler. */ 
  if (bool)
    ctxt->sax->cdataBlock = NULL;
  else
    ctxt->sax->cdataBlock = xmlDefaultSAXHandler.cdataBlock;

  return bool;
}

#disable_cdata?Boolean

Determine whether CDATA nodes will be created in this context.

Returns:

  • (Boolean)


257
258
259
260
261
262
263
264
265
266
267
# File 'ext/libxml/ruby_xml_parser_context.c', line 257

static VALUE rxml_parser_context_disable_cdata_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  /* LibXML controls this internally with the default SAX handler. */
  if (ctxt->sax && ctxt->sax->cdataBlock)
    return (Qfalse);
  else
    return (Qtrue);
}

#disable_sax?Boolean

Determine whether SAX-based processing is disabled in this context.

Returns:

  • (Boolean)


299
300
301
302
303
304
305
306
307
308
# File 'ext/libxml/ruby_xml_parser_context.c', line 299

static VALUE rxml_parser_context_disable_sax_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->disableSAX)
    return (Qtrue);
  else
    return (Qfalse);
}

#docbook?Boolean

Determine whether this is a docbook context.

Returns:

  • (Boolean)


316
317
318
319
320
321
322
323
324
325
# File 'ext/libxml/ruby_xml_parser_context.c', line 316

static VALUE rxml_parser_context_docbook_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->html == 2) // TODO check this
    return (Qtrue);
  else
    return (Qfalse);
}

#encodingXML::Encoding::UTF_8

Obtain the character encoding identifier used in this context.



334
335
336
337
338
339
# File 'ext/libxml/ruby_xml_parser_context.c', line 334

static VALUE rxml_parser_context_encoding_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);
  return INT2NUM(xmlParseCharEncoding(ctxt->encoding));
}

#encoding=(XML) ⇒ Object

Sets the character encoding for this context.



347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'ext/libxml/ruby_xml_parser_context.c', line 347

static VALUE rxml_parser_context_encoding_set(VALUE self, VALUE encoding)
{
  xmlParserCtxtPtr ctxt;
  int result;
  const char* xencoding = xmlGetCharEncodingName((xmlCharEncoding)NUM2INT(encoding));
  xmlCharEncodingHandlerPtr hdlr = xmlFindCharEncodingHandler(xencoding);
  
  if (!hdlr)
    rb_raise(rb_eRuntimeError, "Unknown encoding: %s", encoding);

  Data_Get_Struct(self, xmlParserCtxt, ctxt);
  result = xmlSwitchToEncoding(ctxt, hdlr);

  if (result != 0)
    rxml_raise(&xmlLastError);

  if (ctxt->encoding != NULL)
    xmlFree((xmlChar *) ctxt->encoding);

  ctxt->encoding = xmlStrdup((const xmlChar *) xencoding);
  return self;
}

#errnoNumeric

Obtain the last-error number in this context.

Returns:

  • (Numeric)


376
377
378
379
380
381
382
# File 'ext/libxml/ruby_xml_parser_context.c', line 376

static VALUE rxml_parser_context_errno_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return (INT2NUM(ctxt->errNo));
}

#html?Boolean

Determine whether this is an html context.

Returns:

  • (Boolean)


390
391
392
393
394
395
396
397
398
399
# File 'ext/libxml/ruby_xml_parser_context.c', line 390

static VALUE rxml_parser_context_html_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->html == 1)
    return (Qtrue);
  else
    return (Qfalse);
}

#max_num_streamsNumeric

Obtain the limit on the number of IO streams opened in this context.

Returns:

  • (Numeric)


408
409
410
411
412
413
414
415
# File 'ext/libxml/ruby_xml_parser_context.c', line 408

static VALUE rxml_parser_context_io_max_num_streams_get(VALUE self)
{
  // TODO alias to max_streams and dep this?
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return (INT2NUM(ctxt->inputMax));
}

#num_streamsObject

Obtain the actual number of IO streams in this context.



424
425
426
427
428
429
430
# File 'ext/libxml/ruby_xml_parser_context.c', line 424

static VALUE rxml_parser_context_io_num_streams_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return (INT2NUM(ctxt->inputNr));
}

#keep_blanks?Boolean

Determine whether parsers in this context retain whitespace.

Returns:

  • (Boolean)


439
440
441
442
443
444
445
446
447
448
# File 'ext/libxml/ruby_xml_parser_context.c', line 439

static VALUE rxml_parser_context_keep_blanks_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->keepBlanks)
    return (Qtrue);
  else
    return (Qfalse);
}

#name_depthNumeric

Obtain the name depth for this context.

Returns:

  • (Numeric)


456
457
458
459
460
461
462
# File 'ext/libxml/ruby_xml_parser_context.c', line 456

static VALUE rxml_parser_context_name_depth_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return (INT2NUM(ctxt->nameNr));
}

#name_depth_maxNumeric

Obtain the maximum name depth for this context.

Returns:

  • (Numeric)


470
471
472
473
474
475
476
# File 'ext/libxml/ruby_xml_parser_context.c', line 470

static VALUE rxml_parser_context_name_depth_max_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return (INT2NUM(ctxt->nameMax));
}

#name_nodeObject

Obtain the name node for this context.



484
485
486
487
488
489
490
491
492
493
# File 'ext/libxml/ruby_xml_parser_context.c', line 484

static VALUE rxml_parser_context_name_node_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->name == NULL)
    return (Qnil);
  else
    return (rb_str_new2((const char*) ctxt->name));
}

#name_tabArray

Obtain the name table for this context.

Returns:

  • (Array)


501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
# File 'ext/libxml/ruby_xml_parser_context.c', line 501

static VALUE rxml_parser_context_name_tab_get(VALUE self)
{
  int i;
  xmlParserCtxtPtr ctxt;
  VALUE tab_ary;

  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->nameTab == NULL)
    return (Qnil);

  tab_ary = rb_ary_new();

  for (i = (ctxt->nameNr - 1); i >= 0; i--)
  {
    if (ctxt->nameTab[i] == NULL)
      continue;
    else
      rb_ary_push(tab_ary, rb_str_new2((const char*) ctxt->nameTab[i]));
  }

  return (tab_ary);
}

#nodeObject

Obtain the root node of this context.



545
546
547
548
549
550
551
552
553
554
# File 'ext/libxml/ruby_xml_parser_context.c', line 545

static VALUE rxml_parser_context_node_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->node == NULL)
    return (Qnil);
  else
    return (rxml_node_wrap(ctxt->node));
}

#node_depthNumeric

Obtain the node depth for this context.

Returns:

  • (Numeric)


531
532
533
534
535
536
537
# File 'ext/libxml/ruby_xml_parser_context.c', line 531

static VALUE rxml_parser_context_node_depth_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return (INT2NUM(ctxt->nodeNr));
}

#node_depth_maxNumeric

Obtain the maximum node depth for this context.

Returns:

  • (Numeric)


562
563
564
565
566
567
568
# File 'ext/libxml/ruby_xml_parser_context.c', line 562

static VALUE rxml_parser_context_node_depth_max_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return (INT2NUM(ctxt->nodeMax));
}

#num_charsNumeric

Obtain the number of characters in this context.

Returns:

  • (Numeric)


576
577
578
579
580
581
582
# File 'ext/libxml/ruby_xml_parser_context.c', line 576

static VALUE rxml_parser_context_num_chars_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return (LONG2NUM(ctxt->nbChars));
}

#>(XML: :Parser::Options::NOENT) ⇒ Object

Returns the parser options for this context. Multiple options can be combined by using Bitwise OR (|).



592
593
594
595
596
597
598
# File 'ext/libxml/ruby_xml_parser_context.c', line 592

static VALUE rxml_parser_context_options_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return INT2NUM(ctxt->options);
}

#options=(XML) ⇒ Object #XML::Parser::Options::NOCDATAObject

Provides control over the execution of a parser. Valid values are the constants defined on XML::Parser::Options. Multiple options can be combined by using Bitwise OR (|).



609
610
611
612
613
614
615
616
617
618
619
# File 'ext/libxml/ruby_xml_parser_context.c', line 609

static VALUE rxml_parser_context_options_set(VALUE self, VALUE options)
{
  int result;
  xmlParserCtxtPtr ctxt;
  Check_Type(options, T_FIXNUM);

  Data_Get_Struct(self, xmlParserCtxt, ctxt);
  result = xmlCtxtUseOptions(ctxt, NUM2INT(options));

  return self;
}

#recovery=(true) ⇒ Object

Control whether recovery mode is enabled in this context.



646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
# File 'ext/libxml/ruby_xml_parser_context.c', line 646

static VALUE rxml_parser_context_recovery_set(VALUE self, VALUE bool)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (TYPE(bool) == T_FALSE)
  {
    ctxt->recovery = 0;
    return (Qfalse);
  }
  else
  {
    ctxt->recovery = 1;
    return (Qtrue);
  }
}

#recovery?Boolean

Determine whether recovery mode is enabled in this context.

Returns:

  • (Boolean)


628
629
630
631
632
633
634
635
636
637
# File 'ext/libxml/ruby_xml_parser_context.c', line 628

static VALUE rxml_parser_context_recovery_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->recovery)
    return (Qtrue);
  else
    return (Qfalse);
}

#replace_entities=(true) ⇒ Object

Control whether external entity replacement is enabled in this context.



688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
# File 'ext/libxml/ruby_xml_parser_context.c', line 688

static VALUE rxml_parser_context_replace_entities_set(VALUE self, VALUE bool)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (TYPE(bool) == T_FALSE)
  {
    ctxt->replaceEntities = 0;
    return (Qfalse);
  }
  else
  {
    ctxt->replaceEntities = 1;
    return (Qtrue);
  }
}

#replace_entities?Boolean

Determine whether external entity replacement is enabled in this context.

Returns:

  • (Boolean)


670
671
672
673
674
675
676
677
678
679
# File 'ext/libxml/ruby_xml_parser_context.c', line 670

static VALUE rxml_parser_context_replace_entities_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->replaceEntities)
    return (Qtrue);
  else
    return (Qfalse);
}

#space_depthNumeric

Obtain the space depth for this context.

Returns:

  • (Numeric)


711
712
713
714
715
716
717
# File 'ext/libxml/ruby_xml_parser_context.c', line 711

static VALUE rxml_parser_context_space_depth_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return (INT2NUM(ctxt->spaceNr));
}

#space_depthNumeric

Obtain the maximum space depth for this context.

Returns:

  • (Numeric)


725
726
727
728
729
730
731
# File 'ext/libxml/ruby_xml_parser_context.c', line 725

static VALUE rxml_parser_context_space_depth_max_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  return (INT2NUM(ctxt->spaceMax));
}

#standalone?Boolean

Determine whether this is a standalone context.

Returns:

  • (Boolean)


832
833
834
835
836
837
838
839
840
841
# File 'ext/libxml/ruby_xml_parser_context.c', line 832

static VALUE rxml_parser_context_standalone_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->standalone)
    return (Qtrue);
  else
    return (Qfalse);
}

#stats?Boolean

Determine whether this context maintains statistics.

Returns:

  • (Boolean)


849
850
851
852
853
854
855
856
857
858
# File 'ext/libxml/ruby_xml_parser_context.c', line 849

static VALUE rxml_parser_context_stats_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->record_info)
    return (Qtrue);
  else
    return (Qfalse);
}

#subset_external?Boolean

Determine whether this context is a subset of an external context.

Returns:

  • (Boolean)


740
741
742
743
744
745
746
747
748
749
# File 'ext/libxml/ruby_xml_parser_context.c', line 740

static VALUE rxml_parser_context_subset_external_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->inSubset == 2)
    return (Qtrue);
  else
    return (Qfalse);
}

#subset_external_system_idObject

Obtain this context’s external subset system identifier. (valid only if either of subset_external? or subset_internal? is true).



815
816
817
818
819
820
821
822
823
824
# File 'ext/libxml/ruby_xml_parser_context.c', line 815

static VALUE rxml_parser_context_subset_external_system_id_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->extSubSystem == NULL)
    return (Qnil);
  else
    return (rb_str_new2((const char*) ctxt->extSubSystem));
}

#subset_external_uriObject

Obtain this context’s external subset URI. (valid only if either of subset_external? or subset_internal? is true).



796
797
798
799
800
801
802
803
804
805
# File 'ext/libxml/ruby_xml_parser_context.c', line 796

static VALUE rxml_parser_context_subset_external_uri_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->extSubURI == NULL)
    return (Qnil);
  else
    return (rb_str_new2((const char*) ctxt->extSubURI));
}

#subset_internal?Boolean

Determine whether this context is a subset of an internal context.

Returns:

  • (Boolean)


758
759
760
761
762
763
764
765
766
767
# File 'ext/libxml/ruby_xml_parser_context.c', line 758

static VALUE rxml_parser_context_subset_internal_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->inSubset == 1)
    return (Qtrue);
  else
    return (Qfalse);
}

#subset_internal_nameObject

Obtain this context’s subset name (valid only if either of subset_external? or subset_internal? is true).



777
778
779
780
781
782
783
784
785
786
# File 'ext/libxml/ruby_xml_parser_context.c', line 777

static VALUE rxml_parser_context_subset_name_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->intSubName == NULL)
    return (Qnil);
  else
    return (rb_str_new2((const char*) ctxt->intSubName));
}

#valid?Object

Determine whether this context is valid.



866
867
868
869
870
871
872
873
874
875
# File 'ext/libxml/ruby_xml_parser_context.c', line 866

static VALUE rxml_parser_context_valid_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->valid)
    return (Qtrue);
  else
    return (Qfalse);
}

#validate?Boolean

Determine whether validation is enabled in this context.

Returns:

  • (Boolean)


883
884
885
886
887
888
889
890
891
892
# File 'ext/libxml/ruby_xml_parser_context.c', line 883

static VALUE rxml_parser_context_validate_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->validate)
    return (Qtrue);
  else
    return (Qfalse);
}

#versionObject

Obtain this context’s version identifier.



900
901
902
903
904
905
906
907
908
909
# File 'ext/libxml/ruby_xml_parser_context.c', line 900

static VALUE rxml_parser_context_version_get(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->version == NULL)
    return (Qnil);
  else
    return (rb_str_new2((const char*) ctxt->version));
}

#well_formed?Boolean

Determine whether this context contains well-formed XML.

Returns:

  • (Boolean)


917
918
919
920
921
922
923
924
925
926
# File 'ext/libxml/ruby_xml_parser_context.c', line 917

static VALUE rxml_parser_context_well_formed_q(VALUE self)
{
  xmlParserCtxtPtr ctxt;
  Data_Get_Struct(self, xmlParserCtxt, ctxt);

  if (ctxt->wellFormed)
    return (Qtrue);
  else
    return (Qfalse);
}