Class: LibXML::XML::Parser::Context
- Inherits:
-
Object
- Object
- LibXML::XML::Parser::Context
- 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
Class Method Summary collapse
-
.XML::Parser::Context.document(document) ⇒ XML::Parser::Context
Creates a new parser context based on the specified document.
-
.XML::Parser::Context.file(file) ⇒ XML::Parser::Context
Creates a new parser context based on the specified file or uri.
-
.XML::Parser::Context.io(io) ⇒ XML::Parser::Context
Creates a new parser context based on the specified io object.
-
.XML::Parser::Context.string(string) ⇒ XML::Parser::Context
Creates a new parser context based on the specified string.
Instance Method Summary collapse
-
#base_uri ⇒ Object
Obtain the base url for this parser context.
-
#base_uri=(url) ⇒ Object
Sets the base url for this parser context.
-
#close ⇒ nil
Closes the underlying input streams.
-
#data_directory ⇒ Object
Obtain the data directory associated with this context.
-
#depth ⇒ Numeric
Obtain the depth of this context.
-
#disable_cdata=(value) ⇒ Object
Control whether CDATA nodes will be created in this context.
-
#disable_cdata? ⇒ Boolean
Determine whether CDATA nodes will be created in this context.
-
#disable_sax? ⇒ Boolean
Determine whether SAX-based processing is disabled in this context.
-
#docbook? ⇒ Boolean
Determine whether this is a docbook context.
-
#encoding ⇒ XML::Encoding::UTF_8
Obtain the character encoding identifier used in this context.
-
#encoding=(XML) ⇒ Object
Sets the character encoding for this context.
-
#errno ⇒ Numeric
Obtain the last-error number in this context.
-
#html? ⇒ Boolean
Determine whether this is an html context.
-
#max_num_streams ⇒ Numeric
Obtain the limit on the number of IO streams opened in this context.
-
#num_streams ⇒ Object
Obtain the actual number of IO streams in this context.
-
#keep_blanks? ⇒ Boolean
Determine whether parsers in this context retain whitespace.
-
#name_depth ⇒ Numeric
Obtain the name depth for this context.
-
#name_depth_max ⇒ Numeric
Obtain the maximum name depth for this context.
-
#name_node ⇒ Object
Obtain the name node for this context.
-
#name_tab ⇒ Array
Obtain the name table for this context.
-
#node ⇒ Object
Obtain the root node of this context.
-
#node_depth ⇒ Numeric
Obtain the node depth for this context.
-
#node_depth_max ⇒ Numeric
Obtain the maximum node depth for this context.
-
#num_chars ⇒ Numeric
Obtain the number of characters in this context.
-
#>(XML: :Parser::Options::NOENT) ⇒ Object
Returns the parser options for this context.
-
#options=(options) ⇒ Object
Provides control over the execution of a parser.
-
#recovery=(true) ⇒ Object
Control whether recovery mode is enabled in this context.
-
#recovery? ⇒ Boolean
Determine whether recovery mode is enabled in this context.
-
#replace_entities=(true) ⇒ Object
Control whether external entity replacement is enabled in this context.
-
#replace_entities? ⇒ Boolean
Determine whether external entity replacement is enabled in this context.
-
#space_depth ⇒ Numeric
Obtain the space depth for this context.
-
#space_depth ⇒ Numeric
Obtain the maximum space depth for this context.
-
#standalone? ⇒ Boolean
Determine whether this is a standalone context.
-
#stats? ⇒ Boolean
Determine whether this context maintains statistics.
-
#subset_external? ⇒ Boolean
Determine whether this context is a subset of an external context.
-
#subset_external_system_id ⇒ Object
Obtain this context’s external subset system identifier.
-
#subset_external_uri ⇒ Object
Obtain this context’s external subset URI.
-
#subset_internal? ⇒ Boolean
Determine whether this context is a subset of an internal context.
-
#subset_internal_name ⇒ Object
Obtain this context’s subset name (valid only if either of subset_external? or subset_internal? is true).
-
#valid? ⇒ Object
Determine whether this context is valid.
-
#validate? ⇒ Boolean
Determine whether validation is enabled in this context.
-
#version ⇒ Object
Obtain this context’s version identifier.
-
#well_formed? ⇒ Boolean
Determine whether this context contains well-formed XML.
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
options - A or'ed together list of LibXML::XML::Parser::Options values
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 45
static VALUE rxml_parser_context_document(int argc, VALUE* argv, VALUE klass)
{
VALUE document, options;
rb_scan_args(argc, argv, "11", &document, &options);
if (rb_obj_is_kind_of(document, cXMLDocument) == Qfalse)
rb_raise(rb_eTypeError, "Must pass an LibXML::XML::Document object");
xmlDocPtr xdoc;
xmlChar *buffer;
int length;
Data_Get_Struct(document, xmlDoc, xdoc);
xmlDocDumpFormatMemoryEnc(xdoc, &buffer, &length, (const char*)xdoc->encoding, 0);
xmlParserCtxtPtr ctxt = xmlCreateDocParserCtxt(buffer);
if (!ctxt)
rxml_raise(xmlGetLastError());
/* 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, options == Qnil ? 0 : NUM2INT(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
options - A or'ed together list of LibXML::XML::Parser::Options values
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 83
static VALUE rxml_parser_context_file(int argc, VALUE* argv, VALUE klass)
{
VALUE file, options;
rb_scan_args(argc, argv, "11", &file, &options);
xmlParserCtxtPtr ctxt = xmlCreateURLParserCtxt(StringValuePtr(file), 0);
if (!ctxt)
rxml_raise(xmlGetLastError());
/* 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, options == Qnil ? 0 : NUM2INT(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
options - A or'ed together list of LibXML::XML::Parser::Options values
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 146
static VALUE rxml_parser_context_io(int argc, VALUE* argv, VALUE klass)
{
VALUE io, options;
rb_scan_args(argc, argv, "11", &io, &options);
if (NIL_P(io))
rb_raise(rb_eTypeError, "Must pass in an IO object");
xmlParserInputBufferPtr input = xmlParserInputBufferCreateIO((xmlInputReadCallback) rxml_read_callback, NULL,
(void*)io, XML_CHAR_ENCODING_NONE);
xmlParserCtxtPtr ctxt = xmlNewParserCtxt();
if (!ctxt)
{
xmlFreeParserInputBuffer(input);
rxml_raise(xmlGetLastError());
}
/* 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, options == Qnil ? 0 : NUM2INT(options));
xmlParserInputPtr stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
if (!stream)
{
xmlFreeParserInputBuffer(input);
xmlFreeParserCtxt(ctxt);
rxml_raise(xmlGetLastError());
}
inputPush(ctxt, stream);
VALUE 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
options - A or'ed together list of LibXML::XML::Parser::Options values
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 112
static VALUE rxml_parser_context_string(int argc, VALUE* argv, VALUE klass)
{
VALUE string, options;
rb_scan_args(argc, argv, "11", &string, &options);
Check_Type(string, T_STRING);
if (RSTRING_LEN(string) == 0)
rb_raise(rb_eArgError, "Must specify a string with one or more characters");
xmlParserCtxtPtr ctxt = xmlCreateMemoryParserCtxt(StringValuePtr(string), (int)RSTRING_LEN(string));
if (!ctxt)
rxml_raise(xmlGetLastError());
/* 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, options == Qnil ? 0 : NUM2INT(options));
return rxml_parser_context_wrap(ctxt);
}
|
Instance Method Details
#base_uri ⇒ Object
Obtain the base url for this parser context.
194 195 196 197 198 199 200 201 202 203 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 194
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 rxml_new_cstr((const xmlChar*)ctxt->input->filename, ctxt->encoding);
else
return Qnil;
}
|
#base_uri=(url) ⇒ Object
Sets the base url for this parser context.
211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 211
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 char* xurl = StringValuePtr(url);
ctxt->input->filename = (const char*)xmlStrdup((const xmlChar*)xurl);
}
return self;
}
|
#close ⇒ nil
Closes the underlying input streams. This is useful when parsing a large amount of files and you want to close the files without relying on Ruby’s garbage collector to run.
234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 234
static VALUE rxml_parser_context_close(VALUE self)
{
xmlParserCtxtPtr ctxt;
xmlParserInputPtr xinput;
Data_Get_Struct(self, xmlParserCtxt, ctxt);
while ((xinput = inputPop(ctxt)) != NULL)
{
xmlFreeInputStream(xinput);
}
return Qnil;
}
|
#data_directory ⇒ Object
Obtain the data directory associated with this context.
253 254 255 256 257 258 259 260 261 262 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 253
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 (rxml_new_cstr((const xmlChar*)ctxt->directory, ctxt->encoding));
}
|
#depth ⇒ Numeric
Obtain the depth of this context.
270 271 272 273 274 275 276 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 270
static VALUE rxml_parser_context_depth_get(VALUE self)
{
xmlParserCtxtPtr ctxt;
Data_Get_Struct(self, xmlParserCtxt, ctxt);
return (INT2NUM(ctxt->depth));
}
|
#disable_cdata=(value) ⇒ Object
Control whether CDATA nodes will be created in this context.
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 302
static VALUE rxml_parser_context_disable_cdata_set(VALUE self, VALUE value)
{
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 (value)
ctxt->sax->cdataBlock = NULL;
else
ctxt->sax->cdataBlock = xmlSAX2CDataBlock;
return value;
}
|
#disable_cdata? ⇒ Boolean
Determine whether CDATA nodes will be created in this context.
284 285 286 287 288 289 290 291 292 293 294 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 284
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.
326 327 328 329 330 331 332 333 334 335 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 326
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.
343 344 345 346 347 348 349 350 351 352 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 343
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);
}
|
#encoding ⇒ XML::Encoding::UTF_8
Obtain the character encoding identifier used in this context.
361 362 363 364 365 366 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 361
static VALUE rxml_parser_context_encoding_get(VALUE self)
{
xmlParserCtxtPtr ctxt;
Data_Get_Struct(self, xmlParserCtxt, ctxt);
return INT2NUM(xmlParseCharEncoding((const char*)ctxt->encoding));
}
|
#encoding=(XML) ⇒ Object
Sets the character encoding for this context.
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 374
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_eArgError, "Unknown encoding: %i", NUM2INT(encoding));
Data_Get_Struct(self, xmlParserCtxt, ctxt);
result = xmlSwitchToEncoding(ctxt, hdlr);
if (result != 0)
rxml_raise(xmlGetLastError());
if (ctxt->encoding != NULL)
xmlFree((xmlChar *) ctxt->encoding);
ctxt->encoding = xmlStrdup((const xmlChar *) xencoding);
return self;
}
|
#errno ⇒ Numeric
Obtain the last-error number in this context.
403 404 405 406 407 408 409 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 403
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.
417 418 419 420 421 422 423 424 425 426 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 417
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_streams ⇒ Numeric
Obtain the limit on the number of IO streams opened in this context.
435 436 437 438 439 440 441 442 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 435
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_streams ⇒ Object
Obtain the actual number of IO streams in this context.
451 452 453 454 455 456 457 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 451
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.
466 467 468 469 470 471 472 473 474 475 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 466
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_depth ⇒ Numeric
Obtain the name depth for this context.
483 484 485 486 487 488 489 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 483
static VALUE rxml_parser_context_name_depth_get(VALUE self)
{
xmlParserCtxtPtr ctxt;
Data_Get_Struct(self, xmlParserCtxt, ctxt);
return (INT2NUM(ctxt->nameNr));
}
|
#name_depth_max ⇒ Numeric
Obtain the maximum name depth for this context.
497 498 499 500 501 502 503 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 497
static VALUE rxml_parser_context_name_depth_max_get(VALUE self)
{
xmlParserCtxtPtr ctxt;
Data_Get_Struct(self, xmlParserCtxt, ctxt);
return (INT2NUM(ctxt->nameMax));
}
|
#name_node ⇒ Object
Obtain the name node for this context.
511 512 513 514 515 516 517 518 519 520 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 511
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 (rxml_new_cstr( ctxt->name, ctxt->encoding));
}
|
#name_tab ⇒ Array
Obtain the name table for this context.
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 528
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, rxml_new_cstr( ctxt->nameTab[i], ctxt->encoding));
}
return (tab_ary);
}
|
#node ⇒ Object
Obtain the root node of this context.
572 573 574 575 576 577 578 579 580 581 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 572
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_depth ⇒ Numeric
Obtain the node depth for this context.
558 559 560 561 562 563 564 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 558
static VALUE rxml_parser_context_node_depth_get(VALUE self)
{
xmlParserCtxtPtr ctxt;
Data_Get_Struct(self, xmlParserCtxt, ctxt);
return (INT2NUM(ctxt->nodeNr));
}
|
#node_depth_max ⇒ Numeric
Obtain the maximum node depth for this context.
589 590 591 592 593 594 595 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 589
static VALUE rxml_parser_context_node_depth_max_get(VALUE self)
{
xmlParserCtxtPtr ctxt;
Data_Get_Struct(self, xmlParserCtxt, ctxt);
return (INT2NUM(ctxt->nodeMax));
}
|
#num_chars ⇒ Numeric
Obtain the number of characters in this context.
603 604 605 606 607 608 609 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 603
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 (|).
619 620 621 622 623 624 625 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 619
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::NOCDATA ⇒ Object
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 (|).
636 637 638 639 640 641 642 643 644 645 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 636
static VALUE rxml_parser_context_options_set(VALUE self, VALUE options)
{
xmlParserCtxtPtr ctxt;
Check_Type(options, T_FIXNUM);
Data_Get_Struct(self, xmlParserCtxt, ctxt);
xmlCtxtUseOptions(ctxt, NUM2INT(options));
return self;
}
|
#recovery=(true) ⇒ Object
Control whether recovery mode is enabled in this context.
672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 672
static VALUE rxml_parser_context_recovery_set(VALUE self, VALUE value)
{
xmlParserCtxtPtr ctxt;
Data_Get_Struct(self, xmlParserCtxt, ctxt);
if (value == Qfalse)
{
ctxt->recovery = 0;
return (Qfalse);
}
else
{
ctxt->recovery = 1;
return (Qtrue);
}
}
|
#recovery? ⇒ Boolean
Determine whether recovery mode is enabled in this context.
654 655 656 657 658 659 660 661 662 663 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 654
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.
714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 714
static VALUE rxml_parser_context_replace_entities_set(VALUE self, VALUE value)
{
xmlParserCtxtPtr ctxt;
Data_Get_Struct(self, xmlParserCtxt, ctxt);
if (value == Qfalse)
{
ctxt->replaceEntities = 0;
return (Qfalse);
}
else
{
ctxt->replaceEntities = 1;
return (Qtrue);
}
}
|
#replace_entities? ⇒ Boolean
Determine whether external entity replacement is enabled in this context.
696 697 698 699 700 701 702 703 704 705 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 696
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_depth ⇒ Numeric
Obtain the space depth for this context.
737 738 739 740 741 742 743 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 737
static VALUE rxml_parser_context_space_depth_get(VALUE self)
{
xmlParserCtxtPtr ctxt;
Data_Get_Struct(self, xmlParserCtxt, ctxt);
return (INT2NUM(ctxt->spaceNr));
}
|
#space_depth ⇒ Numeric
Obtain the maximum space depth for this context.
751 752 753 754 755 756 757 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 751
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.
858 859 860 861 862 863 864 865 866 867 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 858
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.
875 876 877 878 879 880 881 882 883 884 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 875
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.
766 767 768 769 770 771 772 773 774 775 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 766
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_id ⇒ Object
Obtain this context’s external subset system identifier. (valid only if either of subset_external? or subset_internal? is true).
841 842 843 844 845 846 847 848 849 850 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 841
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 (rxml_new_cstr( ctxt->extSubSystem, ctxt->encoding));
}
|
#subset_external_uri ⇒ Object
Obtain this context’s external subset URI. (valid only if either of subset_external? or subset_internal? is true).
822 823 824 825 826 827 828 829 830 831 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 822
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 (rxml_new_cstr( ctxt->extSubURI, ctxt->encoding));
}
|
#subset_internal? ⇒ Boolean
Determine whether this context is a subset of an internal context.
784 785 786 787 788 789 790 791 792 793 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 784
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_name ⇒ Object
Obtain this context’s subset name (valid only if either of subset_external? or subset_internal? is true).
803 804 805 806 807 808 809 810 811 812 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 803
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 (rxml_new_cstr(ctxt->intSubName, ctxt->encoding));
}
|
#valid? ⇒ Object
Determine whether this context is valid.
892 893 894 895 896 897 898 899 900 901 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 892
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.
909 910 911 912 913 914 915 916 917 918 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 909
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);
}
|
#version ⇒ Object
Obtain this context’s version identifier.
926 927 928 929 930 931 932 933 934 935 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 926
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 (rxml_new_cstr( ctxt->version, ctxt->encoding));
}
|
#well_formed? ⇒ Boolean
Determine whether this context contains well-formed XML.
943 944 945 946 947 948 949 950 951 952 |
# File 'ext/libxml/ruby_xml_parser_context.c', line 943
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);
}
|