libxml-ruby 0.9.2-x86-mswin32-60 → 0.9.3-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +13 -0
- data/ext/libxml/libxml.c +885 -886
- data/ext/libxml/ruby_libxml.h +70 -72
- data/ext/libxml/ruby_xml_attr.c +76 -76
- data/ext/libxml/ruby_xml_attr.h +8 -8
- data/ext/libxml/ruby_xml_attributes.c +36 -36
- data/ext/libxml/ruby_xml_attributes.h +6 -6
- data/ext/libxml/ruby_xml_document.c +133 -220
- data/ext/libxml/ruby_xml_document.h +4 -7
- data/ext/libxml/ruby_xml_dtd.c +30 -109
- data/ext/libxml/ruby_xml_dtd.h +2 -11
- data/ext/libxml/ruby_xml_error.c +10 -10
- data/ext/libxml/ruby_xml_error.h +4 -4
- data/ext/libxml/ruby_xml_html_parser.c +28 -40
- data/ext/libxml/ruby_xml_html_parser.h +4 -4
- data/ext/libxml/ruby_xml_input.c +208 -32
- data/ext/libxml/ruby_xml_input.h +7 -5
- data/ext/libxml/ruby_xml_input_cbg.c +3 -3
- data/ext/libxml/ruby_xml_node.c +217 -217
- data/ext/libxml/ruby_xml_node.h +5 -5
- data/ext/libxml/ruby_xml_ns.c +26 -26
- data/ext/libxml/ruby_xml_ns.h +4 -4
- data/ext/libxml/ruby_xml_parser.c +151 -164
- data/ext/libxml/ruby_xml_parser.h +3 -8
- data/ext/libxml/ruby_xml_parser_context.c +105 -105
- data/ext/libxml/ruby_xml_parser_context.h +4 -4
- data/ext/libxml/ruby_xml_reader.c +145 -162
- data/ext/libxml/ruby_xml_reader.h +4 -4
- data/ext/libxml/ruby_xml_relaxng.c +30 -43
- data/ext/libxml/ruby_xml_relaxng.h +2 -7
- data/ext/libxml/ruby_xml_sax_parser.c +174 -228
- data/ext/libxml/ruby_xml_sax_parser.h +12 -20
- data/ext/libxml/ruby_xml_schema.c +31 -44
- data/ext/libxml/ruby_xml_schema.h +2 -7
- data/ext/libxml/ruby_xml_state.c +6 -6
- data/ext/libxml/ruby_xml_state.h +2 -2
- data/ext/libxml/ruby_xml_xinclude.c +1 -1
- data/ext/libxml/ruby_xml_xinclude.h +3 -3
- data/ext/libxml/ruby_xml_xpath.c +1 -1
- data/ext/libxml/ruby_xml_xpath.h +3 -12
- data/ext/libxml/ruby_xml_xpath_context.c +293 -294
- data/ext/libxml/ruby_xml_xpath_context.h +3 -7
- data/ext/libxml/ruby_xml_xpath_expression.c +11 -11
- data/ext/libxml/ruby_xml_xpath_expression.h +2 -2
- data/ext/libxml/ruby_xml_xpath_object.c +52 -66
- data/ext/libxml/ruby_xml_xpath_object.h +3 -14
- data/ext/libxml/ruby_xml_xpointer.c +11 -12
- data/ext/libxml/ruby_xml_xpointer.h +5 -7
- data/ext/libxml/sax_parser_callbacks.inc +53 -36
- data/ext/libxml/version.h +2 -2
- data/ext/mingw/libxml_ruby.dll.a +0 -0
- data/ext/mingw/libxml_ruby.so +0 -0
- data/ext/vc/libxml_ruby.vcproj +1 -9
- data/lib/libxml/html_parser.rb +5 -5
- data/lib/libxml/parser.rb +4 -4
- data/lib/libxml/sax_parser.rb +24 -0
- data/test/tc_document_write.rb +2 -16
- data/test/tc_html_parser.rb +57 -5
- data/test/tc_input.rb +13 -0
- data/test/tc_parser.rb +11 -3
- data/test/tc_reader.rb +53 -34
- data/test/tc_sax_parser.rb +30 -8
- data/test/test.rb +8 -0
- data/test/test_suite.rb +1 -1
- metadata +5 -6
- data/ext/libxml/ruby_xml_encoding.c +0 -164
- data/ext/libxml/ruby_xml_encoding.h +0 -13
- data/test/tc_encoding.rb +0 -13
@@ -1,20 +1,17 @@
|
|
1
|
-
/* $Id: ruby_xml_document.h
|
1
|
+
/* $Id: ruby_xml_document.h 614 2008-11-22 08:04:39Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
5
|
-
#ifndef
|
6
|
-
#define
|
5
|
+
#ifndef __rxml_DOCUMENT__
|
6
|
+
#define __rxml_DOCUMENT__
|
7
7
|
|
8
8
|
extern VALUE cXMLDocument;
|
9
9
|
|
10
10
|
void ruby_init_xml_document();
|
11
|
-
int ruby_xml_document_incr(xmlDocPtr xdoc);
|
12
|
-
int ruby_xml_document_decr(xmlDocPtr xdoc);
|
13
11
|
|
14
12
|
|
15
13
|
#if defined(_WIN32)
|
16
14
|
__declspec(dllexport)
|
17
15
|
#endif
|
18
|
-
VALUE
|
19
|
-
|
16
|
+
VALUE rxml_document_wrap(xmlDocPtr xnode);
|
20
17
|
#endif
|
data/ext/libxml/ruby_xml_dtd.c
CHANGED
@@ -31,20 +31,13 @@
|
|
31
31
|
VALUE cXMLDtd;
|
32
32
|
|
33
33
|
void
|
34
|
-
|
35
|
-
|
36
|
-
xmlFreeDtd(rxdtd->dtd);
|
37
|
-
rxdtd->dtd = NULL;
|
38
|
-
}
|
39
|
-
|
40
|
-
ruby_xfree(rxdtd);
|
34
|
+
rxml_dtd_free(xmlDtdPtr xdtd) {
|
35
|
+
xmlFreeDtd(xdtd);
|
41
36
|
}
|
42
37
|
|
43
|
-
static
|
44
|
-
|
45
|
-
return;
|
46
|
-
//if (rxdtd == NULL) return;
|
47
|
-
//if (!NIL_P(rxd->xmlver)) rb_gc_mark(rxd->xmlver);
|
38
|
+
static VALUE
|
39
|
+
rxml_dtd_alloc(VALUE klass) {
|
40
|
+
return Data_Wrap_Struct(klass, NULL, rxml_dtd_free, NULL);
|
48
41
|
}
|
49
42
|
|
50
43
|
/*
|
@@ -55,13 +48,13 @@ ruby_xml_dtd_mark(ruby_xml_dtd *rxdtd) {
|
|
55
48
|
* Create a new Dtd from the specified public and system
|
56
49
|
* identifiers.
|
57
50
|
*/
|
58
|
-
VALUE
|
59
|
-
|
60
|
-
ruby_xml_dtd *rxdtd;
|
51
|
+
static VALUE
|
52
|
+
rxml_dtd_initialize(int argc, VALUE *argv, VALUE self) {
|
61
53
|
VALUE external, system, dtd_string;
|
62
54
|
xmlParserInputBufferPtr buffer;
|
63
55
|
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
|
64
56
|
xmlChar *new_string;
|
57
|
+
xmlDtdPtr xdtd;
|
65
58
|
|
66
59
|
// 1 argument -- string --> parsujeme jako dtd
|
67
60
|
// 2 argumenty -- public, system --> bude se hledat
|
@@ -71,114 +64,42 @@ ruby_xml_dtd_initialize(int argc, VALUE *argv, VALUE class) {
|
|
71
64
|
|
72
65
|
Check_Type(external, T_STRING);
|
73
66
|
Check_Type(system, T_STRING);
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
if (rxdtd->dtd == NULL) {
|
78
|
-
ruby_xfree(rxdtd);
|
79
|
-
return(Qfalse);
|
80
|
-
}
|
81
|
-
|
82
|
-
xmlSetTreeDoc( (xmlNodePtr)rxdtd->dtd, NULL );
|
83
|
-
return( Data_Wrap_Struct(cXMLDtd, ruby_xml_dtd_mark, ruby_xml_dtd_free, rxdtd) );
|
84
|
-
break;
|
67
|
+
|
68
|
+
xdtd = xmlParseDTD((xmlChar*)StringValuePtr(external),
|
69
|
+
(xmlChar*)StringValuePtr(system));
|
85
70
|
|
86
|
-
|
87
|
-
|
88
|
-
new(CLASS, external, system)
|
89
|
-
char * CLASS
|
90
|
-
char * external
|
91
|
-
char * system
|
92
|
-
ALIAS:
|
93
|
-
parse_uri = 1
|
94
|
-
PREINIT:
|
95
|
-
xmlDtdPtr dtd = NULL;
|
96
|
-
CODE:
|
97
|
-
LibXML_error = sv_2mortal(newSVpv("", 0));
|
98
|
-
dtd = xmlParseDTD((const xmlChar*)external, (const xmlChar*)system);
|
99
|
-
if ( dtd == NULL ) {
|
100
|
-
XSRETURN_UNDEF;
|
101
|
-
}
|
102
|
-
xmlSetTreeDoc((xmlNodePtr)dtd, NULL);
|
103
|
-
RETVAL = PmmNodeToSv( (xmlNodePtr) dtd, NULL );
|
104
|
-
OUTPUT:
|
105
|
-
RETVAL
|
106
|
-
*/
|
71
|
+
if (xdtd == NULL)
|
72
|
+
rxml_raise(&xmlLastError);
|
107
73
|
|
108
|
-
|
74
|
+
DATA_PTR(self) = xdtd;
|
75
|
+
|
76
|
+
xmlSetTreeDoc((xmlNodePtr)xdtd, NULL);
|
77
|
+
break;
|
109
78
|
|
79
|
+
case 1:
|
110
80
|
rb_scan_args(argc, argv, "10", &dtd_string);
|
81
|
+
Check_Type(dtd_string, T_STRING);
|
82
|
+
|
83
|
+
/* Note that buffer is freed by xmlParserInputBufferPush*/
|
111
84
|
buffer = xmlAllocParserInputBuffer(enc);
|
112
|
-
//if ( !buffer) return Qnil
|
113
85
|
new_string = xmlStrdup((xmlChar*)StringValuePtr(dtd_string));
|
114
86
|
xmlParserInputBufferPush(buffer, xmlStrlen(new_string), (const char*)new_string);
|
115
87
|
|
116
|
-
|
117
|
-
rxdtd->dtd = xmlIOParseDTD(NULL, buffer, enc);
|
88
|
+
xdtd = xmlIOParseDTD(NULL, buffer, enc);
|
118
89
|
|
119
|
-
|
120
|
-
|
121
|
-
xmlFree(new_string);
|
90
|
+
if (xdtd == NULL)
|
91
|
+
rxml_raise(&xmlLastError);
|
122
92
|
|
123
|
-
|
93
|
+
xmlFree(new_string);
|
124
94
|
|
95
|
+
DATA_PTR(self) = xdtd;
|
125
96
|
break;
|
126
|
-
/*
|
127
|
-
SV * parse_string(CLASS, str, ...)
|
128
|
-
char * CLASS
|
129
|
-
char * str
|
130
|
-
PREINIT:
|
131
|
-
STRLEN n_a;
|
132
|
-
xmlDtdPtr res;
|
133
|
-
SV * encoding_sv;
|
134
|
-
xmlParserInputBufferPtr buffer;
|
135
|
-
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
|
136
|
-
xmlChar * new_string;
|
137
|
-
STRLEN len;
|
138
|
-
CODE:
|
139
|
-
LibXML_init_error();
|
140
|
-
if (items > 2) {
|
141
|
-
encoding_sv = ST(2);
|
142
|
-
if (items > 3) {
|
143
|
-
croak("parse_string: too many parameters");
|
144
|
-
}
|
145
|
-
// warn("getting encoding...\n");
|
146
|
-
enc = xmlParseCharEncoding(SvPV(encoding_sv, n_a));
|
147
|
-
if (enc == XML_CHAR_ENCODING_ERROR) {
|
148
|
-
croak("Parse of encoding %s failed: %s", SvPV(encoding_sv, n_a), SvPV(LibXML_error, n_a));
|
149
|
-
}
|
150
|
-
}
|
151
|
-
buffer = xmlAllocParserInputBuffer(enc);
|
152
|
-
// buffer = xmlParserInputBufferCreateMem(str, xmlStrlen(str), enc);
|
153
|
-
if ( !buffer)
|
154
|
-
croak("cant create buffer!\n" );
|
155
|
-
|
156
|
-
new_string = xmlStrdup((const xmlChar*)str);
|
157
|
-
xmlParserInputBufferPush(buffer, xmlStrlen(new_string), (const char*)new_string);
|
158
|
-
|
159
|
-
res = xmlIOParseDTD(NULL, buffer, enc);
|
160
|
-
|
161
|
-
// NOTE: For some reason freeing this InputBuffer causes a segfault!
|
162
|
-
// xmlFreeParserInputBuffer(buffer);
|
163
|
-
xmlFree(new_string);
|
164
|
-
|
165
|
-
sv_2mortal( LibXML_error );
|
166
|
-
LibXML_croak_error();
|
167
|
-
|
168
|
-
if (res == NULL) {
|
169
|
-
croak("no DTD parsed!");
|
170
|
-
}
|
171
|
-
RETVAL = PmmNodeToSv((xmlNodePtr)res, NULL);
|
172
|
-
OUTPUT:
|
173
|
-
RETVAL
|
174
|
-
*/
|
175
97
|
|
176
98
|
default:
|
177
99
|
rb_raise(rb_eArgError, "wrong number of arguments (need 1 or 2)");
|
178
100
|
}
|
179
101
|
|
180
|
-
|
181
|
-
return Qnil;
|
102
|
+
return self;
|
182
103
|
}
|
183
104
|
|
184
105
|
// Rdoc needs to know
|
@@ -188,9 +109,9 @@ SV * parse_string(CLASS, str, ...)
|
|
188
109
|
#endif
|
189
110
|
|
190
111
|
void
|
191
|
-
ruby_init_xml_dtd(
|
112
|
+
ruby_init_xml_dtd() {
|
192
113
|
cXMLDtd = rb_define_class_under(mXML, "Dtd", rb_cObject);
|
193
|
-
|
194
|
-
|
114
|
+
rb_define_alloc_func(cXMLDtd, rxml_dtd_alloc);
|
115
|
+
rb_define_method(cXMLDtd, "initialize", rxml_dtd_initialize, -1);
|
195
116
|
}
|
196
117
|
|
data/ext/libxml/ruby_xml_dtd.h
CHANGED
@@ -1,17 +1,8 @@
|
|
1
|
-
#ifndef
|
2
|
-
#define
|
1
|
+
#ifndef __rxml_DTD__
|
2
|
+
#define __rxml_DTD__
|
3
3
|
|
4
4
|
extern VALUE cXMLDtd;
|
5
5
|
|
6
|
-
typedef struct rxp_dtd {
|
7
|
-
xmlDtdPtr dtd; /* DTD interface */
|
8
|
-
//int data_type; /* The data type referenced by *data */
|
9
|
-
//void *data; /* Pointer to an external structure of options */
|
10
|
-
//int is_ptr; /* Determines if this object owns its data or points to it someplace else */
|
11
|
-
//VALUE xmlver; /* T_STRING with the xml version */
|
12
|
-
} ruby_xml_dtd;
|
13
|
-
|
14
6
|
void ruby_init_xml_dtd(void);
|
15
|
-
void ruby_dtd_free(ruby_xml_dtd *rxdtd);
|
16
7
|
|
17
8
|
#endif
|
data/ext/libxml/ruby_xml_error.c
CHANGED
@@ -44,7 +44,7 @@ static ID ERROR_HANDLER_ID;
|
|
44
44
|
* error messages.
|
45
45
|
*/
|
46
46
|
static VALUE
|
47
|
-
|
47
|
+
rxml_error_set_handler(VALUE self)
|
48
48
|
{
|
49
49
|
VALUE block;
|
50
50
|
|
@@ -66,15 +66,15 @@ ruby_xml_error_set_handler(VALUE self)
|
|
66
66
|
*
|
67
67
|
* Removes the current error handler. */
|
68
68
|
static VALUE
|
69
|
-
|
69
|
+
rxml_error_reset_handler(VALUE self)
|
70
70
|
{
|
71
71
|
rb_cvar_set(self, ERROR_HANDLER_ID, Qnil, 0);
|
72
72
|
return self;
|
73
73
|
}
|
74
74
|
|
75
75
|
|
76
|
-
VALUE
|
77
|
-
|
76
|
+
static VALUE
|
77
|
+
rxml_error_wrap(xmlErrorPtr xerror) {
|
78
78
|
VALUE result = Qnil;
|
79
79
|
if (xerror->message)
|
80
80
|
result = rb_exc_new2(eXMLError, xerror->message);
|
@@ -105,7 +105,7 @@ ruby_xml_error_wrap(xmlErrorPtr xerror) {
|
|
105
105
|
|
106
106
|
//rb_define_attr(eXMLError, "ctxt", 1, 0);
|
107
107
|
if (xerror->node) {
|
108
|
-
VALUE node =
|
108
|
+
VALUE node = rxml_node2_wrap(cXMLNode, xerror->node);
|
109
109
|
rb_iv_set(result, "@node", node);
|
110
110
|
}
|
111
111
|
return result;
|
@@ -120,7 +120,7 @@ structuredErrorFunc(void *userData, xmlErrorPtr xerror)
|
|
120
120
|
|
121
121
|
if (block != Qnil)
|
122
122
|
{
|
123
|
-
VALUE error =
|
123
|
+
VALUE error = rxml_error_wrap(xerror);
|
124
124
|
rb_funcall(block, rb_intern("call"), 1, error);
|
125
125
|
}
|
126
126
|
}
|
@@ -132,10 +132,10 @@ structuredErrorFunc(void *userData, xmlErrorPtr xerror)
|
|
132
132
|
#endif
|
133
133
|
|
134
134
|
void
|
135
|
-
|
135
|
+
rxml_raise(xmlErrorPtr xerror)
|
136
136
|
{
|
137
137
|
/* Wrap error up as Ruby object and send it off to ruby */
|
138
|
-
VALUE error =
|
138
|
+
VALUE error = rxml_error_wrap(xerror);
|
139
139
|
rb_exc_raise(error);
|
140
140
|
}
|
141
141
|
|
@@ -147,8 +147,8 @@ ruby_init_xml_error() {
|
|
147
147
|
|
148
148
|
/* Error class */
|
149
149
|
eXMLError = rb_define_class_under(mXML, "Error", rb_eStandardError);
|
150
|
-
rb_define_singleton_method(eXMLError, "set_handler",
|
151
|
-
rb_define_singleton_method(eXMLError, "reset_handler",
|
150
|
+
rb_define_singleton_method(eXMLError, "set_handler", rxml_error_set_handler, 0);
|
151
|
+
rb_define_singleton_method(eXMLError, "reset_handler", rxml_error_reset_handler, 0);
|
152
152
|
|
153
153
|
|
154
154
|
/* Ruby callback to receive errors - set it to nil by default. */
|
data/ext/libxml/ruby_xml_error.h
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
/* $Id:
|
1
|
+
/* $Id: rxml_ns.h 324 2008-07-08 23:00:02Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
5
|
-
#ifndef
|
6
|
-
#define
|
5
|
+
#ifndef __rxml_ERROR__
|
6
|
+
#define __rxml_ERROR__
|
7
7
|
|
8
8
|
extern VALUE eXMLError;
|
9
9
|
|
10
10
|
void ruby_init_xml_error();
|
11
|
-
void
|
11
|
+
void rxml_raise(xmlErrorPtr xerror);
|
12
12
|
|
13
13
|
#endif
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: ruby_xml_html_parser.c
|
1
|
+
/* $Id: ruby_xml_html_parser.c 621 2008-11-22 10:17:09Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
@@ -24,48 +24,38 @@ static ID CONTEXT_ATTR;
|
|
24
24
|
*
|
25
25
|
* Initializes a new parser instance with no pre-determined source.
|
26
26
|
*/
|
27
|
-
VALUE
|
28
|
-
|
27
|
+
static VALUE
|
28
|
+
rxml_html_parser_initialize(VALUE self) {
|
29
29
|
VALUE input = rb_class_new_instance(0, NULL, cXMLInput);
|
30
30
|
rb_iv_set(self, "@input", input);
|
31
31
|
rb_iv_set(self, "@context", Qnil);
|
32
32
|
return self;
|
33
33
|
}
|
34
34
|
|
35
|
-
htmlParserCtxtPtr
|
36
|
-
|
35
|
+
static htmlParserCtxtPtr
|
36
|
+
rxml_html_parser_file_ctxt(VALUE input) {
|
37
37
|
VALUE file = rb_ivar_get(input, FILE_ATTR);
|
38
38
|
VALUE encoding = rb_ivar_get(input, ENCODING_ATTR);
|
39
|
-
VALUE encodingStr =
|
39
|
+
VALUE encodingStr = rxml_input_encoding_to_s(Qnil, encoding);
|
40
40
|
|
41
41
|
return htmlCreateFileParserCtxt(StringValuePtr(file), StringValuePtr(encodingStr));
|
42
42
|
}
|
43
43
|
|
44
|
-
htmlParserCtxtPtr
|
45
|
-
|
44
|
+
static htmlParserCtxtPtr
|
45
|
+
rxml_html_parser_str_ctxt(VALUE input) {
|
46
46
|
VALUE data = rb_ivar_get(input, STRING_ATTR);
|
47
47
|
return htmlCreateMemoryParserCtxt(StringValuePtr(data), RSTRING_LEN(data));
|
48
48
|
}
|
49
49
|
|
50
|
-
/*
|
51
|
-
|
52
|
-
ruby_xml_html_parser_io_ctxt(VALUE input) {
|
50
|
+
/*static htmlDocPtr
|
51
|
+
rxml_html_parser_io_ctxt(VALUE input) {
|
53
52
|
VALUE io = rb_ivar_get(input, IO_ATTR);
|
54
53
|
VALUE encoding = rb_ivar_get(input, ENCODING_ATTR);
|
55
54
|
xmlCharEncoding xmlEncoding = NUM2INT(encoding);
|
56
55
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
GetOpenFile(io, fptr);
|
61
|
-
rb_io_check_readable(fptr);
|
62
|
-
f = GetWriteFile(fptr);
|
63
|
-
|
64
|
-
return htmlCreateIOParserCtxt(NULL, NULL,
|
65
|
-
(xmlInputReadCallback) ctxtRead,
|
66
|
-
NULL, f, xmlEncoding);
|
67
|
-
}
|
68
|
-
*/
|
56
|
+
return htmlReadIO((xmlInputReadCallback) rxml_read_callback, NULL,
|
57
|
+
io, NULL, xmlEncoding);
|
58
|
+
}*/
|
69
59
|
|
70
60
|
/*
|
71
61
|
* call-seq:
|
@@ -75,8 +65,8 @@ ruby_xml_html_parser_io_ctxt(VALUE input) {
|
|
75
65
|
* it's content. If an error occurs, XML::Parser::ParseError
|
76
66
|
* is thrown.
|
77
67
|
*/
|
78
|
-
VALUE
|
79
|
-
|
68
|
+
static VALUE
|
69
|
+
rxml_html_parser_parse(VALUE self) {
|
80
70
|
xmlParserCtxtPtr ctxt;
|
81
71
|
VALUE context;
|
82
72
|
VALUE input = rb_ivar_get(self, INPUT_ATTR);
|
@@ -86,28 +76,26 @@ ruby_xml_html_parser_parse(VALUE self) {
|
|
86
76
|
rb_raise(rb_eRuntimeError, "You cannot parse a data source twice");
|
87
77
|
|
88
78
|
if (rb_ivar_get(input, FILE_ATTR) != Qnil)
|
89
|
-
ctxt =
|
79
|
+
ctxt = rxml_html_parser_file_ctxt(input);
|
90
80
|
else if (rb_ivar_get(input, STRING_ATTR) != Qnil)
|
91
|
-
ctxt =
|
92
|
-
/*else if (rb_ivar_get(input,
|
93
|
-
ctxt =
|
94
|
-
else if (rb_ivar_get(input,
|
95
|
-
ctxt =
|
81
|
+
ctxt = rxml_html_parser_str_ctxt(input);
|
82
|
+
/*else if (rb_ivar_get(input, IO_ATTR) != Qnil)
|
83
|
+
ctxt = rxml_html_parser_io_ctxt(input);
|
84
|
+
else if (rb_ivar_get(input, DOCUMENT_ATTR) != Qnil)
|
85
|
+
ctxt = rxml_html_parser_parse_document(input);*/
|
96
86
|
else
|
97
87
|
rb_raise(rb_eArgError, "You must specify a parser data source");
|
98
88
|
|
99
89
|
if (!ctxt)
|
100
|
-
|
90
|
+
rxml_raise(&xmlLastError);
|
101
91
|
|
102
|
-
context =
|
92
|
+
context = rxml_parser_context_wrap(ctxt);
|
103
93
|
rb_ivar_set(self, CONTEXT_ATTR, context);
|
104
94
|
|
105
|
-
if (htmlParseDocument(ctxt) == -1
|
106
|
-
|
107
|
-
ruby_xml_raise(&ctxt->lastError);
|
108
|
-
}
|
95
|
+
if (htmlParseDocument(ctxt) == -1)
|
96
|
+
rxml_raise(&ctxt->lastError);
|
109
97
|
|
110
|
-
return
|
98
|
+
return rxml_document_wrap(ctxt->myDoc);
|
111
99
|
}
|
112
100
|
|
113
101
|
// Rdoc needs to know
|
@@ -128,6 +116,6 @@ ruby_init_html_parser(void) {
|
|
128
116
|
rb_define_attr(cXMLHTMLParser, "context", 1, 0);
|
129
117
|
|
130
118
|
/* Instance methods */
|
131
|
-
rb_define_method(cXMLHTMLParser, "initialize",
|
132
|
-
rb_define_method(cXMLHTMLParser, "parse",
|
119
|
+
rb_define_method(cXMLHTMLParser, "initialize", rxml_html_parser_initialize, 0);
|
120
|
+
rb_define_method(cXMLHTMLParser, "parse", rxml_html_parser_parse, 0);
|
133
121
|
}
|
@@ -1,11 +1,11 @@
|
|
1
|
-
/* $Id: ruby_xml_html_parser.h
|
1
|
+
/* $Id: ruby_xml_html_parser.h 612 2008-11-21 08:01:29Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
5
|
-
#ifndef
|
6
|
-
#define
|
5
|
+
#ifndef __rxml_HTML_PARSER__
|
6
|
+
#define __rxml_HTML_PARSER__
|
7
7
|
|
8
|
-
extern int
|
8
|
+
extern int rxml_html_parser_count;
|
9
9
|
extern VALUE cXMLHTMLParser;
|
10
10
|
|
11
11
|
void ruby_init_html_parser(void);
|