nokogiri 1.4.7-java → 1.5.0.beta.1-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of nokogiri might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/CHANGELOG.ja.rdoc +8 -83
- data/CHANGELOG.rdoc +6 -80
- data/Manifest.txt +4 -74
- data/README.ja.rdoc +5 -1
- data/README.rdoc +8 -22
- data/Rakefile +79 -60
- data/bin/nokogiri +1 -6
- data/deps.rip +5 -0
- data/ext/nokogiri/extconf.rb +32 -53
- data/ext/nokogiri/nokogiri.c +0 -2
- data/ext/nokogiri/nokogiri.h +0 -9
- data/ext/nokogiri/xml_document.c +0 -14
- data/ext/nokogiri/xml_dtd.c +2 -2
- data/ext/nokogiri/xml_io.c +7 -32
- data/ext/nokogiri/xml_node.c +31 -103
- data/ext/nokogiri/xml_node_set.c +8 -8
- data/ext/nokogiri/xml_reader.c +1 -20
- data/ext/nokogiri/xml_sax_parser.c +3 -5
- data/ext/nokogiri/xml_sax_parser_context.c +0 -40
- data/ext/nokogiri/xml_xpath_context.c +2 -35
- data/ext/nokogiri/xslt_stylesheet.c +6 -124
- data/lib/isorelax.jar +0 -0
- data/lib/jing.jar +0 -0
- data/lib/nekodtd.jar +0 -0
- data/lib/nekohtml.jar +0 -0
- data/lib/nokogiri.rb +7 -3
- data/lib/nokogiri/css.rb +3 -6
- data/lib/nokogiri/css/generated_parser.rb +669 -0
- data/lib/nokogiri/css/generated_tokenizer.rb +145 -0
- data/lib/nokogiri/css/parser.rb +70 -665
- data/lib/nokogiri/css/parser.y +1 -6
- data/lib/nokogiri/css/tokenizer.rb +3 -148
- data/lib/nokogiri/css/tokenizer.rex +1 -1
- data/lib/nokogiri/css/xpath_visitor.rb +14 -16
- data/lib/nokogiri/decorators/slop.rb +3 -5
- data/lib/nokogiri/html.rb +3 -2
- data/lib/nokogiri/html/document.rb +18 -134
- data/lib/nokogiri/html/document_fragment.rb +21 -26
- data/lib/nokogiri/html/element_description_defaults.rb +671 -0
- data/lib/nokogiri/html/sax/parser.rb +2 -6
- data/lib/nokogiri/nokogiri.jar +0 -0
- data/lib/nokogiri/version.rb +4 -9
- data/lib/nokogiri/xml/attribute_decl.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +1 -1
- data/lib/nokogiri/xml/document.rb +3 -27
- data/lib/nokogiri/xml/document_fragment.rb +2 -9
- data/lib/nokogiri/xml/dtd.rb +1 -12
- data/lib/nokogiri/xml/element_decl.rb +1 -1
- data/lib/nokogiri/xml/entity_decl.rb +1 -1
- data/lib/nokogiri/xml/node.rb +75 -172
- data/lib/nokogiri/xml/node/save_options.rb +0 -10
- data/lib/nokogiri/xml/node_set.rb +3 -28
- data/lib/nokogiri/xml/parse_options.rb +0 -8
- data/lib/nokogiri/xml/reader.rb +6 -44
- data/lib/nokogiri/xml/sax/document.rb +5 -9
- data/lib/nokogiri/xml/schema.rb +1 -7
- data/lib/nokogiri/xslt.rb +5 -9
- data/lib/xercesImpl.jar +0 -0
- data/tasks/cross_compile.rb +12 -27
- data/tasks/test.rb +0 -0
- data/test/css/test_parser.rb +19 -40
- data/test/css/test_tokenizer.rb +0 -8
- data/test/helper.rb +1 -4
- data/test/html/sax/test_parser.rb +21 -47
- data/test/html/sax/test_parser_context.rb +2 -2
- data/test/html/test_document.rb +3 -58
- data/test/html/test_document_encoding.rb +0 -53
- data/test/html/test_document_fragment.rb +13 -82
- data/test/html/test_element_description.rb +4 -2
- data/test/html/test_node.rb +0 -9
- data/test/test_memory_leak.rb +2 -57
- data/test/test_nokogiri.rb +14 -20
- data/test/test_reader.rb +7 -47
- data/test/test_xslt_transforms.rb +5 -8
- data/test/xml/sax/test_parser.rb +17 -34
- data/test/xml/sax/test_parser_context.rb +0 -50
- data/test/xml/sax/test_push_parser.rb +1 -18
- data/test/xml/test_attr.rb +4 -31
- data/test/xml/test_attribute_decl.rb +7 -3
- data/test/xml/test_builder.rb +5 -5
- data/test/xml/test_cdata.rb +3 -3
- data/test/xml/test_document.rb +18 -15
- data/test/xml/test_document_fragment.rb +20 -19
- data/test/xml/test_dtd.rb +13 -18
- data/test/xml/test_element_content.rb +1 -1
- data/test/xml/test_element_decl.rb +1 -1
- data/test/xml/test_entity_decl.rb +12 -10
- data/test/xml/test_namespace.rb +7 -5
- data/test/xml/test_node.rb +15 -54
- data/test/xml/test_node_reparenting.rb +42 -85
- data/test/xml/test_node_set.rb +2 -61
- data/test/xml/test_schema.rb +0 -5
- data/test/xml/test_text.rb +2 -11
- data/test/xml/test_unparented_node.rb +1 -1
- data/test/xml/test_xpath.rb +7 -43
- metadata +442 -473
- metadata.gz.sig +0 -0
- data/.gemtest +0 -0
- data/ext/nokogiri/depend +0 -358
- data/ext/nokogiri/libcharset-1.dll +0 -0
- data/ext/nokogiri/libexslt.dll +0 -0
- data/ext/nokogiri/libiconv-2.dll +0 -0
- data/ext/nokogiri/libxml2.dll +0 -0
- data/ext/nokogiri/libxslt.dll +0 -0
- data/ext/nokogiri/xml_libxml2_hacks.c +0 -112
- data/ext/nokogiri/xml_libxml2_hacks.h +0 -12
- data/ext/nokogiri/zlib1.dll +0 -0
- data/lib/nokogiri/css/parser_extras.rb +0 -91
- data/lib/nokogiri/ffi/encoding_handler.rb +0 -42
- data/lib/nokogiri/ffi/html/document.rb +0 -28
- data/lib/nokogiri/ffi/html/element_description.rb +0 -81
- data/lib/nokogiri/ffi/html/entity_lookup.rb +0 -16
- data/lib/nokogiri/ffi/html/sax/parser_context.rb +0 -38
- data/lib/nokogiri/ffi/io_callbacks.rb +0 -42
- data/lib/nokogiri/ffi/libxml.rb +0 -420
- data/lib/nokogiri/ffi/structs/common_node.rb +0 -38
- data/lib/nokogiri/ffi/structs/html_elem_desc.rb +0 -24
- data/lib/nokogiri/ffi/structs/html_entity_desc.rb +0 -13
- data/lib/nokogiri/ffi/structs/xml_alloc.rb +0 -16
- data/lib/nokogiri/ffi/structs/xml_attr.rb +0 -20
- data/lib/nokogiri/ffi/structs/xml_attribute.rb +0 -27
- data/lib/nokogiri/ffi/structs/xml_buffer.rb +0 -16
- data/lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb +0 -11
- data/lib/nokogiri/ffi/structs/xml_document.rb +0 -117
- data/lib/nokogiri/ffi/structs/xml_dtd.rb +0 -28
- data/lib/nokogiri/ffi/structs/xml_element.rb +0 -26
- data/lib/nokogiri/ffi/structs/xml_element_content.rb +0 -17
- data/lib/nokogiri/ffi/structs/xml_entity.rb +0 -32
- data/lib/nokogiri/ffi/structs/xml_enumeration.rb +0 -12
- data/lib/nokogiri/ffi/structs/xml_node.rb +0 -28
- data/lib/nokogiri/ffi/structs/xml_node_set.rb +0 -53
- data/lib/nokogiri/ffi/structs/xml_notation.rb +0 -11
- data/lib/nokogiri/ffi/structs/xml_ns.rb +0 -15
- data/lib/nokogiri/ffi/structs/xml_parser_context.rb +0 -20
- data/lib/nokogiri/ffi/structs/xml_parser_input.rb +0 -19
- data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +0 -14
- data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +0 -51
- data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +0 -124
- data/lib/nokogiri/ffi/structs/xml_schema.rb +0 -13
- data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +0 -31
- data/lib/nokogiri/ffi/structs/xml_text_reader.rb +0 -12
- data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +0 -38
- data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +0 -35
- data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +0 -20
- data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +0 -13
- data/lib/nokogiri/ffi/weak_bucket.rb +0 -40
- data/lib/nokogiri/ffi/xml/attr.rb +0 -41
- data/lib/nokogiri/ffi/xml/attribute_decl.rb +0 -27
- data/lib/nokogiri/ffi/xml/cdata.rb +0 -19
- data/lib/nokogiri/ffi/xml/comment.rb +0 -18
- data/lib/nokogiri/ffi/xml/document.rb +0 -174
- data/lib/nokogiri/ffi/xml/document_fragment.rb +0 -21
- data/lib/nokogiri/ffi/xml/dtd.rb +0 -67
- data/lib/nokogiri/ffi/xml/element_content.rb +0 -43
- data/lib/nokogiri/ffi/xml/element_decl.rb +0 -19
- data/lib/nokogiri/ffi/xml/entity_decl.rb +0 -36
- data/lib/nokogiri/ffi/xml/entity_reference.rb +0 -19
- data/lib/nokogiri/ffi/xml/namespace.rb +0 -44
- data/lib/nokogiri/ffi/xml/node.rb +0 -559
- data/lib/nokogiri/ffi/xml/node_set.rb +0 -150
- data/lib/nokogiri/ffi/xml/processing_instruction.rb +0 -20
- data/lib/nokogiri/ffi/xml/reader.rb +0 -236
- data/lib/nokogiri/ffi/xml/relax_ng.rb +0 -85
- data/lib/nokogiri/ffi/xml/sax/parser.rb +0 -143
- data/lib/nokogiri/ffi/xml/sax/parser_context.rb +0 -79
- data/lib/nokogiri/ffi/xml/sax/push_parser.rb +0 -51
- data/lib/nokogiri/ffi/xml/schema.rb +0 -109
- data/lib/nokogiri/ffi/xml/syntax_error.rb +0 -98
- data/lib/nokogiri/ffi/xml/text.rb +0 -18
- data/lib/nokogiri/ffi/xml/xpath.rb +0 -9
- data/lib/nokogiri/ffi/xml/xpath_context.rb +0 -153
- data/lib/nokogiri/ffi/xslt/stylesheet.rb +0 -77
- data/test/decorators/test_slop.rb +0 -16
- data/test/ffi/test_document.rb +0 -35
- data/test/files/encoding.html +0 -82
- data/test/files/encoding.xhtml +0 -84
- data/test/xslt/test_custom_functions.rb +0 -94
@@ -9,7 +9,7 @@ module Nokogiri
|
|
9
9
|
<?xml version="1.0"?><?TEST-STYLE PIDATA?>
|
10
10
|
<!DOCTYPE staff SYSTEM "staff.dtd" [
|
11
11
|
<!ATTLIST br width CDATA "0">
|
12
|
-
<!ATTLIST a width CDATA >
|
12
|
+
<!ATTLIST a width CDATA "0">
|
13
13
|
<!ATTLIST payment type (check|cash) "cash">
|
14
14
|
]>
|
15
15
|
<root />
|
@@ -64,12 +64,16 @@ module Nokogiri
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_attribute_type
|
67
|
-
|
67
|
+
if Nokogiri.uses_libxml?
|
68
|
+
assert_equal 1, @attr_decl.attribute_type
|
69
|
+
else
|
70
|
+
assert_equal 'CDATA', @attr_decl.attribute_type
|
71
|
+
end
|
68
72
|
end
|
69
73
|
|
70
74
|
def test_default
|
71
75
|
assert_equal '0', @attr_decl.default
|
72
|
-
|
76
|
+
assert_equal '0', @attrs[1].default
|
73
77
|
end
|
74
78
|
|
75
79
|
def test_enumeration
|
data/test/xml/test_builder.rb
CHANGED
@@ -83,8 +83,8 @@ module Nokogiri
|
|
83
83
|
end
|
84
84
|
}
|
85
85
|
doc = b.doc
|
86
|
-
assert_equal 'bar', doc.at('foo|bar', 'foo' => 'bar').namespace.href
|
87
|
-
assert_equal 'bar', doc.at('foo|baz', 'foo' => 'bar').namespace.href
|
86
|
+
assert_equal 'bar', b.doc.at('foo|bar', 'foo' => 'bar').namespace.href
|
87
|
+
assert_equal 'bar', b.doc.at('foo|baz', 'foo' => 'bar').namespace.href
|
88
88
|
end
|
89
89
|
|
90
90
|
def test_specify_namespace_nested
|
@@ -100,12 +100,12 @@ module Nokogiri
|
|
100
100
|
end
|
101
101
|
}
|
102
102
|
doc = b.doc
|
103
|
-
assert_equal 'bar', doc.at('foo|bar', 'foo' => 'bar').namespace.href
|
104
|
-
assert_equal 'bar', doc.at('foo|baz', 'foo' => 'bar').namespace.href
|
103
|
+
assert_equal 'bar', b.doc.at('foo|bar', 'foo' => 'bar').namespace.href
|
104
|
+
assert_equal 'bar', b.doc.at('foo|baz', 'foo' => 'bar').namespace.href
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_specified_namespace_undeclared
|
108
|
-
Nokogiri::XML::Builder.new { |xml|
|
108
|
+
b = Nokogiri::XML::Builder.new { |xml|
|
109
109
|
xml.root do
|
110
110
|
assert_raises(ArgumentError) do
|
111
111
|
xml[:foo]
|
data/test/xml/test_cdata.rb
CHANGED
data/test/xml/test_document.rb
CHANGED
@@ -21,6 +21,12 @@ module Nokogiri
|
|
21
21
|
assert_equal nil, @xml.root
|
22
22
|
end
|
23
23
|
|
24
|
+
def test_parse_should_not_exist
|
25
|
+
assert_raises(NoMethodError) do
|
26
|
+
@xml.parse("foo")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
24
30
|
def test_collect_namespaces
|
25
31
|
doc = Nokogiri::XML(<<-eoxml)
|
26
32
|
<xml>
|
@@ -217,7 +223,12 @@ module Nokogiri
|
|
217
223
|
end
|
218
224
|
|
219
225
|
def test_validate
|
220
|
-
|
226
|
+
if Nokogiri.uses_libxml?
|
227
|
+
assert_equal 44, @xml.validate.length
|
228
|
+
else
|
229
|
+
xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE) {|cfg| cfg.dtdvalid}
|
230
|
+
assert_equal 37, xml.validate.length
|
231
|
+
end
|
221
232
|
end
|
222
233
|
|
223
234
|
def test_validate_no_internal_subset
|
@@ -329,12 +340,12 @@ module Nokogiri
|
|
329
340
|
end
|
330
341
|
|
331
342
|
def test_non_existant_function
|
332
|
-
# WTF. I don't know why this is different between MRI and
|
343
|
+
# WTF. I don't know why this is different between MRI and Jruby
|
333
344
|
# They should be the same... Either way, raising an exception
|
334
345
|
# is the correct thing to do.
|
335
346
|
exception = RuntimeError
|
336
347
|
|
337
|
-
if Nokogiri::VERSION_INFO['libxml']['platform'] == 'jruby'
|
348
|
+
if !Nokogiri.uses_libxml? || (Nokogiri.uses_libxml? && Nokogiri::VERSION_INFO['libxml']['platform'] == 'jruby')
|
338
349
|
exception = Nokogiri::XML::XPath::SyntaxError
|
339
350
|
end
|
340
351
|
|
@@ -406,7 +417,7 @@ module Nokogiri
|
|
406
417
|
end
|
407
418
|
|
408
419
|
# wtf... osx's libxml sucks.
|
409
|
-
unless Nokogiri::LIBXML_VERSION =~ /^2\.6\./
|
420
|
+
unless !Nokogiri.uses_libxml? || Nokogiri::LIBXML_VERSION =~ /^2\.6\./
|
410
421
|
def test_encoding
|
411
422
|
xml = Nokogiri::XML(File.read(XML_FILE), XML_FILE, 'UTF-8')
|
412
423
|
assert_equal 'UTF-8', xml.encoding
|
@@ -606,31 +617,23 @@ module Nokogiri
|
|
606
617
|
<a:foo>hello from a</a:foo>
|
607
618
|
<b:foo>hello from b</b:foo>
|
608
619
|
<container xmlns:c="http://c.flavorjon.es/">
|
609
|
-
<c:foo
|
620
|
+
<c:foo>hello from c</c:foo>
|
610
621
|
</container>
|
611
622
|
</root>
|
612
623
|
EOX
|
613
624
|
|
614
|
-
namespaces = doc.root.namespaces
|
615
|
-
|
616
625
|
# assert on setup
|
617
|
-
assert_equal 2, doc.root.namespaces.length
|
618
|
-
assert_equal 3, doc.at_xpath("//container").namespaces.length
|
619
626
|
assert_equal 0, doc.xpath("//foo").length
|
620
627
|
assert_equal 1, doc.xpath("//a:foo").length
|
621
628
|
assert_equal 1, doc.xpath("//a:foo").length
|
622
629
|
assert_equal 1, doc.xpath("//x:foo", "x" => "http://c.flavorjon.es/").length
|
623
|
-
assert_match %r{foo c:attr}, doc.to_xml
|
624
630
|
|
625
631
|
doc.remove_namespaces!
|
626
632
|
|
627
|
-
assert_equal 0, doc.root.namespaces.length
|
628
|
-
assert_equal 0, doc.at_xpath("//container").namespaces.length
|
629
633
|
assert_equal 3, doc.xpath("//foo").length
|
630
|
-
assert_equal 0, doc.xpath("//a:foo"
|
631
|
-
assert_equal 0, doc.xpath("//a:foo"
|
634
|
+
assert_equal 0, doc.xpath("//a:foo").length
|
635
|
+
assert_equal 0, doc.xpath("//a:foo").length
|
632
636
|
assert_equal 0, doc.xpath("//x:foo", "x" => "http://c.flavorjon.es/").length
|
633
|
-
assert_match %r{foo attr}, doc.to_xml
|
634
637
|
end
|
635
638
|
|
636
639
|
def test_subset_is_decorated
|
@@ -15,21 +15,29 @@ module Nokogiri
|
|
15
15
|
hello = fragment.child
|
16
16
|
|
17
17
|
assert_equal 'hello', hello.name
|
18
|
-
|
18
|
+
if Nokogiri.uses_libxml?
|
19
|
+
assert_equal doc.root.child.namespace, hello.namespace
|
20
|
+
else
|
21
|
+
assert_equal doc.root.child.namespace.href, hello.namespace.href
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
def test_node_fragment_is_relative
|
22
26
|
doc = Nokogiri::XML('<root><a xmlns="blah" /></root>')
|
23
|
-
|
27
|
+
ctx = doc.root.child
|
24
28
|
fragment = doc.root.child.fragment('<hello />')
|
25
29
|
hello = fragment.child
|
26
30
|
|
27
31
|
assert_equal 'hello', hello.name
|
28
|
-
|
32
|
+
if Nokogiri.uses_libxml?
|
33
|
+
assert_equal doc.root.child.namespace, hello.namespace
|
34
|
+
else
|
35
|
+
assert_equal doc.root.child.namespace.href, hello.namespace.href
|
36
|
+
end
|
29
37
|
end
|
30
38
|
|
31
39
|
def test_new
|
32
|
-
|
40
|
+
fragment = Nokogiri::XML::DocumentFragment.new(@xml)
|
33
41
|
end
|
34
42
|
|
35
43
|
def test_fragment_should_have_document
|
@@ -100,13 +108,13 @@ module Nokogiri
|
|
100
108
|
def test_xml_fragment_with_leading_whitespace
|
101
109
|
doc = " <div>b</div> "
|
102
110
|
fragment = Nokogiri::XML::Document.new.fragment(doc)
|
103
|
-
assert_equal "
|
111
|
+
assert_equal "<div>b</div>", fragment.to_s
|
104
112
|
end
|
105
113
|
|
106
114
|
def test_xml_fragment_with_leading_whitespace_and_newline
|
107
115
|
doc = " \n<div>b</div> "
|
108
116
|
fragment = Nokogiri::XML::Document.new.fragment(doc)
|
109
|
-
assert_equal "
|
117
|
+
assert_equal "<div>b</div>", fragment.to_s
|
110
118
|
end
|
111
119
|
|
112
120
|
def test_fragment_children_search
|
@@ -147,7 +155,12 @@ module Nokogiri
|
|
147
155
|
|
148
156
|
frag = doc.fragment "<bar:newnode></bar:newnode>"
|
149
157
|
assert frag.children.first.namespace
|
150
|
-
|
158
|
+
if Nokogiri.uses_libxml?
|
159
|
+
assert_equal ns, frag.children.first.namespace
|
160
|
+
else
|
161
|
+
assert_equal ns.href, frag.children.first.namespace.href
|
162
|
+
assert_equal ns.prefix, frag.children.first.namespace.prefix
|
163
|
+
end
|
151
164
|
end
|
152
165
|
|
153
166
|
def test_fragment_invalid_namespace_is_silently_ignored
|
@@ -175,18 +188,6 @@ module Nokogiri
|
|
175
188
|
end
|
176
189
|
assert fragment.children.respond_to?(:awesome!), fragment.children.class
|
177
190
|
end
|
178
|
-
|
179
|
-
def test_for_libxml_in_context_fragment_parsing_bug_workaround
|
180
|
-
10.times do
|
181
|
-
begin
|
182
|
-
fragment = Nokogiri::XML.fragment("<div></div>")
|
183
|
-
parent = fragment.children.first
|
184
|
-
child = parent.parse("<h1></h1>").first
|
185
|
-
parent.add_child child
|
186
|
-
end
|
187
|
-
GC.start
|
188
|
-
end
|
189
|
-
end
|
190
191
|
end
|
191
192
|
end
|
192
193
|
end
|
data/test/xml/test_dtd.rb
CHANGED
@@ -14,7 +14,11 @@ module Nokogiri
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_external_id
|
17
|
-
|
17
|
+
if Nokogiri.uses_libxml?
|
18
|
+
xml = Nokogiri::XML('<!DOCTYPE foo PUBLIC "bar"><foo />')
|
19
|
+
else
|
20
|
+
xml = Nokogiri::XML('<!DOCTYPE foo PUBLIC "bar" ""><foo />')
|
21
|
+
end
|
18
22
|
assert dtd = xml.internal_subset
|
19
23
|
assert_equal 'bar', dtd.external_id
|
20
24
|
end
|
@@ -25,26 +29,11 @@ module Nokogiri
|
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
28
|
-
def test_empty_attributes
|
29
|
-
dtd = Nokogiri::HTML("<html></html>").internal_subset
|
30
|
-
assert_equal Hash.new, dtd.attributes
|
31
|
-
end
|
32
|
-
|
33
32
|
def test_attributes
|
34
33
|
assert_equal ['width'], @dtd.attributes.keys
|
35
34
|
assert_equal '0', @dtd.attributes['width'].default
|
36
35
|
end
|
37
36
|
|
38
|
-
def test_keys
|
39
|
-
assert_equal ['width'], @dtd.keys
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_each
|
43
|
-
hash = {}
|
44
|
-
@dtd.each { |key, value| hash[key] = value }
|
45
|
-
assert_equal @dtd.attributes, hash
|
46
|
-
end
|
47
|
-
|
48
37
|
def test_namespace
|
49
38
|
assert_raise NoMethodError do
|
50
39
|
@dtd.namespace
|
@@ -64,8 +53,14 @@ module Nokogiri
|
|
64
53
|
end
|
65
54
|
|
66
55
|
def test_validate
|
67
|
-
|
68
|
-
|
56
|
+
if Nokogiri.uses_libxml?
|
57
|
+
list = @xml.internal_subset.validate @xml
|
58
|
+
assert_equal 44, list.length
|
59
|
+
else
|
60
|
+
xml = Nokogiri::XML(File.open(XML_FILE)) {|cfg| cfg.dtdvalid}
|
61
|
+
list = xml.internal_subset.validate xml
|
62
|
+
assert_equal 37, list.length
|
63
|
+
end
|
69
64
|
end
|
70
65
|
|
71
66
|
def test_external_subsets
|
@@ -9,7 +9,7 @@ module Nokogiri
|
|
9
9
|
<?xml version="1.0"?><?TEST-STYLE PIDATA?>
|
10
10
|
<!DOCTYPE staff SYSTEM "staff.dtd" [
|
11
11
|
<!ENTITY ent1 "es">
|
12
|
-
<!ENTITY nocontent >
|
12
|
+
<!ENTITY nocontent "">
|
13
13
|
]>
|
14
14
|
<root />
|
15
15
|
eoxml
|
@@ -18,19 +18,13 @@ module Nokogiri
|
|
18
18
|
@entity_decl = @entities.first
|
19
19
|
end
|
20
20
|
|
21
|
-
def test_constants
|
21
|
+
def test_constants
|
22
22
|
assert_equal 1, EntityDecl::INTERNAL_GENERAL
|
23
23
|
assert_equal 2, EntityDecl::EXTERNAL_GENERAL_PARSED
|
24
24
|
assert_equal 3, EntityDecl::EXTERNAL_GENERAL_UNPARSED
|
25
25
|
assert_equal 4, EntityDecl::INTERNAL_PARAMETER
|
26
26
|
assert_equal 5, EntityDecl::EXTERNAL_PARAMETER
|
27
27
|
assert_equal 6, EntityDecl::INTERNAL_PREDEFINED
|
28
|
-
|
29
|
-
# While I'm here, another problem with libffi comes to mind. If someone
|
30
|
-
# upgrades their version of any particular C library, and the constants
|
31
|
-
# change values, the client using Ruby code is fucked. That sucks.
|
32
|
-
# Basically anything to do with the preprocessor fucks someone using
|
33
|
-
# libffi. :-(
|
34
28
|
end
|
35
29
|
|
36
30
|
def test_create_typed_entity
|
@@ -69,12 +63,20 @@ module Nokogiri
|
|
69
63
|
|
70
64
|
def test_original_content
|
71
65
|
assert_equal "es", @entity_decl.original_content
|
72
|
-
|
66
|
+
if Nokogiri.jruby?
|
67
|
+
assert_nil @entities[1].original_content
|
68
|
+
else
|
69
|
+
assert_equal "", @entities[1].original_content
|
70
|
+
end
|
73
71
|
end
|
74
72
|
|
75
73
|
def test_content
|
76
74
|
assert_equal "es", @entity_decl.content
|
77
|
-
|
75
|
+
if Nokogiri.jruby?
|
76
|
+
assert_nil @entities[1].content
|
77
|
+
else
|
78
|
+
assert_equal "", @entities[1].content
|
79
|
+
end
|
78
80
|
end
|
79
81
|
|
80
82
|
def test_type
|
data/test/xml/test_namespace.rb
CHANGED
@@ -12,6 +12,13 @@ module Nokogiri
|
|
12
12
|
eoxml
|
13
13
|
end
|
14
14
|
|
15
|
+
if Nokogiri.uses_libxml?
|
16
|
+
def test_namespace_is_in_node_cache
|
17
|
+
node = @xml.root.namespace
|
18
|
+
assert @xml.instance_variable_get(:@node_cache).include?(node)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
15
22
|
def test_built_nodes_keep_namespace_decls
|
16
23
|
doc = Document.new
|
17
24
|
e = Node.new 'element', doc
|
@@ -31,11 +38,6 @@ module Nokogiri
|
|
31
38
|
assert_equal "#<#{ns.class.name}:#{sprintf("0x%x", ns.object_id)} href=#{ns.href.inspect}>", ns.inspect
|
32
39
|
end
|
33
40
|
|
34
|
-
def test_namespace_is_in_node_cache
|
35
|
-
node = @xml.root.namespace
|
36
|
-
assert @xml.instance_variable_get(:@node_cache).include?(node)
|
37
|
-
end
|
38
|
-
|
39
41
|
def test_namespace_node_prefix
|
40
42
|
namespaces = @xml.root.namespace_definitions
|
41
43
|
assert_equal [nil, 'foo'], namespaces.map { |x| x.prefix }
|
data/test/xml/test_node.rb
CHANGED
@@ -82,47 +82,18 @@ module Nokogiri
|
|
82
82
|
assert_equal 0, list.length
|
83
83
|
end
|
84
84
|
|
85
|
-
def test_parse_config_option
|
86
|
-
node = @xml.root
|
87
|
-
options = nil
|
88
|
-
node.parse("<item></item>") do |config|
|
89
|
-
options = config
|
90
|
-
end
|
91
|
-
assert_equal Nokogiri::XML::ParseOptions::DEFAULT_XML, options.to_i
|
92
|
-
end
|
93
|
-
|
94
85
|
# descriptive, not prescriptive.
|
95
86
|
def test_parse_invalid_html_markup_results_in_empty_nodeset
|
96
87
|
doc = Nokogiri::HTML("<html></html>")
|
97
88
|
nodeset = doc.root.parse "<div><div>a</div><snippet>b</snippet></div>"
|
98
89
|
assert_equal 1, doc.errors.length # "Tag snippet invalid"
|
99
|
-
assert_equal 1, nodeset.length
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_node_context_parsing_of_malformed_html_fragment_with_recover_is_corrected
|
103
|
-
doc = HTML.parse "<html><body><div></div></body></html>"
|
104
|
-
context_node = doc.at_css "div"
|
105
|
-
nodeset = context_node.parse("<div </div>") do |options|
|
106
|
-
options.recover
|
107
|
-
end
|
108
|
-
assert_equal "<div></div>", nodeset.to_s
|
109
|
-
assert_equal 1, doc.errors.length
|
110
|
-
assert_equal 1, nodeset.length
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_node_context_parsing_of_malformed_html_fragment_without_recover_is_not_corrected
|
114
|
-
doc = HTML.parse "<html><body><div></div></body></html>"
|
115
|
-
context_node = doc.at_css "div"
|
116
|
-
nodeset = context_node.parse("<div </div>") do |options|
|
117
|
-
options.strict
|
118
|
-
end
|
119
|
-
assert_equal 1, doc.errors.length
|
120
90
|
assert_equal 0, nodeset.length
|
121
91
|
end
|
122
92
|
|
123
93
|
def test_parse_error_list
|
124
94
|
error_count = @xml.errors.length
|
125
|
-
@xml.root.parse('<hello>')
|
95
|
+
list = @xml.root.parse('<hello>')
|
96
|
+
assert_equal 0, list.length
|
126
97
|
assert(error_count < @xml.errors.length, "errors should have increased")
|
127
98
|
end
|
128
99
|
|
@@ -414,7 +385,7 @@ module Nokogiri
|
|
414
385
|
def test_add_namespace_does_not_associate_node
|
415
386
|
node = @xml.at('address')
|
416
387
|
assert_nil node.namespace
|
417
|
-
|
388
|
+
definition = node.add_namespace_definition 'foo', 'http://tlm.com/'
|
418
389
|
assert_nil node.namespace
|
419
390
|
end
|
420
391
|
|
@@ -497,9 +468,7 @@ module Nokogiri
|
|
497
468
|
end
|
498
469
|
io.rewind
|
499
470
|
assert called
|
500
|
-
|
501
|
-
assert_equal @xml.serialize(nil, conf.options), string
|
502
|
-
assert_equal @xml.serialize(nil, conf), string
|
471
|
+
assert_equal @xml.serialize(nil, conf.options), io.read
|
503
472
|
end
|
504
473
|
|
505
474
|
%w{ xml html xhtml }.each do |type|
|
@@ -521,7 +490,6 @@ module Nokogiri
|
|
521
490
|
end
|
522
491
|
assert called
|
523
492
|
assert_equal @xml.serialize(nil, conf.options), string
|
524
|
-
assert_equal @xml.serialize(nil, conf), string
|
525
493
|
end
|
526
494
|
|
527
495
|
def test_hold_refence_to_subnode
|
@@ -699,15 +667,6 @@ module Nokogiri
|
|
699
667
|
assert_equal('/staff/employee[1]', node.path)
|
700
668
|
end
|
701
669
|
|
702
|
-
def test_parent_xpath
|
703
|
-
assert set = @xml.search('//employee')
|
704
|
-
assert node = set.first
|
705
|
-
assert parent_set = node.search('..')
|
706
|
-
assert parent_node = parent_set.first
|
707
|
-
assert_equal '/staff', parent_node.path
|
708
|
-
assert_equal node.parent, parent_node
|
709
|
-
end
|
710
|
-
|
711
670
|
def test_search_by_symbol
|
712
671
|
assert set = @xml.search(:employee)
|
713
672
|
assert 5, set.length
|
@@ -855,17 +814,19 @@ module Nokogiri
|
|
855
814
|
assert_equal nil, set[3].namespace
|
856
815
|
end
|
857
816
|
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
817
|
+
if Nokogiri.uses_libxml?
|
818
|
+
def test_namespace_without_an_href_on_html_node
|
819
|
+
# because microsoft word's HTML formatting does this. ick.
|
820
|
+
xml = Nokogiri::HTML.parse <<-EOF
|
821
|
+
<div><o:p>foo</o:p></div>
|
822
|
+
EOF
|
863
823
|
|
864
|
-
|
824
|
+
assert_not_nil(node = xml.at('p'))
|
865
825
|
|
866
|
-
|
867
|
-
|
868
|
-
|
826
|
+
assert_equal 1, node.namespaces.keys.size
|
827
|
+
assert node.namespaces.has_key?('xmlns:o')
|
828
|
+
assert_equal nil, node.namespaces['xmlns:o']
|
829
|
+
end
|
869
830
|
end
|
870
831
|
|
871
832
|
def test_line
|