libxml-ruby 1.1.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{CHANGES → HISTORY} +35 -0
- data/LICENSE +1 -0
- data/MANIFEST +165 -0
- data/{README → README.rdoc} +2 -2
- data/Rakefile +47 -147
- data/ext/libxml/libxml.c +17 -1
- data/ext/libxml/ruby_libxml.h +9 -1
- data/ext/libxml/ruby_xml_attr.c +3 -3
- data/ext/libxml/ruby_xml_attr_decl.c +32 -32
- data/ext/libxml/ruby_xml_attributes.c +1 -1
- data/ext/libxml/ruby_xml_cbg.c +1 -2
- data/ext/libxml/ruby_xml_document.c +26 -4
- data/ext/libxml/ruby_xml_dtd.c +3 -3
- data/ext/libxml/ruby_xml_encoding.c +92 -5
- data/ext/libxml/ruby_xml_encoding.h +4 -0
- data/ext/libxml/ruby_xml_namespace.c +2 -2
- data/ext/libxml/ruby_xml_node.c +14 -14
- data/ext/libxml/ruby_xml_parser_context.c +8 -8
- data/ext/libxml/ruby_xml_reader.c +98 -43
- data/ext/libxml/ruby_xml_sax2_handler.c +13 -1
- data/ext/libxml/ruby_xml_sax_parser.c +4 -5
- data/ext/libxml/ruby_xml_version.h +5 -5
- data/ext/libxml/ruby_xml_xpath_context.c +9 -6
- data/ext/libxml/ruby_xml_xpath_object.c +1 -1
- data/ext/vc/libxml_ruby.sln +4 -4
- data/lib/libxml.rb +29 -29
- data/lib/libxml/attr.rb +112 -110
- data/lib/libxml/attr_decl.rb +2 -0
- data/lib/libxml/attributes.rb +13 -11
- data/lib/libxml/document.rb +192 -190
- data/lib/libxml/error.rb +89 -87
- data/lib/libxml/hpricot.rb +77 -75
- data/lib/libxml/html_parser.rb +96 -94
- data/lib/libxml/namespace.rb +61 -59
- data/lib/libxml/namespaces.rb +37 -35
- data/lib/libxml/node.rb +398 -384
- data/lib/libxml/ns.rb +21 -19
- data/lib/libxml/parser.rb +366 -364
- data/lib/libxml/properties.rb +22 -20
- data/lib/libxml/reader.rb +2 -0
- data/lib/libxml/sax_callbacks.rb +179 -177
- data/lib/libxml/sax_parser.rb +57 -55
- data/lib/libxml/tree.rb +28 -26
- data/lib/libxml/xpath_object.rb +15 -13
- data/lib/xml.rb +16 -14
- data/lib/xml/libxml.rb +10 -8
- data/libxml-ruby.gemspec +50 -0
- data/script/benchmark/depixelate +634 -0
- data/script/benchmark/hamlet.xml +9055 -0
- data/script/benchmark/parsecount +170 -0
- data/script/benchmark/sock_entries.xml +507 -0
- data/script/benchmark/throughput +41 -0
- data/script/test +6 -0
- data/test/etc_doc_to_s.rb +21 -19
- data/test/ets_doc_file.rb +17 -15
- data/test/ets_doc_to_s.rb +23 -21
- data/test/ets_gpx.rb +28 -26
- data/test/ets_node_gc.rb +23 -21
- data/test/ets_tsr.rb +11 -9
- data/test/model/bands.iso-8859-1.xml +5 -0
- data/test/model/bands.utf-8.xml +5 -0
- data/test/rb-magic-comment.rb +33 -0
- data/test/tc_attr.rb +181 -170
- data/test/tc_attr_decl.rb +3 -1
- data/test/tc_attributes.rb +134 -132
- data/test/tc_deprecated_require.rb +13 -11
- data/test/tc_document.rb +119 -113
- data/test/tc_document_write.rb +186 -117
- data/test/tc_dtd.rb +125 -123
- data/test/tc_error.rb +3 -1
- data/test/tc_html_parser.rb +139 -137
- data/test/tc_namespace.rb +61 -58
- data/test/tc_namespaces.rb +176 -173
- data/test/tc_node.rb +257 -180
- data/test/tc_node_cdata.rb +51 -49
- data/test/tc_node_comment.rb +33 -30
- data/test/tc_node_copy.rb +42 -40
- data/test/tc_node_edit.rb +159 -157
- data/test/tc_node_text.rb +71 -69
- data/test/tc_node_write.rb +41 -16
- data/test/tc_node_xlink.rb +29 -26
- data/test/tc_parser.rb +335 -329
- data/test/tc_parser_context.rb +188 -185
- data/test/tc_properties.rb +39 -36
- data/test/tc_reader.rb +297 -283
- data/test/tc_relaxng.rb +54 -51
- data/test/tc_sax_parser.rb +275 -273
- data/test/tc_schema.rb +53 -51
- data/test/tc_traversal.rb +222 -220
- data/test/tc_xinclude.rb +21 -19
- data/test/tc_xml.rb +3 -1
- data/test/tc_xpath.rb +195 -193
- data/test/tc_xpath_context.rb +80 -78
- data/test/tc_xpath_expression.rb +38 -35
- data/test/tc_xpointer.rb +74 -72
- data/test/test_helper.rb +14 -0
- data/test/test_suite.rb +39 -33
- metadata +65 -105
- data/doc/css/normal.css +0 -182
- data/doc/img/raze-tiny.png +0 -0
- data/doc/img/red-cube.jpg +0 -0
- data/doc/img/xml-ruby.png +0 -0
- data/doc/index.xml +0 -43
- data/doc/install.xml +0 -77
- data/doc/layout.rhtml +0 -38
- data/doc/layout.xsl +0 -67
- data/doc/license.xml +0 -32
- data/doc/log/changelog.xml +0 -1324
- data/doc/log/changelog.xsl +0 -42
- data/ext/libxml/Makefile +0 -156
- data/ext/libxml/extconf.h +0 -5
- data/ext/libxml/libxml-ruby.so.a +0 -0
- data/ext/libxml/libxml.o +0 -0
- data/ext/libxml/libxml_ruby.so +0 -0
- data/ext/libxml/mkmf.log +0 -129
- data/ext/libxml/ruby_xml.o +0 -0
- data/ext/libxml/ruby_xml_attr.o +0 -0
- data/ext/libxml/ruby_xml_attr_decl.o +0 -0
- data/ext/libxml/ruby_xml_attributes.o +0 -0
- data/ext/libxml/ruby_xml_cbg.o +0 -0
- data/ext/libxml/ruby_xml_document.o +0 -0
- data/ext/libxml/ruby_xml_dtd.o +0 -0
- data/ext/libxml/ruby_xml_encoding.o +0 -0
- data/ext/libxml/ruby_xml_error.o +0 -0
- data/ext/libxml/ruby_xml_html_parser.o +0 -0
- data/ext/libxml/ruby_xml_html_parser_context.o +0 -0
- data/ext/libxml/ruby_xml_html_parser_options.o +0 -0
- data/ext/libxml/ruby_xml_input_cbg.o +0 -0
- data/ext/libxml/ruby_xml_io.o +0 -0
- data/ext/libxml/ruby_xml_namespace.o +0 -0
- data/ext/libxml/ruby_xml_namespaces.o +0 -0
- data/ext/libxml/ruby_xml_node.o +0 -0
- data/ext/libxml/ruby_xml_parser.o +0 -0
- data/ext/libxml/ruby_xml_parser_context.o +0 -0
- data/ext/libxml/ruby_xml_parser_options.o +0 -0
- data/ext/libxml/ruby_xml_reader.o +0 -0
- data/ext/libxml/ruby_xml_relaxng.o +0 -0
- data/ext/libxml/ruby_xml_sax2_handler.o +0 -0
- data/ext/libxml/ruby_xml_sax_parser.o +0 -0
- data/ext/libxml/ruby_xml_schema.o +0 -0
- data/ext/libxml/ruby_xml_xinclude.o +0 -0
- data/ext/libxml/ruby_xml_xpath.o +0 -0
- data/ext/libxml/ruby_xml_xpath_context.o +0 -0
- data/ext/libxml/ruby_xml_xpath_expression.o +0 -0
- data/ext/libxml/ruby_xml_xpath_object.o +0 -0
- data/ext/libxml/ruby_xml_xpointer.o +0 -0
@@ -98,7 +98,7 @@ static VALUE rxml_namespace_href_get(VALUE self)
|
|
98
98
|
if (xns->href == NULL)
|
99
99
|
return Qnil;
|
100
100
|
else
|
101
|
-
return
|
101
|
+
return rxml_str_new2((const char*) xns->href, xns->context ? xns->context->encoding : NULL);
|
102
102
|
}
|
103
103
|
|
104
104
|
/*
|
@@ -133,7 +133,7 @@ static VALUE rxml_namespace_prefix_get(VALUE self)
|
|
133
133
|
if (xns->prefix == NULL)
|
134
134
|
return Qnil;
|
135
135
|
else
|
136
|
-
return
|
136
|
+
return rxml_str_new2((const char*) xns->prefix, xns->context ? xns->context->encoding : NULL);
|
137
137
|
}
|
138
138
|
|
139
139
|
/*
|
data/ext/libxml/ruby_xml_node.c
CHANGED
@@ -279,7 +279,7 @@ static VALUE rxml_node_base_uri_get(VALUE self)
|
|
279
279
|
base_uri = xmlNodeGetBase(xnode->doc, xnode);
|
280
280
|
if (base_uri)
|
281
281
|
{
|
282
|
-
result =
|
282
|
+
result = rxml_str_new2((const char*) base_uri, xnode->doc ? xnode->doc->encoding : NULL);
|
283
283
|
xmlFree(base_uri);
|
284
284
|
}
|
285
285
|
|
@@ -323,7 +323,7 @@ static VALUE rxml_node_content_get(VALUE self)
|
|
323
323
|
content = xmlNodeGetContent(xnode);
|
324
324
|
if (content)
|
325
325
|
{
|
326
|
-
result =
|
326
|
+
result = rxml_str_new2((const char *) content, xnode->doc ? xnode->doc->encoding : NULL);
|
327
327
|
xmlFree(content);
|
328
328
|
}
|
329
329
|
|
@@ -370,7 +370,7 @@ static VALUE rxml_node_content_stripped_get(VALUE self)
|
|
370
370
|
content = xmlNodeGetContent(xnode);
|
371
371
|
if (content)
|
372
372
|
{
|
373
|
-
result =
|
373
|
+
result = rxml_str_new2((const char*) content, xnode->doc ? xnode->doc->encoding : NULL);
|
374
374
|
xmlFree(content);
|
375
375
|
}
|
376
376
|
return (result);
|
@@ -538,7 +538,7 @@ static VALUE rxml_node_to_s(int argc, VALUE *argv, VALUE self)
|
|
538
538
|
|
539
539
|
int level = 0;
|
540
540
|
int indent = 1;
|
541
|
-
const char *xencoding =
|
541
|
+
const char *xencoding = "UTF-8";
|
542
542
|
|
543
543
|
rb_scan_args(argc, argv, "01", &options);
|
544
544
|
|
@@ -572,9 +572,9 @@ static VALUE rxml_node_to_s(int argc, VALUE *argv, VALUE self)
|
|
572
572
|
xmlOutputBufferFlush(output);
|
573
573
|
|
574
574
|
if (output->conv)
|
575
|
-
result =
|
575
|
+
result = rxml_str_new2((const char*) output->conv->content, xencoding);
|
576
576
|
else
|
577
|
-
result =
|
577
|
+
result = rxml_str_new2((const char*) output->buffer->content, xencoding);
|
578
578
|
|
579
579
|
xmlOutputBufferClose(output);
|
580
580
|
|
@@ -678,7 +678,7 @@ static VALUE rxml_node_lang_get(VALUE self)
|
|
678
678
|
|
679
679
|
if (lang)
|
680
680
|
{
|
681
|
-
result =
|
681
|
+
result = rxml_str_new2((const char*) lang, xnode->doc ? xnode->doc->encoding : NULL);
|
682
682
|
xmlFree(lang);
|
683
683
|
}
|
684
684
|
|
@@ -811,11 +811,11 @@ static VALUE rxml_node_xlink_type_name(VALUE self)
|
|
811
811
|
case XLINK_TYPE_NONE:
|
812
812
|
return (Qnil);
|
813
813
|
case XLINK_TYPE_SIMPLE:
|
814
|
-
return (
|
814
|
+
return (rxml_str_new2("simple", xnode->doc ? xnode->doc->encoding : NULL));
|
815
815
|
case XLINK_TYPE_EXTENDED:
|
816
|
-
return (
|
816
|
+
return (rxml_str_new2("extended", xnode->doc ? xnode->doc->encoding : NULL));
|
817
817
|
case XLINK_TYPE_EXTENDED_SET:
|
818
|
-
return (
|
818
|
+
return (rxml_str_new2("extended_set", xnode->doc ? xnode->doc->encoding : NULL));
|
819
819
|
default:
|
820
820
|
rb_fatal("Unknowng xlink type, %d", xlt);
|
821
821
|
}
|
@@ -866,7 +866,7 @@ static VALUE rxml_node_name_get(VALUE self)
|
|
866
866
|
if (xnode->name == NULL)
|
867
867
|
return (Qnil);
|
868
868
|
else
|
869
|
-
return (
|
869
|
+
return (rxml_str_new2((const char*) name, xnode->doc ? xnode->doc->encoding : NULL));
|
870
870
|
}
|
871
871
|
|
872
872
|
/*
|
@@ -958,7 +958,7 @@ static VALUE rxml_node_path(VALUE self)
|
|
958
958
|
if (path == NULL)
|
959
959
|
return (Qnil);
|
960
960
|
else
|
961
|
-
return (
|
961
|
+
return (rxml_str_new2((const char*) path, xnode->doc ? xnode->doc->encoding : NULL));
|
962
962
|
}
|
963
963
|
|
964
964
|
/*
|
@@ -1233,9 +1233,9 @@ static VALUE rxml_node_space_preserve_set(VALUE self, VALUE bool)
|
|
1233
1233
|
Data_Get_Struct(self, xmlNode, xnode);
|
1234
1234
|
|
1235
1235
|
if (TYPE(bool) == T_FALSE)
|
1236
|
-
xmlNodeSetSpacePreserve(xnode, 1);
|
1237
|
-
else
|
1238
1236
|
xmlNodeSetSpacePreserve(xnode, 0);
|
1237
|
+
else
|
1238
|
+
xmlNodeSetSpacePreserve(xnode, 1);
|
1239
1239
|
|
1240
1240
|
return (Qnil);
|
1241
1241
|
}
|
@@ -190,7 +190,7 @@ static VALUE rxml_parser_context_base_uri_get(VALUE self)
|
|
190
190
|
Data_Get_Struct(self, xmlParserCtxt, ctxt);
|
191
191
|
|
192
192
|
if (ctxt->input && ctxt->input->filename)
|
193
|
-
return
|
193
|
+
return rxml_str_new2(ctxt->input->filename, ctxt->encoding);
|
194
194
|
else
|
195
195
|
return Qnil;
|
196
196
|
}
|
@@ -231,7 +231,7 @@ static VALUE rxml_parser_context_data_directory_get(VALUE self)
|
|
231
231
|
if (ctxt->directory == NULL)
|
232
232
|
return (Qnil);
|
233
233
|
else
|
234
|
-
return (
|
234
|
+
return (rxml_str_new2(ctxt->directory, ctxt->encoding));
|
235
235
|
}
|
236
236
|
|
237
237
|
/*
|
@@ -489,7 +489,7 @@ static VALUE rxml_parser_context_name_node_get(VALUE self)
|
|
489
489
|
if (ctxt->name == NULL)
|
490
490
|
return (Qnil);
|
491
491
|
else
|
492
|
-
return (
|
492
|
+
return (rxml_str_new2((const char*) ctxt->name, ctxt->encoding));
|
493
493
|
}
|
494
494
|
|
495
495
|
/*
|
@@ -516,7 +516,7 @@ static VALUE rxml_parser_context_name_tab_get(VALUE self)
|
|
516
516
|
if (ctxt->nameTab[i] == NULL)
|
517
517
|
continue;
|
518
518
|
else
|
519
|
-
rb_ary_push(tab_ary,
|
519
|
+
rb_ary_push(tab_ary, rxml_str_new2((const char*) ctxt->nameTab[i], ctxt->encoding));
|
520
520
|
}
|
521
521
|
|
522
522
|
return (tab_ary);
|
@@ -782,7 +782,7 @@ static VALUE rxml_parser_context_subset_name_get(VALUE self)
|
|
782
782
|
if (ctxt->intSubName == NULL)
|
783
783
|
return (Qnil);
|
784
784
|
else
|
785
|
-
return (
|
785
|
+
return (rxml_str_new2((const char*) ctxt->intSubName, ctxt->encoding));
|
786
786
|
}
|
787
787
|
|
788
788
|
/*
|
@@ -801,7 +801,7 @@ static VALUE rxml_parser_context_subset_external_uri_get(VALUE self)
|
|
801
801
|
if (ctxt->extSubURI == NULL)
|
802
802
|
return (Qnil);
|
803
803
|
else
|
804
|
-
return (
|
804
|
+
return (rxml_str_new2((const char*) ctxt->extSubURI, ctxt->encoding));
|
805
805
|
}
|
806
806
|
|
807
807
|
/*
|
@@ -820,7 +820,7 @@ static VALUE rxml_parser_context_subset_external_system_id_get(VALUE self)
|
|
820
820
|
if (ctxt->extSubSystem == NULL)
|
821
821
|
return (Qnil);
|
822
822
|
else
|
823
|
-
return (
|
823
|
+
return (rxml_str_new2((const char*) ctxt->extSubSystem, ctxt->encoding));
|
824
824
|
}
|
825
825
|
|
826
826
|
/*
|
@@ -905,7 +905,7 @@ static VALUE rxml_parser_context_version_get(VALUE self)
|
|
905
905
|
if (ctxt->version == NULL)
|
906
906
|
return (Qnil);
|
907
907
|
else
|
908
|
-
return (
|
908
|
+
return (rxml_str_new2((const char*) ctxt->version, ctxt->encoding));
|
909
909
|
}
|
910
910
|
|
911
911
|
/*
|
@@ -238,6 +238,7 @@ static VALUE rxml_reader_string(int argc, VALUE *argv, VALUE klass)
|
|
238
238
|
VALUE encoding = Qnil;
|
239
239
|
VALUE parserOptions = Qnil;
|
240
240
|
|
241
|
+
int foo;
|
241
242
|
Check_Type(options, T_HASH);
|
242
243
|
|
243
244
|
baseurl = rb_hash_aref(options, BASE_URI_SYMBOL);
|
@@ -458,8 +459,19 @@ static VALUE rxml_reader_read_attr_value(VALUE self)
|
|
458
459
|
*/
|
459
460
|
static VALUE rxml_reader_read_inner_xml(VALUE self)
|
460
461
|
{
|
461
|
-
|
462
|
-
|
462
|
+
VALUE result = Qnil;
|
463
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
464
|
+
|
465
|
+
xmlChar *xml = xmlTextReaderReadInnerXml(xReader);
|
466
|
+
|
467
|
+
if (xml != NULL)
|
468
|
+
{
|
469
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
470
|
+
result = rxml_str_new2((const char*) xml, xencoding);
|
471
|
+
xmlFree(xml);
|
472
|
+
}
|
473
|
+
|
474
|
+
return result;
|
463
475
|
}
|
464
476
|
|
465
477
|
/*
|
@@ -473,8 +485,19 @@ static VALUE rxml_reader_read_inner_xml(VALUE self)
|
|
473
485
|
*/
|
474
486
|
static VALUE rxml_reader_read_outer_xml(VALUE self)
|
475
487
|
{
|
476
|
-
|
477
|
-
|
488
|
+
VALUE result = Qnil;
|
489
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
490
|
+
|
491
|
+
xmlChar *xml = xmlTextReaderReadOuterXml(xReader);
|
492
|
+
|
493
|
+
if (xml != NULL)
|
494
|
+
{
|
495
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
496
|
+
result = rxml_str_new2((const char*) xml, xencoding);
|
497
|
+
xmlFree(xml);
|
498
|
+
}
|
499
|
+
|
500
|
+
return result;
|
478
501
|
}
|
479
502
|
|
480
503
|
/*
|
@@ -499,8 +522,19 @@ static VALUE rxml_reader_read_state(VALUE self)
|
|
499
522
|
*/
|
500
523
|
static VALUE rxml_reader_read_string(VALUE self)
|
501
524
|
{
|
502
|
-
|
503
|
-
|
525
|
+
VALUE result = Qnil;
|
526
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
527
|
+
|
528
|
+
xmlChar *xml = xmlTextReaderReadString(xReader);
|
529
|
+
|
530
|
+
if (xml != NULL)
|
531
|
+
{
|
532
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
533
|
+
result = rxml_str_new2((const char*) xml, xencoding);
|
534
|
+
xmlFree(xml);
|
535
|
+
}
|
536
|
+
|
537
|
+
return result;
|
504
538
|
}
|
505
539
|
|
506
540
|
/*
|
@@ -549,8 +583,11 @@ rxml_reader_schema_validate(VALUE self, VALUE xsd)
|
|
549
583
|
*/
|
550
584
|
static VALUE rxml_reader_name(VALUE self)
|
551
585
|
{
|
552
|
-
|
553
|
-
|
586
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
587
|
+
const xmlChar *result = xmlTextReaderConstName(xReader);
|
588
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
589
|
+
|
590
|
+
return (result == NULL ? Qnil : rxml_str_new2(result, xencoding));
|
554
591
|
}
|
555
592
|
|
556
593
|
/*
|
@@ -561,8 +598,11 @@ static VALUE rxml_reader_name(VALUE self)
|
|
561
598
|
*/
|
562
599
|
static VALUE rxml_reader_local_name(VALUE self)
|
563
600
|
{
|
564
|
-
|
565
|
-
|
601
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
602
|
+
const xmlChar *result = xmlTextReaderConstLocalName(xReader);
|
603
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
604
|
+
|
605
|
+
return (result == NULL ? Qnil : rxml_str_new2(result, xencoding));
|
566
606
|
}
|
567
607
|
|
568
608
|
/*
|
@@ -610,8 +650,11 @@ static VALUE rxml_reader_encoding(VALUE self)
|
|
610
650
|
*/
|
611
651
|
static VALUE rxml_reader_base_uri(VALUE self)
|
612
652
|
{
|
613
|
-
|
614
|
-
|
653
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
654
|
+
const xmlChar *result = xmlTextReaderConstBaseUri(xReader);
|
655
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
656
|
+
|
657
|
+
return (result == NULL ? Qnil : rxml_str_new2(result, xencoding));
|
615
658
|
}
|
616
659
|
|
617
660
|
/*
|
@@ -622,8 +665,11 @@ static VALUE rxml_reader_base_uri(VALUE self)
|
|
622
665
|
*/
|
623
666
|
static VALUE rxml_reader_namespace_uri(VALUE self)
|
624
667
|
{
|
625
|
-
|
626
|
-
|
668
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
669
|
+
const xmlChar *result = xmlTextReaderConstNamespaceUri(xReader);
|
670
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
671
|
+
|
672
|
+
return (result == NULL ? Qnil : rxml_str_new2(result, xencoding));
|
627
673
|
}
|
628
674
|
|
629
675
|
/*
|
@@ -634,8 +680,11 @@ static VALUE rxml_reader_namespace_uri(VALUE self)
|
|
634
680
|
*/
|
635
681
|
static VALUE rxml_reader_value(VALUE self)
|
636
682
|
{
|
637
|
-
|
638
|
-
|
683
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
684
|
+
const xmlChar *result = xmlTextReaderConstValue(xReader);
|
685
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
686
|
+
|
687
|
+
return (result == NULL ? Qnil : rxml_str_new2(result, xencoding));
|
639
688
|
}
|
640
689
|
|
641
690
|
/*
|
@@ -646,8 +695,11 @@ static VALUE rxml_reader_value(VALUE self)
|
|
646
695
|
*/
|
647
696
|
static VALUE rxml_reader_prefix(VALUE self)
|
648
697
|
{
|
649
|
-
|
650
|
-
|
698
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
699
|
+
const xmlChar *result = xmlTextReaderConstPrefix(xReader);
|
700
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
701
|
+
|
702
|
+
return (result == NULL ? Qnil : rxml_str_new2(result, xencoding));
|
651
703
|
}
|
652
704
|
|
653
705
|
/*
|
@@ -696,8 +748,11 @@ static VALUE rxml_reader_standalone(VALUE self)
|
|
696
748
|
*/
|
697
749
|
static VALUE rxml_reader_xml_lang(VALUE self)
|
698
750
|
{
|
699
|
-
|
700
|
-
|
751
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
752
|
+
const xmlChar *result = xmlTextReaderConstXmlLang(xReader);
|
753
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
754
|
+
|
755
|
+
return (result == NULL ? Qnil : rxml_str_new2(result, xencoding));
|
701
756
|
}
|
702
757
|
|
703
758
|
/*
|
@@ -708,8 +763,11 @@ static VALUE rxml_reader_xml_lang(VALUE self)
|
|
708
763
|
*/
|
709
764
|
static VALUE rxml_reader_xml_version(VALUE self)
|
710
765
|
{
|
711
|
-
|
712
|
-
|
766
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
767
|
+
const xmlChar *result = xmlTextReaderConstXmlVersion(xReader);
|
768
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
769
|
+
|
770
|
+
return (result == NULL ? Qnil : rxml_str_new2(result, xencoding));
|
713
771
|
}
|
714
772
|
|
715
773
|
/*
|
@@ -747,18 +805,19 @@ static VALUE rxml_reader_attribute(VALUE self, VALUE key)
|
|
747
805
|
{
|
748
806
|
xmlTextReaderPtr reader;
|
749
807
|
xmlChar *attr;
|
808
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
809
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
750
810
|
|
751
|
-
reader = rxml_text_reader_get(self);
|
752
811
|
|
753
812
|
if (TYPE(key) == T_FIXNUM)
|
754
813
|
{
|
755
|
-
attr = xmlTextReaderGetAttributeNo(
|
814
|
+
attr = xmlTextReaderGetAttributeNo(xReader, FIX2INT(key));
|
756
815
|
}
|
757
816
|
else
|
758
817
|
{
|
759
|
-
attr = xmlTextReaderGetAttribute(
|
818
|
+
attr = xmlTextReaderGetAttribute(xReader, (const xmlChar *) StringValueCStr(key));
|
760
819
|
}
|
761
|
-
return (attr == NULL ? Qnil :
|
820
|
+
return (attr == NULL ? Qnil : rxml_str_new2(attr, xencoding));
|
762
821
|
}
|
763
822
|
|
764
823
|
/*
|
@@ -770,9 +829,11 @@ static VALUE rxml_reader_attribute(VALUE self, VALUE key)
|
|
770
829
|
*/
|
771
830
|
static VALUE rxml_reader_lookup_namespace(VALUE self, VALUE prefix)
|
772
831
|
{
|
773
|
-
|
774
|
-
|
775
|
-
|
832
|
+
xmlTextReaderPtr xReader = rxml_text_reader_get(self);
|
833
|
+
const xmlChar *result = xmlTextReaderLookupNamespace(xReader, (const xmlChar *) StringValueCStr(prefix));
|
834
|
+
const xmlChar *xencoding = xmlTextReaderConstEncoding(xReader);
|
835
|
+
|
836
|
+
return (result == NULL ? Qnil : rxml_str_new2(result, xencoding));
|
776
837
|
}
|
777
838
|
|
778
839
|
/*
|
@@ -786,25 +847,19 @@ static VALUE rxml_reader_lookup_namespace(VALUE self, VALUE prefix)
|
|
786
847
|
*/
|
787
848
|
static VALUE rxml_reader_expand(VALUE self)
|
788
849
|
{
|
789
|
-
xmlNodePtr node;
|
790
|
-
xmlDocPtr doc;
|
850
|
+
xmlNodePtr node, nodec;
|
791
851
|
xmlTextReaderPtr reader = rxml_text_reader_get(self);
|
792
852
|
node = xmlTextReaderExpand(reader);
|
793
853
|
|
794
854
|
if (!node)
|
795
855
|
return Qnil;
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
xmlTextReaderPreserve(reader);
|
804
|
-
doc = xmlTextReaderCurrentDoc(reader);
|
805
|
-
rxml_document_wrap(doc);
|
806
|
-
|
807
|
-
return rxml_node_wrap(node);
|
856
|
+
else {
|
857
|
+
nodec = xmlCopyNode(node, 1);
|
858
|
+
if (!nodec)
|
859
|
+
return Qnil;
|
860
|
+
else
|
861
|
+
return rxml_node_wrap(nodec);
|
862
|
+
}
|
808
863
|
}
|
809
864
|
|
810
865
|
#if LIBXML_VERSION >= 20618
|
@@ -253,7 +253,19 @@ static void start_element_ns_callback(void *ctx,
|
|
253
253
|
|
254
254
|
static void structured_error_callback(void *ctx, xmlErrorPtr xerror)
|
255
255
|
{
|
256
|
-
|
256
|
+
/* Older versions of Libxml will pass a NULL context from the sax parser. Fixed on
|
257
|
+
Feb 23, 2011. See:
|
258
|
+
|
259
|
+
http://git.gnome.org/browse/libxml2/commit/?id=241d4a1069e6bedd0ee2295d7b43858109c1c6d1 */
|
260
|
+
|
261
|
+
VALUE handler;
|
262
|
+
|
263
|
+
#if LIBXML_VERSION <= 20708
|
264
|
+
xmlParserCtxtPtr ctxt = (xmlParserCtxt*)(xerror->ctxt);
|
265
|
+
ctx = ctxt->userData;
|
266
|
+
#endif
|
267
|
+
|
268
|
+
handler = (VALUE) ctx;
|
257
269
|
|
258
270
|
if (handler != Qnil)
|
259
271
|
{
|