diff options
author | ser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-10 12:54:46 +0000 |
---|---|---|
committer | ser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-10-10 12:54:46 +0000 |
commit | a05226855c5262a26adb80a2dee3635e35bfb954 (patch) | |
tree | e9667617b9228d24dbb9833bec2c3d1be0293cb9 /lib/rexml/xpath_parser.rb | |
parent | f198331305b7e0ebc0f1d712781c849bcc5c494d (diff) | |
download | ruby-a05226855c5262a26adb80a2dee3635e35bfb954.tar.gz ruby-a05226855c5262a26adb80a2dee3635e35bfb954.tar.xz ruby-a05226855c5262a26adb80a2dee3635e35bfb954.zip |
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@4737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/xpath_parser.rb')
-rw-r--r-- | lib/rexml/xpath_parser.rb | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb index 215078b76..9cd1e5d64 100644 --- a/lib/rexml/xpath_parser.rb +++ b/lib/rexml/xpath_parser.rb @@ -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 |