1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* Changes to the encoding mechanism. If iconv is found, it is used first

for encoding changes.  This should be the case on all 1.8 installations.
  When it isn't found (<1.6), the native REXML encoding mechanism is used.
  This cleaned out some files, and tightened up the code a bit; and iconv
  should be faster than the pure Ruby code.
* Changed deprecated assert_not_nil to assert throughout the tests.
* Parse exceptions are a little more verbose, and extend RuntimeError.
* Bug fixes to XPathParser
* The Light API is still shifting, like the sands of the desert.
* Fixed a new Ruby 1.8.0 warning, added some speed optimizations, and
  tightened error reporting in the base parser


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ser 2003-10-10 12:54:46 +00:00
parent 662532be00
commit 7d21c237cc
23 changed files with 185 additions and 224 deletions

View file

@ -2,16 +2,6 @@ require 'rexml/namespace'
require 'rexml/xmltokens'
require 'rexml/parsers/xpathparser'
# Ignore this class. It adds a __ne__ method, because Ruby doesn't seem to
# understand object.send( "!=", foo ), whereas it *does* understand "<", "==",
# and all of the other comparison methods. Stupid, and annoying, and not at
# all POLS.
class Object
def __ne__(b)
self != b
end
end
module REXML
# You don't want to use this class. Really. Use XPath, which is a wrapper
# for this class. Believe me. You don't want to poke around in here.
@ -132,11 +122,10 @@ module REXML
when :child
#puts "CHILD"
new_nodeset = []
ps_clone = nil
nt = nil
for node in nodeset
#ps_clone = path_stack.clone
#new_nodeset += internal_parse( ps_clone, node.children ) if node.parent?
new_nodeset += node.children if node.parent?
nt = node.node_type
new_nodeset += node.children if nt == :element or nt == :document
end
#path_stack[0,(path_stack.size-ps_clone.size)] = []
return new_nodeset
@ -238,9 +227,11 @@ module REXML
when :descendant
#puts ":DESCENDANT"
results = []
nt = nil
for node in nodeset
nt = node.node_type
results += internal_parse( path_stack.clone.unshift( :descendant_or_self ),
node.children ) if node.parent?
node.children ) if nt == :element or nt == :document
end
return results
@ -310,11 +301,13 @@ module REXML
def d_o_s( p, ns, r )
#puts r.collect{|n|n.to_s}.inspect
#puts ns.collect{|n|n.to_s}.inspect
nt = nil
ns.each_index do |i|
n = ns[i]
x = match( p.clone, [ n ] )
#puts "Got a match on #{p.inspect} for #{ns.collect{|n|n.to_s+"("+n.type.to_s+")"}.inspect}"
d_o_s( p, n.children, x ) if n.parent?
nt = n.node_type
d_o_s( p, n.children, x ) if nt == :element or nt == :document
r[i,0] = [x] if x.size > 0
end
end