libxml-ruby 0.9.2 → 0.9.3
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/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,15 +1,16 @@
|
|
1
|
-
/* $Id: sax_parser_callbacks.inc
|
1
|
+
/* $Id: sax_parser_callbacks.inc 616 2008-11-22 09:25:12Z cfis $ */
|
2
2
|
|
3
3
|
/* Please see the LICENSE file for copyright and distribution information */
|
4
4
|
|
5
5
|
/*
|
6
6
|
* SAX CALLBACK HANDLERS
|
7
7
|
*/
|
8
|
-
static void internal_subset_func(
|
8
|
+
static void internal_subset_func(void *ctxt,
|
9
9
|
const char *name,
|
10
10
|
const char *extid,
|
11
11
|
const char *sysid) {
|
12
|
-
VALUE
|
12
|
+
VALUE self = (VALUE) ctxt;
|
13
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
13
14
|
|
14
15
|
if (handler != Qnil) {
|
15
16
|
VALUE rname = name ? rb_str_new2(name) : Qnil;
|
@@ -19,49 +20,55 @@ static void internal_subset_func(ruby_xml_sax_parser *cbp,
|
|
19
20
|
}
|
20
21
|
}
|
21
22
|
|
22
|
-
static void is_standalone_func(
|
23
|
-
VALUE
|
23
|
+
static void is_standalone_func(void *ctxt) {
|
24
|
+
VALUE self = (VALUE) ctxt;
|
25
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
24
26
|
|
25
27
|
if (handler != Qnil) {
|
26
28
|
rb_funcall(handler, cbidOnIsStandalone,0);
|
27
29
|
}
|
28
30
|
}
|
29
31
|
|
30
|
-
static void has_internal_subset_func(
|
31
|
-
VALUE
|
32
|
+
static void has_internal_subset_func(void *ctxt) {
|
33
|
+
VALUE self = (VALUE) ctxt;
|
34
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
32
35
|
|
33
36
|
if (handler != Qnil) {
|
34
37
|
rb_funcall(handler, cbidOnHasInternalSubset, 0);
|
35
38
|
}
|
36
39
|
}
|
37
40
|
|
38
|
-
static void has_external_subset_func(
|
39
|
-
VALUE
|
41
|
+
static void has_external_subset_func(void *ctxt) {
|
42
|
+
VALUE self = (VALUE) ctxt;
|
43
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
40
44
|
|
41
45
|
if (handler != Qnil) {
|
42
46
|
rb_funcall(handler, cbidOnHasExternalSubset, 0);
|
43
47
|
}
|
44
48
|
}
|
45
49
|
|
46
|
-
static void start_document_func(
|
47
|
-
VALUE
|
50
|
+
static void start_document_func(void *ctxt) {
|
51
|
+
VALUE self = (VALUE) ctxt;
|
52
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
48
53
|
|
49
54
|
if (handler != Qnil) {
|
50
55
|
rb_funcall(handler, cbidOnStartDocument, 0);
|
51
56
|
}
|
52
57
|
}
|
53
58
|
|
54
|
-
static void end_document_func(
|
55
|
-
VALUE
|
59
|
+
static void end_document_func(void *ctxt) {
|
60
|
+
VALUE self = (VALUE) ctxt;
|
61
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
56
62
|
|
57
63
|
if (handler != Qnil) {
|
58
64
|
rb_funcall(handler, cbidOnEndDocument, 0);
|
59
65
|
}
|
60
66
|
}
|
61
67
|
|
62
|
-
static void start_element_func(
|
68
|
+
static void start_element_func(void *ctxt,
|
63
69
|
const char *name, const char **attrs) {
|
64
|
-
VALUE
|
70
|
+
VALUE self = (VALUE) ctxt;
|
71
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
65
72
|
VALUE ahsh = rb_hash_new();
|
66
73
|
const char *attr, *value;
|
67
74
|
|
@@ -77,26 +84,29 @@ static void start_element_func(ruby_xml_sax_parser *cbp,
|
|
77
84
|
}
|
78
85
|
}
|
79
86
|
|
80
|
-
static void end_element_func(
|
81
|
-
VALUE
|
87
|
+
static void end_element_func(void *ctxt, const char *name) {
|
88
|
+
VALUE self = (VALUE) ctxt;
|
89
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
82
90
|
|
83
91
|
if (handler != Qnil) {
|
84
92
|
rb_funcall(handler, cbidOnEndElement, 1, rb_str_new2(name));
|
85
93
|
}
|
86
94
|
}
|
87
95
|
|
88
|
-
static void reference_func(
|
96
|
+
static void reference_func(void *ctxt,
|
89
97
|
const char *name) {
|
90
|
-
VALUE
|
98
|
+
VALUE self = (VALUE) ctxt;
|
99
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
91
100
|
|
92
101
|
if (handler != Qnil) {
|
93
102
|
rb_funcall(handler, cbidOnReference,1,rb_str_new2(name));
|
94
103
|
}
|
95
104
|
}
|
96
105
|
|
97
|
-
static void characters_func(
|
106
|
+
static void characters_func(void *ctxt,
|
98
107
|
const char *chars, int len) {
|
99
|
-
VALUE
|
108
|
+
VALUE self = (VALUE) ctxt;
|
109
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
100
110
|
|
101
111
|
if (handler != Qnil) {
|
102
112
|
VALUE rchars = rb_str_new(chars, len);
|
@@ -104,9 +114,10 @@ static void characters_func(ruby_xml_sax_parser *cbp,
|
|
104
114
|
}
|
105
115
|
}
|
106
116
|
|
107
|
-
static void processing_instruction_func(
|
117
|
+
static void processing_instruction_func(void *ctxt,
|
108
118
|
const char *target, const char *data) {
|
109
|
-
VALUE
|
119
|
+
VALUE self = (VALUE) ctxt;
|
120
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
110
121
|
|
111
122
|
if (handler != Qnil) {
|
112
123
|
VALUE rtarget = target ? rb_str_new2(target) : Qnil;
|
@@ -115,9 +126,10 @@ static void processing_instruction_func(ruby_xml_sax_parser *cbp,
|
|
115
126
|
}
|
116
127
|
}
|
117
128
|
|
118
|
-
static void comment_func(
|
129
|
+
static void comment_func(void *ctxt,
|
119
130
|
const char *msg) {
|
120
|
-
VALUE
|
131
|
+
VALUE self = (VALUE) ctxt;
|
132
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
121
133
|
|
122
134
|
if (handler != Qnil) {
|
123
135
|
rb_funcall(handler, cbidOnComment,1,rb_str_new2(msg));
|
@@ -136,47 +148,52 @@ static void comment_func(ruby_xml_sax_parser *cbp,
|
|
136
148
|
while (0)
|
137
149
|
|
138
150
|
// TODO these next three should actually be formatting messages.
|
139
|
-
static void warning_func(
|
151
|
+
static void warning_func(void *ctxt,
|
140
152
|
const char *msg, ...) {
|
141
|
-
VALUE
|
153
|
+
VALUE self = (VALUE) ctxt;
|
154
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
142
155
|
|
143
156
|
if (handler != Qnil) {
|
144
157
|
FORMAT_AND_CALL(cbidOnXmlParserWarning);
|
145
158
|
}
|
146
159
|
}
|
147
160
|
|
148
|
-
static void error_func(
|
161
|
+
static void error_func(void *ctxt,
|
149
162
|
const char *msg, ...) {
|
150
|
-
VALUE
|
163
|
+
VALUE self = (VALUE) ctxt;
|
164
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
151
165
|
|
152
166
|
if (handler != Qnil) {
|
153
167
|
FORMAT_AND_CALL(cbidOnXmlParserError);
|
154
168
|
}
|
155
169
|
}
|
156
170
|
|
157
|
-
static void fatal_error_func(
|
171
|
+
static void fatal_error_func(void *ctxt,
|
158
172
|
const char *msg, ...) {
|
159
|
-
VALUE
|
173
|
+
VALUE self = (VALUE) ctxt;
|
174
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
160
175
|
|
161
176
|
if (handler != Qnil) {
|
162
177
|
FORMAT_AND_CALL(cbidOnXmlParserFatalError);
|
163
178
|
}
|
164
179
|
}
|
165
180
|
|
166
|
-
static void cdata_block_func(
|
181
|
+
static void cdata_block_func(void *ctxt,
|
167
182
|
const char *value, int len) {
|
168
|
-
VALUE
|
183
|
+
VALUE self = (VALUE) ctxt;
|
184
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
169
185
|
|
170
186
|
if (handler != Qnil) {
|
171
187
|
rb_funcall(handler, cbidOnCdataBlock,1,rb_str_new(value, len));
|
172
188
|
}
|
173
189
|
}
|
174
190
|
|
175
|
-
static void external_subset_func(
|
191
|
+
static void external_subset_func(void *ctxt,
|
176
192
|
const char *name,
|
177
193
|
const char *extid,
|
178
194
|
const char *sysid) {
|
179
|
-
VALUE
|
195
|
+
VALUE self = (VALUE) ctxt;
|
196
|
+
VALUE handler = rb_ivar_get(self, CALLBACKS_ATTR);
|
180
197
|
|
181
198
|
if (handler != Qnil) {
|
182
199
|
VALUE rname = name ? rb_str_new2(name) : Qnil;
|
@@ -186,7 +203,7 @@ static void external_subset_func(ruby_xml_sax_parser *cbp,
|
|
186
203
|
}
|
187
204
|
}
|
188
205
|
|
189
|
-
static xmlSAXHandler
|
206
|
+
static xmlSAXHandler rxml_sax_hander_struct = {
|
190
207
|
(internalSubsetSAXFunc)internal_subset_func,
|
191
208
|
(isStandaloneSAXFunc)is_standalone_func,
|
192
209
|
(hasInternalSubsetSAXFunc)has_internal_subset_func,
|
data/ext/libxml/version.h
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
/* Don't nuke this block! It is used for automatically updating the
|
2
2
|
* versions below. VERSION = string formatting, VERNUM = numbered
|
3
3
|
* version for inline testing: increment both or none at all.*/
|
4
|
-
#define RUBY_LIBXML_VERSION "0.9.
|
4
|
+
#define RUBY_LIBXML_VERSION "0.9.3"
|
5
5
|
#define RUBY_LIBXML_VERNUM 0
|
6
6
|
#define RUBY_LIBXML_VER_MAJ 0
|
7
7
|
#define RUBY_LIBXML_VER_MIN 9
|
8
|
-
#define RUBY_LIBXML_VER_MIC
|
8
|
+
#define RUBY_LIBXML_VER_MIC 3
|
9
9
|
#define RUBY_LIBXML_VER_PATCH 0
|
data/ext/vc/libxml_ruby.vcproj
CHANGED
@@ -63,7 +63,7 @@
|
|
63
63
|
<Tool
|
64
64
|
Name="VCLinkerTool"
|
65
65
|
AdditionalDependencies="msvcrt-ruby18.lib libxml2.lib"
|
66
|
-
OutputFile="C:\Development\ruby\lib\ruby\gems\1.8\gems\libxml-ruby-0.9.
|
66
|
+
OutputFile="C:\Development\ruby\lib\ruby\gems\1.8\gems\libxml-ruby-0.9.3-x86-mswin32-60\lib\$(ProjectName).so"
|
67
67
|
LinkIncremental="2"
|
68
68
|
AdditionalLibraryDirectories="C:\Development\ruby\lib;C:\Development\msys\local\lib"
|
69
69
|
GenerateDebugInformation="true"
|
@@ -205,10 +205,6 @@
|
|
205
205
|
RelativePath="..\libxml\ruby_xml_dtd.c"
|
206
206
|
>
|
207
207
|
</File>
|
208
|
-
<File
|
209
|
-
RelativePath="..\libxml\ruby_xml_encoding.c"
|
210
|
-
>
|
211
|
-
</File>
|
212
208
|
<File
|
213
209
|
RelativePath="..\libxml\ruby_xml_error.c"
|
214
210
|
>
|
@@ -311,10 +307,6 @@
|
|
311
307
|
RelativePath="..\libxml\ruby_xml_dtd.h"
|
312
308
|
>
|
313
309
|
</File>
|
314
|
-
<File
|
315
|
-
RelativePath="..\libxml\ruby_xml_encoding.h"
|
316
|
-
>
|
317
|
-
</File>
|
318
310
|
<File
|
319
311
|
RelativePath="..\libxml\ruby_xml_error.h"
|
320
312
|
>
|
data/lib/libxml/html_parser.rb
CHANGED
@@ -2,31 +2,31 @@ module LibXML
|
|
2
2
|
module XML
|
3
3
|
class HTMLParser
|
4
4
|
def self.file(value)
|
5
|
-
parser =
|
5
|
+
parser = self.new
|
6
6
|
parser.input.file = value
|
7
7
|
parser
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.string(value)
|
11
|
-
parser =
|
11
|
+
parser = self.new
|
12
12
|
parser.input.string = value
|
13
13
|
parser
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.document(value)
|
17
|
-
parser =
|
17
|
+
parser = self.new
|
18
18
|
parser.input.document = value
|
19
19
|
parser
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.io(value)
|
23
|
-
parser =
|
23
|
+
parser = self.new
|
24
24
|
parser.input.io = value
|
25
25
|
parser
|
26
26
|
end
|
27
27
|
|
28
28
|
def file
|
29
|
-
input.
|
29
|
+
input.file
|
30
30
|
end
|
31
31
|
|
32
32
|
def file=(value)
|
data/lib/libxml/parser.rb
CHANGED
@@ -7,25 +7,25 @@ module LibXML
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.file(value)
|
10
|
-
parser =
|
10
|
+
parser = self.new
|
11
11
|
parser.input.file = value
|
12
12
|
parser
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.string(value)
|
16
|
-
parser =
|
16
|
+
parser = self.new
|
17
17
|
parser.input.string = value
|
18
18
|
parser
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.document(value)
|
22
|
-
parser =
|
22
|
+
parser = self.new
|
23
23
|
parser.input.document = value
|
24
24
|
parser
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.io(value)
|
28
|
-
parser =
|
28
|
+
parser = self.new
|
29
29
|
parser.input.io = value
|
30
30
|
parser
|
31
31
|
end
|
data/lib/libxml/sax_parser.rb
CHANGED
@@ -1,6 +1,30 @@
|
|
1
1
|
module LibXML
|
2
2
|
module XML
|
3
3
|
class SaxParser
|
4
|
+
def self.file(value)
|
5
|
+
parser = self.new
|
6
|
+
parser.input.file = value
|
7
|
+
parser
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.string(value)
|
11
|
+
parser = self.new
|
12
|
+
parser.input.string = value
|
13
|
+
parser
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.document(value)
|
17
|
+
parser = self.new
|
18
|
+
parser.input.document = value
|
19
|
+
parser
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.io(value)
|
23
|
+
parser = self.new
|
24
|
+
parser.input.io = value
|
25
|
+
parser
|
26
|
+
end
|
27
|
+
|
4
28
|
def filename=(value)
|
5
29
|
warn("SaxParser.filename is deprecated. Use SaxParser#file instead.")
|
6
30
|
self.file = value
|
data/test/tc_document_write.rb
CHANGED
@@ -132,29 +132,15 @@ class TestDocumentWrite < Test::Unit::TestCase
|
|
132
132
|
|
133
133
|
def test_encoding_utf
|
134
134
|
@doc.root = XML::Node.new('rubynet')
|
135
|
-
@doc.encoding = XML::
|
135
|
+
@doc.encoding = XML::Input.encoding_to_s(XML::Input::UTF8)
|
136
136
|
assert_instance_of(XML::Node, @doc.root)
|
137
137
|
assert_equal("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rubynet/>\n", @doc.to_s)
|
138
138
|
end
|
139
139
|
|
140
140
|
def test_encoding_latin1
|
141
141
|
@doc.root = XML::Node.new('rubynet')
|
142
|
-
@doc.encoding = XML::
|
142
|
+
@doc.encoding = XML::Input.encoding_to_s(XML::Input::ISO_8859_1)
|
143
143
|
assert_instance_of(XML::Node, @doc.root)
|
144
144
|
assert_equal("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<rubynet/>\n", @doc.to_s)
|
145
145
|
end
|
146
|
-
|
147
|
-
def test_encoding_to_s
|
148
|
-
doc = XML::Document.new
|
149
|
-
doc.encoding = 'UTF-8'
|
150
|
-
doc.root = XML::Node.new 'node'
|
151
|
-
doc.root.content = ''
|
152
|
-
|
153
|
-
xml = doc.to_s(true, 'UTF-8')
|
154
|
-
puts xml
|
155
|
-
|
156
|
-
parser = XML::Parser.string(xml)
|
157
|
-
doc = parser.parse
|
158
|
-
p doc.root.content
|
159
|
-
end
|
160
146
|
end
|
data/test/tc_html_parser.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require "xml"
|
2
2
|
require 'test/unit'
|
3
3
|
|
4
|
-
class
|
5
|
-
def setup
|
4
|
+
class HtmlParserTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
6
|
@xp = XML::HTMLParser.new()
|
7
7
|
assert_not_nil(@xp)
|
8
8
|
str = '<html><head><meta name=keywords content=nasty></head><body>Hello<br>World</html>'
|
@@ -14,7 +14,59 @@ class TC_XML_HTMLParser < Test::Unit::TestCase
|
|
14
14
|
@xp = nil
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def html_file
|
18
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'model/rubynet.xml'))
|
19
|
+
end
|
20
|
+
|
21
|
+
# ----- Sources ------
|
22
|
+
def test_file
|
23
|
+
xp = XML::HTMLParser.file(html_file)
|
24
|
+
assert_instance_of(XML::HTMLParser, xp)
|
25
|
+
assert_equal(html_file, xp.file)
|
26
|
+
assert_equal(html_file, xp.input.file)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_string
|
30
|
+
str = '<html><body><p>hi</p></body></html>'
|
31
|
+
xp = XML::HTMLParser.string(str)
|
32
|
+
|
33
|
+
assert_instance_of(XML::HTMLParser, xp)
|
34
|
+
assert_instance_of(XML::HTMLParser, xp)
|
35
|
+
assert_equal(str, xp.string)
|
36
|
+
assert_equal(str, xp.input.string)
|
37
|
+
|
38
|
+
doc = xp.parse
|
39
|
+
assert_instance_of(XML::Document, doc)
|
40
|
+
assert_instance_of(XML::Parser::Context, xp.context)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_io
|
44
|
+
File.open(html_file) do |io|
|
45
|
+
xp = XML::HTMLParser.io(io)
|
46
|
+
assert_instance_of(XML::HTMLParser, xp)
|
47
|
+
assert_equal(io, xp.io)
|
48
|
+
assert_equal(io, xp.input.io)
|
49
|
+
|
50
|
+
doc = xp.parse
|
51
|
+
assert_instance_of(XML::Document, doc)
|
52
|
+
assert_instance_of(XML::Parser::Context, xp.context)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_string_io
|
57
|
+
data = File.read(html_file)
|
58
|
+
io = StringIO.new(data)
|
59
|
+
xp = XML::HTMLParser.io(io)
|
60
|
+
assert_instance_of(XML::HTMLParser, xp)
|
61
|
+
assert_equal(io, xp.io)
|
62
|
+
assert_equal(io, xp.input.io)
|
63
|
+
|
64
|
+
doc = xp.parse
|
65
|
+
assert_instance_of(XML::Document, doc)
|
66
|
+
assert_instance_of(XML::Parser::Context, xp.context)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_libxml_html_parser_parse
|
18
70
|
doc = @xp.parse
|
19
71
|
|
20
72
|
assert_instance_of XML::Document, doc
|
@@ -54,10 +106,10 @@ class TC_XML_HTMLParser < Test::Unit::TestCase
|
|
54
106
|
assert_equal 'World', world.content
|
55
107
|
end
|
56
108
|
|
57
|
-
def test_libxml_html_parser_context
|
109
|
+
def test_libxml_html_parser_context
|
58
110
|
doc = @xp.parse
|
59
111
|
assert_instance_of(XML::Document, doc)
|
60
112
|
assert_instance_of(XML::Parser::Context, @xp.context)
|
61
113
|
assert @xp.context.html?
|
62
114
|
end
|
63
|
-
end
|
115
|
+
end
|