nokogiri-maglev- 1.5.0.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/CHANGELOG.ja.rdoc +56 -12
  2. data/CHANGELOG.rdoc +49 -0
  3. data/C_CODING_STYLE.rdoc +27 -0
  4. data/Manifest.txt +4 -0
  5. data/README.rdoc +11 -7
  6. data/Rakefile +42 -27
  7. data/bin/nokogiri +10 -2
  8. data/ext/nokogiri/extconf.rb +11 -3
  9. data/ext/nokogiri/html_document.c +16 -0
  10. data/ext/nokogiri/html_sax_parser_context.c +59 -37
  11. data/ext/nokogiri/html_sax_push_parser.c +87 -0
  12. data/ext/nokogiri/html_sax_push_parser.h +9 -0
  13. data/ext/nokogiri/nokogiri.c +7 -9
  14. data/ext/nokogiri/nokogiri.h +3 -0
  15. data/ext/nokogiri/xml_document.c +101 -3
  16. data/ext/nokogiri/xml_document.h +3 -3
  17. data/ext/nokogiri/xml_node.c +151 -58
  18. data/ext/nokogiri/xml_node_set.c +169 -120
  19. data/ext/nokogiri/xml_node_set.h +5 -0
  20. data/ext/nokogiri/xml_sax_parser_context.c +64 -41
  21. data/ext/nokogiri/xml_text.c +2 -0
  22. data/ext/nokogiri/xml_xpath_context.c +31 -25
  23. data/ext/nokogiri/xslt_stylesheet.c +62 -16
  24. data/ext/nokogiri/xslt_stylesheet.h +5 -0
  25. data/lib/nokogiri/css/parser.rb +165 -159
  26. data/lib/nokogiri/css/parser.y +6 -3
  27. data/lib/nokogiri/css/tokenizer.rb +1 -1
  28. data/lib/nokogiri/css/tokenizer.rex +1 -1
  29. data/lib/nokogiri/html.rb +1 -0
  30. data/lib/nokogiri/html/document.rb +82 -42
  31. data/lib/nokogiri/html/sax/push_parser.rb +16 -0
  32. data/lib/nokogiri/version.rb +1 -1
  33. data/lib/nokogiri/xml.rb +6 -0
  34. data/lib/nokogiri/xml/builder.rb +7 -1
  35. data/lib/nokogiri/xml/document.rb +32 -17
  36. data/lib/nokogiri/xml/document_fragment.rb +6 -1
  37. data/lib/nokogiri/xml/node.rb +40 -9
  38. data/lib/nokogiri/xslt.rb +5 -1
  39. data/tasks/cross_compile.rb +1 -0
  40. data/tasks/nokogiri.org.rb +6 -0
  41. data/tasks/test.rb +1 -0
  42. data/test/css/test_xpath_visitor.rb +6 -0
  43. data/test/helper.rb +1 -0
  44. data/test/html/test_document.rb +26 -0
  45. data/test/html/test_document_fragment.rb +1 -2
  46. data/test/test_memory_leak.rb +81 -1
  47. data/test/test_xslt_transforms.rb +152 -123
  48. data/test/xml/test_builder.rb +24 -2
  49. data/test/xml/test_c14n.rb +151 -0
  50. data/test/xml/test_document.rb +48 -0
  51. data/test/xml/test_namespace.rb +5 -0
  52. data/test/xml/test_node.rb +82 -1
  53. data/test/xml/test_node_attributes.rb +19 -0
  54. data/test/xml/test_node_inheritance.rb +32 -0
  55. data/test/xml/test_node_reparenting.rb +32 -0
  56. data/test/xml/test_node_set.rb +16 -8
  57. data/test/xml/test_reader_encoding.rb +16 -0
  58. data/test/xml/test_unparented_node.rb +32 -0
  59. data/test/xml/test_xinclude.rb +83 -0
  60. data/test/xml/test_xpath.rb +22 -0
  61. metadata +208 -241
data/lib/nokogiri/xslt.rb CHANGED
@@ -26,7 +26,11 @@ module Nokogiri
26
26
  XSLT.register url, klass
27
27
  end
28
28
 
29
- Stylesheet.parse_stylesheet_doc(XML.parse(string))
29
+ if Nokogiri.jruby?
30
+ Stylesheet.parse_stylesheet_doc(XML.parse(string), string)
31
+ else
32
+ Stylesheet.parse_stylesheet_doc(XML.parse(string))
33
+ end
30
34
  end
31
35
 
32
36
  ###
@@ -1,3 +1,4 @@
1
+ gem 'rake-compiler'
1
2
  require 'rake/extensioncompiler'
2
3
  HOST = Rake::ExtensionCompiler.mingw_host
3
4
 
@@ -1,6 +1,12 @@
1
+ #
2
+ # note that this file will only work if you've got the `nokogiri.org`
3
+ # repo checked out, and you've got an rvm gemset "1.8.7@nokogiri"
4
+ # bundled with both nokogiri's and nokogiri.org's gems.
5
+ #
1
6
  namespace :docs do
2
7
  desc "generate HTML docs for nokogiri.org"
3
8
  task :website do
9
+ system 'rvm use 1.8.7@nokogiri' # see above
4
10
  title = "#{HOE.name}-#{HOE.version} Documentation"
5
11
 
6
12
  options = []
data/tasks/test.rb CHANGED
@@ -40,6 +40,7 @@ namespace :test do
40
40
  }
41
41
  Dir.chdir File.join(MULTI_XML, 'versions') do
42
42
  require 'net/ftp'
43
+ puts "Contacting xmlsoft.org ..."
43
44
  ftp = Net::FTP.new('xmlsoft.org')
44
45
  ftp.login('anonymous', 'anonymous')
45
46
  ftp.chdir('libxml2')
@@ -28,6 +28,12 @@ module Nokogiri
28
28
  assert_xpath("//a", @parser.parse('|a'))
29
29
  end
30
30
 
31
+ def test_namespaced_attribute_conversion
32
+ assert_xpath("//a[@flavorjones:href]", @parser.parse('a[flavorjones|href]'))
33
+ assert_xpath("//a[@href]", @parser.parse('a[|href]'))
34
+ assert_xpath("//*[@flavorjones:href]", @parser.parse('*[flavorjones|href]'))
35
+ end
36
+
31
37
  def test_unknown_psuedo_classes_get_pushed_down
32
38
  assert_xpath("//a[aaron(.)]", @parser.parse('a:aaron'))
33
39
  end
data/test/helper.rb CHANGED
@@ -29,6 +29,7 @@ module Nokogiri
29
29
  ADDRESS_SCHEMA_FILE = File.join(ASSETS_DIR, 'address_book.rlx')
30
30
  ADDRESS_XML_FILE = File.join(ASSETS_DIR, 'address_book.xml')
31
31
  SNUGGLES_FILE = File.join(ASSETS_DIR, 'snuggles.xml')
32
+ XML_XINCLUDE_FILE = File.join(ASSETS_DIR, 'xinclude.xml')
32
33
 
33
34
  def teardown
34
35
  if ENV['NOKOGIRI_GC']
@@ -199,6 +199,32 @@ eohtml
199
199
  assert_nil html.meta_encoding
200
200
  end
201
201
 
202
+ def test_meta_encoding_with_empty_content_type
203
+ html = Nokogiri::HTML(<<-eohtml)
204
+ <html>
205
+ <head>
206
+ <meta http-equiv="Content-Type" content="">
207
+ </head>
208
+ <body>
209
+ foo
210
+ </body>
211
+ </html>
212
+ eohtml
213
+ assert_nil html.meta_encoding
214
+
215
+ html = Nokogiri::HTML(<<-eohtml)
216
+ <html>
217
+ <head>
218
+ <meta http-equiv="Content-Type">
219
+ </head>
220
+ <body>
221
+ foo
222
+ </body>
223
+ </html>
224
+ eohtml
225
+ assert_nil html.meta_encoding
226
+ end
227
+
202
228
  def test_root_node_parent_is_document
203
229
  parent = @html.root.parent
204
230
  assert_equal @html, parent
@@ -190,8 +190,7 @@ module Nokogiri
190
190
  def test_to_xhtml
191
191
  doc = "<span>foo<br></span><span>bar</span>"
192
192
  fragment = Nokogiri::HTML::Document.new.fragment(doc)
193
- if !Nokogiri.uses_libxml? ||
194
- Nokogiri::VERSION_INFO['libxml']['loaded'] >= "2.7.0"
193
+ if !Nokogiri.jruby? && Nokogiri::VERSION_INFO['libxml']['loaded'] >= "2.7.0"
195
194
  assert_equal "<span>foo<br /></span><span>bar</span>", fragment.to_xhtml
196
195
  else
197
196
  assert_equal "<span>foo<br></span><span>bar</span>", fragment.to_xhtml
@@ -1,6 +1,18 @@
1
1
  require "helper"
2
2
 
3
3
  class TestMemoryLeak < Nokogiri::TestCase
4
+ def setup
5
+ super
6
+ @str = <<EOF
7
+ <!DOCTYPE HTML>
8
+ <html>
9
+ <body>
10
+ <br />
11
+ </body>
12
+ </html>
13
+ EOF
14
+ end
15
+
4
16
  if ENV['NOKOGIRI_GC'] # turning these off by default for now
5
17
  def test_dont_hurt_em_why
6
18
  content = File.open("#{File.dirname(__FILE__)}/files/dont_hurt_em_why.xml").read
@@ -26,7 +38,7 @@ class TestMemoryLeak < Nokogiri::TestCase
26
38
  io = File.open SNUGGLES_FILE
27
39
  Nokogiri::XML.parse(io)
28
40
 
29
- (10**10).times do
41
+ loop do
30
42
  Nokogiri::XML.parse(BadIO.new) rescue nil
31
43
  doc.write BadIO.new rescue nil
32
44
  end
@@ -60,6 +72,74 @@ class TestMemoryLeak < Nokogiri::TestCase
60
72
  puts "\ndike is not installed, skipping memory leak test"
61
73
  end
62
74
  end
75
+
76
+ def test_node_set_namespace_mem_leak
77
+ xml = Nokogiri::XML "<foo></foo>"
78
+ ctx = Nokogiri::XML::XPathContext.new(xml)
79
+ loop do
80
+ ctx.evaluate("//namespace::*")
81
+ end
82
+ end
83
+
84
+ def test_leak_on_node_replace
85
+ loop do
86
+ doc = Nokogiri.XML("<root><foo /></root>")
87
+ n = Nokogiri::XML::CDATA.new(doc, "bar")
88
+ pivot = doc.root.children[0]
89
+ pivot.replace(n)
90
+ end
91
+ end
92
+
93
+ def test_sax_parser_context
94
+ io = StringIO.new(@str)
95
+
96
+ loop do
97
+ Nokogiri::XML::SAX::ParserContext.new(@str)
98
+ Nokogiri::XML::SAX::ParserContext.new(io)
99
+ io.rewind
100
+
101
+ Nokogiri::HTML::SAX::ParserContext.new(@str)
102
+ Nokogiri::HTML::SAX::ParserContext.new(io)
103
+ io.rewind
104
+ end
105
+ end
106
+
107
+ class JumpingSaxHandler < Nokogiri::XML::SAX::Document
108
+ def initialize(jumptag)
109
+ @jumptag = jumptag
110
+ super()
111
+ end
112
+
113
+ def start_element(name, attrs = [])
114
+ throw @jumptag
115
+ end
116
+ end
117
+
118
+ def test_jumping_sax_handler
119
+ doc = JumpingSaxHandler.new(:foo)
120
+
121
+ loop do
122
+ catch(:foo) do
123
+ Nokogiri::HTML::SAX::Parser.new(doc).parse(@str)
124
+ end
125
+ end
126
+ end
127
+
128
+ def test_in_context_parser_leak
129
+ loop do
130
+ doc = Nokogiri::XML::Document.new
131
+ fragment1 = Nokogiri::XML::DocumentFragment.new(doc, '<foo/>')
132
+ node = fragment1.children[0]
133
+ node.parse('<bar></bar>')
134
+ end
135
+ end
136
+
137
+ def test_leak_on_xpath_string_function
138
+ doc = Nokogiri::XML(@str)
139
+ loop do
140
+ doc.xpath('name(//node())')
141
+ end
142
+ end
63
143
  end # if NOKOGIRI_GC
64
144
 
65
145
  private
@@ -5,38 +5,39 @@ class TestXsltTransforms < Nokogiri::TestCase
5
5
  @doc = Nokogiri::XML(File.open(XML_FILE))
6
6
  end
7
7
 
8
- if Nokogiri.uses_libxml?
9
- def test_class_methods
10
- style = Nokogiri::XSLT(File.read(XSLT_FILE))
8
+ def test_class_methods
9
+ style = Nokogiri::XSLT(File.read(XSLT_FILE))
11
10
 
12
- assert result = style.apply_to(@doc, ['title', '"Grandma"'])
13
- assert_match %r{<h1>Grandma</h1>}, result
14
- end
11
+ assert result = style.apply_to(@doc, ['title', '"Grandma"'])
12
+ assert_match %r{<h1>Grandma</h1>}, result
13
+ end
15
14
 
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
31
-
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
37
- end
15
+ def test_transform
16
+ assert style = Nokogiri::XSLT.parse(File.read(XSLT_FILE))
17
+
18
+ assert result = style.apply_to(@doc, ['title', '"Booyah"'])
19
+ assert_match %r{<h1>Booyah</h1>}, result
20
+ assert_match %r{<th.*Employee ID</th>}, result
21
+ assert_match %r{<th.*Name</th>}, result
22
+ assert_match %r{<th.*Position</th>}, result
23
+ assert_match %r{<th.*Salary</th>}, result
24
+ assert_match %r{<td>EMP0003</td>}, result
25
+ assert_match %r{<td>Margaret Martin</td>}, result
26
+ assert_match %r{<td>Computer Specialist</td>}, result
27
+ assert_match %r{<td>100,000</td>}, result
28
+ assert_no_match %r{Dallas|Texas}, result
29
+ assert_no_match %r{Female}, result
30
+
31
+ assert result = style.apply_to(@doc, ['title', '"Grandma"'])
32
+ assert_match %r{<h1>Grandma</h1>}, result
33
+
34
+ assert result = style.apply_to(@doc)
35
+ assert_match %r{<h1></h1>}, result
36
+ end
38
37
 
39
- def test_transform_with_output_style
38
+ def test_transform_with_output_style
39
+ xslt = ""
40
+ if Nokogiri.jruby?
40
41
  xslt = Nokogiri::XSLT(<<-eoxslt)
41
42
  <?xml version="1.0" encoding="ISO-8859-1"?>
42
43
 
@@ -58,109 +59,138 @@ encoding="iso-8859-1" indent="yes"/>
58
59
  <td><xsl:value-of select="salary"/></td>
59
60
  </tr>
60
61
  </xsl:for-each>
61
- </table>
62
62
  </body>
63
63
  </html>
64
64
  </xsl:template>
65
65
 
66
66
  </xsl:stylesheet>
67
67
  eoxslt
68
- assert_no_match(/<td>/, xslt.apply_to(@doc, ['title', 'foo']))
69
- end
68
+ else
69
+ xslt = Nokogiri::XSLT(<<-eoxslt)
70
+ <?xml version="1.0" encoding="ISO-8859-1"?>
70
71
 
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
72
+ <xsl:stylesheet version="1.0"
73
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
74
+ <xsl:output method="text" version="1.0"
75
+ encoding="iso-8859-1" indent="yes"/>
77
76
 
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
77
+ <xsl:param name="title"/>
84
78
 
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
79
+ <xsl:template match="/">
80
+ <html>
81
+ <body>
82
+ <xsl:for-each select="staff/employee">
83
+ <tr>
84
+ <td><xsl:value-of select="employeeId"/></td>
85
+ <td><xsl:value-of select="name"/></td>
86
+ <td><xsl:value-of select="position"/></td>
87
+ <td><xsl:value-of select="salary"/></td>
88
+ </tr>
89
+ </xsl:for-each>
90
+ </table>
91
+ </body>
92
+ </html>
93
+ </xsl:template>
90
94
 
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
+ </xsl:stylesheet>
96
+ eoxslt
97
+ end
98
+ assert_no_match(/<td>/, xslt.apply_to(@doc, ['title', 'foo']))
99
+ end
95
100
 
96
- assert result_string = style.apply_to(@doc, ['title', '"Booyah"'])
97
- assert_equal result_string, style.serialize(result_doc)
101
+ def test_transform_arg_error
102
+ assert style = Nokogiri::XSLT(File.read(XSLT_FILE))
103
+ assert_raises(TypeError) do
104
+ style.transform(@doc, :foo)
98
105
  end
106
+ end
99
107
 
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
108
+ def test_transform_with_hash
109
+ assert style = Nokogiri::XSLT(File.read(XSLT_FILE))
110
+ result = style.transform(@doc, {'title' => '"Booyah"'})
111
+ assert result.html?
112
+ assert_equal "Booyah", result.at_css("h1").content
113
+ end
105
114
 
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
115
+ def test_transform2
116
+ assert style = Nokogiri::XSLT(File.open(XSLT_FILE))
117
+ assert result_doc = style.transform(@doc)
118
+ assert result_doc.html?
119
+ assert_equal "", result_doc.at_css("h1").content
111
120
 
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
121
+ assert style = Nokogiri::XSLT(File.read(XSLT_FILE))
122
+ assert result_doc = style.transform(@doc, ['title', '"Booyah"'])
123
+ assert result_doc.html?
124
+ assert_equal "Booyah", result_doc.at_css("h1").content
123
125
 
124
- a=h.to_a.flatten
125
- result_array = Nokogiri::XSLT.quote_params(a)
126
- assert_equal h.to_a.flatten, a #non-destructive
126
+ assert result_string = style.apply_to(@doc, ['title', '"Booyah"'])
127
+ assert_equal result_string, style.serialize(result_doc)
128
+ end
127
129
 
128
- assert_equal result_array, result_hash
129
- end
130
+ def test_transform_with_quote_params
131
+ assert style = Nokogiri::XSLT(File.open(XSLT_FILE))
132
+ assert result_doc = style.transform(@doc, Nokogiri::XSLT.quote_params(['title', 'Booyah']))
133
+ assert result_doc.html?
134
+ assert_equal "Booyah", result_doc.at_css("h1").content
135
+
136
+ assert style = Nokogiri::XSLT.parse(File.read(XSLT_FILE))
137
+ assert result_doc = style.transform(@doc, Nokogiri::XSLT.quote_params({'title' => 'Booyah'}))
138
+ assert result_doc.html?
139
+ assert_equal "Booyah", result_doc.at_css("h1").content
140
+ end
141
+
142
+ def test_quote_params
143
+ h = {
144
+ :sym => %{xxx},
145
+ 'str' => %{"xxx"},
146
+ :sym2 => %{'xxx'},
147
+ 'str2' => %{x'x'x},
148
+ :sym3 => %{x"x"x},
149
+ }
150
+ hh=h.dup
151
+ result_hash = Nokogiri::XSLT.quote_params(h)
152
+ assert_equal hh, h # non-destructive
153
+
154
+ a=h.to_a.flatten
155
+ result_array = Nokogiri::XSLT.quote_params(a)
156
+ assert_equal h.to_a.flatten, a #non-destructive
157
+
158
+ assert_equal result_array, result_hash
159
+ end
130
160
 
131
- if Nokogiri.uses_libxml? # By now, cannot get it working on JRuby.
132
- def test_z_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 # content is empty String
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
161
+ if Nokogiri.uses_libxml? # By now, cannot get it working on JRuby.
162
+ def test_exslt
163
+ assert doc = Nokogiri::XML.parse(File.read(EXML_FILE))
164
+ assert doc.xml?
165
+
166
+ assert style = Nokogiri::XSLT.parse(File.read(EXSLT_FILE))
167
+ params = {
168
+ :p1 => 'xxx',
169
+ :p2 => "x'x'x",
170
+ :p3 => 'x"x"x',
171
+ :p4 => '"xxx"'
172
+ }
173
+ result_doc = Nokogiri::XML.parse(style.apply_to(doc,
174
+ Nokogiri::XSLT.quote_params(params)))
175
+
176
+ assert_equal 'func-result', result_doc.at('/root/function').content
177
+ assert_equal 3, result_doc.at('/root/max').content.to_i
178
+ assert_match(
179
+ /\d{4}-\d\d-\d\d([-|+]\d\d:\d\d)?/,
180
+ result_doc.at('/root/date').content
181
+ )
182
+ result_doc.xpath('/root/params/*').each do |p|
183
+ assert_equal p.content, params[p.name.intern]
159
184
  end
185
+ check_params result_doc, params
186
+ result_doc = Nokogiri::XML.parse(style.apply_to(doc,
187
+ Nokogiri::XSLT.quote_params(params.to_a.flatten)))
188
+ check_params result_doc, params
160
189
  end
190
+ end
161
191
 
162
- def test_xslt_parse_error
163
- xslt_str = <<-EOX
192
+ def test_xslt_parse_error
193
+ xslt_str = <<-EOX
164
194
  <xsl:stylesheet version="1.0"
165
195
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
166
196
  <!-- Not well-formed: -->
@@ -174,20 +204,19 @@ encoding="iso-8859-1" indent="yes"/>
174
204
  </values>
175
205
  </xsl:template>
176
206
  </xsl:stylesheet>}
177
- EOX
178
- assert_raises(RuntimeError) { Nokogiri::XSLT.parse(xslt_str) }
179
- end
207
+ EOX
208
+ assert_raises(RuntimeError) { Nokogiri::XSLT.parse(xslt_str) }
209
+ end
180
210
 
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
211
+ def test_passing_a_non_document_to_transform
212
+ xsl = Nokogiri::XSLT('<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"></xsl:stylesheet>')
213
+ assert_raises(ArgumentError) { xsl.transform("<div></div>") }
214
+ assert_raises(ArgumentError) { xsl.transform(Nokogiri::HTML("").css("body")) }
215
+ end
186
216
 
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
217
+ def check_params result_doc, params
218
+ result_doc.xpath('/root/params/*').each do |p|
219
+ assert_equal p.content, params[p.name.intern]
191
220
  end
192
221
  end
193
222
  end