Module: LibXML::XML

Defined in:
lib/libxml/attr.rb,
lib/libxml/node.rb,
lib/libxml/tree.rb,
lib/libxml/error.rb,
lib/libxml/parser.rb,
lib/libxml/schema.rb,
lib/libxml/document.rb,
lib/libxml/attr_decl.rb,
lib/libxml/namespace.rb,
lib/libxml/attributes.rb,
lib/libxml/namespaces.rb,
lib/libxml/sax_parser.rb,
lib/libxml/html_parser.rb,
lib/libxml/schema/type.rb,
lib/libxml/sax_callbacks.rb,
lib/libxml/schema/element.rb,
lib/libxml/schema/attribute.rb,
ext/libxml/ruby_xml.c

Defined Under Namespace

Modules: Encoding, XPath Classes: Attr, AttrDecl, Attributes, Document, Dtd, Error, HTMLParser, InputCallbacks, Namespace, Namespaces, Node, Parser, Reader, RelaxNG, SaxParser, Schema, Tree, Writer, XInclude

Constant Summary collapse

LIBXML_VERSION =

Constants

rb_str_new2(LIBXML_DOTTED_VERSION)
VERSION =
rb_str_new2(RUBY_LIBXML_VERSION)
VERNUM =
INT2NUM(RUBY_LIBXML_VERNUM)
XML_NAMESPACE =
rb_str_new2((const char*) XML_XML_NAMESPACE)

Class Method Summary collapse

Class Method Details

.catalog_dumptrue

Dump all the global catalog content stdout.

Returns:

  • (true)


14
15
16
17
18
# File 'ext/libxml/ruby_xml.c', line 14

static VALUE rxml_catalog_dump(VALUE self)
{
  xmlCatalogDump(stdout);
  return (Qtrue);
}

.catalog_remove(catalog) ⇒ true

Remove the specified resource catalog.

Returns:

  • (true)


26
27
28
29
30
31
# File 'ext/libxml/ruby_xml.c', line 26

static VALUE rxml_catalog_remove(VALUE self, VALUE cat)
{
  Check_Type(cat, T_STRING);
  xmlCatalogRemove((xmlChar *) StringValuePtr(cat));
  return (Qtrue);
}

.check_lib_versionstrue

Check LIBXML version matches version the bindings were compiled to. Throws an exception if not.

Returns:

  • (true)


40
41
42
43
44
# File 'ext/libxml/ruby_xml.c', line 40

static VALUE rxml_check_lib_versions(VALUE klass)
{
  xmlCheckVersion(LIBXML_VERSION);
  return (Qtrue);
}

.default_compressionObject

Determine whether parsers use Zlib compression by default (requires libxml to be compiled with Zlib support).



367
368
369
370
371
372
373
374
375
# File 'ext/libxml/ruby_xml.c', line 367

static VALUE rxml_default_compression_get(VALUE klass)
{
#ifdef HAVE_ZLIB_H
  return(INT2FIX(xmlGetCompressMode()));
#else
  rb_warn("libxml was compiled without zlib support");
  return (Qfalse);
#endif
}

.default_compression=(true) ⇒ Object

Controls whether parsers use Zlib compression by default (requires libxml to be compiled with Zlib support).



384
385
386
387
388
389
390
391
392
393
394
# File 'ext/libxml/ruby_xml.c', line 384

static VALUE rxml_default_compression_set(VALUE klass, VALUE num)
{
#ifdef HAVE_ZLIB_H
  Check_Type(num, T_FIXNUM);
  xmlSetCompressMode(FIX2INT(num));
  return(num);
#else
  rb_warn("libxml was compiled without zlib support");
  return (Qfalse);
#endif
}

.default_save_no_empty_tagsObject

Determine whether serializer outputs empty tags by default.



402
403
404
405
406
407
408
# File 'ext/libxml/ruby_xml.c', line 402

static VALUE rxml_default_save_no_empty_tags_get(VALUE klass)
{
  if (xmlSaveNoEmptyTags)
    return (Qtrue);
  else
    return (Qfalse);
}

.default_save_no_empty_tags=(true) ⇒ Object

Controls whether serializer outputs empty tags by default.



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
# File 'ext/libxml/ruby_xml.c', line 416

static VALUE rxml_default_save_no_empty_tags_set(VALUE klass, VALUE value)
{
  if (value == Qfalse)
  {
    xmlSaveNoEmptyTags = 0;
    return (Qfalse);
  }
  else if (value == Qtrue)
  {
    xmlSaveNoEmptyTags = 1;
    return (Qtrue);
  }
  else
  {
    rb_raise(rb_eArgError, "Invalid argument, must be a boolean");
  }
}

.default_tree_indent_stringObject

Obtain the default string used by parsers to indent the XML tree for output.



338
339
340
341
342
343
344
# File 'ext/libxml/ruby_xml.c', line 338

static VALUE rxml_default_tree_indent_string_get(VALUE klass)
{
  if (xmlTreeIndentString == NULL)
    return (Qnil);
  else
    return (rb_str_new2(xmlTreeIndentString));
}

.default_tree_indent_string=(string) ⇒ Object

Set the default string used by parsers to indent the XML tree for output.



353
354
355
356
357
358
# File 'ext/libxml/ruby_xml.c', line 353

static VALUE rxml_default_tree_indent_string_set(VALUE klass, VALUE string)
{
  Check_Type(string, T_STRING);
  xmlTreeIndentString = (const char *)xmlStrdup((xmlChar *)StringValuePtr(string));
  return (string);
}

.enabled_automata?Boolean

Determine whether libxml regexp automata support is enabled.

Returns:

  • (Boolean)


52
53
54
55
56
57
58
59
# File 'ext/libxml/ruby_xml.c', line 52

static VALUE rxml_enabled_automata_q(VALUE klass)
{
#ifdef LIBXML_AUTOMATA_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_c14n?Boolean

Determine whether libxml ‘canonical XML’ support is enabled. See “Canonical XML” (www.w3.org/TR/xml-c14n)

Returns:

  • (Boolean)


68
69
70
71
72
73
74
75
# File 'ext/libxml/ruby_xml.c', line 68

static VALUE rxml_enabled_c14n_q(VALUE klass)
{
#ifdef LIBXML_C14N_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_catalog?Boolean

Determine whether libxml resource catalog support is enabled.

Returns:

  • (Boolean)


83
84
85
86
87
88
89
90
# File 'ext/libxml/ruby_xml.c', line 83

static VALUE rxml_enabled_catalog_q(VALUE klass)
{
#ifdef LIBXML_CATALOG_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_debug?Boolean

Determine whether libxml debugging support is enabled.

Returns:

  • (Boolean)


98
99
100
101
102
103
104
105
# File 'ext/libxml/ruby_xml.c', line 98

static VALUE rxml_enabled_debug_q(VALUE klass)
{
#ifdef LIBXML_DEBUG_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_docbook?Boolean

Determine whether libxml docbook support is enabled.

Returns:

  • (Boolean)


113
114
115
116
117
118
119
120
# File 'ext/libxml/ruby_xml.c', line 113

static VALUE rxml_enabled_docbook_q(VALUE klass)
{
#ifdef LIBXML_DOCB_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_ftp?Boolean

Determine whether libxml ftp client support is enabled.

Returns:

  • (Boolean)


128
129
130
131
132
133
134
135
# File 'ext/libxml/ruby_xml.c', line 128

static VALUE rxml_enabled_ftp_q(VALUE klass)
{
#ifdef LIBXML_FTP_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_html?Boolean

Determine whether libxml html support is enabled.

Returns:

  • (Boolean)


158
159
160
161
162
163
164
165
# File 'ext/libxml/ruby_xml.c', line 158

static VALUE rxml_enabled_html_q(VALUE klass)
{
#ifdef LIBXML_HTML_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_http?Boolean

Determine whether libxml http client support is enabled.

Returns:

  • (Boolean)


143
144
145
146
147
148
149
150
# File 'ext/libxml/ruby_xml.c', line 143

static VALUE rxml_enabled_http_q(VALUE klass)
{
#ifdef LIBXML_HTTP_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_iconv?Boolean

Determine whether libxml iconv support is enabled.

Returns:

  • (Boolean)


173
174
175
176
177
178
179
180
# File 'ext/libxml/ruby_xml.c', line 173

static VALUE rxml_enabled_iconv_q(VALUE klass)
{
#ifdef LIBXML_ICONV_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_memory_debug?Boolean

Determine whether libxml memory location debugging support is enabled.

Returns:

  • (Boolean)


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

static VALUE rxml_enabled_memory_debug_location_q(VALUE klass)
{
#ifdef DEBUG_MEMORY_LOCATION
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_regexp?Boolean

Determine whether libxml regular expression support is enabled.

Returns:

  • (Boolean)


204
205
206
207
208
209
210
211
# File 'ext/libxml/ruby_xml.c', line 204

static VALUE rxml_enabled_regexp_q(VALUE klass)
{
#ifdef LIBXML_REGEXP_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_schemas?Boolean

Determine whether libxml schema support is enabled.

Returns:

  • (Boolean)


219
220
221
222
223
224
225
226
# File 'ext/libxml/ruby_xml.c', line 219

static VALUE rxml_enabled_schemas_q(VALUE klass)
{
#ifdef LIBXML_SCHEMAS_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_thread?Boolean

Determine whether thread-safe semantics support for libxml is enabled and is used by this ruby extension. Threading support in libxml uses pthread on Unix-like systems and Win32 threads on Windows.

Returns:

  • (Boolean)


236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'ext/libxml/ruby_xml.c', line 236

static VALUE rxml_enabled_thread_q(VALUE klass)
{
  /* This won't be defined unless this code is compiled with _REENTRANT or __MT__
   * defined or the compiler is in C99 mode.
   *
   * Note the relevant portion libxml/xmlversion.h on a thread-enabled build:
   *
   *    #if defined(_REENTRANT) || defined(__MT__) || \
   *        (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L))
   *        #define LIBXML_THREAD_ENABLED
   *    #endif
   *
   */
#ifdef LIBXML_THREAD_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_unicode?Boolean

Determine whether libxml unicode support is enabled.

Returns:

  • (Boolean)


262
263
264
265
266
267
268
269
# File 'ext/libxml/ruby_xml.c', line 262

static VALUE rxml_enabled_unicode_q(VALUE klass)
{
#ifdef LIBXML_UNICODE_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_xinclude?Boolean

Determine whether libxml xinclude support is enabled.

Returns:

  • (Boolean)


277
278
279
280
281
282
283
284
# File 'ext/libxml/ruby_xml.c', line 277

static VALUE rxml_enabled_xinclude_q(VALUE klass)
{
#ifdef LIBXML_XINCLUDE_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_xpath?Boolean

Determine whether libxml xpath support is enabled.

Returns:

  • (Boolean)


292
293
294
295
296
297
298
299
# File 'ext/libxml/ruby_xml.c', line 292

static VALUE rxml_enabled_xpath_q(VALUE klass)
{
#ifdef LIBXML_XPATH_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_xpointer?Boolean

Determine whether libxml xpointer support is enabled.

Returns:

  • (Boolean)


307
308
309
310
311
312
313
314
# File 'ext/libxml/ruby_xml.c', line 307

static VALUE rxml_enabled_xpointer_q(VALUE klass)
{
#ifdef LIBXML_XPTR_ENABLED
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.enabled_zlib?Boolean

Determine whether libxml zlib support is enabled.

Returns:

  • (Boolean)


322
323
324
325
326
327
328
329
# File 'ext/libxml/ruby_xml.c', line 322

static VALUE rxml_enabled_zlib_q(VALUE klass)
{
#ifdef HAVE_ZLIB_H
  return(Qtrue);
#else
  return (Qfalse);
#endif
}

.indent_tree_outputObject

Determines whether XML output will be indented (using the string supplied to default_indent_tree_string)



441
442
443
444
445
446
447
# File 'ext/libxml/ruby_xml.c', line 441

static VALUE rxml_indent_tree_output_get(VALUE klass)
{
  if (xmlIndentTreeOutput)
    return (Qtrue);
  else
    return (Qfalse);
}

.indent_tree_output=(true) ⇒ Object

Controls whether XML output will be indented (using the string supplied to default_indent_tree_string)



456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
# File 'ext/libxml/ruby_xml.c', line 456

static VALUE rxml_indent_tree_output_set(VALUE klass, VALUE value)
{
  if (value == Qtrue)
  {
    xmlIndentTreeOutput = 1;
    return (Qtrue);
  }
  else if (value == Qfalse)
  {
    xmlIndentTreeOutput = 0;
    return (Qfalse);
  }
  else
  {
    rb_raise(rb_eArgError, "Invalid argument, must be boolean");
  }
}

.memory_dumpObject

Perform a parser memory dump (requires memory debugging support in libxml).



481
482
483
484
485
486
487
488
489
490
# File 'ext/libxml/ruby_xml.c', line 481

static VALUE rxml_memory_dump(VALUE self)
{
#ifdef DEBUG_MEMORY_LOCATION
  xmlMemoryDump();
  return(Qtrue);
#else
  rb_warn("libxml was compiled without memory debugging support");
  return (Qfalse);
#endif
}

.memory_usedObject

Perform a parser memory dump (requires memory debugging support in libxml).



499
500
501
502
503
504
505
506
507
# File 'ext/libxml/ruby_xml.c', line 499

static VALUE rxml_memory_used(VALUE self)
{
#ifdef DEBUG_MEMORY_LOCATION
  return(INT2NUM(xmlMemUsed()));
#else
  rb_warn("libxml was compiled without memory debugging support");
  return (Qfalse);
#endif
}