nokogiri 1.4.1 → 1.4.2
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 +45 -0
- data/CHANGELOG.rdoc +53 -1
- data/Manifest.txt +3 -3
- data/README.ja.rdoc +1 -1
- data/README.rdoc +11 -5
- data/Rakefile +13 -79
- data/ext/nokogiri/extconf.rb +22 -74
- data/ext/nokogiri/html_document.c +17 -8
- data/ext/nokogiri/html_element_description.c +20 -16
- data/ext/nokogiri/html_entity_lookup.c +2 -2
- data/ext/nokogiri/html_sax_parser_context.c +10 -8
- data/ext/nokogiri/nokogiri.c +0 -1
- data/ext/nokogiri/nokogiri.h +33 -28
- data/ext/nokogiri/xml_attr.c +7 -5
- data/ext/nokogiri/xml_attribute_decl.c +5 -2
- data/ext/nokogiri/xml_cdata.c +4 -2
- data/ext/nokogiri/xml_comment.c +4 -2
- data/ext/nokogiri/xml_document.c +93 -15
- data/ext/nokogiri/xml_document.h +0 -1
- data/ext/nokogiri/xml_document_fragment.c +4 -2
- data/ext/nokogiri/xml_dtd.c +18 -8
- data/ext/nokogiri/xml_element_content.c +2 -2
- data/ext/nokogiri/xml_entity_decl.c +15 -2
- data/ext/nokogiri/xml_entity_reference.c +4 -2
- data/ext/nokogiri/xml_io.c +1 -1
- data/ext/nokogiri/xml_namespace.c +5 -3
- data/ext/nokogiri/xml_node.c +353 -114
- data/ext/nokogiri/xml_node_set.c +35 -22
- data/ext/nokogiri/xml_node_set.h +1 -1
- data/ext/nokogiri/xml_processing_instruction.c +4 -2
- data/ext/nokogiri/xml_reader.c +119 -47
- data/ext/nokogiri/xml_relax_ng.c +21 -12
- data/ext/nokogiri/xml_sax_parser.c +6 -3
- data/ext/nokogiri/xml_sax_parser.h +13 -17
- data/ext/nokogiri/xml_sax_parser_context.c +8 -6
- data/ext/nokogiri/xml_sax_push_parser.c +7 -6
- data/ext/nokogiri/xml_schema.c +62 -13
- data/ext/nokogiri/xml_syntax_error.c +18 -12
- data/ext/nokogiri/xml_syntax_error.h +1 -1
- data/ext/nokogiri/xml_text.c +4 -2
- data/ext/nokogiri/xml_xpath_context.c +60 -23
- data/ext/nokogiri/xslt_stylesheet.c +14 -3
- data/lib/nokogiri.rb +17 -0
- data/lib/nokogiri/css/generated_parser.rb +72 -62
- data/lib/nokogiri/css/generated_tokenizer.rb +23 -24
- data/lib/nokogiri/css/parser.y +3 -1
- data/lib/nokogiri/css/tokenizer.rex +3 -3
- data/lib/nokogiri/css/xpath_visitor.rb +8 -3
- data/lib/nokogiri/ffi/html/sax/parser_context.rb +3 -3
- data/lib/nokogiri/ffi/libxml.rb +16 -2
- data/lib/nokogiri/ffi/structs/common_node.rb +15 -3
- data/lib/nokogiri/ffi/structs/xml_document.rb +13 -4
- data/lib/nokogiri/ffi/structs/xml_xpath_context.rb +3 -2
- data/lib/nokogiri/ffi/weak_bucket.rb +40 -0
- data/lib/nokogiri/ffi/xml/document.rb +27 -0
- data/lib/nokogiri/ffi/xml/entity_decl.rb +9 -0
- data/lib/nokogiri/ffi/xml/node.rb +142 -61
- data/lib/nokogiri/ffi/xml/node_set.rb +15 -12
- data/lib/nokogiri/ffi/xml/reader.rb +5 -0
- data/lib/nokogiri/ffi/xml/schema.rb +17 -0
- data/lib/nokogiri/ffi/xml/syntax_error.rb +4 -4
- data/lib/nokogiri/ffi/xml/xpath.rb +0 -10
- data/lib/nokogiri/ffi/xml/xpath_context.rb +22 -9
- data/lib/nokogiri/ffi/xslt/stylesheet.rb +3 -0
- data/lib/nokogiri/html/document.rb +5 -3
- data/lib/nokogiri/html/document_fragment.rb +28 -7
- data/lib/nokogiri/version.rb +6 -2
- data/lib/nokogiri/version_warning.rb +6 -3
- data/lib/nokogiri/xml.rb +1 -1
- data/lib/nokogiri/xml/builder.rb +35 -22
- data/lib/nokogiri/xml/document.rb +44 -12
- data/lib/nokogiri/xml/document_fragment.rb +16 -12
- data/lib/nokogiri/xml/entity_decl.rb +4 -0
- data/lib/nokogiri/xml/node.rb +152 -95
- data/lib/nokogiri/xml/node_set.rb +2 -1
- data/lib/nokogiri/xml/sax/push_parser.rb +1 -1
- data/lib/nokogiri/xml/schema.rb +1 -5
- data/lib/nokogiri/xml/syntax_error.rb +4 -0
- data/lib/nokogiri/xml/text.rb +9 -0
- data/lib/nokogiri/xml/xpath/syntax_error.rb +3 -0
- data/tasks/cross_compile.rb +158 -0
- data/tasks/test.rb +0 -6
- data/test/css/test_xpath_visitor.rb +9 -0
- data/test/helper.rb +49 -11
- data/test/html/sax/test_parser.rb +11 -1
- data/test/html/test_document.rb +8 -0
- data/test/html/test_document_fragment.rb +14 -2
- data/test/html/test_element_description.rb +5 -1
- data/test/html/test_node.rb +5 -66
- data/test/test_reader.rb +28 -0
- data/test/test_xslt_transforms.rb +14 -0
- data/test/xml/test_builder.rb +43 -0
- data/test/xml/test_cdata.rb +12 -0
- data/test/xml/test_document.rb +74 -39
- data/test/xml/test_document_fragment.rb +36 -0
- data/test/xml/test_entity_decl.rb +37 -0
- data/test/xml/test_node.rb +192 -65
- data/test/xml/test_node_reparenting.rb +253 -236
- data/test/xml/test_node_set.rb +67 -0
- data/test/xml/test_text.rb +8 -0
- data/test/xml/test_xpath.rb +32 -0
- metadata +103 -48
- data.tar.gz.sig +0 -0
- data/ext/nokogiri/xml_xpath.c +0 -53
- data/ext/nokogiri/xml_xpath.h +0 -11
- data/lib/nokogiri/xml/fragment_handler.rb +0 -79
- metadata.gz.sig +0 -0
data/lib/nokogiri/xml/node.rb
CHANGED
@@ -35,6 +35,7 @@ module Nokogiri
|
|
35
35
|
# You may search this node's subtree using Node#xpath and Node#css
|
36
36
|
class Node
|
37
37
|
include Nokogiri::XML::PP::Node
|
38
|
+
include Enumerable
|
38
39
|
|
39
40
|
# Element node type, see Nokogiri::XML::Node#element?
|
40
41
|
ELEMENT_NODE = 1
|
@@ -79,7 +80,7 @@ module Nokogiri
|
|
79
80
|
# DOCB document node type
|
80
81
|
DOCB_DOCUMENT_NODE = 21
|
81
82
|
|
82
|
-
def initialize name, document
|
83
|
+
def initialize name, document # :nodoc:
|
83
84
|
# ... Ya. This is empty on purpose.
|
84
85
|
end
|
85
86
|
|
@@ -139,15 +140,11 @@ module Nokogiri
|
|
139
140
|
sets = paths.map { |path|
|
140
141
|
ctx = XPathContext.new(self)
|
141
142
|
ctx.register_namespaces(ns)
|
142
|
-
|
143
|
-
set.document = document
|
144
|
-
document.decorate(set)
|
145
|
-
set
|
143
|
+
ctx.evaluate(path, handler)
|
146
144
|
}
|
147
145
|
return sets.first if sets.length == 1
|
148
146
|
|
149
147
|
NodeSet.new(document) do |combined|
|
150
|
-
document.decorate(combined)
|
151
148
|
sets.each do |set|
|
152
149
|
set.each do |node|
|
153
150
|
combined << node
|
@@ -193,7 +190,7 @@ module Nokogiri
|
|
193
190
|
end
|
194
191
|
|
195
192
|
###
|
196
|
-
# Search this node's
|
193
|
+
# Search this node's immediate children using CSS selector +selector+
|
197
194
|
def > selector
|
198
195
|
ns = document.root.namespaces
|
199
196
|
xpath CSS.xpath_for(selector, :prefix => "./", :ns => ns).first
|
@@ -201,6 +198,7 @@ module Nokogiri
|
|
201
198
|
|
202
199
|
###
|
203
200
|
# Search for the first occurrence of +path+.
|
201
|
+
#
|
204
202
|
# Returns nil if nothing is found, otherwise a Node.
|
205
203
|
def at path, ns = document.root ? document.root.namespaces : {}
|
206
204
|
search(path, ns).first
|
@@ -233,46 +231,124 @@ module Nokogiri
|
|
233
231
|
end
|
234
232
|
|
235
233
|
###
|
236
|
-
# Add +
|
237
|
-
#
|
234
|
+
# Add +node_or_tags+ as a child of this Node.
|
235
|
+
# +node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
|
236
|
+
#
|
238
237
|
# Returns the new child node.
|
239
|
-
def add_child
|
240
|
-
|
241
|
-
if
|
242
|
-
|
243
|
-
add_child_node child
|
244
|
-
end
|
238
|
+
def add_child node_or_tags
|
239
|
+
node_or_tags = coerce(node_or_tags)
|
240
|
+
if node_or_tags.is_a?(XML::NodeSet)
|
241
|
+
node_or_tags.each { |n| add_child_node n }
|
245
242
|
else
|
246
|
-
add_child_node
|
243
|
+
add_child_node node_or_tags
|
247
244
|
end
|
248
245
|
end
|
249
246
|
|
250
247
|
###
|
251
|
-
# Insert +
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
248
|
+
# Insert +node_or_tags+ before this Node (as a sibling).
|
249
|
+
# +node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
|
250
|
+
#
|
251
|
+
# Returns the new sibling node.
|
252
|
+
#
|
253
|
+
# Also see related method +before+.
|
254
|
+
def add_previous_sibling node_or_tags
|
255
|
+
node_or_tags = coerce(node_or_tags)
|
256
|
+
if node_or_tags.is_a?(XML::NodeSet)
|
257
|
+
node_or_tags.each { |n| add_previous_sibling_node n }
|
258
258
|
else
|
259
|
-
add_previous_sibling_node
|
259
|
+
add_previous_sibling_node node_or_tags
|
260
260
|
end
|
261
261
|
end
|
262
262
|
|
263
263
|
###
|
264
|
-
# Insert +
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
264
|
+
# Insert +node_or_tags+ after this Node (as a sibling).
|
265
|
+
# +node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
|
266
|
+
#
|
267
|
+
# Returns the new sibling node.
|
268
|
+
#
|
269
|
+
# Also see related method +after+.
|
270
|
+
def add_next_sibling node_or_tags
|
271
|
+
node_or_tags = coerce(node_or_tags)
|
272
|
+
if node_or_tags.is_a?(XML::NodeSet)
|
273
|
+
if '1.8.6' == RUBY_VERSION
|
274
|
+
node_or_tags.reverse.each { |n| add_next_sibling_node n }
|
275
|
+
else
|
276
|
+
node_or_tags.reverse_each { |n| add_next_sibling_node n }
|
270
277
|
end
|
271
278
|
else
|
272
|
-
add_next_sibling_node
|
279
|
+
add_next_sibling_node node_or_tags
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
####
|
284
|
+
# Insert +node_or_tags+ before this node (as a sibling).
|
285
|
+
# +node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
|
286
|
+
#
|
287
|
+
# Returns self, to support chaining of calls.
|
288
|
+
#
|
289
|
+
# Also see related method +add_previous_sibling+.
|
290
|
+
def before node_or_tags
|
291
|
+
add_previous_sibling node_or_tags
|
292
|
+
self
|
293
|
+
end
|
294
|
+
|
295
|
+
####
|
296
|
+
# Insert +node_or_tags+ after this node (as a sibling).
|
297
|
+
# +node_or_tags+ can be a Nokogiri::XML::Node, a Nokogiri::XML::DocumentFragment, or a string containing markup.
|
298
|
+
#
|
299
|
+
# Returns self, to support chaining of calls.
|
300
|
+
#
|
301
|
+
# Also see related method +add_next_sibling+.
|
302
|
+
def after node_or_tags
|
303
|
+
add_next_sibling node_or_tags
|
304
|
+
self
|
305
|
+
end
|
306
|
+
|
307
|
+
####
|
308
|
+
# Set the inner_html for this Node to +node_or_tags+
|
309
|
+
# +node_or_tags+ can be a Nokogiri::XML::Node, a Nokogiri::XML::DocumentFragment, or a string containing markup.
|
310
|
+
#
|
311
|
+
# Returns self.
|
312
|
+
def inner_html= node_or_tags
|
313
|
+
node_or_tags = coerce(node_or_tags)
|
314
|
+
children.unlink
|
315
|
+
if node_or_tags.is_a?(XML::NodeSet)
|
316
|
+
node_or_tags.each { |n| add_child_node n }
|
317
|
+
else
|
318
|
+
add_child node_or_tags
|
319
|
+
end
|
320
|
+
self
|
321
|
+
end
|
322
|
+
|
323
|
+
####
|
324
|
+
# Replace this Node with +node_or_tags+.
|
325
|
+
# +node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
|
326
|
+
#
|
327
|
+
# Returns the new child node.
|
328
|
+
#
|
329
|
+
# Also see related method +swap+.
|
330
|
+
def replace node_or_tags
|
331
|
+
node_or_tags = coerce(node_or_tags)
|
332
|
+
if node_or_tags.is_a?(XML::NodeSet)
|
333
|
+
node_or_tags.each { |n| add_previous_sibling n }
|
334
|
+
unlink
|
335
|
+
else
|
336
|
+
replace_node node_or_tags
|
273
337
|
end
|
274
338
|
end
|
275
339
|
|
340
|
+
####
|
341
|
+
# Swap this Node for +node_or_tags+
|
342
|
+
# +node_or_tags+ can be a Nokogiri::XML::Node, a ::DocumentFragment, a ::NodeSet, or a string containing markup.
|
343
|
+
#
|
344
|
+
# Returns self, to support chaining of calls.
|
345
|
+
#
|
346
|
+
# Also see related method +replace+.
|
347
|
+
def swap node_or_tags
|
348
|
+
replace node_or_tags
|
349
|
+
self
|
350
|
+
end
|
351
|
+
|
276
352
|
alias :next :next_sibling
|
277
353
|
alias :previous :previous_sibling
|
278
354
|
|
@@ -295,6 +371,7 @@ module Nokogiri
|
|
295
371
|
alias :type :node_type
|
296
372
|
alias :to_str :text
|
297
373
|
alias :clone :dup
|
374
|
+
alias :elements :element_children
|
298
375
|
|
299
376
|
####
|
300
377
|
# Returns a hash containing the node's attributes. The key is
|
@@ -322,7 +399,7 @@ module Nokogiri
|
|
322
399
|
# Iterate over each attribute name and value pair for this Node.
|
323
400
|
def each &block
|
324
401
|
attribute_nodes.each { |node|
|
325
|
-
block.call(node.node_name, node.value)
|
402
|
+
block.call([node.node_name, node.value])
|
326
403
|
}
|
327
404
|
end
|
328
405
|
|
@@ -339,52 +416,35 @@ module Nokogiri
|
|
339
416
|
ancestors.last.search(selector).include?(self)
|
340
417
|
end
|
341
418
|
|
342
|
-
|
343
|
-
# Create
|
344
|
-
#
|
345
|
-
def
|
346
|
-
|
347
|
-
|
348
|
-
end
|
349
|
-
self
|
419
|
+
###
|
420
|
+
# Create a DocumentFragment containing +tags+ that is relative to _this_
|
421
|
+
# context node.
|
422
|
+
def fragment tags
|
423
|
+
type = document.html? ? Nokogiri::HTML : Nokogiri::XML
|
424
|
+
type::DocumentFragment.new(document, tags, self)
|
350
425
|
end
|
351
426
|
|
352
|
-
|
353
|
-
#
|
354
|
-
#
|
355
|
-
|
356
|
-
|
357
|
-
|
427
|
+
###
|
428
|
+
# Parse +string_or_io+ as a document fragment within the context of
|
429
|
+
# *this* node. Returns a XML::NodeSet containing the nodes parsed from
|
430
|
+
# +string_or_io+.
|
431
|
+
def parse string_or_io, options = ParseOptions::DEFAULT_XML
|
432
|
+
if Fixnum === options
|
433
|
+
options = Nokogiri::XML::ParseOptions.new(options)
|
358
434
|
end
|
359
|
-
|
360
|
-
|
435
|
+
# Give the options to the user
|
436
|
+
yield options if block_given?
|
361
437
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
before(data)
|
366
|
-
remove
|
367
|
-
self
|
368
|
-
end
|
369
|
-
|
370
|
-
####
|
371
|
-
# Set the inner_html for this Node to +tags+
|
372
|
-
def inner_html= tags
|
373
|
-
children.each { |x| x.remove}
|
438
|
+
contents = string_or_io.respond_to?(:read) ?
|
439
|
+
string_or_io.read :
|
440
|
+
string_or_io
|
374
441
|
|
375
|
-
|
376
|
-
|
377
|
-
end
|
378
|
-
self
|
379
|
-
end
|
380
|
-
|
381
|
-
def fragment tags # :nodoc:
|
382
|
-
# TODO: deprecate?
|
383
|
-
document.fragment(tags)
|
442
|
+
return Nokogiri::XML::NodeSet.new(document) if contents.empty?
|
443
|
+
in_context(contents, options.to_i)
|
384
444
|
end
|
385
445
|
|
386
446
|
####
|
387
|
-
# Set the Node content to +string+.
|
447
|
+
# Set the Node's content to a Text node containing +string+. The string gets XML escaped, not interpreted as markup.
|
388
448
|
def content= string
|
389
449
|
self.native_content = encode_special_chars(string.to_s)
|
390
450
|
end
|
@@ -399,7 +459,7 @@ module Nokogiri
|
|
399
459
|
###
|
400
460
|
# Get a hash containing the Namespace definitions for this Node
|
401
461
|
def namespaces
|
402
|
-
Hash[*
|
462
|
+
Hash[*namespace_scopes.map { |nd|
|
403
463
|
key = ['xmlns', nd.prefix].compact.join(':')
|
404
464
|
if RUBY_VERSION >= '1.9' && document.encoding
|
405
465
|
begin
|
@@ -436,6 +496,11 @@ module Nokogiri
|
|
436
496
|
type == TEXT_NODE
|
437
497
|
end
|
438
498
|
|
499
|
+
# Returns true if this is a DocumentFragment
|
500
|
+
def fragment?
|
501
|
+
type == DOCUMENT_FRAG_NODE
|
502
|
+
end
|
503
|
+
|
439
504
|
###
|
440
505
|
# Fetch the Nokogiri::HTML::ElementDescription for this node. Returns
|
441
506
|
# nil on XML documents and on unknown tags.
|
@@ -509,12 +574,15 @@ module Nokogiri
|
|
509
574
|
###
|
510
575
|
# Set the namespace for this node to +ns+
|
511
576
|
def namespace= ns
|
577
|
+
return set_namespace(ns) unless ns
|
578
|
+
|
579
|
+
unless Nokogiri::XML::Namespace === ns
|
580
|
+
raise TypeError, "#{ns.class} can't be coerced into Nokogiri::XML::Namespace"
|
581
|
+
end
|
512
582
|
if ns.document != document
|
513
583
|
raise ArgumentError, 'namespace must be declared on the same document'
|
514
584
|
end
|
515
|
-
|
516
|
-
raise TypeError, "#{ns.class} can't be coerced into Nokogiri::XML::Namespace"
|
517
|
-
end
|
585
|
+
|
518
586
|
set_namespace ns
|
519
587
|
end
|
520
588
|
|
@@ -531,22 +599,6 @@ module Nokogiri
|
|
531
599
|
visitor.visit(self)
|
532
600
|
end
|
533
601
|
|
534
|
-
####
|
535
|
-
# +replace+ this Node with the +node+ in the Document.
|
536
|
-
# The new node must be a Nokogiri::XML::Node or a non-empty String.
|
537
|
-
# Returns the new child node.
|
538
|
-
def replace node
|
539
|
-
Node.verify_nodeishness(node)
|
540
|
-
if node.type == DOCUMENT_FRAG_NODE
|
541
|
-
node.children.each do |child|
|
542
|
-
add_previous_sibling child
|
543
|
-
end
|
544
|
-
unlink
|
545
|
-
else
|
546
|
-
replace_node node
|
547
|
-
end
|
548
|
-
end
|
549
|
-
|
550
602
|
###
|
551
603
|
# Test to see if this Node is equal to +other+
|
552
604
|
def == other
|
@@ -612,8 +664,6 @@ module Nokogiri
|
|
612
664
|
#
|
613
665
|
# See Node#write_to for a list of +options+
|
614
666
|
def to_xml options = {}
|
615
|
-
encoding = nil
|
616
|
-
|
617
667
|
options[:save_with] ||= SaveOptions::FORMAT | SaveOptions::AS_XML
|
618
668
|
|
619
669
|
serialize(options)
|
@@ -719,13 +769,20 @@ module Nokogiri
|
|
719
769
|
end
|
720
770
|
|
721
771
|
private
|
722
|
-
|
723
|
-
|
772
|
+
|
773
|
+
def coerce(data) # :nodoc:
|
774
|
+
return data if data.is_a?(XML::NodeSet)
|
775
|
+
return data.children if data.is_a?(XML::DocumentFragment)
|
776
|
+
return fragment(data).children if data.is_a?(String)
|
777
|
+
|
778
|
+
if data.is_a?(Document) || !data.is_a?(XML::Node)
|
724
779
|
raise ArgumentError, <<-EOERR
|
725
|
-
|
780
|
+
Requires a Node, NodeSet or String argument, and cannot accept a #{data.class}.
|
726
781
|
(You probably want to select a node from the Document with at() or search(), or create a new Node via Node.new().)
|
727
782
|
EOERR
|
728
783
|
end
|
784
|
+
|
785
|
+
data
|
729
786
|
end
|
730
787
|
|
731
788
|
def inspect_attributes
|
@@ -13,6 +13,7 @@ module Nokogiri
|
|
13
13
|
# Create a NodeSet with +document+ defaulting to +list+
|
14
14
|
def initialize document, list = []
|
15
15
|
@document = document
|
16
|
+
document.decorate(self)
|
16
17
|
list.each { |x| self << x }
|
17
18
|
yield self if block_given?
|
18
19
|
end
|
@@ -231,7 +232,7 @@ module Nokogiri
|
|
231
232
|
# Wrap this NodeSet with +html+ or the results of the builder in +blk+
|
232
233
|
def wrap(html, &blk)
|
233
234
|
each do |j|
|
234
|
-
new_parent =
|
235
|
+
new_parent = document.root.parse(html).first
|
235
236
|
j.add_next_sibling(new_parent)
|
236
237
|
new_parent.add_child(j)
|
237
238
|
end
|
@@ -42,7 +42,7 @@ module Nokogiri
|
|
42
42
|
|
43
43
|
###
|
44
44
|
# Write a +chunk+ of XML to the PushParser. Any callback methods
|
45
|
-
# that can be called will be called
|
45
|
+
# that can be called will be called immediately.
|
46
46
|
def write chunk, last_chunk = false
|
47
47
|
native_write(chunk, last_chunk)
|
48
48
|
end
|
data/lib/nokogiri/xml/schema.rb
CHANGED
@@ -43,11 +43,7 @@ module Nokogiri
|
|
43
43
|
# Nokogiri::XML::SyntaxError objects found while validating the
|
44
44
|
# +thing+ is returned.
|
45
45
|
def validate thing
|
46
|
-
|
47
|
-
|
48
|
-
# FIXME libxml2 has an api for validating files. We should switch
|
49
|
-
# to that because it will probably save memory.
|
50
|
-
validate_document(Nokogiri::XML(File.read(thing)))
|
46
|
+
thing.is_a?(Nokogiri::XML::Document) ? validate_document(thing) : validate_file(thing)
|
51
47
|
end
|
52
48
|
|
53
49
|
###
|