libxml-ruby 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +23 -23
- data/README +144 -144
- data/ext/libxml/extconf.rb +26 -27
- data/ext/libxml/libxml.c +7 -37
- data/ext/libxml/{libxml.h → ruby_libxml.h} +93 -98
- data/ext/libxml/ruby_xml_attr.c +405 -387
- data/ext/libxml/ruby_xml_attr.h +19 -18
- data/ext/libxml/ruby_xml_document.c +1111 -1115
- data/ext/libxml/ruby_xml_document.h +27 -24
- data/ext/libxml/ruby_xml_dtd.c +168 -168
- data/ext/libxml/ruby_xml_html_parser.c +449 -450
- data/ext/libxml/ruby_xml_html_parser.h +1 -1
- data/ext/libxml/ruby_xml_input_cbg.c +158 -158
- data/ext/libxml/ruby_xml_node.c +2410 -2395
- data/ext/libxml/ruby_xml_node.h +1 -1
- data/ext/libxml/ruby_xml_node_set.c +170 -170
- data/ext/libxml/ruby_xml_node_set.h +1 -1
- data/ext/libxml/ruby_xml_ns.c +153 -153
- data/ext/libxml/ruby_xml_ns.h +1 -1
- data/ext/libxml/ruby_xml_parser.c +1425 -1422
- data/ext/libxml/ruby_xml_parser.h +1 -1
- data/ext/libxml/ruby_xml_parser_context.c +750 -716
- data/ext/libxml/ruby_xml_parser_context.h +1 -1
- data/ext/libxml/ruby_xml_reader.c +900 -896
- data/ext/libxml/ruby_xml_sax_parser.c +485 -485
- data/ext/libxml/ruby_xml_sax_parser.h +1 -1
- data/ext/libxml/ruby_xml_schema.c +146 -142
- data/ext/libxml/ruby_xml_state.c +5 -6
- data/ext/libxml/ruby_xml_state.h +1 -0
- data/ext/libxml/ruby_xml_tree.c +43 -43
- data/ext/libxml/ruby_xml_tree.h +1 -1
- data/ext/libxml/ruby_xml_xinclude.c +20 -20
- data/ext/libxml/ruby_xml_xinclude.h +1 -1
- data/ext/libxml/ruby_xml_xpath.c +243 -252
- data/ext/libxml/ruby_xml_xpath.h +1 -1
- data/ext/libxml/ruby_xml_xpath_context.c +118 -118
- data/ext/libxml/ruby_xml_xpath_context.h +1 -1
- data/ext/libxml/ruby_xml_xpath_object.c +43 -29
- data/ext/libxml/ruby_xml_xpath_object.h +0 -1
- data/ext/libxml/ruby_xml_xpointer.c +100 -100
- data/ext/libxml/ruby_xml_xpointer.h +1 -1
- data/ext/libxml/ruby_xml_xpointer_context.c +21 -21
- data/ext/libxml/ruby_xml_xpointer_context.h +1 -1
- data/ext/libxml/sax_parser_callbacks.inc +213 -213
- data/ext/libxml/version.h +9 -9
- data/lib/libxml.rb +24 -3
- data/mingw/libiconv-2.dll +0 -0
- data/mingw/libxml2-2.dll +0 -0
- data/mingw/libxml_ruby.so +0 -0
- data/mingw/mingw.rake +36 -0
- data/test/dtd-test.rb +24 -24
- data/test/etc_doc_to_s.rb +1 -3
- data/test/ets_copy_bug.rb +21 -21
- data/test/ets_copy_bug2.rb +32 -32
- data/test/ets_copy_bug3.rb +38 -0
- data/test/ets_doc_file.rb +1 -0
- data/test/{model/default_validation_bug.rb → gc.log} +0 -0
- data/test/merge_bug.rb +55 -55
- data/test/schema-test.rb +74 -74
- data/test/tc_well_formed.rb +11 -0
- data/test/tc_xml_document.rb +52 -52
- data/test/tc_xml_document_write.rb +24 -24
- data/test/tc_xml_document_write2.rb +54 -54
- data/test/tc_xml_document_write3.rb +96 -96
- data/test/tc_xml_html_parser.rb +63 -63
- data/test/tc_xml_node.rb +59 -59
- data/test/tc_xml_node2.rb +25 -25
- data/test/tc_xml_node3.rb +27 -27
- data/test/tc_xml_node4.rb +86 -86
- data/test/tc_xml_node5.rb +52 -52
- data/test/tc_xml_node6.rb +27 -27
- data/test/tc_xml_node7.rb +35 -35
- data/test/tc_xml_node8.rb +32 -32
- data/test/tc_xml_node9.rb +32 -32
- data/test/tc_xml_node_set.rb +24 -24
- data/test/tc_xml_node_set2.rb +37 -37
- data/test/tc_xml_node_xlink.rb +28 -28
- data/test/tc_xml_parser.rb +190 -178
- data/test/tc_xml_parser2.rb +16 -17
- data/test/tc_xml_parser3.rb +23 -23
- data/test/tc_xml_parser4.rb +33 -33
- data/test/tc_xml_parser5.rb +27 -27
- data/test/tc_xml_parser6.rb +23 -23
- data/test/tc_xml_parser7.rb +28 -28
- data/test/tc_xml_parser8.rb +32 -32
- data/test/tc_xml_parser9.rb +11 -0
- data/test/tc_xml_parser_context.rb +88 -88
- data/test/tc_xml_reader.rb +112 -109
- data/test/tc_xml_sax_parser.rb +104 -94
- data/test/tc_xml_sax_parser2.rb +51 -0
- data/test/tc_xml_xinclude.rb +30 -30
- data/test/tc_xml_xpath.rb +38 -38
- data/test/tc_xml_xpath2.rb +14 -0
- data/test/tc_xml_xpointer.rb +78 -78
- data/vc/libxml.sln +20 -0
- data/vc/libxml.vcproj +389 -0
- data/work/Rakefile +247 -0
- data/work/task/make +26 -0
- data/work/task/memory +37 -0
- data/work/task/rdoc +39 -0
- data/work/task/setup +1616 -0
- data/work/task/test +29 -0
- data/work/test/ets_runner.rb +33 -0
- data/work/test/libxml_test.rb +3 -0
- data/work/test/runner.rb +0 -0
- data/work/test/runner_ets.rb +33 -0
- data/work/vc/debug/libxml.exp +0 -0
- data/work/vc/debug/libxml.ilk +0 -0
- data/work/vc/debug/libxml.lib +0 -0
- data/work/vc/debug/libxml.pdb +0 -0
- data/work/vc/debug/libxml.so +0 -0
- metadata +158 -189
- data/MANIFEST +0 -138
- data/NOTES +0 -9
- data/Rakefile +0 -38
- data/TODO +0 -75
- data/VERSION +0 -1
- data/log/Changelog-0.txt +0 -426
- data/log/Changelog.txt +0 -435
- data/meta/project.yaml +0 -27
- data/meta/unixname +0 -1
- data/setup.rb +0 -1472
- data/site/css/normal.css +0 -182
- data/site/img/raze-tiny.png +0 -0
- data/site/img/red-cube.jpg +0 -0
- data/site/img/xml-ruby.png +0 -0
- data/site/index.xml +0 -43
- data/site/install.xml +0 -77
- data/site/layout.rhtml +0 -38
- data/site/layout.xsl +0 -67
- data/site/license.xml +0 -32
- data/site/log/changelog.xml +0 -1324
- data/site/log/changelog.xsl +0 -42
- data/test/model/merge_bug_data.xml +0 -58
- data/test/model/rubynet.xml +0 -78
- data/test/model/rubynet_project +0 -13
- data/test/model/saxtest.xml +0 -5
- data/test/model/simple.xml +0 -7
- data/test/model/xinclude.xml +0 -5
@@ -1,24 +1,27 @@
|
|
1
|
-
/* $Id: ruby_xml_document.h
|
2
|
-
|
3
|
-
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
-
|
5
|
-
#ifndef __RUBY_XML_DOCUMENT__
|
6
|
-
#define __RUBY_XML_DOCUMENT__
|
7
|
-
|
8
|
-
extern VALUE cXMLDocument;
|
9
|
-
|
10
|
-
typedef struct rxp_document {
|
11
|
-
xmlDocPtr doc; /* Tree/DOM interface */
|
12
|
-
int data_type; /* The data type referenced by *data */
|
13
|
-
void *data; /* Pointer to an external structure of options */
|
14
|
-
} ruby_xml_document_t;
|
15
|
-
|
16
|
-
VALUE ruby_xml_document_filename_get(VALUE self);
|
17
|
-
VALUE ruby_xml_document_new_native(VALUE class, VALUE xmlver);
|
18
|
-
|
19
|
-
VALUE
|
20
|
-
void
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
#endif
|
1
|
+
/* $Id: ruby_xml_document.h 304 2008-07-02 17:42:41Z cfis $ */
|
2
|
+
|
3
|
+
/* Please see the LICENSE file for copyright and distribution information */
|
4
|
+
|
5
|
+
#ifndef __RUBY_XML_DOCUMENT__
|
6
|
+
#define __RUBY_XML_DOCUMENT__
|
7
|
+
|
8
|
+
extern VALUE cXMLDocument;
|
9
|
+
|
10
|
+
typedef struct rxp_document {
|
11
|
+
xmlDocPtr doc; /* Tree/DOM interface */
|
12
|
+
int data_type; /* The data type referenced by *data */
|
13
|
+
void *data; /* Pointer to an external structure of options */
|
14
|
+
} ruby_xml_document_t;
|
15
|
+
|
16
|
+
VALUE ruby_xml_document_filename_get(VALUE self);
|
17
|
+
VALUE ruby_xml_document_new_native(VALUE class, VALUE xmlver);
|
18
|
+
void ruby_xml_document_free(ruby_xml_document_t *rxd);
|
19
|
+
VALUE ruby_xml_document_root_get(VALUE self);
|
20
|
+
void ruby_init_xml_document(void);
|
21
|
+
|
22
|
+
#if defined(_WIN32)
|
23
|
+
__declspec(dllexport)
|
24
|
+
#endif
|
25
|
+
VALUE ruby_xml_document_wrap(xmlDocPtr xnode);
|
26
|
+
|
27
|
+
#endif
|
data/ext/libxml/ruby_xml_dtd.c
CHANGED
@@ -1,168 +1,168 @@
|
|
1
|
-
#include "
|
2
|
-
#include "ruby_xml_dtd.h"
|
3
|
-
|
4
|
-
VALUE cXMLDtd;
|
5
|
-
|
6
|
-
void
|
7
|
-
ruby_xml_dtd_free(ruby_xml_dtd *rxdtd) {
|
8
|
-
if (rxdtd->dtd != NULL) {
|
9
|
-
xmlFreeDtd(rxdtd->dtd);
|
10
|
-
rxdtd->dtd = NULL;
|
11
|
-
}
|
12
|
-
|
13
|
-
|
14
|
-
}
|
15
|
-
|
16
|
-
static void
|
17
|
-
ruby_xml_dtd_mark(ruby_xml_dtd *rxdtd) {
|
18
|
-
return;
|
19
|
-
//if (rxdtd == NULL) return;
|
20
|
-
//if (!NIL_P(rxd->xmlver)) rb_gc_mark(rxd->xmlver);
|
21
|
-
}
|
22
|
-
|
23
|
-
/*
|
24
|
-
* call-seq:
|
25
|
-
* XML::Dtd.new("public system") => dtd
|
26
|
-
* XML::Dtd.new("public", "system") => dtd
|
27
|
-
*
|
28
|
-
* Create a new Dtd from the specified public and system
|
29
|
-
* identifiers.
|
30
|
-
*/
|
31
|
-
VALUE
|
32
|
-
ruby_xml_dtd_initialize(int argc, VALUE *argv, VALUE class) {
|
33
|
-
ruby_xml_dtd *rxdtd;
|
34
|
-
VALUE external, system, dtd_string;
|
35
|
-
xmlParserInputBufferPtr buffer;
|
36
|
-
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
|
37
|
-
xmlChar *new_string;
|
38
|
-
|
39
|
-
// 1 argument -- string --> parsujeme jako dtd
|
40
|
-
// 2 argumenty -- public, system --> bude se hledat
|
41
|
-
switch (argc) {
|
42
|
-
case 2:
|
43
|
-
rb_scan_args(argc, argv, "20", &external, &system);
|
44
|
-
|
45
|
-
Check_Type(external, T_STRING);
|
46
|
-
Check_Type(system, T_STRING);
|
47
|
-
rxdtd = ALLOC(ruby_xml_dtd);
|
48
|
-
rxdtd->dtd = xmlParseDTD( (xmlChar*)StringValuePtr(external),
|
49
|
-
(xmlChar*)StringValuePtr(system) );
|
50
|
-
if (rxdtd->dtd == NULL) {
|
51
|
-
|
52
|
-
return(Qfalse);
|
53
|
-
}
|
54
|
-
|
55
|
-
xmlSetTreeDoc( (xmlNodePtr)rxdtd->dtd, NULL );
|
56
|
-
return( Data_Wrap_Struct(cXMLDtd, ruby_xml_dtd_mark, ruby_xml_dtd_free, rxdtd) );
|
57
|
-
break;
|
58
|
-
|
59
|
-
/*
|
60
|
-
SV *
|
61
|
-
new(CLASS, external, system)
|
62
|
-
char * CLASS
|
63
|
-
char * external
|
64
|
-
char * system
|
65
|
-
ALIAS:
|
66
|
-
parse_uri = 1
|
67
|
-
PREINIT:
|
68
|
-
xmlDtdPtr dtd = NULL;
|
69
|
-
CODE:
|
70
|
-
LibXML_error = sv_2mortal(newSVpv("", 0));
|
71
|
-
dtd = xmlParseDTD((const xmlChar*)external, (const xmlChar*)system);
|
72
|
-
if ( dtd == NULL ) {
|
73
|
-
XSRETURN_UNDEF;
|
74
|
-
}
|
75
|
-
xmlSetTreeDoc((xmlNodePtr)dtd, NULL);
|
76
|
-
RETVAL = PmmNodeToSv( (xmlNodePtr) dtd, NULL );
|
77
|
-
OUTPUT:
|
78
|
-
RETVAL
|
79
|
-
*/
|
80
|
-
|
81
|
-
case 1:
|
82
|
-
|
83
|
-
rb_scan_args(argc, argv, "10", &dtd_string);
|
84
|
-
buffer = xmlAllocParserInputBuffer(enc);
|
85
|
-
//if ( !buffer) return Qnil
|
86
|
-
new_string = xmlStrdup((xmlChar*)StringValuePtr(dtd_string));
|
87
|
-
xmlParserInputBufferPush(buffer, xmlStrlen(new_string), (const char*)new_string);
|
88
|
-
|
89
|
-
rxdtd = ALLOC(ruby_xml_dtd);
|
90
|
-
rxdtd->dtd = xmlIOParseDTD(NULL, buffer, enc);
|
91
|
-
|
92
|
-
// NOTE: For some reason freeing this InputBuffer causes a segfault!
|
93
|
-
// xmlFreeParserInputBuffer(buffer);
|
94
|
-
xmlFree(new_string);
|
95
|
-
|
96
|
-
return( Data_Wrap_Struct(cXMLDtd, ruby_xml_dtd_mark, ruby_xml_dtd_free, rxdtd) );
|
97
|
-
|
98
|
-
break;
|
99
|
-
/*
|
100
|
-
SV * parse_string(CLASS, str, ...)
|
101
|
-
char * CLASS
|
102
|
-
char * str
|
103
|
-
PREINIT:
|
104
|
-
STRLEN n_a;
|
105
|
-
xmlDtdPtr res;
|
106
|
-
SV * encoding_sv;
|
107
|
-
xmlParserInputBufferPtr buffer;
|
108
|
-
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
|
109
|
-
xmlChar * new_string;
|
110
|
-
STRLEN len;
|
111
|
-
CODE:
|
112
|
-
LibXML_init_error();
|
113
|
-
if (items > 2) {
|
114
|
-
encoding_sv = ST(2);
|
115
|
-
if (items > 3) {
|
116
|
-
croak("parse_string: too many parameters");
|
117
|
-
}
|
118
|
-
// warn("getting encoding...\n");
|
119
|
-
enc = xmlParseCharEncoding(SvPV(encoding_sv, n_a));
|
120
|
-
if (enc == XML_CHAR_ENCODING_ERROR) {
|
121
|
-
croak("Parse of encoding %s failed: %s", SvPV(encoding_sv, n_a), SvPV(LibXML_error, n_a));
|
122
|
-
}
|
123
|
-
}
|
124
|
-
buffer = xmlAllocParserInputBuffer(enc);
|
125
|
-
// buffer = xmlParserInputBufferCreateMem(str, xmlStrlen(str), enc);
|
126
|
-
if ( !buffer)
|
127
|
-
croak("cant create buffer!\n" );
|
128
|
-
|
129
|
-
new_string = xmlStrdup((const xmlChar*)str);
|
130
|
-
xmlParserInputBufferPush(buffer, xmlStrlen(new_string), (const char*)new_string);
|
131
|
-
|
132
|
-
res = xmlIOParseDTD(NULL, buffer, enc);
|
133
|
-
|
134
|
-
// NOTE: For some reason freeing this InputBuffer causes a segfault!
|
135
|
-
// xmlFreeParserInputBuffer(buffer);
|
136
|
-
xmlFree(new_string);
|
137
|
-
|
138
|
-
sv_2mortal( LibXML_error );
|
139
|
-
LibXML_croak_error();
|
140
|
-
|
141
|
-
if (res == NULL) {
|
142
|
-
croak("no DTD parsed!");
|
143
|
-
}
|
144
|
-
RETVAL = PmmNodeToSv((xmlNodePtr)res, NULL);
|
145
|
-
OUTPUT:
|
146
|
-
RETVAL
|
147
|
-
*/
|
148
|
-
|
149
|
-
default:
|
150
|
-
rb_raise(rb_eArgError, "wrong number of arguments (need 1 or 2)");
|
151
|
-
}
|
152
|
-
|
153
|
-
//docobj = ruby_xml_document_new2(cXMLDocument, xmlver);
|
154
|
-
return Qnil;
|
155
|
-
}
|
156
|
-
|
157
|
-
// Rdoc needs to know
|
158
|
-
#ifdef RDOC_NEVER_DEFINED
|
159
|
-
mXML = rb_define_module("XML");
|
160
|
-
#endif
|
161
|
-
|
162
|
-
void
|
163
|
-
ruby_init_xml_dtd(void) {
|
164
|
-
cXMLDtd = rb_define_class_under(mXML, "Dtd", rb_cObject);
|
165
|
-
rb_define_singleton_method(cXMLDtd, "new", ruby_xml_dtd_initialize, -1);
|
166
|
-
//rb_define_method(cXMLDocument, "xinclude", ruby_xml_document_xinclude, 0);
|
167
|
-
}
|
168
|
-
|
1
|
+
#include "ruby_libxml.h"
|
2
|
+
#include "ruby_xml_dtd.h"
|
3
|
+
|
4
|
+
VALUE cXMLDtd;
|
5
|
+
|
6
|
+
void
|
7
|
+
ruby_xml_dtd_free(ruby_xml_dtd *rxdtd) {
|
8
|
+
if (rxdtd->dtd != NULL) {
|
9
|
+
xmlFreeDtd(rxdtd->dtd);
|
10
|
+
rxdtd->dtd = NULL;
|
11
|
+
}
|
12
|
+
|
13
|
+
ruby_xfree(rxdtd);
|
14
|
+
}
|
15
|
+
|
16
|
+
static void
|
17
|
+
ruby_xml_dtd_mark(ruby_xml_dtd *rxdtd) {
|
18
|
+
return;
|
19
|
+
//if (rxdtd == NULL) return;
|
20
|
+
//if (!NIL_P(rxd->xmlver)) rb_gc_mark(rxd->xmlver);
|
21
|
+
}
|
22
|
+
|
23
|
+
/*
|
24
|
+
* call-seq:
|
25
|
+
* XML::Dtd.new("public system") => dtd
|
26
|
+
* XML::Dtd.new("public", "system") => dtd
|
27
|
+
*
|
28
|
+
* Create a new Dtd from the specified public and system
|
29
|
+
* identifiers.
|
30
|
+
*/
|
31
|
+
VALUE
|
32
|
+
ruby_xml_dtd_initialize(int argc, VALUE *argv, VALUE class) {
|
33
|
+
ruby_xml_dtd *rxdtd;
|
34
|
+
VALUE external, system, dtd_string;
|
35
|
+
xmlParserInputBufferPtr buffer;
|
36
|
+
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
|
37
|
+
xmlChar *new_string;
|
38
|
+
|
39
|
+
// 1 argument -- string --> parsujeme jako dtd
|
40
|
+
// 2 argumenty -- public, system --> bude se hledat
|
41
|
+
switch (argc) {
|
42
|
+
case 2:
|
43
|
+
rb_scan_args(argc, argv, "20", &external, &system);
|
44
|
+
|
45
|
+
Check_Type(external, T_STRING);
|
46
|
+
Check_Type(system, T_STRING);
|
47
|
+
rxdtd = ALLOC(ruby_xml_dtd);
|
48
|
+
rxdtd->dtd = xmlParseDTD( (xmlChar*)StringValuePtr(external),
|
49
|
+
(xmlChar*)StringValuePtr(system) );
|
50
|
+
if (rxdtd->dtd == NULL) {
|
51
|
+
ruby_xfree(rxdtd);
|
52
|
+
return(Qfalse);
|
53
|
+
}
|
54
|
+
|
55
|
+
xmlSetTreeDoc( (xmlNodePtr)rxdtd->dtd, NULL );
|
56
|
+
return( Data_Wrap_Struct(cXMLDtd, ruby_xml_dtd_mark, ruby_xml_dtd_free, rxdtd) );
|
57
|
+
break;
|
58
|
+
|
59
|
+
/*
|
60
|
+
SV *
|
61
|
+
new(CLASS, external, system)
|
62
|
+
char * CLASS
|
63
|
+
char * external
|
64
|
+
char * system
|
65
|
+
ALIAS:
|
66
|
+
parse_uri = 1
|
67
|
+
PREINIT:
|
68
|
+
xmlDtdPtr dtd = NULL;
|
69
|
+
CODE:
|
70
|
+
LibXML_error = sv_2mortal(newSVpv("", 0));
|
71
|
+
dtd = xmlParseDTD((const xmlChar*)external, (const xmlChar*)system);
|
72
|
+
if ( dtd == NULL ) {
|
73
|
+
XSRETURN_UNDEF;
|
74
|
+
}
|
75
|
+
xmlSetTreeDoc((xmlNodePtr)dtd, NULL);
|
76
|
+
RETVAL = PmmNodeToSv( (xmlNodePtr) dtd, NULL );
|
77
|
+
OUTPUT:
|
78
|
+
RETVAL
|
79
|
+
*/
|
80
|
+
|
81
|
+
case 1:
|
82
|
+
|
83
|
+
rb_scan_args(argc, argv, "10", &dtd_string);
|
84
|
+
buffer = xmlAllocParserInputBuffer(enc);
|
85
|
+
//if ( !buffer) return Qnil
|
86
|
+
new_string = xmlStrdup((xmlChar*)StringValuePtr(dtd_string));
|
87
|
+
xmlParserInputBufferPush(buffer, xmlStrlen(new_string), (const char*)new_string);
|
88
|
+
|
89
|
+
rxdtd = ALLOC(ruby_xml_dtd);
|
90
|
+
rxdtd->dtd = xmlIOParseDTD(NULL, buffer, enc);
|
91
|
+
|
92
|
+
// NOTE: For some reason freeing this InputBuffer causes a segfault!
|
93
|
+
// xmlFreeParserInputBuffer(buffer);
|
94
|
+
xmlFree(new_string);
|
95
|
+
|
96
|
+
return( Data_Wrap_Struct(cXMLDtd, ruby_xml_dtd_mark, ruby_xml_dtd_free, rxdtd) );
|
97
|
+
|
98
|
+
break;
|
99
|
+
/*
|
100
|
+
SV * parse_string(CLASS, str, ...)
|
101
|
+
char * CLASS
|
102
|
+
char * str
|
103
|
+
PREINIT:
|
104
|
+
STRLEN n_a;
|
105
|
+
xmlDtdPtr res;
|
106
|
+
SV * encoding_sv;
|
107
|
+
xmlParserInputBufferPtr buffer;
|
108
|
+
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
|
109
|
+
xmlChar * new_string;
|
110
|
+
STRLEN len;
|
111
|
+
CODE:
|
112
|
+
LibXML_init_error();
|
113
|
+
if (items > 2) {
|
114
|
+
encoding_sv = ST(2);
|
115
|
+
if (items > 3) {
|
116
|
+
croak("parse_string: too many parameters");
|
117
|
+
}
|
118
|
+
// warn("getting encoding...\n");
|
119
|
+
enc = xmlParseCharEncoding(SvPV(encoding_sv, n_a));
|
120
|
+
if (enc == XML_CHAR_ENCODING_ERROR) {
|
121
|
+
croak("Parse of encoding %s failed: %s", SvPV(encoding_sv, n_a), SvPV(LibXML_error, n_a));
|
122
|
+
}
|
123
|
+
}
|
124
|
+
buffer = xmlAllocParserInputBuffer(enc);
|
125
|
+
// buffer = xmlParserInputBufferCreateMem(str, xmlStrlen(str), enc);
|
126
|
+
if ( !buffer)
|
127
|
+
croak("cant create buffer!\n" );
|
128
|
+
|
129
|
+
new_string = xmlStrdup((const xmlChar*)str);
|
130
|
+
xmlParserInputBufferPush(buffer, xmlStrlen(new_string), (const char*)new_string);
|
131
|
+
|
132
|
+
res = xmlIOParseDTD(NULL, buffer, enc);
|
133
|
+
|
134
|
+
// NOTE: For some reason freeing this InputBuffer causes a segfault!
|
135
|
+
// xmlFreeParserInputBuffer(buffer);
|
136
|
+
xmlFree(new_string);
|
137
|
+
|
138
|
+
sv_2mortal( LibXML_error );
|
139
|
+
LibXML_croak_error();
|
140
|
+
|
141
|
+
if (res == NULL) {
|
142
|
+
croak("no DTD parsed!");
|
143
|
+
}
|
144
|
+
RETVAL = PmmNodeToSv((xmlNodePtr)res, NULL);
|
145
|
+
OUTPUT:
|
146
|
+
RETVAL
|
147
|
+
*/
|
148
|
+
|
149
|
+
default:
|
150
|
+
rb_raise(rb_eArgError, "wrong number of arguments (need 1 or 2)");
|
151
|
+
}
|
152
|
+
|
153
|
+
//docobj = ruby_xml_document_new2(cXMLDocument, xmlver);
|
154
|
+
return Qnil;
|
155
|
+
}
|
156
|
+
|
157
|
+
// Rdoc needs to know
|
158
|
+
#ifdef RDOC_NEVER_DEFINED
|
159
|
+
mXML = rb_define_module("XML");
|
160
|
+
#endif
|
161
|
+
|
162
|
+
void
|
163
|
+
ruby_init_xml_dtd(void) {
|
164
|
+
cXMLDtd = rb_define_class_under(mXML, "Dtd", rb_cObject);
|
165
|
+
rb_define_singleton_method(cXMLDtd, "new", ruby_xml_dtd_initialize, -1);
|
166
|
+
//rb_define_method(cXMLDocument, "xinclude", ruby_xml_document_xinclude, 0);
|
167
|
+
}
|
168
|
+
|