nokogiri 1.3.1-x86-mswin32 → 1.3.2-x86-mswin32
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 +25 -0
- data/CHANGELOG.rdoc +23 -0
- data/Manifest.txt +5 -0
- data/README.ja.rdoc +5 -5
- data/README.rdoc +3 -3
- data/Rakefile +25 -21
- data/ext/nokogiri/extconf.rb +54 -12
- data/ext/nokogiri/xml_document.c +4 -1
- data/ext/nokogiri/xml_document.h +2 -0
- data/ext/nokogiri/xml_dtd.c +29 -0
- data/ext/nokogiri/xml_node.c +9 -1
- data/ext/nokogiri/xml_node_set.c +5 -1
- data/ext/nokogiri/xml_relax_ng.c +50 -3
- data/ext/nokogiri/xml_sax_parser.c +84 -77
- data/ext/nokogiri/xml_schema.c +52 -3
- data/ext/nokogiri/xml_syntax_error.c +7 -0
- data/ext/nokogiri/xml_syntax_error.h +1 -0
- data/lib/nokogiri.rb +2 -2
- data/lib/nokogiri/1.8/nokogiri.so +0 -0
- data/lib/nokogiri/1.9/nokogiri.so +0 -0
- data/lib/nokogiri/css/parser.rb +2 -2
- data/lib/nokogiri/ffi/io_callbacks.rb +20 -12
- data/lib/nokogiri/ffi/libxml.rb +8 -0
- data/lib/nokogiri/ffi/xml/document.rb +1 -1
- data/lib/nokogiri/ffi/xml/dtd.rb +22 -6
- data/lib/nokogiri/ffi/xml/namespace.rb +9 -7
- data/lib/nokogiri/ffi/xml/node.rb +4 -0
- data/lib/nokogiri/ffi/xml/node_set.rb +4 -1
- data/lib/nokogiri/ffi/xml/relax_ng.rb +35 -3
- data/lib/nokogiri/ffi/xml/sax/parser.rb +20 -19
- data/lib/nokogiri/ffi/xml/schema.rb +41 -4
- data/lib/nokogiri/html.rb +2 -2
- data/lib/nokogiri/html/document.rb +3 -3
- data/lib/nokogiri/version.rb +2 -2
- data/lib/nokogiri/xml.rb +3 -3
- data/lib/nokogiri/xml/document.rb +14 -4
- data/lib/nokogiri/xml/fragment_handler.rb +8 -0
- data/lib/nokogiri/xml/node.rb +1 -104
- data/lib/nokogiri/xml/node_set.rb +46 -6
- data/lib/nokogiri/xml/parse_options.rb +7 -2
- data/lib/nokogiri/xml/relax_ng.rb +2 -2
- data/lib/nokogiri/xml/sax.rb +1 -0
- data/lib/nokogiri/xml/sax/document.rb +4 -4
- data/lib/nokogiri/xml/sax/legacy_handlers.rb +65 -0
- data/lib/nokogiri/xml/sax/parser.rb +7 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +3 -0
- data/lib/nokogiri/xml/schema.rb +1 -5
- data/lib/xsd/xmlparser/nokogiri.rb +14 -7
- data/tasks/test.rb +1 -62
- data/test/files/bar/bar.xsd +4 -0
- data/test/files/foo/foo.xsd +4 -0
- data/test/files/snuggles.xml +3 -0
- data/test/files/valid_bar.xml +2 -0
- data/test/helper.rb +9 -8
- data/test/html/test_document_fragment.rb +14 -0
- data/test/test_reader.rb +10 -10
- data/test/xml/sax/test_parser.rb +77 -0
- data/test/xml/sax/test_push_parser.rb +11 -7
- data/test/xml/test_document.rb +25 -0
- data/test/xml/test_dtd.rb +6 -1
- data/test/xml/test_node.rb +7 -0
- data/test/xml/test_node_set.rb +19 -0
- data/test/xml/test_schema.rb +24 -0
- metadata +10 -5
data/tasks/test.rb
CHANGED
@@ -1,64 +1,3 @@
|
|
1
|
-
# partial-loads-ok and undef-value-errors necessary to ignore
|
2
|
-
# spurious (and eminently ignorable) warnings from the ruby
|
3
|
-
# interpreter
|
4
|
-
VALGRIND_BASIC_OPTS = "--num-callers=50 --error-limit=no --partial-loads-ok=yes --undef-value-errors=no"
|
5
|
-
|
6
|
-
class NokogiriTestTask < Rake::TestTask
|
7
|
-
def initialize *args
|
8
|
-
super
|
9
|
-
%w[ ext lib bin test ].each do |dir|
|
10
|
-
self.libs << dir
|
11
|
-
end
|
12
|
-
self.test_files = FileList['test/**/test_*.rb'] +
|
13
|
-
FileList['test/**/*_test.rb']
|
14
|
-
self.verbose = "verbose"
|
15
|
-
self.warning = true
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
desc "run test suite under valgrind with basic ruby options"
|
20
|
-
NokogiriTestTask.new('test:valgrind').extend(Module.new {
|
21
|
-
def ruby *args
|
22
|
-
run_with_env "valgrind #{VALGRIND_BASIC_OPTS} #{RUBY} #{args.join(' ')} test/test_nokogiri.rb --verbose=verbose"
|
23
|
-
end
|
24
|
-
})
|
25
|
-
|
26
|
-
desc "run test suite under valgrind with memory-fill ruby options"
|
27
|
-
NokogiriTestTask.new('test:valgrind_mem').extend(Module.new {
|
28
|
-
def ruby *args
|
29
|
-
run_with_env "valgrind #{VALGRIND_BASIC_OPTS} --freelist-vol=100000000 --malloc-fill=6D --free-fill=66 #{RUBY} #{args.join(' ')} test/test_nokogiri.rb --verbose=verbose"
|
30
|
-
end
|
31
|
-
})
|
32
|
-
|
33
|
-
desc "run test suite under valgrind with memory-zero ruby options"
|
34
|
-
NokogiriTestTask.new('test:valgrind_mem0').extend(Module.new {
|
35
|
-
def ruby *args
|
36
|
-
run_with_env "valgrind #{VALGRIND_BASIC_OPTS} --freelist-vol=100000000 --malloc-fill=00 --free-fill=00 #{RUBY} #{args.join(' ')} test/test_nokogiri.rb --verbose=verbose"
|
37
|
-
end
|
38
|
-
})
|
39
|
-
|
40
|
-
desc "run test suite under gdb"
|
41
|
-
NokogiriTestTask.new('test:gdb').extend(Module.new {
|
42
|
-
def ruby *args
|
43
|
-
run_with_env "gdb --args #{RUBY} #{args.join(' ')}"
|
44
|
-
end
|
45
|
-
})
|
46
|
-
|
47
|
-
desc "test coverage"
|
48
|
-
NokogiriTestTask.new('test:coverage').extend(Module.new {
|
49
|
-
def ruby *args
|
50
|
-
rm_rf "coverage"
|
51
|
-
run_with_env "rcov -x Library -I lib:ext:test #{args.join(' ')}"
|
52
|
-
end
|
53
|
-
})
|
54
|
-
|
55
|
-
desc "run test suite with verbose output"
|
56
|
-
NokogiriTestTask.new('test:verbose').extend(Module.new {
|
57
|
-
def ruby *args
|
58
|
-
run_with_env "#{RUBY} #{args.join(' ')} test/test_nokogiri.rb --verbose=verbose"
|
59
|
-
end
|
60
|
-
})
|
61
|
-
|
62
1
|
def run_with_env(cmd)
|
63
2
|
cmd = "LD_LIBRARY_PATH='#{ENV['LD_LIBRARY_PATH']}' #{cmd}"
|
64
3
|
puts "=> #{cmd}"
|
@@ -142,7 +81,7 @@ namespace :test do
|
|
142
81
|
directories = ENV['MULTIXML2_DIR'] ? [ENV['MULTIXML2_DIR']] : Dir[File.join(MULTI_XML, 'install', '*')]
|
143
82
|
directories.sort.reverse.each do |xml2_version|
|
144
83
|
next unless xml2_version =~ /libxml2/
|
145
|
-
extopts = "--with-xml2-include=#{xml2_version}/include/libxml2 --with-xml2-lib=#{xml2_version}/lib --with-xslt-dir=#{libxslt}"
|
84
|
+
extopts = "--with-xml2-include=#{xml2_version}/include/libxml2 --with-xml2-lib=#{xml2_version}/lib --with-xslt-dir=#{libxslt} --with-iconv-dir=/usr"
|
146
85
|
cmd = "#{$0} clean test EXTOPTS='#{extopts}' LD_LIBRARY_PATH='#{xml2_version}/lib'"
|
147
86
|
|
148
87
|
version = File.basename(xml2_version)
|
data/test/helper.rb
CHANGED
@@ -23,6 +23,7 @@ module Nokogiri
|
|
23
23
|
PO_SCHEMA_FILE = File.join(ASSETS_DIR, 'po.xsd')
|
24
24
|
ADDRESS_SCHEMA_FILE = File.join(ASSETS_DIR, 'address_book.rlx')
|
25
25
|
ADDRESS_XML_FILE = File.join(ASSETS_DIR, 'address_book.xml')
|
26
|
+
SNUGGLES_FILE = File.join(ASSETS_DIR, 'snuggles.xml')
|
26
27
|
|
27
28
|
unless RUBY_VERSION >= '1.9'
|
28
29
|
undef :default_test
|
@@ -55,10 +56,10 @@ module Nokogiri
|
|
55
56
|
module SAX
|
56
57
|
class TestCase < Nokogiri::TestCase
|
57
58
|
class Doc < XML::SAX::Document
|
58
|
-
attr_reader :start_elements, :
|
59
|
-
attr_reader :end_elements, :
|
60
|
-
attr_reader :data, :comments, :cdata_blocks
|
61
|
-
attr_reader :errors, :warnings
|
59
|
+
attr_reader :start_elements, :start_document_called
|
60
|
+
attr_reader :end_elements, :end_document_called
|
61
|
+
attr_reader :data, :comments, :cdata_blocks, :start_elements_namespace
|
62
|
+
attr_reader :errors, :warnings, :end_elements_namespace
|
62
63
|
|
63
64
|
def start_document
|
64
65
|
@start_document_called = true
|
@@ -85,8 +86,8 @@ module Nokogiri
|
|
85
86
|
super
|
86
87
|
end
|
87
88
|
|
88
|
-
def
|
89
|
-
(@
|
89
|
+
def start_element_namespace *args
|
90
|
+
(@start_elements_namespace ||= []) << args
|
90
91
|
super
|
91
92
|
end
|
92
93
|
|
@@ -95,8 +96,8 @@ module Nokogiri
|
|
95
96
|
super
|
96
97
|
end
|
97
98
|
|
98
|
-
def
|
99
|
-
(@
|
99
|
+
def end_element_namespace *args
|
100
|
+
(@end_elements_namespace ||= []) << args
|
100
101
|
super
|
101
102
|
end
|
102
103
|
|
@@ -92,6 +92,20 @@ module Nokogiri
|
|
92
92
|
assert_equal "<span>foo<br/></span><span>bar</span>", fragment.to_xml
|
93
93
|
end
|
94
94
|
|
95
|
+
def test_fragment_script_tag_with_cdata
|
96
|
+
doc = HTML::Document.new
|
97
|
+
fragment = doc.fragment("<script>var foo = 'bar';</script>")
|
98
|
+
assert_equal("<script>var foo = 'bar';</script>",
|
99
|
+
fragment.to_s)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_fragment_with_comment
|
103
|
+
doc = HTML::Document.new
|
104
|
+
fragment = doc.fragment("<p>hello<!-- your ad here --></p>")
|
105
|
+
assert_equal("<p>hello<!-- your ad here --></p>",
|
106
|
+
fragment.to_s)
|
107
|
+
end
|
108
|
+
|
95
109
|
end
|
96
110
|
end
|
97
111
|
end
|
data/test/test_reader.rb
CHANGED
@@ -3,11 +3,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "helper"))
|
|
3
3
|
|
4
4
|
class TestReader < Nokogiri::TestCase
|
5
5
|
def test_from_io_sets_io_as_source
|
6
|
-
io =
|
7
|
-
<x xmlns:tenderlove='http://tenderlovemaking.com/'>
|
8
|
-
<tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
|
9
|
-
</x>
|
10
|
-
eoxml
|
6
|
+
io = File.open SNUGGLES_FILE
|
11
7
|
reader = Nokogiri::XML::Reader.from_io(io)
|
12
8
|
assert_equal io, reader.source
|
13
9
|
end
|
@@ -33,11 +29,7 @@ class TestReader < Nokogiri::TestCase
|
|
33
29
|
end
|
34
30
|
|
35
31
|
def test_from_io
|
36
|
-
io =
|
37
|
-
<x xmlns:tenderlove='http://tenderlovemaking.com/'>
|
38
|
-
<tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
|
39
|
-
</x>
|
40
|
-
eoxml
|
32
|
+
io = File.open SNUGGLES_FILE
|
41
33
|
reader = Nokogiri::XML::Reader.from_io(io)
|
42
34
|
assert_equal false, reader.default?
|
43
35
|
assert_equal [false, false, false, false, false, false, false],
|
@@ -45,6 +37,14 @@ class TestReader < Nokogiri::TestCase
|
|
45
37
|
end
|
46
38
|
|
47
39
|
def test_io
|
40
|
+
io = File.open SNUGGLES_FILE
|
41
|
+
reader = Nokogiri::XML::Reader(io)
|
42
|
+
assert_equal false, reader.default?
|
43
|
+
assert_equal [false, false, false, false, false, false, false],
|
44
|
+
reader.map { |x| x.default? }
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_string_io
|
48
48
|
io = StringIO.new(<<-eoxml)
|
49
49
|
<x xmlns:tenderlove='http://tenderlovemaking.com/'>
|
50
50
|
<tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
|
data/test/xml/sax/test_parser.rb
CHANGED
@@ -9,12 +9,89 @@ module Nokogiri
|
|
9
9
|
@parser = XML::SAX::Parser.new(Doc.new)
|
10
10
|
end
|
11
11
|
|
12
|
+
def test_namespace_declaration_order_is_saved
|
13
|
+
@parser.parse <<-eoxml
|
14
|
+
<root xmlns:foo='http://foo.example.com/' xmlns='http://example.com/'>
|
15
|
+
<a foo:bar='hello' />
|
16
|
+
</root>
|
17
|
+
eoxml
|
18
|
+
assert_equal 2, @parser.document.start_elements_namespace.length
|
19
|
+
el = @parser.document.start_elements_namespace.first
|
20
|
+
namespaces = el.last
|
21
|
+
assert_equal ['foo', 'http://foo.example.com/'], namespaces.first
|
22
|
+
assert_equal [nil, 'http://example.com/'], namespaces.last
|
23
|
+
end
|
24
|
+
|
12
25
|
def test_bad_document_calls_error_handler
|
13
26
|
@parser.parse('<foo><bar></foo>')
|
14
27
|
assert @parser.document.errors
|
15
28
|
assert @parser.document.errors.length > 0
|
16
29
|
end
|
17
30
|
|
31
|
+
def test_namespace_are_super_fun_to_parse
|
32
|
+
@parser.parse <<-eoxml
|
33
|
+
<root xmlns:foo='http://foo.example.com/'>
|
34
|
+
<a foo:bar='hello' />
|
35
|
+
<b xmlns:foo='http://bar.example.com/'>
|
36
|
+
<a foo:bar='hello' />
|
37
|
+
</b>
|
38
|
+
<foo:bar>hello world</foo:bar>
|
39
|
+
</root>
|
40
|
+
eoxml
|
41
|
+
assert @parser.document.start_elements_namespace.length > 0
|
42
|
+
el = @parser.document.start_elements_namespace[1]
|
43
|
+
assert_equal 'a', el.first
|
44
|
+
assert_equal 1, el[1].length
|
45
|
+
|
46
|
+
attribute = el[1].first
|
47
|
+
assert_equal 'bar', attribute.localname
|
48
|
+
assert_equal 'foo', attribute.prefix
|
49
|
+
assert_equal 'hello', attribute.value
|
50
|
+
assert_equal 'http://foo.example.com/', attribute.uri
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_sax_v1_namespace_attribute_declarations
|
54
|
+
@parser.parse <<-eoxml
|
55
|
+
<root xmlns:foo='http://foo.example.com/' xmlns='http://example.com/'>
|
56
|
+
<a foo:bar='hello' />
|
57
|
+
<b xmlns:foo='http://bar.example.com/'>
|
58
|
+
<a foo:bar='hello' />
|
59
|
+
</b>
|
60
|
+
<foo:bar>hello world</foo:bar>
|
61
|
+
</root>
|
62
|
+
eoxml
|
63
|
+
assert @parser.document.start_elements.length > 0
|
64
|
+
elm = @parser.document.start_elements.first
|
65
|
+
assert_equal 'root', elm.first
|
66
|
+
assert elm[1].include?(['xmlns:foo', 'http://foo.example.com/'])
|
67
|
+
assert elm[1].include?(['xmlns', 'http://example.com/'])
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_sax_v1_namespace_nodes
|
71
|
+
@parser.parse <<-eoxml
|
72
|
+
<root xmlns:foo='http://foo.example.com/' xmlns='http://example.com/'>
|
73
|
+
<a foo:bar='hello' />
|
74
|
+
<b xmlns:foo='http://bar.example.com/'>
|
75
|
+
<a foo:bar='hello' />
|
76
|
+
</b>
|
77
|
+
<foo:bar>hello world</foo:bar>
|
78
|
+
</root>
|
79
|
+
eoxml
|
80
|
+
assert_equal 5, @parser.document.start_elements.length
|
81
|
+
assert @parser.document.start_elements.map { |se|
|
82
|
+
se.first
|
83
|
+
}.include?('foo:bar')
|
84
|
+
assert @parser.document.end_elements.map { |se|
|
85
|
+
se.first
|
86
|
+
}.include?('foo:bar')
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_start_is_called_without_namespace
|
90
|
+
@parser.parse('<foo:f><bar></foo:f>')
|
91
|
+
assert_equal ['foo:f', 'bar'],
|
92
|
+
@parser.document.start_elements.map { |x| x.first }
|
93
|
+
end
|
94
|
+
|
18
95
|
def test_parser_sets_encoding
|
19
96
|
parser = XML::SAX::Parser.new(Doc.new, 'UTF-8')
|
20
97
|
assert_equal 'UTF-8', parser.encoding
|
@@ -43,12 +43,16 @@ module Nokogiri
|
|
43
43
|
<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' size='large'></stream:stream>
|
44
44
|
eoxml
|
45
45
|
|
46
|
-
assert_equal
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
46
|
+
assert_equal 1, @parser.document.start_elements_namespace.length
|
47
|
+
el = @parser.document.start_elements_namespace.first
|
48
|
+
|
49
|
+
assert_equal 'stream', el.first
|
50
|
+
assert_equal 2, el[1].length
|
51
|
+
assert_equal [['version', '1.0'], ['size', 'large']],
|
52
|
+
el[1].map { |x| [x.localname, x.value] }
|
53
|
+
|
54
|
+
assert_equal 'stream', el[2]
|
55
|
+
assert_equal 'http://etherx.jabber.org/streams', el[3]
|
52
56
|
@parser.finish
|
53
57
|
end
|
54
58
|
|
@@ -58,7 +62,7 @@ module Nokogiri
|
|
58
62
|
eoxml
|
59
63
|
|
60
64
|
assert_equal [['stream', 'stream', 'http://etherx.jabber.org/streams']],
|
61
|
-
@parser.document.
|
65
|
+
@parser.document.end_elements_namespace
|
62
66
|
@parser.finish
|
63
67
|
end
|
64
68
|
|
data/test/xml/test_document.rb
CHANGED
@@ -10,6 +10,31 @@ module Nokogiri
|
|
10
10
|
@xml = Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE)
|
11
11
|
end
|
12
12
|
|
13
|
+
def test_validate
|
14
|
+
assert_equal 44, @xml.validate.length
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_validate_no_internal_subset
|
18
|
+
doc = Nokogiri::XML('<test/>')
|
19
|
+
assert_nil doc.validate
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_clone
|
23
|
+
assert @xml.clone
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_document_should_not_have_default_ns
|
27
|
+
doc = Nokogiri::XML::Document.new
|
28
|
+
|
29
|
+
assert_raises NoMethodError do
|
30
|
+
doc.default_namespace = 'http://innernet.com/'
|
31
|
+
end
|
32
|
+
|
33
|
+
assert_raises NoMethodError do
|
34
|
+
doc.add_namespace_definition('foo', 'bar')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
13
38
|
def test_parse_takes_block
|
14
39
|
options = nil
|
15
40
|
Nokogiri::XML.parse(File.read(XML_FILE), XML_FILE) do |cfg|
|
data/test/xml/test_dtd.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.expand_path(File.join(File.dirname(__FILE__), '..', "helper"))
|
2
2
|
|
3
3
|
module Nokogiri
|
4
|
-
module
|
4
|
+
module XML
|
5
5
|
class TestDTD < Nokogiri::TestCase
|
6
6
|
def setup
|
7
7
|
super
|
@@ -9,6 +9,11 @@ module Nokogiri
|
|
9
9
|
assert @dtd = @xml.internal_subset
|
10
10
|
end
|
11
11
|
|
12
|
+
def test_validate
|
13
|
+
list = @xml.internal_subset.validate @xml
|
14
|
+
assert_equal 44, list.length
|
15
|
+
end
|
16
|
+
|
12
17
|
def test_external_subsets
|
13
18
|
assert subset = @xml.internal_subset
|
14
19
|
assert_equal 'staff', subset.name
|
data/test/xml/test_node.rb
CHANGED
@@ -157,6 +157,13 @@ module Nokogiri
|
|
157
157
|
assert_equal 'http://tenderlovemaking.com', node.namespaces['xmlns:foo']
|
158
158
|
end
|
159
159
|
|
160
|
+
def test_add_namespace_twice
|
161
|
+
node = @xml.at('address')
|
162
|
+
ns = node.add_namespace('foo', 'http://tenderlovemaking.com')
|
163
|
+
ns2 = node.add_namespace('foo', 'http://tenderlovemaking.com')
|
164
|
+
assert_equal ns, ns2
|
165
|
+
end
|
166
|
+
|
160
167
|
def test_add_default_ns
|
161
168
|
node = @xml.at('address')
|
162
169
|
node.add_namespace(nil, 'http://tenderlovemaking.com')
|
data/test/xml/test_node_set.rb
CHANGED
@@ -8,6 +8,25 @@ module Nokogiri
|
|
8
8
|
@xml = Nokogiri::XML(File.read(XML_FILE), XML_FILE)
|
9
9
|
end
|
10
10
|
|
11
|
+
def test_search_empty_node_set
|
12
|
+
set = Nokogiri::XML::NodeSet.new(Nokogiri::XML::Document.new)
|
13
|
+
assert_equal 0, set.css('foo').length
|
14
|
+
assert_equal 0, set.xpath('.//foo').length
|
15
|
+
assert_equal 0, set.search('foo').length
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_css_searches_match_self
|
19
|
+
html = Nokogiri::HTML("<html><body><div class='a'></div></body></html>")
|
20
|
+
set = html.xpath("/html/body/div")
|
21
|
+
assert_equal set.first, set.css(".a").first
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_search_with_css_matches_self
|
25
|
+
html = Nokogiri::HTML("<html><body><div class='a'></div></body></html>")
|
26
|
+
set = html.xpath("/html/body/div")
|
27
|
+
assert_equal set.first, set.search(".a").first
|
28
|
+
end
|
29
|
+
|
11
30
|
def test_double_equal
|
12
31
|
assert node_set_one = @xml.xpath('//employee')
|
13
32
|
assert node_set_two = @xml.xpath('//employee')
|
data/test/xml/test_schema.rb
CHANGED
@@ -7,6 +7,30 @@ module Nokogiri
|
|
7
7
|
assert @xsd = Nokogiri::XML::Schema(File.read(PO_SCHEMA_FILE))
|
8
8
|
end
|
9
9
|
|
10
|
+
def test_schema_from_document
|
11
|
+
doc = Nokogiri::XML(File.open(PO_SCHEMA_FILE))
|
12
|
+
assert doc
|
13
|
+
xsd = Nokogiri::XML::Schema.from_document doc
|
14
|
+
assert_instance_of Nokogiri::XML::Schema, xsd
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_schema_from_document_node
|
18
|
+
doc = Nokogiri::XML(File.open(PO_SCHEMA_FILE))
|
19
|
+
assert doc
|
20
|
+
xsd = Nokogiri::XML::Schema.from_document doc.root
|
21
|
+
assert_instance_of Nokogiri::XML::Schema, xsd
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_schema_validates_with_relative_paths
|
25
|
+
xsd = File.join(ASSETS_DIR, 'foo', 'foo.xsd')
|
26
|
+
xml = File.join(ASSETS_DIR, 'valid_bar.xml')
|
27
|
+
doc = Nokogiri::XML(File.open(xsd))
|
28
|
+
xsd = Nokogiri::XML::Schema.from_document doc
|
29
|
+
|
30
|
+
doc = Nokogiri::XML(File.open(xml))
|
31
|
+
assert xsd.valid?(doc)
|
32
|
+
end
|
33
|
+
|
10
34
|
def test_parse_with_memory
|
11
35
|
assert_instance_of Nokogiri::XML::Schema, @xsd
|
12
36
|
assert_equal 0, @xsd.errors.length
|