nokogiri 1.6.8.rc3 → 1.6.8

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.

Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +5 -3
  3. data/CHANGELOG.rdoc +27 -4
  4. data/CONTRIBUTING.md +1 -1
  5. data/Gemfile +7 -7
  6. data/Manifest.txt +1 -1
  7. data/README.md +0 -3
  8. data/Rakefile +10 -11
  9. data/dependencies.yml +29 -4
  10. data/ext/nokogiri/extconf.rb +74 -19
  11. data/ext/nokogiri/xml_node.c +22 -9
  12. data/ext/nokogiri/xml_reader.c +0 -13
  13. data/ext/nokogiri/xml_sax_parser.c +7 -7
  14. data/lib/nokogiri.rb +11 -7
  15. data/lib/nokogiri/html/document.rb +4 -2
  16. data/lib/nokogiri/version.rb +1 -1
  17. data/lib/nokogiri/xml/document.rb +1 -1
  18. data/lib/nokogiri/xml/parse_options.rb +22 -0
  19. data/ports/archives/libxml2-2.9.4.tar.gz +0 -0
  20. data/ports/archives/libxslt-1.1.29.tar.gz +0 -0
  21. data/tasks/test.rb +5 -0
  22. data/test/html/test_document.rb +26 -0
  23. data/test/html/test_document_encoding.rb +5 -0
  24. data/test/html/test_document_fragment.rb +5 -0
  25. data/test/test_encoding_handler.rb +2 -0
  26. data/test/test_xslt_transforms.rb +33 -0
  27. data/test/xml/sax/test_parser.rb +15 -7
  28. data/test/xml/test_document_encoding.rb +5 -0
  29. data/test/xml/test_document_fragment.rb +12 -0
  30. data/test/xml/test_node_attributes.rb +6 -0
  31. data/test/xml/test_node_reparenting.rb +193 -18
  32. data/test/xml/test_reader.rb +589 -0
  33. data/test/xml/test_unparented_node.rb +13 -0
  34. data/test_all +33 -42
  35. metadata +34 -51
  36. data/patches/libxslt/0001-Adding-doc-update-related-to-1.1.28.patch +0 -222
  37. data/patches/libxslt/0002-Fix-a-couple-of-places-where-f-printf-parameters-wer.patch +0 -53
  38. data/patches/libxslt/0003-Initialize-pseudo-random-number-generator-with-curre.patch +0 -60
  39. data/patches/libxslt/0004-EXSLT-function-str-replace-is-broken-as-is.patch +0 -42
  40. data/patches/libxslt/0006-Fix-str-padding-to-work-with-UTF-8-strings.patch +0 -164
  41. data/patches/libxslt/0007-Separate-function-for-predicate-matching-in-patterns.patch +0 -587
  42. data/patches/libxslt/0008-Fix-direct-pattern-matching.patch +0 -80
  43. data/patches/libxslt/0009-Fix-certain-patterns-with-predicates.patch +0 -185
  44. data/patches/libxslt/0010-Fix-handling-of-UTF-8-strings-in-EXSLT-crypto-module.patch +0 -126
  45. data/patches/libxslt/0013-Memory-leak-in-xsltCompileIdKeyPattern-error-path.patch +0 -25
  46. data/patches/libxslt/0014-Fix-for-bug-436589.patch +0 -43
  47. data/patches/libxslt/0015-Fix-mkdir-for-mingw.patch +0 -41
  48. data/patches/libxslt/0016-Fix-for-type-confusion-in-preprocessing-attributes.patch +0 -29
  49. data/patches/libxslt/0017-Updated-config.guess.patch +0 -1226
  50. data/ports/archives/libxml2-2.9.3.tar.gz +0 -0
  51. data/ports/archives/libxslt-1.1.28.tar.gz +0 -0
  52. data/test/test_reader.rb +0 -577
@@ -1,577 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require "helper"
3
-
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
- # Issue #831
38
- # Make sure that the reader doesn't block reading the entire input
39
- def test_reader_blocking
40
- rd, wr = IO.pipe()
41
- node_out = nil
42
- t = Thread.start do
43
- reader = Nokogiri::XML::Reader(rd, 'UTF-8')
44
- reader.each do |node|
45
- node_out = node
46
- break
47
- end
48
- rd.close
49
- end
50
- sleep(1) # sleep for one second to make sure the reader will actually block for input
51
- begin
52
- wr.puts "<foo>"
53
- wr.puts "<bar/>" * 10000
54
- wr.flush
55
- rescue Errno::EPIPE
56
- end
57
- res = t.join(5) # wait 5 seconds for the thread to finish
58
- wr.close
59
- refute_nil node_out, "Didn't read any nodes, exclude the trivial case"
60
- refute_nil res, "Reader blocks trying to read the entire stream"
61
- end
62
-
63
- def test_reader_takes_block
64
- options = nil
65
- Nokogiri::XML::Reader(File.read(XML_FILE), XML_FILE) do |cfg|
66
- options = cfg
67
- options.nonet.nowarning.dtdattr
68
- end
69
- assert options.nonet?
70
- assert options.nowarning?
71
- assert options.dtdattr?
72
- end
73
-
74
- def test_nil_raises
75
- assert_raises(ArgumentError) {
76
- Nokogiri::XML::Reader.from_memory(nil)
77
- }
78
- assert_raises(ArgumentError) {
79
- Nokogiri::XML::Reader.from_io(nil)
80
- }
81
- end
82
-
83
- def test_from_io
84
- io = File.open SNUGGLES_FILE
85
- reader = Nokogiri::XML::Reader.from_io(io)
86
- assert_equal false, reader.default?
87
- assert_equal [false, false, false, false, false, false, false],
88
- reader.map(&:default?)
89
- end
90
-
91
- def test_io
92
- io = File.open SNUGGLES_FILE
93
- reader = Nokogiri::XML::Reader(io)
94
- assert_equal false, reader.default?
95
- assert_equal [false, false, false, false, false, false, false],
96
- reader.map(&:default?)
97
- end
98
-
99
- def test_string_io
100
- io = StringIO.new(<<-eoxml)
101
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
102
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
103
- </x>
104
- eoxml
105
- reader = Nokogiri::XML::Reader(io)
106
- assert_equal false, reader.default?
107
- assert_equal [false, false, false, false, false, false, false],
108
- reader.map(&:default?)
109
- end
110
-
111
- class ReallyBadIO
112
- def read(size)
113
- 'a' * size ** 10
114
- end
115
- end
116
-
117
- class ReallyBadIO4Java
118
- def read(size=1)
119
- 'a' * size ** 10
120
- end
121
- end
122
-
123
- def test_io_that_reads_too_much
124
- if Nokogiri.jruby?
125
- io = ReallyBadIO4Java.new
126
- Nokogiri::XML::Reader(io)
127
- else
128
- io = ReallyBadIO.new
129
- Nokogiri::XML::Reader(io)
130
- end
131
- end
132
-
133
- def test_in_memory
134
- assert Nokogiri::XML::Reader(<<-eoxml)
135
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
136
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
137
- </x>
138
- eoxml
139
- end
140
-
141
- def test_reader_holds_on_to_string
142
- xml = <<-eoxml
143
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
144
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
145
- </x>
146
- eoxml
147
- reader = Nokogiri::XML::Reader(xml)
148
- assert_equal xml, reader.source
149
- end
150
-
151
- def test_default?
152
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
153
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
154
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
155
- </x>
156
- eoxml
157
- assert_equal false, reader.default?
158
- assert_equal [false, false, false, false, false, false, false],
159
- reader.map(&:default?)
160
- end
161
-
162
- def test_value?
163
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
164
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
165
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
166
- </x>
167
- eoxml
168
- assert_equal false, reader.value?
169
- assert_equal [false, true, false, true, false, true, false],
170
- reader.map(&:value?)
171
- end
172
-
173
- def test_read_error_document
174
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
175
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
176
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
177
- <foo>
178
- </x>
179
- eoxml
180
- assert_raises(Nokogiri::XML::SyntaxError) do
181
- reader.each { |node| }
182
- end
183
- assert 1, reader.errors.length
184
- end
185
-
186
- def test_attributes?
187
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
188
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
189
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
190
- </x>
191
- eoxml
192
- assert_equal false, reader.attributes?
193
- assert_equal [true, false, true, false, true, false, true],
194
- reader.map(&:attributes?)
195
- end
196
-
197
- def test_attributes
198
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
199
- <x xmlns:tenderlove='http://tenderlovemaking.com/'
200
- xmlns='http://mothership.connection.com/'
201
- >
202
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
203
- </x>
204
- eoxml
205
- assert_equal({}, reader.attributes)
206
- assert_equal [{'xmlns:tenderlove'=>'http://tenderlovemaking.com/',
207
- 'xmlns'=>'http://mothership.connection.com/'},
208
- {}, {"awesome"=>"true"}, {}, {"awesome"=>"true"}, {},
209
- {'xmlns:tenderlove'=>'http://tenderlovemaking.com/',
210
- 'xmlns'=>'http://mothership.connection.com/'}],
211
- reader.map(&:attributes)
212
- end
213
-
214
- def test_attribute_roundtrip
215
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
216
- <x xmlns:tenderlove='http://tenderlovemaking.com/'
217
- xmlns='http://mothership.connection.com/'
218
- >
219
- <tenderlove:foo awesome='true' size='giant'>snuggles!</tenderlove:foo>
220
- </x>
221
- eoxml
222
- reader.each do |node|
223
- node.attributes.each do |key, value|
224
- assert_equal value, node.attribute(key)
225
- end
226
- end
227
- end
228
-
229
- def test_attribute_at
230
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
231
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
232
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
233
- </x>
234
- eoxml
235
- assert_nil reader.attribute_at(nil)
236
- assert_nil reader.attribute_at(0)
237
- assert_equal ['http://tenderlovemaking.com/', nil, 'true', nil, 'true', nil, 'http://tenderlovemaking.com/'],
238
- reader.map { |x| x.attribute_at(0) }
239
- end
240
-
241
- def test_attribute
242
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
243
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
244
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
245
- </x>
246
- eoxml
247
- assert_nil reader.attribute(nil)
248
- assert_nil reader.attribute('awesome')
249
- assert_equal [nil, nil, 'true', nil, 'true', nil, nil],
250
- reader.map { |x| x.attribute('awesome') }
251
- end
252
-
253
- def test_attribute_length
254
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
255
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
256
- <tenderlove:foo awesome='true'>snuggles!</tenderlove:foo>
257
- </x>
258
- eoxml
259
- assert_equal 0, reader.attribute_count
260
- assert_equal [1, 0, 1, 0, 0, 0, 0], reader.map(&:attribute_count)
261
- end
262
-
263
- def test_depth
264
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
265
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
266
- <tenderlove:foo>snuggles!</tenderlove:foo>
267
- </x>
268
- eoxml
269
- assert_equal 0, reader.depth
270
- assert_equal [0, 1, 1, 2, 1, 1, 0], reader.map(&:depth)
271
- end
272
-
273
- def test_encoding
274
- string = <<-eoxml
275
- <awesome>
276
- <p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>
277
- <p xml:lang="ja">日本語が上手です</p>
278
- </awesome>
279
- eoxml
280
- reader = Nokogiri::XML::Reader.from_memory(string, nil, 'UTF-8')
281
- assert_equal ['UTF-8'], reader.map(&:encoding).uniq
282
- end
283
-
284
- def test_xml_version
285
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
286
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
287
- <tenderlove:foo>snuggles!</tenderlove:foo>
288
- </x>
289
- eoxml
290
- assert_nil reader.xml_version
291
- assert_equal ['1.0'], reader.map(&:xml_version).uniq
292
- end
293
-
294
- def test_lang
295
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
296
- <awesome>
297
- <p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>
298
- <p xml:lang="ja">日本語が上手です</p>
299
- </awesome>
300
- eoxml
301
- assert_nil reader.lang
302
- assert_equal [nil, nil, "en", "en", "en", nil, "ja", "ja", "ja", nil, nil],
303
- reader.map(&:lang)
304
- end
305
-
306
- def test_value
307
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
308
- <x xmlns:tenderlove='http://tenderlovemaking.com/'>
309
- <tenderlove:foo>snuggles!</tenderlove:foo>
310
- </x>
311
- eoxml
312
- assert_nil reader.value
313
- assert_equal [nil, "\n ", nil, "snuggles!", nil, "\n ", nil],
314
- reader.map(&:value)
315
- end
316
-
317
- def test_prefix
318
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
319
- <x xmlns:edi='http://ecommerce.example.org/schema'>
320
- <edi:foo>hello</edi:foo>
321
- </x>
322
- eoxml
323
- assert_nil reader.prefix
324
- assert_equal [nil, nil, "edi", nil, "edi", nil, nil],
325
- reader.map(&:prefix)
326
- end
327
-
328
- def test_node_type
329
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
330
- <x>
331
- <y>hello</y>
332
- </x>
333
- eoxml
334
- assert_equal 0, reader.node_type
335
- assert_equal [1, 14, 1, 3, 15, 14, 15], reader.map(&:node_type)
336
- end
337
-
338
- def test_inner_xml
339
- str = "<x><y>hello</y></x>"
340
- reader = Nokogiri::XML::Reader.from_memory(str)
341
-
342
- reader.read
343
-
344
- assert_equal "<y>hello</y>", reader.inner_xml
345
- end
346
-
347
- def test_outer_xml
348
- str = ["<x><y>hello</y></x>", "<y>hello</y>", "hello", "<y/>", "<x/>"]
349
- reader = Nokogiri::XML::Reader.from_memory(str.first)
350
-
351
- xml = []
352
- reader.map { |node| xml << node.outer_xml }
353
-
354
- assert_equal str, xml
355
- end
356
-
357
- def test_outer_xml_with_empty_nodes
358
- str = ["<x><y/></x>", "<y/>", "<x/>"]
359
- reader = Nokogiri::XML::Reader.from_memory(str.first)
360
-
361
- xml = []
362
- reader.map { |node| xml << node.outer_xml }
363
-
364
- assert_equal str, xml
365
- end
366
-
367
- def test_state
368
- reader = Nokogiri::XML::Reader.from_memory('<foo>bar</bar>')
369
- assert reader.state
370
- end
371
-
372
- def test_ns_uri
373
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
374
- <x xmlns:edi='http://ecommerce.example.org/schema'>
375
- <edi:foo>hello</edi:foo>
376
- </x>
377
- eoxml
378
- assert_nil reader.namespace_uri
379
- assert_equal([nil,
380
- nil,
381
- "http://ecommerce.example.org/schema",
382
- nil,
383
- "http://ecommerce.example.org/schema",
384
- nil,
385
- nil],
386
- reader.map(&:namespace_uri))
387
- end
388
-
389
- def test_namespaced_attributes
390
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
391
- <x xmlns:edi='http://ecommerce.example.org/schema' xmlns:commons="http://rets.org/xsd/RETSCommons">
392
- <edi:foo commons:street-number="43">hello</edi:foo>
393
- <y edi:name="francis" bacon="87"/>
394
- </x>
395
- eoxml
396
- attr_ns = []
397
- while reader.read
398
- if reader.node_type == Nokogiri::XML::Node::ELEMENT_NODE
399
- reader.attribute_nodes.each {|attr| attr_ns << (attr.namespace.nil? ? nil : attr.namespace.prefix) }
400
- end
401
- end
402
- assert_equal(['commons',
403
- 'edi',
404
- nil],
405
- attr_ns)
406
- end
407
-
408
- def test_local_name
409
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
410
- <x xmlns:edi='http://ecommerce.example.org/schema'>
411
- <edi:foo>hello</edi:foo>
412
- </x>
413
- eoxml
414
- assert_nil reader.local_name
415
- assert_equal(["x", "#text", "foo", "#text", "foo", "#text", "x"],
416
- reader.map(&:local_name))
417
- end
418
-
419
- def test_name
420
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
421
- <x xmlns:edi='http://ecommerce.example.org/schema'>
422
- <edi:foo>hello</edi:foo>
423
- </x>
424
- eoxml
425
- assert_nil reader.name
426
- assert_equal(["x", "#text", "edi:foo", "#text", "edi:foo", "#text", "x"],
427
- reader.map(&:name))
428
- end
429
-
430
- def test_base_uri
431
- reader = Nokogiri::XML::Reader.from_memory(<<-eoxml)
432
- <x xml:base="http://base.example.org/base/">
433
- <link href="link"/>
434
- <other xml:base="http://other.example.org/"/>
435
- <relative xml:base="relative">
436
- <link href="stuff" />
437
- </relative>
438
- </x>
439
- eoxml
440
-
441
- assert_nil reader.base_uri
442
- assert_equal(["http://base.example.org/base/",
443
- "http://base.example.org/base/",
444
- "http://base.example.org/base/",
445
- "http://base.example.org/base/",
446
- "http://other.example.org/",
447
- "http://base.example.org/base/",
448
- "http://base.example.org/base/relative",
449
- "http://base.example.org/base/relative",
450
- "http://base.example.org/base/relative",
451
- "http://base.example.org/base/relative",
452
- "http://base.example.org/base/relative",
453
- "http://base.example.org/base/",
454
- "http://base.example.org/base/"],
455
- reader.map(&:base_uri))
456
- end
457
-
458
- def test_xlink_href_without_base_uri
459
- reader = Nokogiri::XML::Reader(<<-eoxml)
460
- <x xmlns:xlink="http://www.w3.org/1999/xlink">
461
- <link xlink:href="#other">Link</link>
462
- <other id="other">Linked Element</other>
463
- </x>
464
- eoxml
465
-
466
- reader.each do |node|
467
- if node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT
468
- if node.name == 'link'
469
- assert_nil node.base_uri
470
- end
471
- end
472
- end
473
- end
474
-
475
- def test_xlink_href_with_base_uri
476
- reader = Nokogiri::XML::Reader(<<-eoxml)
477
- <x xml:base="http://base.example.org/base/"
478
- xmlns:xlink="http://www.w3.org/1999/xlink">
479
- <link xlink:href="#other">Link</link>
480
- <other id="other">Linked Element</other>
481
- </x>
482
- eoxml
483
-
484
- reader.each do |node|
485
- if node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT
486
- assert_equal node.base_uri, "http://base.example.org/base/"
487
- end
488
- end
489
- end
490
-
491
- def test_read_from_memory
492
- called = false
493
- reader = Nokogiri::XML::Reader.from_memory('<foo>bar</foo>')
494
- reader.each do |node|
495
- called = true
496
- assert node
497
- end
498
- assert called
499
- end
500
-
501
- def test_large_document_smoke_test
502
- # simply run on a large document to verify that there no GC issues
503
- xml = []
504
- xml << "<elements>"
505
- 10000.times { |j| xml << "<element id=\"#{j}\"/>" }
506
- xml << "</elements>"
507
- xml = xml.join("\n")
508
-
509
- Nokogiri::XML::Reader.from_memory(xml).each do |e|
510
- e.attributes
511
- end
512
- end
513
-
514
- def test_correct_outer_xml_inclusion
515
- xml = Nokogiri::XML::Reader.from_io(StringIO.new(<<-eoxml))
516
- <root-element>
517
- <children>
518
- <child n="1">
519
- <field>child-1</field>
520
- </child>
521
- <child n="2">
522
- <field>child-2</field>
523
- </child>
524
- <child n="3">
525
- <field>child-3</field>
526
- </child>
527
- </children>
528
- </root-element>
529
- eoxml
530
-
531
- nodelengths = []
532
- has_child2 = []
533
-
534
- xml.each do |node|
535
- if node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT and node.name == "child"
536
- nodelengths << node.outer_xml.length
537
- has_child2 << !!(node.outer_xml =~ /child-2/)
538
- end
539
- end
540
-
541
- assert_equal(nodelengths[0], nodelengths[1])
542
- assert(has_child2[1])
543
- assert(!has_child2[0])
544
- end
545
-
546
- def test_correct_inner_xml_inclusion
547
- xml = Nokogiri::XML::Reader.from_io(StringIO.new(<<-eoxml))
548
- <root-element>
549
- <children>
550
- <child n="1">
551
- <field>child-1</field>
552
- </child>
553
- <child n="2">
554
- <field>child-2</field>
555
- </child>
556
- <child n="3">
557
- <field>child-3</field>
558
- </child>
559
- </children>
560
- </root-element>
561
- eoxml
562
-
563
- nodelengths = []
564
- has_child2 = []
565
-
566
- xml.each do |node|
567
- if node.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT and node.name == "child"
568
- nodelengths << node.inner_xml.length
569
- has_child2 << !!(node.inner_xml =~ /child-2/)
570
- end
571
- end
572
-
573
- assert_equal(nodelengths[0], nodelengths[1])
574
- assert(has_child2[1])
575
- assert(!has_child2[0])
576
- end
577
- end