nokogiri 1.2.3-x86-mswin32-60 → 1.4.5-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/.autotest +18 -7
- data/.gemtest +0 -0
- data/CHANGELOG.ja.rdoc +297 -3
- data/CHANGELOG.rdoc +289 -0
- data/Manifest.txt +148 -37
- data/README.ja.rdoc +20 -20
- data/README.rdoc +53 -22
- data/Rakefile +127 -211
- data/bin/nokogiri +54 -0
- data/ext/nokogiri/depend +358 -0
- data/ext/nokogiri/extconf.rb +89 -54
- data/ext/nokogiri/html_document.c +34 -27
- data/ext/nokogiri/html_document.h +1 -1
- data/ext/nokogiri/html_element_description.c +276 -0
- data/ext/nokogiri/html_element_description.h +10 -0
- data/ext/nokogiri/html_entity_lookup.c +7 -5
- data/ext/nokogiri/html_entity_lookup.h +1 -1
- data/ext/nokogiri/html_sax_parser_context.c +94 -0
- data/ext/nokogiri/html_sax_parser_context.h +11 -0
- data/ext/nokogiri/{native.c → nokogiri.c} +31 -7
- data/ext/nokogiri/{native.h → nokogiri.h} +68 -41
- data/ext/nokogiri/xml_attr.c +20 -9
- data/ext/nokogiri/xml_attr.h +1 -1
- data/ext/nokogiri/xml_attribute_decl.c +70 -0
- data/ext/nokogiri/xml_attribute_decl.h +9 -0
- data/ext/nokogiri/xml_cdata.c +21 -9
- data/ext/nokogiri/xml_cdata.h +1 -1
- data/ext/nokogiri/xml_comment.c +18 -6
- data/ext/nokogiri/xml_comment.h +1 -1
- data/ext/nokogiri/xml_document.c +247 -68
- data/ext/nokogiri/xml_document.h +5 -3
- data/ext/nokogiri/xml_document_fragment.c +15 -7
- data/ext/nokogiri/xml_document_fragment.h +1 -1
- data/ext/nokogiri/xml_dtd.c +110 -10
- data/ext/nokogiri/xml_dtd.h +3 -1
- data/ext/nokogiri/xml_element_content.c +123 -0
- data/ext/nokogiri/xml_element_content.h +10 -0
- data/ext/nokogiri/xml_element_decl.c +69 -0
- data/ext/nokogiri/xml_element_decl.h +9 -0
- data/ext/nokogiri/xml_encoding_handler.c +79 -0
- data/ext/nokogiri/xml_encoding_handler.h +8 -0
- data/ext/nokogiri/xml_entity_decl.c +110 -0
- data/ext/nokogiri/xml_entity_decl.h +10 -0
- data/ext/nokogiri/xml_entity_reference.c +16 -5
- data/ext/nokogiri/xml_entity_reference.h +1 -1
- data/ext/nokogiri/xml_io.c +40 -8
- data/ext/nokogiri/xml_io.h +2 -1
- data/ext/nokogiri/xml_libxml2_hacks.c +112 -0
- data/ext/nokogiri/xml_libxml2_hacks.h +12 -0
- data/ext/nokogiri/xml_namespace.c +84 -0
- data/ext/nokogiri/xml_namespace.h +13 -0
- data/ext/nokogiri/xml_node.c +782 -225
- data/ext/nokogiri/xml_node.h +2 -4
- data/ext/nokogiri/xml_node_set.c +253 -34
- data/ext/nokogiri/xml_node_set.h +2 -2
- data/ext/nokogiri/xml_processing_instruction.c +17 -5
- data/ext/nokogiri/xml_processing_instruction.h +1 -1
- data/ext/nokogiri/xml_reader.c +277 -85
- data/ext/nokogiri/xml_reader.h +1 -1
- data/ext/nokogiri/xml_relax_ng.c +168 -0
- data/ext/nokogiri/xml_relax_ng.h +9 -0
- data/ext/nokogiri/xml_sax_parser.c +183 -111
- data/ext/nokogiri/xml_sax_parser.h +30 -1
- data/ext/nokogiri/xml_sax_parser_context.c +199 -0
- data/ext/nokogiri/xml_sax_parser_context.h +10 -0
- data/ext/nokogiri/xml_sax_push_parser.c +42 -12
- data/ext/nokogiri/xml_sax_push_parser.h +1 -1
- data/ext/nokogiri/xml_schema.c +205 -0
- data/ext/nokogiri/xml_schema.h +9 -0
- data/ext/nokogiri/xml_syntax_error.c +28 -173
- data/ext/nokogiri/xml_syntax_error.h +2 -1
- data/ext/nokogiri/xml_text.c +16 -6
- data/ext/nokogiri/xml_text.h +1 -1
- data/ext/nokogiri/xml_xpath_context.c +104 -47
- data/ext/nokogiri/xml_xpath_context.h +1 -1
- data/ext/nokogiri/xslt_stylesheet.c +161 -19
- data/ext/nokogiri/xslt_stylesheet.h +1 -1
- data/lib/nokogiri.rb +47 -8
- data/lib/nokogiri/1.8/nokogiri.so +0 -0
- data/lib/nokogiri/1.9/nokogiri.so +0 -0
- data/lib/nokogiri/css.rb +6 -3
- data/lib/nokogiri/css/node.rb +14 -12
- data/lib/nokogiri/css/parser.rb +665 -62
- data/lib/nokogiri/css/parser.y +20 -10
- data/lib/nokogiri/css/parser_extras.rb +91 -0
- data/lib/nokogiri/css/tokenizer.rb +148 -5
- data/lib/nokogiri/css/tokenizer.rex +10 -9
- data/lib/nokogiri/css/xpath_visitor.rb +47 -44
- data/lib/nokogiri/decorators/slop.rb +8 -4
- data/lib/nokogiri/ffi/encoding_handler.rb +42 -0
- data/lib/nokogiri/ffi/html/document.rb +28 -0
- data/lib/nokogiri/ffi/html/element_description.rb +81 -0
- data/lib/nokogiri/ffi/html/entity_lookup.rb +16 -0
- data/lib/nokogiri/ffi/html/sax/parser_context.rb +38 -0
- data/lib/nokogiri/ffi/io_callbacks.rb +42 -0
- data/lib/nokogiri/ffi/libxml.rb +420 -0
- data/lib/nokogiri/ffi/structs/common_node.rb +38 -0
- data/lib/nokogiri/ffi/structs/html_elem_desc.rb +24 -0
- data/lib/nokogiri/ffi/structs/html_entity_desc.rb +13 -0
- data/lib/nokogiri/ffi/structs/xml_alloc.rb +16 -0
- data/lib/nokogiri/ffi/structs/xml_attr.rb +20 -0
- data/lib/nokogiri/ffi/structs/xml_attribute.rb +27 -0
- data/lib/nokogiri/ffi/structs/xml_buffer.rb +16 -0
- data/lib/nokogiri/ffi/structs/xml_char_encoding_handler.rb +11 -0
- data/lib/nokogiri/ffi/structs/xml_document.rb +117 -0
- data/lib/nokogiri/ffi/structs/xml_dtd.rb +28 -0
- data/lib/nokogiri/ffi/structs/xml_element.rb +26 -0
- data/lib/nokogiri/ffi/structs/xml_element_content.rb +17 -0
- data/lib/nokogiri/ffi/structs/xml_entity.rb +32 -0
- data/lib/nokogiri/ffi/structs/xml_enumeration.rb +12 -0
- data/lib/nokogiri/ffi/structs/xml_node.rb +28 -0
- data/lib/nokogiri/ffi/structs/xml_node_set.rb +53 -0
- data/lib/nokogiri/ffi/structs/xml_notation.rb +11 -0
- data/lib/nokogiri/ffi/structs/xml_ns.rb +15 -0
- data/lib/nokogiri/ffi/structs/xml_parser_context.rb +20 -0
- data/lib/nokogiri/ffi/structs/xml_parser_input.rb +19 -0
- data/lib/nokogiri/ffi/structs/xml_relax_ng.rb +14 -0
- data/lib/nokogiri/ffi/structs/xml_sax_handler.rb +51 -0
- data/lib/nokogiri/ffi/structs/xml_sax_push_parser_context.rb +124 -0
- data/lib/nokogiri/ffi/structs/xml_schema.rb +13 -0
- data/lib/nokogiri/ffi/structs/xml_syntax_error.rb +31 -0
- data/lib/nokogiri/ffi/structs/xml_text_reader.rb +12 -0
- data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +38 -0
- data/lib/nokogiri/ffi/structs/xml_xpath_object.rb +35 -0
- data/lib/nokogiri/ffi/structs/xml_xpath_parser_context.rb +20 -0
- data/lib/nokogiri/ffi/structs/xslt_stylesheet.rb +13 -0
- data/lib/nokogiri/ffi/weak_bucket.rb +40 -0
- data/lib/nokogiri/ffi/xml/attr.rb +41 -0
- data/lib/nokogiri/ffi/xml/attribute_decl.rb +27 -0
- data/lib/nokogiri/ffi/xml/cdata.rb +19 -0
- data/lib/nokogiri/ffi/xml/comment.rb +18 -0
- data/lib/nokogiri/ffi/xml/document.rb +174 -0
- data/lib/nokogiri/ffi/xml/document_fragment.rb +21 -0
- data/lib/nokogiri/ffi/xml/dtd.rb +67 -0
- data/lib/nokogiri/ffi/xml/element_content.rb +43 -0
- data/lib/nokogiri/ffi/xml/element_decl.rb +19 -0
- data/lib/nokogiri/ffi/xml/entity_decl.rb +36 -0
- data/lib/nokogiri/ffi/xml/entity_reference.rb +19 -0
- data/lib/nokogiri/ffi/xml/namespace.rb +44 -0
- data/lib/nokogiri/ffi/xml/node.rb +559 -0
- data/lib/nokogiri/ffi/xml/node_set.rb +150 -0
- data/lib/nokogiri/ffi/xml/processing_instruction.rb +20 -0
- data/lib/nokogiri/ffi/xml/reader.rb +236 -0
- data/lib/nokogiri/ffi/xml/relax_ng.rb +85 -0
- data/lib/nokogiri/ffi/xml/sax/parser.rb +143 -0
- data/lib/nokogiri/ffi/xml/sax/parser_context.rb +79 -0
- data/lib/nokogiri/ffi/xml/sax/push_parser.rb +51 -0
- data/lib/nokogiri/ffi/xml/schema.rb +109 -0
- data/lib/nokogiri/ffi/xml/syntax_error.rb +98 -0
- data/lib/nokogiri/ffi/xml/text.rb +18 -0
- data/lib/nokogiri/ffi/xml/xpath.rb +9 -0
- data/lib/nokogiri/ffi/xml/xpath_context.rb +153 -0
- data/lib/nokogiri/ffi/xslt/stylesheet.rb +77 -0
- data/lib/nokogiri/html.rb +13 -47
- data/lib/nokogiri/html/builder.rb +27 -1
- data/lib/nokogiri/html/document.rb +201 -7
- data/lib/nokogiri/html/document_fragment.rb +41 -0
- data/lib/nokogiri/html/element_description.rb +23 -0
- data/lib/nokogiri/html/entity_lookup.rb +2 -0
- data/lib/nokogiri/html/sax/parser.rb +34 -3
- data/lib/nokogiri/html/sax/parser_context.rb +16 -0
- data/lib/nokogiri/nokogiri.rb +1 -0
- data/lib/nokogiri/version.rb +40 -1
- data/lib/nokogiri/version_warning.rb +14 -0
- data/lib/nokogiri/xml.rb +32 -53
- data/lib/nokogiri/xml/attr.rb +5 -0
- data/lib/nokogiri/xml/attribute_decl.rb +18 -0
- data/lib/nokogiri/xml/builder.rb +349 -29
- data/lib/nokogiri/xml/cdata.rb +3 -1
- data/lib/nokogiri/xml/character_data.rb +7 -0
- data/lib/nokogiri/xml/document.rb +166 -14
- data/lib/nokogiri/xml/document_fragment.rb +76 -1
- data/lib/nokogiri/xml/dtd.rb +16 -3
- data/lib/nokogiri/xml/element_content.rb +36 -0
- data/lib/nokogiri/xml/element_decl.rb +13 -0
- data/lib/nokogiri/xml/entity_decl.rb +19 -0
- data/lib/nokogiri/xml/namespace.rb +13 -0
- data/lib/nokogiri/xml/node.rb +561 -166
- data/lib/nokogiri/xml/node/save_options.rb +22 -2
- data/lib/nokogiri/xml/node_set.rb +202 -40
- data/lib/nokogiri/xml/parse_options.rb +93 -0
- data/lib/nokogiri/xml/pp.rb +2 -0
- data/lib/nokogiri/xml/pp/character_data.rb +18 -0
- data/lib/nokogiri/xml/pp/node.rb +56 -0
- data/lib/nokogiri/xml/processing_instruction.rb +2 -0
- data/lib/nokogiri/xml/reader.rb +93 -8
- data/lib/nokogiri/xml/relax_ng.rb +32 -0
- data/lib/nokogiri/xml/sax.rb +1 -7
- data/lib/nokogiri/xml/sax/document.rb +107 -2
- data/lib/nokogiri/xml/sax/parser.rb +57 -7
- data/lib/nokogiri/xml/sax/parser_context.rb +16 -0
- data/lib/nokogiri/xml/sax/push_parser.rb +13 -1
- data/lib/nokogiri/xml/schema.rb +63 -0
- data/lib/nokogiri/xml/syntax_error.rb +25 -1
- data/lib/nokogiri/xml/text.rb +4 -1
- data/lib/nokogiri/xml/xpath.rb +1 -1
- data/lib/nokogiri/xml/xpath/syntax_error.rb +3 -0
- data/lib/nokogiri/xml/xpath_context.rb +2 -0
- data/lib/nokogiri/xslt.rb +26 -2
- data/lib/nokogiri/xslt/stylesheet.rb +19 -0
- data/lib/xsd/xmlparser/nokogiri.rb +45 -9
- data/tasks/cross_compile.rb +173 -0
- data/tasks/test.rb +25 -69
- data/test/css/test_nthiness.rb +3 -4
- data/test/css/test_parser.rb +75 -20
- data/test/css/test_tokenizer.rb +23 -1
- data/test/css/test_xpath_visitor.rb +10 -1
- data/test/decorators/test_slop.rb +16 -0
- data/test/ffi/test_document.rb +35 -0
- data/test/files/2ch.html +108 -0
- data/test/files/address_book.rlx +12 -0
- data/test/files/address_book.xml +10 -0
- data/test/files/bar/bar.xsd +4 -0
- data/test/files/encoding.html +82 -0
- data/test/files/encoding.xhtml +84 -0
- data/test/files/foo/foo.xsd +4 -0
- data/test/files/po.xml +32 -0
- data/test/files/po.xsd +66 -0
- data/test/files/shift_jis.html +10 -0
- data/test/files/shift_jis.xml +5 -0
- data/test/files/snuggles.xml +3 -0
- data/test/files/staff.dtd +10 -0
- data/test/files/valid_bar.xml +2 -0
- data/test/helper.rb +101 -23
- data/test/html/sax/test_parser.rb +81 -2
- data/test/html/sax/test_parser_context.rb +48 -0
- data/test/html/test_builder.rb +39 -8
- data/test/html/test_document.rb +186 -23
- data/test/html/test_document_encoding.rb +78 -1
- data/test/html/test_document_fragment.rb +253 -0
- data/test/html/test_element_description.rb +98 -0
- data/test/html/test_named_characters.rb +1 -1
- data/test/html/test_node.rb +124 -36
- data/test/html/test_node_encoding.rb +27 -0
- data/test/test_convert_xpath.rb +1 -52
- data/test/test_css_cache.rb +2 -13
- data/test/test_encoding_handler.rb +46 -0
- data/test/test_memory_leak.rb +88 -19
- data/test/test_nokogiri.rb +38 -5
- data/test/test_reader.rb +188 -6
- data/test/test_soap4r_sax.rb +52 -0
- data/test/test_xslt_transforms.rb +183 -83
- data/test/xml/node/test_save_options.rb +1 -1
- data/test/xml/node/test_subclass.rb +44 -0
- data/test/xml/sax/test_parser.rb +175 -4
- data/test/xml/sax/test_parser_context.rb +113 -0
- data/test/xml/sax/test_push_parser.rb +90 -2
- data/test/xml/test_attr.rb +35 -1
- data/test/xml/test_attribute_decl.rb +82 -0
- data/test/xml/test_builder.rb +186 -1
- data/test/xml/test_cdata.rb +32 -1
- data/test/xml/test_comment.rb +13 -1
- data/test/xml/test_document.rb +415 -43
- data/test/xml/test_document_encoding.rb +1 -1
- data/test/xml/test_document_fragment.rb +173 -5
- data/test/xml/test_dtd.rb +61 -6
- data/test/xml/test_dtd_encoding.rb +3 -1
- data/test/xml/test_element_content.rb +56 -0
- data/test/xml/test_element_decl.rb +73 -0
- data/test/xml/test_entity_decl.rb +120 -0
- data/test/xml/test_entity_reference.rb +5 -1
- data/test/xml/test_namespace.rb +68 -0
- data/test/xml/test_node.rb +546 -201
- data/test/xml/test_node_attributes.rb +34 -0
- data/test/xml/test_node_encoding.rb +33 -3
- data/test/xml/test_node_reparenting.rb +321 -0
- data/test/xml/test_node_set.rb +538 -2
- data/test/xml/test_parse_options.rb +52 -0
- data/test/xml/test_processing_instruction.rb +6 -1
- data/test/xml/test_reader_encoding.rb +1 -1
- data/test/xml/test_relax_ng.rb +60 -0
- data/test/xml/test_schema.rb +94 -0
- data/test/xml/test_syntax_error.rb +12 -0
- data/test/xml/test_text.rb +35 -1
- data/test/xml/test_unparented_node.rb +5 -5
- data/test/xml/test_xpath.rb +142 -11
- data/test/xslt/test_custom_functions.rb +94 -0
- metadata +328 -92
- data/ext/nokogiri/html_sax_parser.c +0 -57
- data/ext/nokogiri/html_sax_parser.h +0 -11
- data/ext/nokogiri/iconv.dll +0 -0
- data/ext/nokogiri/libexslt.dll +0 -0
- data/ext/nokogiri/libxml2.dll +0 -0
- data/ext/nokogiri/libxslt.dll +0 -0
- data/ext/nokogiri/native.so +0 -0
- data/ext/nokogiri/xml_xpath.c +0 -53
- data/ext/nokogiri/xml_xpath.h +0 -11
- data/ext/nokogiri/zlib1.dll +0 -0
- data/lib/action-nokogiri.rb +0 -30
- data/lib/nokogiri/css/generated_parser.rb +0 -713
- data/lib/nokogiri/css/generated_tokenizer.rb +0 -144
- data/lib/nokogiri/decorators.rb +0 -2
- data/lib/nokogiri/decorators/hpricot.rb +0 -3
- data/lib/nokogiri/decorators/hpricot/node.rb +0 -56
- data/lib/nokogiri/decorators/hpricot/node_set.rb +0 -54
- data/lib/nokogiri/decorators/hpricot/xpath_visitor.rb +0 -28
- data/lib/nokogiri/hpricot.rb +0 -51
- data/lib/nokogiri/xml/comment.rb +0 -6
- data/lib/nokogiri/xml/element.rb +0 -6
- data/lib/nokogiri/xml/entity_declaration.rb +0 -9
- data/lib/nokogiri/xml/fragment_handler.rb +0 -34
- data/test/hpricot/files/basic.xhtml +0 -17
- data/test/hpricot/files/boingboing.html +0 -2266
- data/test/hpricot/files/cy0.html +0 -3653
- data/test/hpricot/files/immob.html +0 -400
- data/test/hpricot/files/pace_application.html +0 -1320
- data/test/hpricot/files/tenderlove.html +0 -16
- data/test/hpricot/files/uswebgen.html +0 -220
- data/test/hpricot/files/utf8.html +0 -1054
- data/test/hpricot/files/week9.html +0 -1723
- data/test/hpricot/files/why.xml +0 -19
- data/test/hpricot/load_files.rb +0 -11
- data/test/hpricot/test_alter.rb +0 -68
- data/test/hpricot/test_builder.rb +0 -20
- data/test/hpricot/test_parser.rb +0 -426
- data/test/hpricot/test_paths.rb +0 -15
- data/test/hpricot/test_preserved.rb +0 -77
- data/test/hpricot/test_xml.rb +0 -30
- data/test/test_gc.rb +0 -15
data/test/test_nokogiri.rb
CHANGED
@@ -1,12 +1,44 @@
|
|
1
|
-
require
|
1
|
+
require "helper"
|
2
2
|
|
3
3
|
class TestNokogiri < Nokogiri::TestCase
|
4
|
-
def
|
4
|
+
def test_versions
|
5
|
+
version_match = /\d+\.\d+\.\d+/
|
6
|
+
assert_match version_match, Nokogiri::VERSION
|
7
|
+
assert_match version_match, Nokogiri::LIBXML_VERSION
|
8
|
+
|
9
|
+
if defined?(FFI) && defined?(Nokogiri::LibXML)
|
10
|
+
assert_equal 'ffi', Nokogiri::VERSION_INFO['libxml']['binding']
|
11
|
+
if RUBY_PLATFORM =~ /java/
|
12
|
+
assert_equal 'jruby', Nokogiri::VERSION_INFO['libxml']['platform']
|
13
|
+
else
|
14
|
+
assert_equal 'ruby', Nokogiri::VERSION_INFO['libxml']['platform']
|
15
|
+
end
|
16
|
+
assert Nokogiri.ffi?
|
17
|
+
else
|
18
|
+
assert_equal 'extension', Nokogiri::VERSION_INFO['libxml']['binding']
|
19
|
+
|
20
|
+
assert_match version_match, Nokogiri::VERSION_INFO['libxml']['compiled']
|
21
|
+
assert_equal Nokogiri::LIBXML_VERSION, Nokogiri::VERSION_INFO['libxml']['compiled']
|
22
|
+
assert ! Nokogiri.ffi?
|
23
|
+
end
|
24
|
+
|
25
|
+
assert_match version_match, Nokogiri::VERSION_INFO['libxml']['loaded']
|
5
26
|
Nokogiri::LIBXML_PARSER_VERSION =~ /(\d)(\d{2})(\d{2})/
|
6
27
|
major = $1.to_i
|
7
28
|
minor = $2.to_i
|
8
29
|
bug = $3.to_i
|
9
|
-
assert_equal "#{major}.#{minor}.#{bug}", Nokogiri::
|
30
|
+
assert_equal "#{major}.#{minor}.#{bug}", Nokogiri::VERSION_INFO['libxml']['loaded']
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_libxml_iconv
|
34
|
+
assert Nokogiri.const_defined?(:LIBXML_ICONV_ENABLED)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_parse_with_io
|
38
|
+
doc = Nokogiri.parse(
|
39
|
+
StringIO.new("<html><head><title></title><body></body></html>")
|
40
|
+
)
|
41
|
+
assert_instance_of Nokogiri::HTML::Document, doc
|
10
42
|
end
|
11
43
|
|
12
44
|
def test_xml?
|
@@ -41,7 +73,7 @@ class TestNokogiri < Nokogiri::TestCase
|
|
41
73
|
doc = Nokogiri.make { b "bold tag" }
|
42
74
|
assert_equal('<b>bold tag</b>', doc.to_html.chomp)
|
43
75
|
end
|
44
|
-
|
76
|
+
|
45
77
|
SLOP_HTML = <<-END
|
46
78
|
<html>
|
47
79
|
<body>
|
@@ -91,7 +123,7 @@ class TestNokogiri < Nokogiri::TestCase
|
|
91
123
|
|
92
124
|
assert_raise(NoMethodError) { doc.nonexistent }
|
93
125
|
end
|
94
|
-
|
126
|
+
|
95
127
|
def test_slop_decorator
|
96
128
|
doc = Nokogiri(SLOP_HTML)
|
97
129
|
assert !doc.decorators(Nokogiri::XML::Node).include?(Nokogiri::Decorators::Slop)
|
@@ -102,4 +134,5 @@ class TestNokogiri < Nokogiri::TestCase
|
|
102
134
|
doc.slop!
|
103
135
|
assert_equal 1, doc.decorators(Nokogiri::XML::Node).select { |d| d == Nokogiri::Decorators::Slop }.size
|
104
136
|
end
|
137
|
+
|
105
138
|
end
|
data/test/test_reader.rb
CHANGED
@@ -1,7 +1,123 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
require
|
2
|
+
require "helper"
|
3
3
|
|
4
4
|
class TestReader < Nokogiri::TestCase
|
5
|
+
def test_from_io_sets_io_as_source
|
6
|
+
io = File.open SNUGGLES_FILE
|
7
|
+
reader = Nokogiri::XML::Reader.from_io(io)
|
8
|
+
assert_equal io, reader.source
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_empty_element?
|
12
|
+
reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
|
13
|
+
<xml><city>Paris</city><state/></xml>
|
14
|
+
eoxml
|
15
|
+
|
16
|
+
results = reader.map do |node|
|
17
|
+
if node.node_type == Nokogiri::XML::Node::ELEMENT_NODE
|
18
|
+
node.empty_element?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
assert_equal [false, false, nil, nil, true, nil], results
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_self_closing?
|
25
|
+
reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
|
26
|
+
<xml><city>Paris</city><state/></xml>
|
27
|
+
eoxml
|
28
|
+
|
29
|
+
results = reader.map do |node|
|
30
|
+
if node.node_type == Nokogiri::XML::Node::ELEMENT_NODE
|
31
|
+
node.self_closing?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
assert_equal [false, false, nil, nil, true, nil], results
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_reader_takes_block
|
38
|
+
options = nil
|
39
|
+
Nokogiri::XML::Reader(File.read(XML_FILE), XML_FILE) do |cfg|
|
40
|
+
options = cfg
|
41
|
+
options.nonet.nowarning.dtdattr
|
42
|
+
end
|
43
|
+
assert options.nonet?
|
44
|
+
assert options.nowarning?
|
45
|
+
assert options.dtdattr?
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_nil_raises
|
49
|
+
assert_raises(ArgumentError) {
|
50
|
+
Nokogiri::XML::Reader.from_memory(nil)
|
51
|
+
}
|
52
|
+
assert_raises(ArgumentError) {
|
53
|
+
Nokogiri::XML::Reader.from_io(nil)
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_from_io
|
58
|
+
io = File.open SNUGGLES_FILE
|
59
|
+
reader = Nokogiri::XML::Reader.from_io(io)
|
60
|
+
assert_equal false, reader.default?
|
61
|
+
assert_equal [false, false, false, false, false, false, false],
|
62
|
+
reader.map { |x| x.default? }
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_io
|
66
|
+
io = File.open SNUGGLES_FILE
|
67
|
+
reader = Nokogiri::XML::Reader(io)
|
68
|
+
assert_equal false, reader.default?
|
69
|
+
assert_equal [false, false, false, false, false, false, false],
|
70
|
+
reader.map { |x| x.default? }
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_string_io
|
74
|
+
io = StringIO.new(<<-eoxml)
|
75
|
+
<x xmlns:tenderlove='http://tenderlovemaking.com/'>
|
76
|
+
<tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
|
77
|
+
</x>
|
78
|
+
eoxml
|
79
|
+
reader = Nokogiri::XML::Reader(io)
|
80
|
+
assert_equal false, reader.default?
|
81
|
+
assert_equal [false, false, false, false, false, false, false],
|
82
|
+
reader.map { |x| x.default? }
|
83
|
+
end
|
84
|
+
|
85
|
+
class ReallyBadIO
|
86
|
+
def read(size)
|
87
|
+
'a' * size ** 10
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
unless Nokogiri.ffi?
|
92
|
+
def test_io_that_reads_too_much
|
93
|
+
io = ReallyBadIO.new
|
94
|
+
Nokogiri::XML::Reader(io)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_in_memory
|
99
|
+
assert Nokogiri::XML::Reader(<<-eoxml)
|
100
|
+
<x xmlns:tenderlove='http://tenderlovemaking.com/'>
|
101
|
+
<tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
|
102
|
+
</x>
|
103
|
+
eoxml
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_reader_holds_on_to_string
|
107
|
+
xml = <<-eoxml
|
108
|
+
<x xmlns:tenderlove='http://tenderlovemaking.com/'>
|
109
|
+
<tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
|
110
|
+
</x>
|
111
|
+
eoxml
|
112
|
+
reader = Nokogiri::XML::Reader(xml)
|
113
|
+
if Nokogiri.ffi?
|
114
|
+
assert_not_nil reader.source
|
115
|
+
assert reader.source.is_a?(FFI::MemoryPointer)
|
116
|
+
else
|
117
|
+
assert_equal xml, reader.source
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
5
121
|
def test_default?
|
6
122
|
reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
|
7
123
|
<x xmlns:tenderlove='http://tenderlovemaking.com/'>
|
@@ -31,13 +147,9 @@ class TestReader < Nokogiri::TestCase
|
|
31
147
|
<foo>
|
32
148
|
</x>
|
33
149
|
eoxml
|
34
|
-
|
35
|
-
begin
|
150
|
+
assert_raises(Nokogiri::XML::SyntaxError) do
|
36
151
|
reader.each { |node| }
|
37
|
-
rescue Nokogiri::XML::SyntaxError => ex
|
38
|
-
error_happened = true
|
39
152
|
end
|
40
|
-
assert error_happened
|
41
153
|
assert 1, reader.errors.length
|
42
154
|
end
|
43
155
|
|
@@ -183,6 +295,34 @@ class TestReader < Nokogiri::TestCase
|
|
183
295
|
reader.map { |n| n.prefix }
|
184
296
|
end
|
185
297
|
|
298
|
+
def test_node_type
|
299
|
+
reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
|
300
|
+
<x>
|
301
|
+
<y>hello</y>
|
302
|
+
</x>
|
303
|
+
eoxml
|
304
|
+
assert_equal 0, reader.node_type
|
305
|
+
assert_equal [1, 14, 1, 3, 15, 14, 15], reader.map { |n| n.node_type }
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_inner_xml
|
309
|
+
str = "<x><y>hello</y></x>"
|
310
|
+
reader = Nokogiri::XML::Reader.from_memory(str)
|
311
|
+
|
312
|
+
reader.read
|
313
|
+
|
314
|
+
assert_equal "<y>hello</y>", reader.inner_xml
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_outer_xml
|
318
|
+
str = "<x><y>hello</y></x>"
|
319
|
+
reader = Nokogiri::XML::Reader.from_memory(str)
|
320
|
+
|
321
|
+
reader.read
|
322
|
+
|
323
|
+
assert_equal str, reader.outer_xml
|
324
|
+
end
|
325
|
+
|
186
326
|
def test_state
|
187
327
|
reader = Nokogiri::XML::Reader.from_memory('<foo>bar</bar>')
|
188
328
|
assert reader.state
|
@@ -227,6 +367,34 @@ class TestReader < Nokogiri::TestCase
|
|
227
367
|
reader.map { |n| n.name })
|
228
368
|
end
|
229
369
|
|
370
|
+
def test_base_uri
|
371
|
+
reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
|
372
|
+
<x xml:base="http://base.example.org/base/">
|
373
|
+
<link href="link"/>
|
374
|
+
<other xml:base="http://other.example.org/"/>
|
375
|
+
<relative xml:base="relative">
|
376
|
+
<link href="stuff" />
|
377
|
+
</relative>
|
378
|
+
</x>
|
379
|
+
eoxml
|
380
|
+
|
381
|
+
assert_nil reader.base_uri
|
382
|
+
assert_equal(["http://base.example.org/base/",
|
383
|
+
"http://base.example.org/base/",
|
384
|
+
"http://base.example.org/base/",
|
385
|
+
"http://base.example.org/base/",
|
386
|
+
"http://other.example.org/",
|
387
|
+
"http://base.example.org/base/",
|
388
|
+
"http://base.example.org/base/relative",
|
389
|
+
"http://base.example.org/base/relative",
|
390
|
+
"http://base.example.org/base/relative",
|
391
|
+
"http://base.example.org/base/relative",
|
392
|
+
"http://base.example.org/base/relative",
|
393
|
+
"http://base.example.org/base/",
|
394
|
+
"http://base.example.org/base/"],
|
395
|
+
reader.map {|n| n.base_uri })
|
396
|
+
end
|
397
|
+
|
230
398
|
def test_read_from_memory
|
231
399
|
called = false
|
232
400
|
reader = Nokogiri::XML::Reader.from_memory('<foo>bar</foo>')
|
@@ -236,4 +404,18 @@ class TestReader < Nokogiri::TestCase
|
|
236
404
|
end
|
237
405
|
assert called
|
238
406
|
end
|
407
|
+
|
408
|
+
def test_large_document_smoke_test
|
409
|
+
# simply run on a large document to verify that there no GC issues
|
410
|
+
xml = []
|
411
|
+
xml << "<elements>"
|
412
|
+
10000.times { |j| xml << "<element id=\"#{j}\"/>" }
|
413
|
+
xml << "</elements>"
|
414
|
+
xml = xml.join("\n")
|
415
|
+
|
416
|
+
Nokogiri::XML::Reader.from_memory(xml).each do |e|
|
417
|
+
e.attributes
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
239
421
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
module XSD
|
4
|
+
module XMLParser
|
5
|
+
class Parser
|
6
|
+
@factory_added = nil
|
7
|
+
|
8
|
+
class << self; attr_reader :factory_added; end
|
9
|
+
|
10
|
+
def self.add_factory o
|
11
|
+
@factory_added = o
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize *args
|
15
|
+
@charset = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def characters foo
|
19
|
+
end
|
20
|
+
|
21
|
+
def start_element *args
|
22
|
+
end
|
23
|
+
|
24
|
+
def end_element *args
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'xsd/xmlparser/nokogiri'
|
31
|
+
|
32
|
+
class TestSoap4rSax < Nokogiri::TestCase
|
33
|
+
def test_factory_added
|
34
|
+
assert_equal XSD::XMLParser::Nokogiri, XSD::XMLParser::Nokogiri.factory_added
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_parse
|
38
|
+
o = Class.new(::XSD::XMLParser::Nokogiri) do
|
39
|
+
attr_accessor :element_started
|
40
|
+
def initialize *args
|
41
|
+
super
|
42
|
+
@element_started = false
|
43
|
+
end
|
44
|
+
|
45
|
+
def start_element *args
|
46
|
+
@element_started = true
|
47
|
+
end
|
48
|
+
end.new 'foo'
|
49
|
+
o.do_parse '<?xml version="1.0" ?><root xmlns="http://example.com/"/>'
|
50
|
+
assert o.element_started, 'element started'
|
51
|
+
end
|
52
|
+
end
|
@@ -1,93 +1,193 @@
|
|
1
|
-
require
|
1
|
+
require "helper"
|
2
2
|
|
3
3
|
class TestXsltTransforms < Nokogiri::TestCase
|
4
|
-
def
|
5
|
-
|
6
|
-
assert doc.xml?
|
7
|
-
|
8
|
-
assert style = Nokogiri::XSLT.parse(File.read(XSLT_FILE))
|
9
|
-
|
10
|
-
assert result = style.apply_to(doc, ['title', '"Booyah"'])
|
11
|
-
assert_match %r{<h1>Booyah</h1>}, result
|
12
|
-
assert_match %r{<th.*Employee ID</th>}, result
|
13
|
-
assert_match %r{<th.*Name</th>}, result
|
14
|
-
assert_match %r{<th.*Position</th>}, result
|
15
|
-
assert_match %r{<th.*Salary</th>}, result
|
16
|
-
assert_match %r{<td>EMP0003</td>}, result
|
17
|
-
assert_match %r{<td>Margaret Martin</td>}, result
|
18
|
-
assert_match %r{<td>Computer Specialist</td>}, result
|
19
|
-
assert_match %r{<td>100,000</td>}, result
|
20
|
-
assert_no_match %r{Dallas|Texas}, result
|
21
|
-
assert_no_match %r{Female}, result
|
22
|
-
|
23
|
-
assert result = style.apply_to(doc, ['title', '"Grandma"'])
|
24
|
-
assert_match %r{<h1>Grandma</h1>}, result
|
25
|
-
|
26
|
-
assert result = style.apply_to(doc)
|
27
|
-
assert_match %r{<h1></h1>}, result
|
4
|
+
def setup
|
5
|
+
@doc = Nokogiri::XML(File.open(XML_FILE))
|
28
6
|
end
|
29
|
-
def test_transform2
|
30
|
-
assert doc = Nokogiri::XML.parse(File.read(XML_FILE))
|
31
|
-
assert doc.xml?
|
32
7
|
|
33
|
-
|
34
|
-
|
35
|
-
|
8
|
+
if Nokogiri.uses_libxml?
|
9
|
+
def test_class_methods
|
10
|
+
style = Nokogiri::XSLT(File.read(XSLT_FILE))
|
36
11
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
assert_equal result_array, result_hash
|
57
|
-
end
|
12
|
+
assert result = style.apply_to(@doc, ['title', '"Grandma"'])
|
13
|
+
assert_match %r{<h1>Grandma</h1>}, result
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_transform
|
17
|
+
assert style = Nokogiri::XSLT.parse(File.read(XSLT_FILE))
|
18
|
+
|
19
|
+
assert result = style.apply_to(@doc, ['title', '"Booyah"'])
|
20
|
+
assert_match %r{<h1>Booyah</h1>}, result
|
21
|
+
assert_match %r{<th.*Employee ID</th>}, result
|
22
|
+
assert_match %r{<th.*Name</th>}, result
|
23
|
+
assert_match %r{<th.*Position</th>}, result
|
24
|
+
assert_match %r{<th.*Salary</th>}, result
|
25
|
+
assert_match %r{<td>EMP0003</td>}, result
|
26
|
+
assert_match %r{<td>Margaret Martin</td>}, result
|
27
|
+
assert_match %r{<td>Computer Specialist</td>}, result
|
28
|
+
assert_match %r{<td>100,000</td>}, result
|
29
|
+
assert_no_match %r{Dallas|Texas}, result
|
30
|
+
assert_no_match %r{Female}, result
|
58
31
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
params = {
|
65
|
-
:p1 => 'xxx',
|
66
|
-
:p2 => "x'x'x",
|
67
|
-
:p3 => 'x"x"x',
|
68
|
-
:p4 => '"xxx"'
|
69
|
-
}
|
70
|
-
result_doc = Nokogiri::XML.parse(style.apply_to(doc,
|
71
|
-
Nokogiri::XSLT.quote_params(params)))
|
72
|
-
|
73
|
-
assert_equal 'func-result', result_doc.at('/root/function').content
|
74
|
-
assert_equal 3, result_doc.at('/root/max').content.to_i
|
75
|
-
assert_match(
|
76
|
-
/\d{4}-\d\d-\d\d[-|+]\d\d:\d\d/,
|
77
|
-
result_doc.at('/root/date').content
|
78
|
-
)
|
79
|
-
result_doc.xpath('/root/params/*').each do |p|
|
80
|
-
assert_equal p.content, params[p.name.intern]
|
32
|
+
assert result = style.apply_to(@doc, ['title', '"Grandma"'])
|
33
|
+
assert_match %r{<h1>Grandma</h1>}, result
|
34
|
+
|
35
|
+
assert result = style.apply_to(@doc)
|
36
|
+
assert_match %r{<h1></h1>}, result
|
81
37
|
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
38
|
+
|
39
|
+
def test_transform_with_output_style
|
40
|
+
xslt = Nokogiri::XSLT(<<-eoxslt)
|
41
|
+
<?xml version="1.0" encoding="ISO-8859-1"?>
|
42
|
+
|
43
|
+
<xsl:stylesheet version="1.0"
|
44
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
45
|
+
<xsl:output method="text" version="1.0"
|
46
|
+
encoding="iso-8859-1" indent="yes"/>
|
47
|
+
|
48
|
+
<xsl:param name="title"/>
|
49
|
+
|
50
|
+
<xsl:template match="/">
|
51
|
+
<html>
|
52
|
+
<body>
|
53
|
+
<xsl:for-each select="staff/employee">
|
54
|
+
<tr>
|
55
|
+
<td><xsl:value-of select="employeeId"/></td>
|
56
|
+
<td><xsl:value-of select="name"/></td>
|
57
|
+
<td><xsl:value-of select="position"/></td>
|
58
|
+
<td><xsl:value-of select="salary"/></td>
|
59
|
+
</tr>
|
60
|
+
</xsl:for-each>
|
61
|
+
</table>
|
62
|
+
</body>
|
63
|
+
</html>
|
64
|
+
</xsl:template>
|
65
|
+
|
66
|
+
</xsl:stylesheet>
|
67
|
+
eoxslt
|
68
|
+
assert_no_match(/<td>/, xslt.apply_to(@doc, ['title', 'foo']))
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_transform_arg_error
|
72
|
+
assert style = Nokogiri::XSLT(File.read(XSLT_FILE))
|
73
|
+
assert_raises(TypeError) do
|
74
|
+
style.transform(@doc, :foo)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_transform_with_hash
|
79
|
+
assert style = Nokogiri::XSLT(File.read(XSLT_FILE))
|
80
|
+
result = style.transform(@doc, {'title' => '"Booyah"'})
|
81
|
+
assert result.html?
|
82
|
+
assert_equal "Booyah", result.at_css("h1").content
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_transform2
|
86
|
+
assert style = Nokogiri::XSLT(File.open(XSLT_FILE))
|
87
|
+
assert result_doc = style.transform(@doc)
|
88
|
+
assert result_doc.html?
|
89
|
+
assert_equal "", result_doc.at_css("h1").content
|
90
|
+
|
91
|
+
assert style = Nokogiri::XSLT(File.read(XSLT_FILE))
|
92
|
+
assert result_doc = style.transform(@doc, ['title', '"Booyah"'])
|
93
|
+
assert result_doc.html?
|
94
|
+
assert_equal "Booyah", result_doc.at_css("h1").content
|
95
|
+
|
96
|
+
assert result_string = style.apply_to(@doc, ['title', '"Booyah"'])
|
97
|
+
assert_equal result_string, style.serialize(result_doc)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_transform_with_quote_params
|
101
|
+
assert style = Nokogiri::XSLT(File.open(XSLT_FILE))
|
102
|
+
assert result_doc = style.transform(@doc, Nokogiri::XSLT.quote_params(['title', 'Booyah']))
|
103
|
+
assert result_doc.html?
|
104
|
+
assert_equal "Booyah", result_doc.at_css("h1").content
|
105
|
+
|
106
|
+
assert style = Nokogiri::XSLT.parse(File.read(XSLT_FILE))
|
107
|
+
assert result_doc = style.transform(@doc, Nokogiri::XSLT.quote_params({'title' => 'Booyah'}))
|
108
|
+
assert result_doc.html?
|
109
|
+
assert_equal "Booyah", result_doc.at_css("h1").content
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_quote_params
|
113
|
+
h = {
|
114
|
+
:sym => %{xxx},
|
115
|
+
'str' => %{"xxx"},
|
116
|
+
:sym2 => %{'xxx'},
|
117
|
+
'str2' => %{x'x'x},
|
118
|
+
:sym3 => %{x"x"x},
|
119
|
+
}
|
120
|
+
hh=h.dup
|
121
|
+
result_hash = Nokogiri::XSLT.quote_params(h)
|
122
|
+
assert_equal hh, h # non-destructive
|
123
|
+
|
124
|
+
a=h.to_a.flatten
|
125
|
+
result_array = Nokogiri::XSLT.quote_params(a)
|
126
|
+
assert_equal h.to_a.flatten, a #non-destructive
|
127
|
+
|
128
|
+
assert_equal result_array, result_hash
|
129
|
+
end
|
130
|
+
|
131
|
+
if Nokogiri.uses_libxml? # By now, cannot get it working on JRuby.
|
132
|
+
def test_exslt
|
133
|
+
assert doc = Nokogiri::XML.parse(File.read(EXML_FILE))
|
134
|
+
assert doc.xml?
|
135
|
+
|
136
|
+
assert style = Nokogiri::XSLT.parse(File.read(EXSLT_FILE))
|
137
|
+
params = {
|
138
|
+
:p1 => 'xxx',
|
139
|
+
:p2 => "x'x'x",
|
140
|
+
:p3 => 'x"x"x',
|
141
|
+
:p4 => '"xxx"'
|
142
|
+
}
|
143
|
+
result_doc = Nokogiri::XML.parse(style.apply_to(doc,
|
144
|
+
Nokogiri::XSLT.quote_params(params)))
|
145
|
+
|
146
|
+
assert_equal 'func-result', result_doc.at('/root/function').content
|
147
|
+
assert_equal 3, result_doc.at('/root/max').content.to_i
|
148
|
+
assert_match(
|
149
|
+
/\d{4}-\d\d-\d\d([-|+]\d\d:\d\d)?/,
|
150
|
+
result_doc.at('/root/date').content
|
151
|
+
)
|
152
|
+
result_doc.xpath('/root/params/*').each do |p|
|
153
|
+
assert_equal p.content, params[p.name.intern]
|
154
|
+
end
|
155
|
+
check_params result_doc, params
|
156
|
+
result_doc = Nokogiri::XML.parse(style.apply_to(doc,
|
157
|
+
Nokogiri::XSLT.quote_params(params.to_a.flatten)))
|
158
|
+
check_params result_doc, params
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_xslt_parse_error
|
163
|
+
xslt_str = <<-EOX
|
164
|
+
<xsl:stylesheet version="1.0"
|
165
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
166
|
+
<!-- Not well-formed: -->
|
167
|
+
<xsl:template match="/"/>
|
168
|
+
<values>
|
169
|
+
<xsl:for-each select="//*">
|
170
|
+
<value>
|
171
|
+
<xsl:value-of select="@id"/>
|
172
|
+
</value>
|
173
|
+
</xsl:for-each>
|
174
|
+
</values>
|
175
|
+
</xsl:template>
|
176
|
+
</xsl:stylesheet>}
|
177
|
+
EOX
|
178
|
+
assert_raises(RuntimeError) { Nokogiri::XSLT.parse(xslt_str) }
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_passing_a_non_document_to_transform
|
182
|
+
xsl = Nokogiri::XSLT('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"></xsl:stylesheet>')
|
183
|
+
assert_raises(ArgumentError) { xsl.transform("<div></div>") }
|
184
|
+
assert_raises(ArgumentError) { xsl.transform(Nokogiri::HTML("").css("body")) }
|
185
|
+
end
|
186
|
+
|
187
|
+
def check_params result_doc, params
|
188
|
+
result_doc.xpath('/root/params/*').each do |p|
|
189
|
+
assert_equal p.content, params[p.name.intern]
|
190
|
+
end
|
91
191
|
end
|
92
192
|
end
|
93
193
|
end
|