nokogiri 1.5.7.rc1-java → 1.5.7.rc2-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.

@@ -0,0 +1,60 @@
1
+ require "helper"
2
+
3
+ module Nokogiri
4
+ module XML
5
+ class TestNamespacesInBuilderDoc < Nokogiri::TestCase
6
+ def setup
7
+ super
8
+ b = Nokogiri::XML::Builder.new do |x|
9
+ x.fruit(:xmlns => 'ns:fruit', :'xmlns:veg' => 'ns:veg', :'xmlns:xlink' => 'http://www.w3.org/1999/xlink') do
10
+ x.pear { x.bosc }
11
+ x.orange
12
+ x[:veg].carrot do
13
+ x.cheese(:xmlns => 'ns:dairy', :'xlink:href' => 'http://example.com/cheese/')
14
+ end
15
+ x[:meat].bacon(:'xmlns:meat' => 'ns:meat') do
16
+ x.apple :count => 2
17
+ x[:veg].tomato
18
+ end
19
+ end
20
+ end
21
+
22
+ @doc = b.doc
23
+ end
24
+
25
+ def check_namespace e
26
+ e.namespace.nil? ? nil : e.namespace.href
27
+ end
28
+
29
+ def test_builder_default_ns
30
+ assert_equal 'ns:fruit', check_namespace(@doc.root)
31
+ end
32
+ def test_builder_parent_default_ns
33
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[0])
34
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[1])
35
+ end
36
+ def test_builder_grandparent_default_ns
37
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[0].elements[0])
38
+ end
39
+ def test_builder_parent_nondefault_ns
40
+ assert_equal 'ns:veg', check_namespace(@doc.root.elements[2])
41
+ end
42
+ def test_builder_single_decl_ns_1
43
+ assert_equal 'ns:dairy', check_namespace(@doc.root.elements[2].elements[0])
44
+ end
45
+ def test_builder_nondefault_attr_ns
46
+ assert_equal 'http://www.w3.org/1999/xlink',
47
+ check_namespace(@doc.root.elements[2].elements[0].attribute_nodes.find { |a| a.name =~ /href/ })
48
+ end
49
+ def test_builder_single_decl_ns_2
50
+ assert_equal 'ns:meat', check_namespace(@doc.root.elements[3])
51
+ end
52
+ def test_builder_buried_default_ns
53
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[3].elements[0])
54
+ end
55
+ def test_builder_buried_decl_ns
56
+ assert_equal 'ns:veg', check_namespace(@doc.root.elements[3].elements[1])
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,62 @@
1
+ require "helper"
2
+
3
+ module Nokogiri
4
+ module XML
5
+ class TestNamespacesInCreatedDoc < Nokogiri::TestCase
6
+ def setup
7
+ super
8
+ @doc = Nokogiri::XML('<fruit xmlns="ns:fruit" xmlns:veg="ns:veg" xmlns:xlink="http://www.w3.org/1999/xlink"/>')
9
+ pear = @doc.create_element('pear')
10
+ bosc = @doc.create_element('bosc')
11
+ pear.add_child(bosc)
12
+ @doc.root << pear
13
+ @doc.root.add_child('<orange/>')
14
+ carrot = @doc.create_element('veg:carrot')
15
+ @doc.root << carrot
16
+ cheese = @doc.create_element('cheese', :xmlns => 'ns:dairy', :'xlink:href' => 'http://example.com/cheese/')
17
+ carrot << cheese
18
+ bacon = @doc.create_element('meat:bacon', :'xmlns:meat' => 'ns:meat')
19
+ apple = @doc.create_element('apple')
20
+ apple['count'] = 2
21
+ bacon << apple
22
+ tomato = @doc.create_element('veg:tomato')
23
+ bacon << tomato
24
+ @doc.root << bacon
25
+ end
26
+
27
+ def check_namespace e
28
+ e.namespace.nil? ? nil : e.namespace.href
29
+ end
30
+
31
+ def test_created_default_ns
32
+ assert_equal 'ns:fruit', check_namespace(@doc.root)
33
+ end
34
+ def test_created_parent_default_ns
35
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[0])
36
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[1])
37
+ end
38
+ def test_created_grandparent_default_ns
39
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[0].elements[0])
40
+ end
41
+ def test_created_parent_nondefault_ns
42
+ assert_equal 'ns:veg', check_namespace(@doc.root.elements[2])
43
+ end
44
+ def test_created_single_decl_ns_1
45
+ assert_equal 'ns:dairy', check_namespace(@doc.root.elements[2].elements[0])
46
+ end
47
+ def test_created_nondefault_attr_ns
48
+ assert_equal 'http://www.w3.org/1999/xlink',
49
+ check_namespace(@doc.root.elements[2].elements[0].attribute_nodes.find { |a| a.name =~ /href/ })
50
+ end
51
+ def test_created_single_decl_ns_2
52
+ assert_equal 'ns:meat', check_namespace(@doc.root.elements[3])
53
+ end
54
+ def test_created_buried_default_ns
55
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[3].elements[0])
56
+ end
57
+ def test_created_buried_decl_ns
58
+ assert_equal 'ns:veg', check_namespace(@doc.root.elements[3].elements[1])
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,60 @@
1
+ require "helper"
2
+
3
+ module Nokogiri
4
+ module XML
5
+ class TestNamespacesInParsedDoc < Nokogiri::TestCase
6
+ def setup
7
+ super
8
+ @doc = Nokogiri::XML <<-eoxml
9
+ <fruit xmlns="ns:fruit" xmlns:veg="ns:veg" xmlns:xlink="http://www.w3.org/1999/xlink">
10
+ <pear>
11
+ <bosc/>
12
+ </pear>
13
+ <orange/>
14
+ <veg:carrot>
15
+ <cheese xmlns="ns:dairy" xlink:href="http://example.com/cheese/"/>
16
+ </veg:carrot>
17
+ <meat:bacon xmlns:meat="ns:meat">
18
+ <apple count="2"/>
19
+ <veg:tomato/>
20
+ </meat:bacon>
21
+ </fruit>
22
+ eoxml
23
+ end
24
+
25
+ def check_namespace e
26
+ e.namespace.nil? ? nil : e.namespace.href
27
+ end
28
+
29
+ def test_parsed_default_ns
30
+ assert_equal 'ns:fruit', check_namespace(@doc.root)
31
+ end
32
+ def test_parsed_parent_default_ns
33
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[0])
34
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[1])
35
+ end
36
+ def test_parsed_grandparent_default_ns
37
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[0].elements[0])
38
+ end
39
+ def test_parsed_parent_nondefault_ns
40
+ assert_equal 'ns:veg', check_namespace(@doc.root.elements[2])
41
+ end
42
+ def test_parsed_single_decl_ns_1
43
+ assert_equal 'ns:dairy', check_namespace(@doc.root.elements[2].elements[0])
44
+ end
45
+ def test_parsed_nondefault_attr_ns
46
+ assert_equal 'http://www.w3.org/1999/xlink',
47
+ check_namespace(@doc.root.elements[2].elements[0].attribute_nodes.find { |a| a.name =~ /href/ })
48
+ end
49
+ def test_parsed_single_decl_ns_2
50
+ assert_equal 'ns:meat', check_namespace(@doc.root.elements[3])
51
+ end
52
+ def test_parsed_buried_default_ns
53
+ assert_equal 'ns:fruit', check_namespace(@doc.root.elements[3].elements[0])
54
+ end
55
+ def test_parsed_buried_decl_ns
56
+ assert_equal 'ns:veg', check_namespace(@doc.root.elements[3].elements[1])
57
+ end
58
+ end
59
+ end
60
+ end
@@ -143,11 +143,27 @@ module Nokogiri
143
143
  assert_equal 'bar', doc.at('foo|baz', 'foo' => 'bar').namespace.href
144
144
  end
145
145
 
146
+ def test_specified_namespace_postdeclared
147
+ doc = Nokogiri::XML::Builder.new { |xml|
148
+ xml.a do
149
+ xml[:foo].b("xmlns:foo" => "bar")
150
+ end
151
+ }.doc
152
+ a = doc.at('a')
153
+ assert_equal({}, a.namespaces)
154
+
155
+ b = doc.at_xpath('//foo:b', {:foo=>'bar'})
156
+ assert b
157
+ assert_equal({"xmlns:foo"=>"bar"}, b.namespaces)
158
+ assert_equal("b", b.name)
159
+ assert_equal("bar", b.namespace.href)
160
+ end
161
+
146
162
  def test_specified_namespace_undeclared
147
163
  Nokogiri::XML::Builder.new { |xml|
148
164
  xml.root do
149
165
  assert_raises(ArgumentError) do
150
- xml[:foo]
166
+ xml[:foo].bar
151
167
  end
152
168
  end
153
169
  }
@@ -63,11 +63,13 @@ module Nokogiri
63
63
  def test_ignore_unknown_namespace
64
64
  doc = Nokogiri::XML(<<-eoxml)
65
65
  <xml>
66
- <unknown:foo xmlns='hello' />
66
+ <unknown:foo xmlns='http://hello.com/' />
67
67
  <bar />
68
68
  </xml>
69
69
  eoxml
70
- refute doc.xpath('//foo').first.namespace # assert that the namespace is nil
70
+ if Nokogiri.jruby?
71
+ refute doc.xpath('//foo').first.namespace # assert that the namespace is nil
72
+ end
71
73
  refute_empty doc.xpath('//bar'), "bar wasn't found in the document" # bar should be part of the doc
72
74
  end
73
75
 
@@ -651,6 +651,18 @@ module Nokogiri
651
651
  assert_equal "<!-- < -->", comment.to_xml
652
652
  end
653
653
 
654
+ def test_find_by_css_class_with_nonstandard_whitespace
655
+ doc = Nokogiri::HTML '
656
+ <html>
657
+ <body>
658
+ <div class="a
659
+ b"></div>
660
+ </body>
661
+ </html>
662
+ '
663
+ assert_not_nil doc.at_css(".b")
664
+ end
665
+
654
666
  def test_find_by_css_with_tilde_eql
655
667
  xml = Nokogiri::XML.parse(<<-eoxml)
656
668
  <root>
@@ -905,7 +917,7 @@ module Nokogiri
905
917
  </root>
906
918
  eoxml
907
919
 
908
- tires = xml.css('bike|tire', 'bike' => 'http://schwinn.com/')
920
+ tires = xml.css('bike|tire', 'bike' => 'http://schwinn.com/' )
909
921
  assert_equal 1, tires.length
910
922
  end
911
923
 
data/test_all CHANGED
@@ -10,7 +10,7 @@
10
10
  # (e.g., 1.9.3's glob_helper). ["rake test:valgrind:suppression"]
11
11
  #
12
12
 
13
- RUBIES="ruby-1.9.3-p194 jruby-1.7.0 jruby-1.6.5.1 jruby-1.6.7.2 ree-1.8.7-2011.12 ruby-1.9.2-p320 ruby-1.8.7-p370"
13
+ RUBIES="ruby-1.9.3-p327 jruby-1.7.3 jruby-1.6.5.1 jruby-1.6.7.2 ree-1.8.7-2011.12 ruby-1.9.2-p320 ruby-1.8.7-p370"
14
14
  TEST_LOG=test.log
15
15
  VALGRIND_LOG=valgrind.log
16
16
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: nokogiri
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease: 6
5
- version: 1.5.7.rc1
5
+ version: 1.5.7.rc2
6
6
  platform: java
7
7
  authors:
8
8
  - Aaron Patterson
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-02-22 00:00:00.000000000 Z
15
+ date: 2013-03-11 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: hoe-bundler
@@ -225,40 +225,40 @@ extra_rdoc_files:
225
225
  - Manifest.txt
226
226
  - README.ja.rdoc
227
227
  - README.rdoc
228
+ - ext/nokogiri/html_document.c
229
+ - ext/nokogiri/html_element_description.c
230
+ - ext/nokogiri/html_entity_lookup.c
228
231
  - ext/nokogiri/html_sax_parser_context.c
229
- - ext/nokogiri/xslt_stylesheet.c
230
- - ext/nokogiri/xml_namespace.c
231
- - ext/nokogiri/xml_node.c
232
+ - ext/nokogiri/html_sax_push_parser.c
233
+ - ext/nokogiri/nokogiri.c
232
234
  - ext/nokogiri/xml_attr.c
233
- - ext/nokogiri/xml_entity_decl.c
234
- - ext/nokogiri/xml_reader.c
235
- - ext/nokogiri/xml_document.c
236
- - ext/nokogiri/xml_sax_push_parser.c
235
+ - ext/nokogiri/xml_attribute_decl.c
236
+ - ext/nokogiri/xml_cdata.c
237
237
  - ext/nokogiri/xml_comment.c
238
+ - ext/nokogiri/xml_document.c
239
+ - ext/nokogiri/xml_document_fragment.c
240
+ - ext/nokogiri/xml_dtd.c
238
241
  - ext/nokogiri/xml_element_content.c
239
- - ext/nokogiri/xml_sax_parser_context.c
240
242
  - ext/nokogiri/xml_element_decl.c
241
- - ext/nokogiri/xml_node_set.c
242
- - ext/nokogiri/xml_entity_reference.c
243
- - ext/nokogiri/xml_xpath_context.c
244
- - ext/nokogiri/xml_document_fragment.c
245
243
  - ext/nokogiri/xml_encoding_handler.c
246
- - ext/nokogiri/html_sax_push_parser.c
247
- - ext/nokogiri/xml_text.c
244
+ - ext/nokogiri/xml_entity_decl.c
245
+ - ext/nokogiri/xml_entity_reference.c
246
+ - ext/nokogiri/xml_io.c
247
+ - ext/nokogiri/xml_libxml2_hacks.c
248
+ - ext/nokogiri/xml_namespace.c
249
+ - ext/nokogiri/xml_node.c
250
+ - ext/nokogiri/xml_node_set.c
251
+ - ext/nokogiri/xml_processing_instruction.c
252
+ - ext/nokogiri/xml_reader.c
253
+ - ext/nokogiri/xml_relax_ng.c
248
254
  - ext/nokogiri/xml_sax_parser.c
255
+ - ext/nokogiri/xml_sax_parser_context.c
256
+ - ext/nokogiri/xml_sax_push_parser.c
249
257
  - ext/nokogiri/xml_schema.c
250
- - ext/nokogiri/xml_dtd.c
251
- - ext/nokogiri/xml_libxml2_hacks.c
252
- - ext/nokogiri/xml_attribute_decl.c
253
258
  - ext/nokogiri/xml_syntax_error.c
254
- - ext/nokogiri/xml_io.c
255
- - ext/nokogiri/xml_relax_ng.c
256
- - ext/nokogiri/nokogiri.c
257
- - ext/nokogiri/xml_processing_instruction.c
258
- - ext/nokogiri/xml_cdata.c
259
- - ext/nokogiri/html_entity_lookup.c
260
- - ext/nokogiri/html_element_description.c
261
- - ext/nokogiri/html_document.c
259
+ - ext/nokogiri/xml_text.c
260
+ - ext/nokogiri/xml_xpath_context.c
261
+ - ext/nokogiri/xslt_stylesheet.c
262
262
  files:
263
263
  - ".autotest"
264
264
  - ".gemtest"
@@ -328,6 +328,7 @@ files:
328
328
  - ext/java/nokogiri/internals/ReaderNode.java
329
329
  - ext/java/nokogiri/internals/SaveContextVisitor.java
330
330
  - ext/java/nokogiri/internals/SchemaErrorHandler.java
331
+ - ext/java/nokogiri/internals/UncloseableInputStream.java
331
332
  - ext/java/nokogiri/internals/XmlDeclHandler.java
332
333
  - ext/java/nokogiri/internals/XmlDomParserContext.java
333
334
  - ext/java/nokogiri/internals/XmlSaxParser.java
@@ -562,6 +563,9 @@ files:
562
563
  - test/xslt/test_custom_functions.rb
563
564
  - test/xslt/test_exception_handling.rb
564
565
  - test_all
566
+ - test/namespaces/test_namespaces_in_builder_doc.rb
567
+ - test/namespaces/test_namespaces_in_created_doc.rb
568
+ - test/namespaces/test_namespaces_in_parsed_doc.rb
565
569
  - lib/nokogiri/nokogiri.jar
566
570
  homepage: http://nokogiri.org
567
571
  licenses: []
@@ -595,65 +599,68 @@ signing_key:
595
599
  specification_version: 3
596
600
  summary: ! "Nokogiri (é\x8b¸) is an HTML, XML, SAX, and Reader parser"
597
601
  test_files:
598
- - test/test_nokogiri.rb
602
+ - test/test_encoding_handler.rb
603
+ - test/test_reader.rb
604
+ - test/test_css_cache.rb
605
+ - test/test_soap4r_sax.rb
599
606
  - test/test_memory_leak.rb
600
607
  - test/test_convert_xpath.rb
601
- - test/test_css_cache.rb
602
608
  - test/test_xslt_transforms.rb
603
- - test/test_encoding_handler.rb
604
- - test/test_soap4r_sax.rb
605
- - test/test_reader.rb
606
- - test/xml/test_element_content.rb
607
- - test/xml/test_builder.rb
608
- - test/xml/test_element_decl.rb
609
- - test/xml/test_parse_options.rb
610
- - test/xml/test_dtd_encoding.rb
611
- - test/xml/test_attribute_decl.rb
612
- - test/xml/test_cdata.rb
613
- - test/xml/test_document_fragment.rb
614
- - test/xml/test_dtd.rb
615
- - test/xml/test_node_reparenting.rb
616
- - test/xml/test_c14n.rb
617
- - test/xml/test_node_inheritance.rb
618
- - test/xml/test_schema.rb
609
+ - test/test_nokogiri.rb
610
+ - test/decorators/test_slop.rb
611
+ - test/css/test_parser.rb
612
+ - test/css/test_nthiness.rb
613
+ - test/css/test_tokenizer.rb
614
+ - test/css/test_xpath_visitor.rb
615
+ - test/xslt/test_exception_handling.rb
616
+ - test/xslt/test_custom_functions.rb
617
+ - test/xml/test_comment.rb
618
+ - test/xml/test_unparented_node.rb
619
619
  - test/xml/test_processing_instruction.rb
620
- - test/xml/test_attr.rb
621
- - test/xml/test_namespace.rb
622
- - test/xml/test_relax_ng.rb
620
+ - test/xml/test_node_attributes.rb
623
621
  - test/xml/test_xpath.rb
624
- - test/xml/test_reader_encoding.rb
625
622
  - test/xml/test_node_encoding.rb
626
- - test/xml/test_node_attributes.rb
623
+ - test/xml/test_element_decl.rb
624
+ - test/xml/test_entity_decl.rb
625
+ - test/xml/test_namespace.rb
626
+ - test/xml/test_cdata.rb
627
+ - test/xml/test_node_inheritance.rb
628
+ - test/xml/test_entity_reference.rb
627
629
  - test/xml/test_text.rb
630
+ - test/xml/test_reader_encoding.rb
631
+ - test/xml/test_dtd.rb
632
+ - test/xml/test_xinclude.rb
633
+ - test/xml/test_parse_options.rb
634
+ - test/xml/test_schema.rb
635
+ - test/xml/test_element_content.rb
628
636
  - test/xml/test_document.rb
629
- - test/xml/test_entity_reference.rb
630
- - test/xml/test_node.rb
631
- - test/xml/test_document_encoding.rb
632
- - test/xml/test_unparented_node.rb
637
+ - test/xml/test_relax_ng.rb
638
+ - test/xml/test_c14n.rb
639
+ - test/xml/test_dtd_encoding.rb
633
640
  - test/xml/test_syntax_error.rb
634
- - test/xml/test_entity_decl.rb
635
- - test/xml/test_comment.rb
641
+ - test/xml/test_attribute_decl.rb
636
642
  - test/xml/test_node_set.rb
637
- - test/xml/test_xinclude.rb
638
- - test/xml/node/test_save_options.rb
639
- - test/xml/node/test_subclass.rb
643
+ - test/xml/test_builder.rb
644
+ - test/xml/test_document_encoding.rb
645
+ - test/xml/test_attr.rb
646
+ - test/xml/test_document_fragment.rb
647
+ - test/xml/test_node.rb
648
+ - test/xml/test_node_reparenting.rb
640
649
  - test/xml/sax/test_parser.rb
641
- - test/xml/sax/test_parser_context.rb
642
650
  - test/xml/sax/test_push_parser.rb
643
- - test/xslt/test_exception_handling.rb
644
- - test/xslt/test_custom_functions.rb
645
- - test/decorators/test_slop.rb
646
- - test/html/test_builder.rb
647
- - test/html/test_document_fragment.rb
648
- - test/html/test_named_characters.rb
649
- - test/html/test_element_description.rb
651
+ - test/xml/sax/test_parser_context.rb
652
+ - test/xml/node/test_save_options.rb
653
+ - test/xml/node/test_subclass.rb
650
654
  - test/html/test_node_encoding.rb
651
655
  - test/html/test_document.rb
652
- - test/html/test_node.rb
656
+ - test/html/test_named_characters.rb
657
+ - test/html/test_builder.rb
653
658
  - test/html/test_document_encoding.rb
659
+ - test/html/test_element_description.rb
660
+ - test/html/test_document_fragment.rb
661
+ - test/html/test_node.rb
654
662
  - test/html/sax/test_parser.rb
655
663
  - test/html/sax/test_parser_context.rb
656
- - test/css/test_tokenizer.rb
657
- - test/css/test_parser.rb
658
- - test/css/test_nthiness.rb
659
- - test/css/test_xpath_visitor.rb
664
+ - test/namespaces/test_namespaces_in_builder_doc.rb
665
+ - test/namespaces/test_namespaces_in_created_doc.rb
666
+ - test/namespaces/test_namespaces_in_parsed_doc.rb