libxml-ruby 0.9.5 → 0.9.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +28 -0
- data/README +8 -12
- data/ext/libxml/cbg.c +86 -86
- data/ext/libxml/libxml.c +875 -899
- data/ext/libxml/ruby_libxml.h +91 -65
- data/ext/libxml/ruby_xml_attr.c +485 -485
- data/ext/libxml/ruby_xml_attr.h +3 -3
- data/ext/libxml/ruby_xml_attributes.h +2 -2
- data/ext/libxml/ruby_xml_document.c +124 -307
- data/ext/libxml/ruby_xml_document.h +3 -3
- data/ext/libxml/ruby_xml_dtd.c +119 -119
- data/ext/libxml/ruby_xml_dtd.h +2 -2
- data/ext/libxml/ruby_xml_error.c +1 -1
- data/ext/libxml/ruby_xml_error.h +2 -2
- data/ext/libxml/ruby_xml_html_parser.c +119 -119
- data/ext/libxml/ruby_xml_html_parser.h +3 -3
- data/ext/libxml/ruby_xml_input.c +13 -11
- data/ext/libxml/ruby_xml_input.h +3 -3
- data/ext/libxml/ruby_xml_input_cbg.c +197 -197
- data/ext/libxml/ruby_xml_namespace.c +158 -0
- data/ext/libxml/ruby_xml_namespace.h +12 -0
- data/ext/libxml/ruby_xml_namespaces.c +303 -0
- data/ext/libxml/{ruby_xml_ns.h → ruby_xml_namespaces.h} +4 -5
- data/ext/libxml/ruby_xml_node.c +88 -293
- data/ext/libxml/ruby_xml_node.h +4 -4
- data/ext/libxml/ruby_xml_parser.c +152 -152
- data/ext/libxml/ruby_xml_parser.h +3 -3
- data/ext/libxml/ruby_xml_parser_context.c +630 -657
- data/ext/libxml/ruby_xml_parser_context.h +3 -3
- data/ext/libxml/ruby_xml_reader.c +899 -904
- data/ext/libxml/ruby_xml_reader.h +2 -2
- data/ext/libxml/ruby_xml_relaxng.h +2 -2
- data/ext/libxml/ruby_xml_sax_parser.c +175 -175
- data/ext/libxml/ruby_xml_sax_parser.h +3 -3
- data/ext/libxml/ruby_xml_schema.c +165 -165
- data/ext/libxml/ruby_xml_schema.h +2 -2
- data/ext/libxml/ruby_xml_state.h +2 -2
- data/ext/libxml/ruby_xml_xinclude.c +24 -24
- data/ext/libxml/ruby_xml_xinclude.h +3 -3
- data/ext/libxml/ruby_xml_xpath.c +108 -108
- data/ext/libxml/ruby_xml_xpath.h +3 -3
- data/ext/libxml/ruby_xml_xpath_context.c +84 -35
- data/ext/libxml/ruby_xml_xpath_context.h +3 -3
- data/ext/libxml/ruby_xml_xpath_expression.c +5 -7
- data/ext/libxml/ruby_xml_xpath_expression.h +2 -2
- data/ext/libxml/ruby_xml_xpath_object.c +7 -7
- data/ext/libxml/ruby_xml_xpath_object.h +2 -2
- data/ext/libxml/ruby_xml_xpointer.c +107 -107
- data/ext/libxml/ruby_xml_xpointer.h +3 -3
- data/ext/libxml/version.h +2 -2
- data/ext/vc/libxml_ruby.vcproj +13 -5
- data/lib/libxml.rb +4 -1
- data/lib/libxml/document.rb +40 -6
- data/lib/libxml/hpricot.rb +76 -76
- data/lib/libxml/namespace.rb +60 -0
- data/lib/libxml/namespaces.rb +36 -0
- data/lib/libxml/node.rb +90 -26
- data/lib/libxml/ns.rb +20 -0
- data/test/model/bands.xml +5 -0
- data/test/tc_attributes.rb +1 -1
- data/test/tc_document.rb +24 -41
- data/test/tc_document_write.rb +87 -115
- data/test/tc_namespace.rb +59 -0
- data/test/tc_namespaces.rb +174 -0
- data/test/tc_node.rb +41 -33
- data/test/tc_node_copy.rb +1 -1
- data/test/tc_node_edit.rb +6 -0
- data/test/tc_node_write.rb +76 -0
- data/test/tc_xinclude.rb +2 -9
- data/test/tc_xpath.rb +38 -11
- data/test/test_suite.rb +3 -1
- metadata +16 -9
- data/ext/libxml/ruby_xml_ns.c +0 -150
- data/test/ets_copy_bug.rb +0 -21
- data/test/ets_copy_bug3.rb +0 -38
- data/test/model/default_validation_bug.rb +0 -0
- data/test/tc_ns.rb +0 -18
data/ext/libxml/ruby_xml_attr.h
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
/* $Id: ruby_xml_attr.h
|
1
|
+
/* $Id: ruby_xml_attr.h 666 2008-12-07 00:16:50Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
5
|
-
#ifndef
|
6
|
-
#define
|
5
|
+
#ifndef __RXML_ATTR__
|
6
|
+
#define __RXML_ATTR__
|
7
7
|
|
8
8
|
extern VALUE cXMLAttr;
|
9
9
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: ruby_xml_document.c
|
1
|
+
/* $Id: ruby_xml_document.c 671 2008-12-08 06:06:10Z cfis $ */
|
2
2
|
|
3
3
|
/*
|
4
4
|
* Document-class: LibXML::XML::Document
|
@@ -60,6 +60,21 @@
|
|
60
60
|
|
61
61
|
VALUE cXMLDocument;
|
62
62
|
|
63
|
+
static void LibXML_validity_warning(void * ctxt, const char * msg, va_list ap)
|
64
|
+
{
|
65
|
+
if (rb_block_given_p())
|
66
|
+
{
|
67
|
+
char buff[1024];
|
68
|
+
snprintf(buff, 1024, msg, ap);
|
69
|
+
rb_yield(rb_ary_new3(2, rb_str_new2(buff), Qfalse));
|
70
|
+
}
|
71
|
+
else
|
72
|
+
{
|
73
|
+
fprintf(stderr, "warning -- found validity error: ");
|
74
|
+
fprintf(stderr, msg, ap);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
|
63
78
|
void rxml_document_free(xmlDocPtr xdoc)
|
64
79
|
{
|
65
80
|
xdoc->_private = NULL;
|
@@ -251,205 +266,27 @@ static VALUE rxml_document_child_q(VALUE self)
|
|
251
266
|
return (Qtrue);
|
252
267
|
}
|
253
268
|
|
254
|
-
/*
|
255
|
-
* call-seq:
|
256
|
-
* document.dump([stream]) -> true
|
257
|
-
*
|
258
|
-
* Dump this document's XML to the specified IO stream.
|
259
|
-
* If no stream is specified, stdout is used.
|
260
|
-
*/
|
261
|
-
static VALUE rxml_document_dump(int argc, VALUE *argv, VALUE self)
|
262
|
-
{
|
263
|
-
OpenFile *fptr;
|
264
|
-
VALUE io;
|
265
|
-
FILE *out;
|
266
|
-
xmlDocPtr xdoc;
|
267
|
-
|
268
|
-
Data_Get_Struct(self, xmlDoc, xdoc);
|
269
|
-
if (xdoc == NULL)
|
270
|
-
return (Qnil);
|
271
|
-
|
272
|
-
switch (argc)
|
273
|
-
{
|
274
|
-
case 0:
|
275
|
-
io = rb_stdout;
|
276
|
-
break;
|
277
|
-
case 1:
|
278
|
-
io = argv[0];
|
279
|
-
if (!rb_obj_is_kind_of(io, rb_cIO))
|
280
|
-
rb_raise(rb_eTypeError, "need an IO object");
|
281
|
-
break;
|
282
|
-
default:
|
283
|
-
rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)");
|
284
|
-
}
|
285
|
-
|
286
|
-
GetOpenFile(io, fptr);
|
287
|
-
rb_io_check_writable(fptr);
|
288
|
-
out = GetWriteFile(fptr);
|
289
|
-
xmlDocDump(out, xdoc);
|
290
|
-
return (Qtrue);
|
291
|
-
}
|
292
|
-
|
293
|
-
/*
|
294
|
-
* call-seq:
|
295
|
-
* document.debug_dump([stream]) -> true
|
296
|
-
*
|
297
|
-
* Debug version of dump.
|
298
|
-
*/
|
299
|
-
static VALUE rxml_document_debug_dump(int argc, VALUE *argv, VALUE self)
|
300
|
-
{
|
301
|
-
#ifdef LIBXML_DEBUG_ENABLED
|
302
|
-
OpenFile *fptr;
|
303
|
-
VALUE io;
|
304
|
-
FILE *out;
|
305
|
-
xmlDocPtr xdoc;
|
306
|
-
|
307
|
-
Data_Get_Struct(self, xmlDoc, xdoc);
|
308
|
-
if (xdoc == NULL)
|
309
|
-
return(Qnil);
|
310
|
-
|
311
|
-
switch (argc)
|
312
|
-
{
|
313
|
-
case 0:
|
314
|
-
io = rb_stderr;
|
315
|
-
break;
|
316
|
-
case 1:
|
317
|
-
io = argv[0];
|
318
|
-
if (!rb_obj_is_kind_of(io, rb_cIO))
|
319
|
-
rb_raise(rb_eTypeError, "need an IO object");
|
320
|
-
break;
|
321
|
-
default:
|
322
|
-
rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)");
|
323
|
-
}
|
324
|
-
|
325
|
-
GetOpenFile(io, fptr);
|
326
|
-
rb_io_check_writable(fptr);
|
327
|
-
out = GetWriteFile(fptr);
|
328
|
-
xmlDebugDumpDocument(out, xdoc);
|
329
|
-
return(Qtrue);
|
330
|
-
#else
|
331
|
-
rb_warn(
|
332
|
-
"libxml was compiled without debugging support. Please recompile libxml and ruby-libxml");
|
333
|
-
return (Qfalse);
|
334
|
-
#endif
|
335
|
-
}
|
336
269
|
|
337
270
|
/*
|
338
271
|
* call-seq:
|
339
|
-
*
|
272
|
+
* node.debug -> true|false
|
340
273
|
*
|
341
|
-
*
|
342
|
-
*
|
343
|
-
|
344
|
-
static VALUE
|
274
|
+
* Print libxml debugging information to stdout.
|
275
|
+
* Requires that libxml was compiled with debugging enabled.
|
276
|
+
*/
|
277
|
+
static VALUE rxml_document_debug(VALUE self)
|
345
278
|
{
|
346
279
|
#ifdef LIBXML_DEBUG_ENABLED
|
347
|
-
OpenFile *fptr;
|
348
|
-
VALUE io;
|
349
|
-
FILE *out;
|
350
280
|
xmlDocPtr xdoc;
|
351
|
-
|
352
281
|
Data_Get_Struct(self, xmlDoc, xdoc);
|
353
|
-
|
354
|
-
return
|
355
|
-
|
356
|
-
switch (argc)
|
357
|
-
{
|
358
|
-
case 0:
|
359
|
-
io = rb_stdout;
|
360
|
-
break;
|
361
|
-
case 1:
|
362
|
-
io = argv[0];
|
363
|
-
if (!rb_obj_is_kind_of(io, rb_cIO))
|
364
|
-
rb_raise(rb_eTypeError, "need an IO object");
|
365
|
-
break;
|
366
|
-
default:
|
367
|
-
rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)");
|
368
|
-
}
|
369
|
-
|
370
|
-
GetOpenFile(io, fptr);
|
371
|
-
rb_io_check_writable(fptr);
|
372
|
-
out = GetWriteFile(fptr);
|
373
|
-
xmlDebugDumpDocumentHead(out, xdoc);
|
374
|
-
return(Qtrue);
|
282
|
+
xmlDebugDumpDocument(NULL, xdoc);
|
283
|
+
return Qtrue;
|
375
284
|
#else
|
376
|
-
rb_warn(
|
377
|
-
|
378
|
-
return (Qfalse);
|
285
|
+
rb_warn("libxml was compiled without debugging support.")
|
286
|
+
return Qfalse;
|
379
287
|
#endif
|
380
288
|
}
|
381
289
|
|
382
|
-
/*
|
383
|
-
* call-seq:
|
384
|
-
* document.format_dump([stream], [spacing]) -> true
|
385
|
-
*
|
386
|
-
* Dump this document's formatted XML to the specified IO stream.
|
387
|
-
* If no stream is specified, stdout is used. If spacing is
|
388
|
-
* specified, it must be a boolean that determines whether
|
389
|
-
* spacing is used.
|
390
|
-
*/
|
391
|
-
static VALUE rxml_document_format_dump(int argc, VALUE *argv, VALUE self)
|
392
|
-
{
|
393
|
-
OpenFile *fptr;
|
394
|
-
VALUE bool, io;
|
395
|
-
FILE *out;
|
396
|
-
xmlDocPtr xdoc;
|
397
|
-
|
398
|
-
int size, spacing;
|
399
|
-
|
400
|
-
Data_Get_Struct(self, xmlDoc, xdoc);
|
401
|
-
if (xdoc == NULL)
|
402
|
-
return (Qnil);
|
403
|
-
|
404
|
-
switch (argc)
|
405
|
-
{
|
406
|
-
case 0:
|
407
|
-
io = rb_stdout;
|
408
|
-
spacing = 1;
|
409
|
-
break;
|
410
|
-
case 1:
|
411
|
-
io = argv[0];
|
412
|
-
if (!rb_obj_is_kind_of(io, rb_cIO))
|
413
|
-
rb_raise(rb_eTypeError, "need an IO object");
|
414
|
-
spacing = 1;
|
415
|
-
break;
|
416
|
-
case 2:
|
417
|
-
io = argv[0];
|
418
|
-
if (!rb_obj_is_kind_of(io, rb_cIO))
|
419
|
-
rb_raise(rb_eTypeError, "need an IO object");
|
420
|
-
bool = argv[1];
|
421
|
-
if (TYPE(bool) == T_TRUE)
|
422
|
-
spacing = 1;
|
423
|
-
else if (TYPE(bool) == T_FALSE)
|
424
|
-
spacing = 0;
|
425
|
-
else
|
426
|
-
rb_raise(rb_eTypeError,
|
427
|
-
"incorect argument type, second argument must be bool");
|
428
|
-
|
429
|
-
break;
|
430
|
-
default:
|
431
|
-
rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)");
|
432
|
-
}
|
433
|
-
|
434
|
-
GetOpenFile(io, fptr);
|
435
|
-
rb_io_check_writable(fptr);
|
436
|
-
out = GetWriteFile(fptr);
|
437
|
-
size = xmlDocFormatDump(out, xdoc, spacing);
|
438
|
-
return (INT2NUM(size));
|
439
|
-
}
|
440
|
-
|
441
|
-
/*
|
442
|
-
* call-seq:
|
443
|
-
* document.debug_format_dump([stream]) -> true
|
444
|
-
*
|
445
|
-
* *Deprecated* in favour of format_dump.
|
446
|
-
*/
|
447
|
-
static VALUE rxml_document_debug_format_dump(int argc, VALUE *argv, VALUE self)
|
448
|
-
{
|
449
|
-
rb_warn("debug_format_dump has been deprecaited, use format_dump instead");
|
450
|
-
return (rxml_document_format_dump(argc, argv, self));
|
451
|
-
}
|
452
|
-
|
453
290
|
/*
|
454
291
|
* call-seq:
|
455
292
|
* document.encoding -> "encoding"
|
@@ -479,7 +316,7 @@ static VALUE rxml_document_encoding_set(VALUE self, VALUE encoding)
|
|
479
316
|
|
480
317
|
Check_Type(encoding, T_STRING);
|
481
318
|
Data_Get_Struct(self, xmlDoc, xdoc);
|
482
|
-
xdoc->encoding = xmlStrdup(StringValuePtr(encoding));
|
319
|
+
xdoc->encoding = xmlStrdup((xmlChar *)StringValuePtr(encoding));
|
483
320
|
return (rxml_document_encoding_get(self));
|
484
321
|
}
|
485
322
|
|
@@ -673,54 +510,61 @@ static VALUE rxml_document_root_set(VALUE self, VALUE node)
|
|
673
510
|
|
674
511
|
/*
|
675
512
|
* call-seq:
|
676
|
-
* document.save(filename
|
513
|
+
* document.save(filename) -> int
|
514
|
+
* document.save(filename, :indent => true, :encoding => 'UTF-8') -> int
|
677
515
|
*
|
678
|
-
*
|
679
|
-
*
|
680
|
-
|
681
|
-
*
|
682
|
-
*
|
683
|
-
*
|
684
|
-
*
|
685
|
-
|
516
|
+
* Saves a document to a file. You may provide an optional hash table
|
517
|
+
* to control how the string is generated. Valid options are:
|
518
|
+
*
|
519
|
+
* :indent - Specifies if the string should be indented. The default value
|
520
|
+
* is true. Note that indentation is only added if both :indent is
|
521
|
+
* true and XML.indent_tree_output is true. If :indent is set to false,
|
522
|
+
* then both indentation and line feeds are removed from the result.
|
523
|
+
*
|
524
|
+
* :encoding - Specifies the output encoding of the string. It
|
525
|
+
* defaults to the original encoding of the document (see
|
526
|
+
* #encoding. To override the orginal encoding, use one of the
|
527
|
+
* XML::Input encoding constants. */
|
686
528
|
static VALUE rxml_document_save(int argc, VALUE *argv, VALUE self)
|
687
|
-
{
|
529
|
+
{
|
530
|
+
VALUE result;
|
531
|
+
VALUE options = Qnil;
|
532
|
+
VALUE filename = Qnil;
|
688
533
|
xmlDocPtr xdoc;
|
534
|
+
int indent = 1;
|
535
|
+
const char *xfilename;
|
536
|
+
const char *encoding;
|
537
|
+
xmlChar *buffer;
|
538
|
+
int length;
|
689
539
|
|
690
|
-
|
691
|
-
int format = 0;
|
692
|
-
int len;
|
540
|
+
rb_scan_args(argc, argv, "11", &filename, &options);
|
693
541
|
|
694
|
-
|
695
|
-
|
542
|
+
Check_Type(filename, T_STRING);
|
543
|
+
xfilename = StringValuePtr(filename);
|
696
544
|
|
697
|
-
|
698
|
-
|
545
|
+
Data_Get_Struct(self, xmlDoc, xdoc);
|
546
|
+
encoding = xdoc->encoding;
|
699
547
|
|
700
|
-
if (
|
548
|
+
if (!NIL_P(options))
|
701
549
|
{
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
"The second parameter (format) must be true or false");
|
713
|
-
}
|
550
|
+
VALUE rencoding, rindent;
|
551
|
+
Check_Type(options, T_HASH);
|
552
|
+
rencoding = rb_hash_aref(options, ID2SYM(rb_intern("encoding")));
|
553
|
+
rindent = rb_hash_aref(options, ID2SYM(rb_intern("indent")));
|
554
|
+
|
555
|
+
if (rindent == Qfalse)
|
556
|
+
indent = 0;
|
557
|
+
|
558
|
+
if (rencoding != Qnil)
|
559
|
+
encoding = RSTRING_PTR(rxml_input_encoding_to_s(cXMLInput, rencoding));
|
714
560
|
}
|
715
561
|
|
716
|
-
|
717
|
-
len = xmlSaveFormatFileEnc(filename, xdoc, (const char*) xdoc->encoding,
|
718
|
-
format);
|
562
|
+
length = xmlSaveFormatFileEnc(xfilename, xdoc, encoding, indent);
|
719
563
|
|
720
|
-
if (
|
721
|
-
|
564
|
+
if (length == -1)
|
565
|
+
rxml_raise(&xmlLastError);
|
722
566
|
else
|
723
|
-
return (INT2NUM(
|
567
|
+
return (INT2NUM(length));
|
724
568
|
}
|
725
569
|
|
726
570
|
/*
|
@@ -742,71 +586,53 @@ static VALUE rxml_document_standalone_q(VALUE self)
|
|
742
586
|
|
743
587
|
/*
|
744
588
|
* call-seq:
|
745
|
-
* document.to_s
|
589
|
+
* document.to_s -> "string"
|
590
|
+
* document.to_s(:indent => true, :encoding => 'UTF-8') -> "string"
|
746
591
|
*
|
747
|
-
*
|
748
|
-
*
|
749
|
-
*
|
750
|
-
*
|
592
|
+
* Converts a document, and all of its children, to a string representation.
|
593
|
+
* You may provide an optional hash table to control how the string is
|
594
|
+
* generated. Valid options are:
|
595
|
+
*
|
596
|
+
* :indent - Specifies if the string should be indented. The default value
|
597
|
+
* is true. Note that indentation is only added if both :indent is
|
598
|
+
* true and XML.indent_tree_output is true. If :indent is set to false,
|
599
|
+
* then both indentation and line feeds are removed from the result.
|
751
600
|
*
|
752
|
-
*
|
753
|
-
*
|
754
|
-
*/
|
601
|
+
* :encoding - Specifies the output encoding of the string. It
|
602
|
+
* defaults to XML::Input::UTF8. To change it, use one of the
|
603
|
+
* XML::Input encoding constants. */
|
755
604
|
static VALUE rxml_document_to_s(int argc, VALUE *argv, VALUE self)
|
756
|
-
{
|
605
|
+
{
|
606
|
+
VALUE result;
|
607
|
+
VALUE options = Qnil;
|
757
608
|
xmlDocPtr xdoc;
|
609
|
+
int indent = 1;
|
610
|
+
const char *encoding = "UTF-8";
|
611
|
+
xmlChar *buffer;
|
612
|
+
int length;
|
758
613
|
|
759
|
-
|
760
|
-
int format, len;
|
761
|
-
VALUE rresult;
|
614
|
+
rb_scan_args(argc, argv, "01", &options);
|
762
615
|
|
763
|
-
|
616
|
+
if (!NIL_P(options))
|
764
617
|
{
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
format = 0;
|
776
|
-
else
|
777
|
-
rb_raise(rb_eTypeError, "wrong type of argument, must be bool");
|
778
|
-
break;
|
779
|
-
default:
|
780
|
-
rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)");
|
618
|
+
VALUE rencoding, rindent;
|
619
|
+
Check_Type(options, T_HASH);
|
620
|
+
rencoding = rb_hash_aref(options, ID2SYM(rb_intern("encoding")));
|
621
|
+
rindent = rb_hash_aref(options, ID2SYM(rb_intern("indent")));
|
622
|
+
|
623
|
+
if (rindent == Qfalse)
|
624
|
+
indent = 0;
|
625
|
+
|
626
|
+
if (rencoding != Qnil)
|
627
|
+
encoding = RSTRING_PTR(rxml_input_encoding_to_s(cXMLInput, rencoding));
|
781
628
|
}
|
782
629
|
|
783
630
|
Data_Get_Struct(self, xmlDoc, xdoc);
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
{
|
790
|
-
if (format)
|
791
|
-
{
|
792
|
-
xmlDocDumpFormatMemoryEnc(xdoc, &result, &len, (const char*) encoding,
|
793
|
-
format);
|
794
|
-
}
|
795
|
-
else
|
796
|
-
{
|
797
|
-
xmlDocDumpMemoryEnc(xdoc, &result, &len, (const char *) encoding);
|
798
|
-
}
|
799
|
-
}
|
800
|
-
else
|
801
|
-
{
|
802
|
-
if (format)
|
803
|
-
xmlDocDumpFormatMemory(xdoc, &result, &len, format);
|
804
|
-
else
|
805
|
-
xmlDocDumpMemory(xdoc, &result, &len);
|
806
|
-
}
|
807
|
-
rresult = rb_str_new((const char*) result, len);
|
808
|
-
xmlFree(result);
|
809
|
-
return rresult;
|
631
|
+
xmlDocDumpFormatMemoryEnc(xdoc, &buffer, &length, encoding, indent);
|
632
|
+
|
633
|
+
result = rb_str_new((const char*) buffer, length);
|
634
|
+
xmlFree(buffer);
|
635
|
+
return result;
|
810
636
|
}
|
811
637
|
|
812
638
|
/*
|
@@ -889,19 +715,19 @@ void LibXML_validity_error(void * ctxt, const char * msg, va_list ap)
|
|
889
715
|
}
|
890
716
|
}
|
891
717
|
|
892
|
-
|
718
|
+
/*
|
719
|
+
* call-seq:
|
720
|
+
* document.order_elements!
|
721
|
+
*
|
722
|
+
* Call this routine to speed up XPath computation on static documents.
|
723
|
+
* This stamps all the element nodes with the document order.
|
724
|
+
*/
|
725
|
+
static VALUE rxml_document_order_elements(VALUE self)
|
893
726
|
{
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
rb_yield(rb_ary_new3(2, rb_str_new2(buff), Qfalse));
|
899
|
-
}
|
900
|
-
else
|
901
|
-
{
|
902
|
-
fprintf(stderr, "warning -- found validity error: ");
|
903
|
-
fprintf(stderr, msg, ap);
|
904
|
-
}
|
727
|
+
xmlDocPtr xdoc;
|
728
|
+
|
729
|
+
Data_Get_Struct(self, xmlDoc, xdoc);
|
730
|
+
return LONG2FIX(xmlXPathOrderDocElems(xdoc));
|
905
731
|
}
|
906
732
|
|
907
733
|
/*
|
@@ -1044,24 +870,17 @@ void ruby_init_xml_document(void)
|
|
1044
870
|
rb_define_method(cXMLDocument, "initialize", rxml_document_initialize, -1);
|
1045
871
|
rb_define_method(cXMLDocument, "child", rxml_document_child_get, 0);
|
1046
872
|
rb_define_method(cXMLDocument, "child?", rxml_document_child_q, 0);
|
1047
|
-
rb_define_method(cXMLDocument, "compression", rxml_document_compression_get,
|
1048
|
-
|
1049
|
-
rb_define_method(cXMLDocument, "compression=", rxml_document_compression_set,
|
1050
|
-
1);
|
873
|
+
rb_define_method(cXMLDocument, "compression", rxml_document_compression_get, 0);
|
874
|
+
rb_define_method(cXMLDocument, "compression=", rxml_document_compression_set, 1);
|
1051
875
|
rb_define_method(cXMLDocument, "compression?", rxml_document_compression_q, 0);
|
1052
|
-
rb_define_method(cXMLDocument, "
|
1053
|
-
rb_define_method(cXMLDocument, "debug_dump", rxml_document_debug_dump, -1);
|
1054
|
-
rb_define_method(cXMLDocument, "debug_dump_head",
|
1055
|
-
rxml_document_debug_dump_head, -1);
|
1056
|
-
rb_define_method(cXMLDocument, "debug_format_dump",
|
1057
|
-
rxml_document_debug_format_dump, -1);
|
876
|
+
rb_define_method(cXMLDocument, "debug", rxml_document_debug, 0);
|
1058
877
|
rb_define_method(cXMLDocument, "encoding", rxml_document_encoding_get, 0);
|
1059
878
|
rb_define_method(cXMLDocument, "encoding=", rxml_document_encoding_set, 1);
|
1060
|
-
rb_define_method(cXMLDocument, "format_dump", rxml_document_format_dump, -1);
|
1061
879
|
rb_define_method(cXMLDocument, "last", rxml_document_last_get, 0);
|
1062
880
|
rb_define_method(cXMLDocument, "last?", rxml_document_last_q, 0);
|
1063
881
|
rb_define_method(cXMLDocument, "next", rxml_document_next_get, 0);
|
1064
882
|
rb_define_method(cXMLDocument, "next?", rxml_document_next_q, 0);
|
883
|
+
rb_define_method(cXMLDocument, "order_elements!", rxml_document_order_elements, 0);
|
1065
884
|
rb_define_method(cXMLDocument, "parent", rxml_document_parent_get, 0);
|
1066
885
|
rb_define_method(cXMLDocument, "parent?", rxml_document_parent_q, 0);
|
1067
886
|
rb_define_method(cXMLDocument, "prev", rxml_document_prev_get, 0);
|
@@ -1075,9 +894,7 @@ void ruby_init_xml_document(void)
|
|
1075
894
|
rb_define_method(cXMLDocument, "version", rxml_document_version_get, 0);
|
1076
895
|
rb_define_method(cXMLDocument, "xinclude", rxml_document_xinclude, 0);
|
1077
896
|
rb_define_method(cXMLDocument, "validate", rxml_document_validate_dtd, 1);
|
1078
|
-
rb_define_method(cXMLDocument, "validate_schema",
|
1079
|
-
|
1080
|
-
rb_define_method(cXMLDocument, "validate_relaxng",
|
1081
|
-
rxml_document_validate_relaxng, 1);
|
897
|
+
rb_define_method(cXMLDocument, "validate_schema", rxml_document_validate_schema, 1);
|
898
|
+
rb_define_method(cXMLDocument, "validate_relaxng", rxml_document_validate_relaxng, 1);
|
1082
899
|
rb_define_method(cXMLDocument, "reader", rxml_document_reader, 0);
|
1083
900
|
}
|