nokogiri 1.4.7-x86-mswin32-60 → 1.5.0-x86-mswin32-60
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/CHANGELOG.ja.rdoc +59 -1
- data/CHANGELOG.rdoc +51 -2
- data/Manifest.txt +66 -66
- data/README.ja.rdoc +4 -0
- data/README.rdoc +31 -3
- data/Rakefile +111 -135
- data/bin/nokogiri +1 -2
- data/ext/nokogiri/extconf.rb +9 -3
- data/ext/nokogiri/nokogiri.c +21 -3
- data/ext/nokogiri/nokogiri.h +0 -2
- data/ext/nokogiri/xml_node.c +0 -6
- data/ext/nokogiri/xml_relax_ng.c +0 -7
- data/ext/nokogiri/xml_sax_parser.c +9 -4
- data/ext/nokogiri/xslt_stylesheet.c +5 -1
- data/lib/nokogiri.rb +19 -25
- data/lib/nokogiri/1.8/nokogiri.so +0 -0
- data/lib/nokogiri/1.9/nokogiri.so +0 -0
- data/lib/nokogiri/css.rb +0 -1
- data/lib/nokogiri/html.rb +1 -0
- data/lib/nokogiri/html/document.rb +9 -2
- data/lib/nokogiri/html/element_description_defaults.rb +671 -0
- data/lib/nokogiri/version.rb +76 -31
- data/lib/nokogiri/xml/attribute_decl.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +7 -0
- data/lib/nokogiri/xml/document.rb +17 -1
- data/lib/nokogiri/xml/document_fragment.rb +14 -0
- data/lib/nokogiri/xml/dtd.rb +1 -1
- data/lib/nokogiri/xml/element_decl.rb +1 -1
- data/lib/nokogiri/xml/entity_decl.rb +1 -1
- data/lib/nokogiri/xml/node.rb +39 -15
- data/lib/nokogiri/xml/node/save_options.rb +14 -5
- data/lib/nokogiri/xml/node_set.rb +7 -0
- data/lib/nokogiri/xml/reader.rb +2 -2
- data/lib/nokogiri/xml/sax/document.rb +2 -2
- data/lib/nokogiri/xslt/stylesheet.rb +1 -1
- data/nokogiri_help_responses.md +40 -0
- data/tasks/cross_compile.rb +134 -155
- data/tasks/nokogiri.org.rb +18 -0
- data/tasks/test.rb +2 -2
- data/test/files/metacharset.html +10 -0
- data/test/files/noencoding.html +47 -0
- data/test/helper.rb +2 -1
- data/test/html/sax/test_parser.rb +22 -5
- data/test/html/test_document.rb +21 -2
- data/test/html/test_document_encoding.rb +9 -1
- data/test/html/test_document_fragment.rb +5 -3
- data/test/html/test_element_description.rb +4 -2
- data/test/test_memory_leak.rb +4 -39
- data/test/test_nokogiri.rb +14 -20
- data/test/test_reader.rb +12 -8
- data/test/xml/node/test_save_options.rb +10 -2
- data/test/xml/sax/test_parser.rb +14 -7
- data/test/xml/test_attribute_decl.rb +7 -3
- data/test/xml/test_builder.rb +17 -0
- data/test/xml/test_document.rb +31 -4
- data/test/xml/test_dtd.rb +13 -3
- 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 +21 -10
- data/test/xml/test_node_reparenting.rb +16 -3
- data/test/xml/test_node_set.rb +34 -0
- data/test/xslt/test_custom_functions.rb +2 -2
- data/test/xslt/test_exception_handling.rb +37 -0
- metadata +110 -88
- 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/lib/nokogiri/version_warning.rb +0 -14
- data/test/ffi/test_document.rb +0 -35
data/test/xml/test_document.rb
CHANGED
@@ -217,7 +217,12 @@ module Nokogiri
|
|
217
217
|
end
|
218
218
|
|
219
219
|
def test_validate
|
220
|
-
|
220
|
+
if Nokogiri.uses_libxml?
|
221
|
+
assert_equal 44, @xml.validate.length
|
222
|
+
else
|
223
|
+
xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE) {|cfg| cfg.dtdvalid}
|
224
|
+
assert_equal 37, xml.validate.length
|
225
|
+
end
|
221
226
|
end
|
222
227
|
|
223
228
|
def test_validate_no_internal_subset
|
@@ -329,12 +334,12 @@ module Nokogiri
|
|
329
334
|
end
|
330
335
|
|
331
336
|
def test_non_existant_function
|
332
|
-
# WTF. I don't know why this is different between MRI and
|
337
|
+
# WTF. I don't know why this is different between MRI and Jruby
|
333
338
|
# They should be the same... Either way, raising an exception
|
334
339
|
# is the correct thing to do.
|
335
340
|
exception = RuntimeError
|
336
341
|
|
337
|
-
if Nokogiri::VERSION_INFO['libxml']['platform'] == 'jruby'
|
342
|
+
if !Nokogiri.uses_libxml? || (Nokogiri.uses_libxml? && Nokogiri::VERSION_INFO['libxml']['platform'] == 'jruby')
|
338
343
|
exception = Nokogiri::XML::XPath::SyntaxError
|
339
344
|
end
|
340
345
|
|
@@ -406,7 +411,7 @@ module Nokogiri
|
|
406
411
|
end
|
407
412
|
|
408
413
|
# wtf... osx's libxml sucks.
|
409
|
-
unless Nokogiri::LIBXML_VERSION =~ /^2\.6\./
|
414
|
+
unless !Nokogiri.uses_libxml? || Nokogiri::LIBXML_VERSION =~ /^2\.6\./
|
410
415
|
def test_encoding
|
411
416
|
xml = Nokogiri::XML(File.read(XML_FILE), XML_FILE, 'UTF-8')
|
412
417
|
assert_equal 'UTF-8', xml.encoding
|
@@ -665,6 +670,28 @@ module Nokogiri
|
|
665
670
|
assert @xml.root.respond_to?(:awesome!)
|
666
671
|
assert @xml.children.respond_to?(:awesome!)
|
667
672
|
end
|
673
|
+
|
674
|
+
def test_java_integration
|
675
|
+
if Nokogiri.jruby?
|
676
|
+
require 'java'
|
677
|
+
factory = javax.xml.parsers.DocumentBuilderFactory.newInstance
|
678
|
+
builder = factory.newDocumentBuilder
|
679
|
+
document = builder.newDocument
|
680
|
+
root = document.createElement("foo")
|
681
|
+
document.appendChild(root)
|
682
|
+
noko_doc = Nokogiri::XML::Document.wrap(document)
|
683
|
+
assert_equal 'foo', noko_doc.root.name
|
684
|
+
|
685
|
+
noko_doc = Nokogiri::XML(<<eoxml)
|
686
|
+
<foo xmlns='hello'>
|
687
|
+
<bar xmlns:foo='world' />
|
688
|
+
</foo>
|
689
|
+
eoxml
|
690
|
+
dom = noko_doc.to_java
|
691
|
+
assert dom.kind_of? org.w3c.dom.Document
|
692
|
+
assert_equal 'foo', dom.getDocumentElement().getTagName()
|
693
|
+
end
|
694
|
+
end
|
668
695
|
end
|
669
696
|
end
|
670
697
|
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
|
@@ -64,8 +68,14 @@ module Nokogiri
|
|
64
68
|
end
|
65
69
|
|
66
70
|
def test_validate
|
67
|
-
|
68
|
-
|
71
|
+
if Nokogiri.uses_libxml?
|
72
|
+
list = @xml.internal_subset.validate @xml
|
73
|
+
assert_equal 44, list.length
|
74
|
+
else
|
75
|
+
xml = Nokogiri::XML(File.open(XML_FILE)) {|cfg| cfg.dtdvalid}
|
76
|
+
list = xml.internal_subset.validate xml
|
77
|
+
assert_equal 37, list.length
|
78
|
+
end
|
69
79
|
end
|
70
80
|
|
71
81
|
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
@@ -486,6 +486,11 @@ module Nokogiri
|
|
486
486
|
assert_equal 'Yes', @xml.css('address').first[:domestic]
|
487
487
|
end
|
488
488
|
|
489
|
+
def test_non_existent_attribute_should_return_nil
|
490
|
+
node = @xml.root.first_element_child
|
491
|
+
assert_nil node.attribute('type')
|
492
|
+
end
|
493
|
+
|
489
494
|
def test_write_to_with_block
|
490
495
|
called = false
|
491
496
|
io = StringIO.new
|
@@ -727,7 +732,7 @@ module Nokogiri
|
|
727
732
|
assert_equal '&', foo
|
728
733
|
end
|
729
734
|
|
730
|
-
def
|
735
|
+
def test_content_equals
|
731
736
|
node = Nokogiri::XML::Node.new('form', @xml)
|
732
737
|
assert_equal('', node.content)
|
733
738
|
|
@@ -737,6 +742,10 @@ module Nokogiri
|
|
737
742
|
node.content = '& <foo> &'
|
738
743
|
assert_equal('& <foo> &', node.content)
|
739
744
|
assert_equal('<form>& <foo> &amp;</form>', node.to_xml)
|
745
|
+
|
746
|
+
node.content = "1234 <-> 1234"
|
747
|
+
assert_equal "1234 <-> 1234", node.content
|
748
|
+
assert_equal "<form>1234 <-> 1234</form>", node.to_xml
|
740
749
|
end
|
741
750
|
|
742
751
|
def test_set_content_should_unlink_existing_content
|
@@ -855,17 +864,19 @@ module Nokogiri
|
|
855
864
|
assert_equal nil, set[3].namespace
|
856
865
|
end
|
857
866
|
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
867
|
+
if Nokogiri.uses_libxml?
|
868
|
+
def test_namespace_without_an_href_on_html_node
|
869
|
+
# because microsoft word's HTML formatting does this. ick.
|
870
|
+
xml = Nokogiri::HTML.parse <<-EOF
|
871
|
+
<div><o:p>foo</o:p></div>
|
872
|
+
EOF
|
863
873
|
|
864
|
-
|
874
|
+
assert_not_nil(node = xml.at('p'))
|
865
875
|
|
866
|
-
|
867
|
-
|
868
|
-
|
876
|
+
assert_equal 1, node.namespaces.keys.size
|
877
|
+
assert node.namespaces.has_key?('xmlns:o')
|
878
|
+
assert_equal nil, node.namespaces['xmlns:o']
|
879
|
+
end
|
869
880
|
end
|
870
881
|
|
871
882
|
def test_line
|
@@ -51,7 +51,7 @@ module Nokogiri
|
|
51
51
|
|
52
52
|
{
|
53
53
|
:add_child => {:target => "/root/a1", :returns_self => false, :children_tags => %w[text b1 b2]},
|
54
|
-
:<< => {:target => "/root/a1", :returns_self =>
|
54
|
+
:<< => {:target => "/root/a1", :returns_self => true, :children_tags => %w[text b1 b2]},
|
55
55
|
|
56
56
|
:replace => {:target => "/root/a1/node()", :returns_self => false, :children_tags => %w[b1 b2]},
|
57
57
|
:swap => {:target => "/root/a1/node()", :returns_self => true, :children_tags => %w[b1 b2]},
|
@@ -166,6 +166,21 @@ module Nokogiri
|
|
166
166
|
end
|
167
167
|
|
168
168
|
describe "ad hoc node reparenting behavior" do
|
169
|
+
describe "#<<" do
|
170
|
+
it "allows chaining" do
|
171
|
+
doc = Nokogiri::XML::Document.new
|
172
|
+
root = Nokogiri::XML::Element.new('root', doc)
|
173
|
+
doc.root = root
|
174
|
+
|
175
|
+
child1 = Nokogiri::XML::Element.new('child1', doc)
|
176
|
+
child2 = Nokogiri::XML::Element.new('child2', doc)
|
177
|
+
|
178
|
+
doc.root << child1 << child2
|
179
|
+
|
180
|
+
assert_equal [child1, child2], doc.root.children.to_a
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
169
184
|
describe "#add_child" do
|
170
185
|
describe "given a new node with a namespace" do
|
171
186
|
it "keeps the namespace" do
|
@@ -276,8 +291,6 @@ module Nokogiri
|
|
276
291
|
it "not blow up" do
|
277
292
|
# see http://github.com/tenderlove/nokogiri/issues#issue/22
|
278
293
|
10.times do
|
279
|
-
STDOUT.putc "."
|
280
|
-
STDOUT.flush
|
281
294
|
begin
|
282
295
|
doc = Nokogiri::XML <<-EOHTML
|
283
296
|
<root>
|
data/test/xml/test_node_set.rb
CHANGED
@@ -30,6 +30,10 @@ module Nokogiri
|
|
30
30
|
@list = @xml.css('employee')
|
31
31
|
end
|
32
32
|
|
33
|
+
def test_break_works
|
34
|
+
assert_equal 7, @xml.root.elements.each { |x| break 7 }
|
35
|
+
end
|
36
|
+
|
33
37
|
def test_filter
|
34
38
|
list = @xml.css('address').filter('*[domestic="Yes"]')
|
35
39
|
assert_equal(%w{ Yes } * 4, list.map { |n| n['domestic'] })
|
@@ -234,6 +238,11 @@ module Nokogiri
|
|
234
238
|
end
|
235
239
|
end
|
236
240
|
|
241
|
+
def test_dup_on_empty_set
|
242
|
+
empty_set = Nokogiri::XML::NodeSet.new @xml, []
|
243
|
+
assert_equal 0, empty_set.dup.length # this shouldn't raise null pointer exception
|
244
|
+
end
|
245
|
+
|
237
246
|
def test_xmlns_is_automatically_registered
|
238
247
|
doc = Nokogiri::XML(<<-eoxml)
|
239
248
|
<root xmlns="http://tenderlovemaking.com/">
|
@@ -358,6 +367,12 @@ module Nokogiri
|
|
358
367
|
assert length, employees.length
|
359
368
|
end
|
360
369
|
|
370
|
+
def test_delete_on_empty_set
|
371
|
+
empty_set = Nokogiri::XML::NodeSet.new @xml, []
|
372
|
+
employee = @xml.at_xpath("//employee")
|
373
|
+
assert_equal nil, empty_set.delete(employee)
|
374
|
+
end
|
375
|
+
|
361
376
|
def test_unlink
|
362
377
|
xml = Nokogiri::XML.parse(<<-eoxml)
|
363
378
|
<root>
|
@@ -518,6 +533,13 @@ module Nokogiri
|
|
518
533
|
assert_equal employees.length, employees[0, employees.length].length
|
519
534
|
end
|
520
535
|
|
536
|
+
def test_slice_on_empty_node_set
|
537
|
+
empty_set = Nokogiri::XML::NodeSet.new @xml, []
|
538
|
+
assert_equal nil, empty_set[99]
|
539
|
+
assert_equal nil, empty_set[99..101]
|
540
|
+
assert_equal nil, empty_set[99,2]
|
541
|
+
end
|
542
|
+
|
521
543
|
def test_slice_waaaaaay_off_the_end
|
522
544
|
xml = Nokogiri::XML::Builder.new {
|
523
545
|
root { 100.times { div } }
|
@@ -572,6 +594,12 @@ module Nokogiri
|
|
572
594
|
assert_equal [employees[2]], (first_set & second_set).to_a
|
573
595
|
end
|
574
596
|
|
597
|
+
def test_intersection_on_empty_set
|
598
|
+
empty_set = Nokogiri::XML::NodeSet.new @xml
|
599
|
+
employees = @xml.search("//employee")
|
600
|
+
assert_equal 0, (empty_set & employees).length
|
601
|
+
end
|
602
|
+
|
575
603
|
def test_include?
|
576
604
|
employees = @xml.search("//employee")
|
577
605
|
yes = employees.first
|
@@ -581,6 +609,12 @@ module Nokogiri
|
|
581
609
|
assert ! employees.include?(no)
|
582
610
|
end
|
583
611
|
|
612
|
+
def test_include_on_empty_node_set
|
613
|
+
empty_set = Nokogiri::XML::NodeSet.new @xml, []
|
614
|
+
employee = @xml.at_xpath("//employee")
|
615
|
+
assert ! empty_set.include?(employee)
|
616
|
+
end
|
617
|
+
|
584
618
|
def test_children
|
585
619
|
employees = @xml.search("//employee")
|
586
620
|
count = 0
|
@@ -25,7 +25,7 @@ EOXML
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_function
|
28
|
-
skip("
|
28
|
+
skip("Pure Java version doesn't support this feature.") if !Nokogiri.uses_libxml?
|
29
29
|
foo = Class.new do
|
30
30
|
def capitalize nodes
|
31
31
|
nodes.first.content.upcase
|
@@ -59,7 +59,7 @@ EOXSL
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_function_XSLT
|
62
|
-
skip("
|
62
|
+
skip("Pure Java version doesn't support this feature.") if !Nokogiri.uses_libxml?
|
63
63
|
foo = Class.new do
|
64
64
|
def america nodes
|
65
65
|
nodes.first.content.upcase
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
module Nokogiri
|
4
|
+
module XSLT
|
5
|
+
class TestExceptionHandling < Nokogiri::TestCase
|
6
|
+
def test_java_exception_handling
|
7
|
+
skip('This test is for Java only') if Nokogiri.uses_libxml?
|
8
|
+
|
9
|
+
xml = Nokogiri.XML(<<-EOXML)
|
10
|
+
<foo>
|
11
|
+
<bar/>
|
12
|
+
</foo>
|
13
|
+
EOXML
|
14
|
+
|
15
|
+
xsl = Nokogiri.XSLT(<<-EOXSL)
|
16
|
+
<?xml version="1.0"?>
|
17
|
+
<xsl:stylesheet version="1.0"
|
18
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
19
|
+
|
20
|
+
<xsl:template match="/">
|
21
|
+
<a/>
|
22
|
+
<b/>
|
23
|
+
</xsl:template>
|
24
|
+
</xsl:stylesheet>
|
25
|
+
EOXSL
|
26
|
+
|
27
|
+
begin
|
28
|
+
xsl.transform xml
|
29
|
+
fail('It should not get here')
|
30
|
+
rescue RuntimeError => e
|
31
|
+
assert_match(/HIERARCHY_REQUEST_ERR/, e.to_s, 'The exception message does not contain the expected information')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nokogiri
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 1.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 1.5.0
|
11
11
|
platform: x86-mswin32-60
|
12
12
|
authors:
|
13
13
|
- Aaron Patterson
|
14
14
|
- Mike Dalessio
|
15
|
+
- Yoko Harada
|
15
16
|
autorequire:
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
@@ -27,10 +28,12 @@ dependencies:
|
|
27
28
|
requirements:
|
28
29
|
- - ">="
|
29
30
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
31
|
+
hash: 11
|
31
32
|
segments:
|
32
|
-
-
|
33
|
-
|
33
|
+
- 1
|
34
|
+
- 4
|
35
|
+
- 6
|
36
|
+
version: 1.4.6
|
34
37
|
type: :development
|
35
38
|
version_requirements: *id001
|
36
39
|
- !ruby/object:Gem::Dependency
|
@@ -41,10 +44,12 @@ dependencies:
|
|
41
44
|
requirements:
|
42
45
|
- - ">="
|
43
46
|
- !ruby/object:Gem::Version
|
44
|
-
hash:
|
47
|
+
hash: 29
|
45
48
|
segments:
|
49
|
+
- 1
|
46
50
|
- 0
|
47
|
-
|
51
|
+
- 5
|
52
|
+
version: 1.0.5
|
48
53
|
type: :development
|
49
54
|
version_requirements: *id002
|
50
55
|
- !ruby/object:Gem::Dependency
|
@@ -55,32 +60,106 @@ dependencies:
|
|
55
60
|
requirements:
|
56
61
|
- - ">="
|
57
62
|
- !ruby/object:Gem::Version
|
58
|
-
hash:
|
63
|
+
hash: 17
|
59
64
|
segments:
|
60
65
|
- 0
|
61
|
-
|
66
|
+
- 7
|
67
|
+
- 9
|
68
|
+
version: 0.7.9
|
62
69
|
type: :development
|
63
70
|
version_requirements: *id003
|
64
71
|
- !ruby/object:Gem::Dependency
|
65
72
|
name: minitest
|
66
73
|
prerelease: false
|
67
74
|
requirement: &id004 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ~>
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: 3
|
80
|
+
segments:
|
81
|
+
- 2
|
82
|
+
- 2
|
83
|
+
- 2
|
84
|
+
version: 2.2.2
|
85
|
+
type: :development
|
86
|
+
version_requirements: *id004
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: mini_portile
|
89
|
+
prerelease: false
|
90
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
68
91
|
none: false
|
69
92
|
requirements:
|
70
93
|
- - ">="
|
71
94
|
- !ruby/object:Gem::Version
|
72
|
-
hash:
|
95
|
+
hash: 19
|
73
96
|
segments:
|
74
|
-
- 1
|
75
|
-
- 6
|
76
97
|
- 0
|
77
|
-
|
98
|
+
- 2
|
99
|
+
- 2
|
100
|
+
version: 0.2.2
|
78
101
|
type: :development
|
79
|
-
version_requirements: *
|
102
|
+
version_requirements: *id005
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: hoe-debugging
|
105
|
+
prerelease: false
|
106
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
type: :development
|
116
|
+
version_requirements: *id006
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: hoe-git
|
119
|
+
prerelease: false
|
120
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 3
|
126
|
+
segments:
|
127
|
+
- 0
|
128
|
+
version: "0"
|
129
|
+
type: :development
|
130
|
+
version_requirements: *id007
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: hoe-gemspec
|
133
|
+
prerelease: false
|
134
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
135
|
+
none: false
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
hash: 3
|
140
|
+
segments:
|
141
|
+
- 0
|
142
|
+
version: "0"
|
143
|
+
type: :development
|
144
|
+
version_requirements: *id008
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: hoe-bundler
|
147
|
+
prerelease: false
|
148
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
hash: 3
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
157
|
+
type: :development
|
158
|
+
version_requirements: *id009
|
80
159
|
- !ruby/object:Gem::Dependency
|
81
160
|
name: hoe
|
82
161
|
prerelease: false
|
83
|
-
requirement: &
|
162
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
84
163
|
none: false
|
85
164
|
requirements:
|
86
165
|
- - ">="
|
@@ -92,7 +171,7 @@ dependencies:
|
|
92
171
|
- 4
|
93
172
|
version: 2.9.4
|
94
173
|
type: :development
|
95
|
-
version_requirements: *
|
174
|
+
version_requirements: *id010
|
96
175
|
description: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser. Among Nokogiri's\n\
|
97
176
|
many features is the ability to search documents via XPath or CSS3 selectors.\n\n\
|
98
177
|
XML is like violence - if it doesn\xE2\x80\x99t solve your problems, you are not using\n\
|
@@ -100,6 +179,7 @@ description: "Nokogiri (\xE9\x8B\xB8) is an HTML, XML, SAX, and Reader parser.
|
|
100
179
|
email:
|
101
180
|
- aaronp@rubyforge.org
|
102
181
|
- mike.dalessio@gmail.com
|
182
|
+
- yokolet@gmail.com
|
103
183
|
executables:
|
104
184
|
- nokogiri
|
105
185
|
extensions: []
|
@@ -232,81 +312,17 @@ files:
|
|
232
312
|
- lib/nokogiri/css/tokenizer.rex
|
233
313
|
- lib/nokogiri/css/xpath_visitor.rb
|
234
314
|
- lib/nokogiri/decorators/slop.rb
|
235
|
-
- lib/nokogiri/ffi/encoding_handler.rb
|
236
|
-
- lib/nokogiri/ffi/html/document.rb
|
237
|
-
- lib/nokogiri/ffi/html/element_description.rb
|
238
|
-
- lib/nokogiri/ffi/html/entity_lookup.rb
|
239
|
-
- lib/nokogiri/ffi/html/sax/parser_context.rb
|
240
|
-
- lib/nokogiri/ffi/io_callbacks.rb
|
241
|
-
- lib/nokogiri/ffi/libxml.rb
|
242
|
-
- lib/nokogiri/ffi/structs/common_node.rb
|
243
|
-
- lib/nokogiri/ffi/structs/html_elem_desc.rb
|
244
|
-
- lib/nokogiri/ffi/structs/html_entity_desc.rb
|
245
|
-
- lib/nokogiri/ffi/structs/xml_alloc.rb
|
246
|
-
- lib/nokogiri/ffi/structs/xml_attr.rb
|
247
|
-
- lib/nokogiri/ffi/structs/xml_attribute.rb
|
248
|
-
- lib/nokogiri/ffi/structs/xml_buffer.rb
|
249
|
-
- lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb
|
250
|
-
- lib/nokogiri/ffi/structs/xml_document.rb
|
251
|
-
- lib/nokogiri/ffi/structs/xml_dtd.rb
|
252
|
-
- lib/nokogiri/ffi/structs/xml_element.rb
|
253
|
-
- lib/nokogiri/ffi/structs/xml_element_content.rb
|
254
|
-
- lib/nokogiri/ffi/structs/xml_entity.rb
|
255
|
-
- lib/nokogiri/ffi/structs/xml_enumeration.rb
|
256
|
-
- lib/nokogiri/ffi/structs/xml_node.rb
|
257
|
-
- lib/nokogiri/ffi/structs/xml_node_set.rb
|
258
|
-
- lib/nokogiri/ffi/structs/xml_notation.rb
|
259
|
-
- lib/nokogiri/ffi/structs/xml_ns.rb
|
260
|
-
- lib/nokogiri/ffi/structs/xml_parser_context.rb
|
261
|
-
- lib/nokogiri/ffi/structs/xml_parser_input.rb
|
262
|
-
- lib/nokogiri/ffi/structs/xml_relax_ng.rb
|
263
|
-
- lib/nokogiri/ffi/structs/xml_sax_handler.rb
|
264
|
-
- lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb
|
265
|
-
- lib/nokogiri/ffi/structs/xml_schema.rb
|
266
|
-
- lib/nokogiri/ffi/structs/xml_syntax_error.rb
|
267
|
-
- lib/nokogiri/ffi/structs/xml_text_reader.rb
|
268
|
-
- lib/nokogiri/ffi/structs/xml_xpath_context.rb
|
269
|
-
- lib/nokogiri/ffi/structs/xml_xpath_object.rb
|
270
|
-
- lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb
|
271
|
-
- lib/nokogiri/ffi/structs/xslt_stylesheet.rb
|
272
|
-
- lib/nokogiri/ffi/weak_bucket.rb
|
273
|
-
- lib/nokogiri/ffi/xml/attr.rb
|
274
|
-
- lib/nokogiri/ffi/xml/attribute_decl.rb
|
275
|
-
- lib/nokogiri/ffi/xml/cdata.rb
|
276
|
-
- lib/nokogiri/ffi/xml/comment.rb
|
277
|
-
- lib/nokogiri/ffi/xml/document.rb
|
278
|
-
- lib/nokogiri/ffi/xml/document_fragment.rb
|
279
|
-
- lib/nokogiri/ffi/xml/dtd.rb
|
280
|
-
- lib/nokogiri/ffi/xml/element_content.rb
|
281
|
-
- lib/nokogiri/ffi/xml/element_decl.rb
|
282
|
-
- lib/nokogiri/ffi/xml/entity_decl.rb
|
283
|
-
- lib/nokogiri/ffi/xml/entity_reference.rb
|
284
|
-
- lib/nokogiri/ffi/xml/namespace.rb
|
285
|
-
- lib/nokogiri/ffi/xml/node.rb
|
286
|
-
- lib/nokogiri/ffi/xml/node_set.rb
|
287
|
-
- lib/nokogiri/ffi/xml/processing_instruction.rb
|
288
|
-
- lib/nokogiri/ffi/xml/reader.rb
|
289
|
-
- lib/nokogiri/ffi/xml/relax_ng.rb
|
290
|
-
- lib/nokogiri/ffi/xml/sax/parser.rb
|
291
|
-
- lib/nokogiri/ffi/xml/sax/parser_context.rb
|
292
|
-
- lib/nokogiri/ffi/xml/sax/push_parser.rb
|
293
|
-
- lib/nokogiri/ffi/xml/schema.rb
|
294
|
-
- lib/nokogiri/ffi/xml/syntax_error.rb
|
295
|
-
- lib/nokogiri/ffi/xml/text.rb
|
296
|
-
- lib/nokogiri/ffi/xml/xpath.rb
|
297
|
-
- lib/nokogiri/ffi/xml/xpath_context.rb
|
298
|
-
- lib/nokogiri/ffi/xslt/stylesheet.rb
|
299
315
|
- lib/nokogiri/html.rb
|
300
316
|
- lib/nokogiri/html/builder.rb
|
301
317
|
- lib/nokogiri/html/document.rb
|
302
318
|
- lib/nokogiri/html/document_fragment.rb
|
303
319
|
- lib/nokogiri/html/element_description.rb
|
320
|
+
- lib/nokogiri/html/element_description_defaults.rb
|
304
321
|
- lib/nokogiri/html/entity_lookup.rb
|
305
322
|
- lib/nokogiri/html/sax/parser.rb
|
306
323
|
- lib/nokogiri/html/sax/parser_context.rb
|
307
324
|
- lib/nokogiri/syntax_error.rb
|
308
325
|
- lib/nokogiri/version.rb
|
309
|
-
- lib/nokogiri/version_warning.rb
|
310
326
|
- lib/nokogiri/xml.rb
|
311
327
|
- lib/nokogiri/xml/attr.rb
|
312
328
|
- lib/nokogiri/xml/attribute_decl.rb
|
@@ -345,14 +361,15 @@ files:
|
|
345
361
|
- lib/nokogiri/xslt.rb
|
346
362
|
- lib/nokogiri/xslt/stylesheet.rb
|
347
363
|
- lib/xsd/xmlparser/nokogiri.rb
|
364
|
+
- nokogiri_help_responses.md
|
348
365
|
- tasks/cross_compile.rb
|
366
|
+
- tasks/nokogiri.org.rb
|
349
367
|
- tasks/test.rb
|
350
368
|
- test/css/test_nthiness.rb
|
351
369
|
- test/css/test_parser.rb
|
352
370
|
- test/css/test_tokenizer.rb
|
353
371
|
- test/css/test_xpath_visitor.rb
|
354
372
|
- test/decorators/test_slop.rb
|
355
|
-
- test/ffi/test_document.rb
|
356
373
|
- test/files/2ch.html
|
357
374
|
- test/files/address_book.rlx
|
358
375
|
- test/files/address_book.xml
|
@@ -363,6 +380,8 @@ files:
|
|
363
380
|
- test/files/exslt.xml
|
364
381
|
- test/files/exslt.xslt
|
365
382
|
- test/files/foo/foo.xsd
|
383
|
+
- test/files/metacharset.html
|
384
|
+
- test/files/noencoding.html
|
366
385
|
- test/files/po.xml
|
367
386
|
- test/files/po.xsd
|
368
387
|
- test/files/shift_jis.html
|
@@ -427,6 +446,7 @@ files:
|
|
427
446
|
- test/xml/test_unparented_node.rb
|
428
447
|
- test/xml/test_xpath.rb
|
429
448
|
- test/xslt/test_custom_functions.rb
|
449
|
+
- test/xslt/test_exception_handling.rb
|
430
450
|
- lib/nokogiri/nokogiri.rb
|
431
451
|
- lib/nokogiri/1.8/nokogiri.so
|
432
452
|
- lib/nokogiri/1.9/nokogiri.so
|
@@ -445,10 +465,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
445
465
|
requirements:
|
446
466
|
- - ">="
|
447
467
|
- !ruby/object:Gem::Version
|
448
|
-
hash:
|
468
|
+
hash: 57
|
449
469
|
segments:
|
450
|
-
-
|
451
|
-
|
470
|
+
- 1
|
471
|
+
- 8
|
472
|
+
- 7
|
473
|
+
version: 1.8.7
|
452
474
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
453
475
|
none: false
|
454
476
|
requirements:
|
@@ -486,7 +508,6 @@ test_files:
|
|
486
508
|
- test/html/sax/test_parser.rb
|
487
509
|
- test/html/test_node_encoding.rb
|
488
510
|
- test/html/test_element_description.rb
|
489
|
-
- test/ffi/test_document.rb
|
490
511
|
- test/test_reader.rb
|
491
512
|
- test/xml/test_parse_options.rb
|
492
513
|
- test/xml/test_unparented_node.rb
|
@@ -524,4 +545,5 @@ test_files:
|
|
524
545
|
- test/xml/test_node_attributes.rb
|
525
546
|
- test/test_xslt_transforms.rb
|
526
547
|
- test/xslt/test_custom_functions.rb
|
548
|
+
- test/xslt/test_exception_handling.rb
|
527
549
|
- test/test_encoding_handler.rb
|