aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rexml/xpath_parser.rb
diff options
context:
space:
mode:
authorser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-10 12:54:46 +0000
committerser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-10-10 12:54:46 +0000
commit7d21c237ccd46ec1d56639ce53b5882bf97d9de3 (patch)
treee9667617b9228d24dbb9833bec2c3d1be0293cb9 /lib/rexml/xpath_parser.rb
parent662532be008867582fc86dd813dcf8f6a79136eb (diff)
downloadruby-7d21c237ccd46ec1d56639ce53b5882bf97d9de3.tar.gz
* 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
Diffstat (limited to 'lib/rexml/xpath_parser.rb')
-rw-r--r--lib/rexml/xpath_parser.rb25
1 files changed, 9 insertions, 16 deletions
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb
index 215078b766..9cd1e5d64c 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