diff options
-rw-r--r-- | lib/rexml/xpath_parser.rb | 29 |
1 files changed, 15 insertions, 14 deletions
@@ -76,6 +76,8 @@ module REXML # Performs a depth-first (document order) XPath search, and returns the # first match. This is the fastest, lightest way to return a single result. def first( path_stack, node ) #puts "#{depth}) Entering match( #{path.inspect}, #{tree.inspect} )" return nil if path.size == 0 @@ -123,14 +125,6 @@ module REXML r = expr( path_stack, nodeset ) #puts "MAIN EXPR => #{r.inspect}" r - - #while ( path_stack.size > 0 and nodeset.size > 0 ) - # #puts "MATCH: #{path_stack.inspect} '#{nodeset.collect{|n|n.class}.inspect}'" - # nodeset = expr( path_stack, nodeset ) - # #puts "NODESET: #{nodeset.inspect}" - # #puts "PATH_STACK: #{path_stack.inspect}" - #end - #nodeset end private @@ -158,9 +152,10 @@ module REXML #puts "IN QNAME" prefix = path_stack.shift name = path_stack.shift - ns = @namespaces[prefix] - ns = ns ? ns : '' nodeset.delete_if do |node| # FIXME: This DOUBLES the time XPath searches take ns = node.namespace( prefix ) if node.node_type == :element and ns == '' #puts "NS = #{ns.inspect}" @@ -353,7 +348,7 @@ module REXML preceding_siblings = all_siblings[ 0 .. current_index-1 ].reverse #results += expr( path_stack.dclone, preceding_siblings ) end - nodeset = preceding_siblings node_types = ELEMENTS when :preceding @@ -385,10 +380,13 @@ module REXML return @variables[ var_name ] # :and, :or, :eq, :neq, :lt, :lteq, :gt, :gteq when :eq, :neq, :lt, :lteq, :gt, :gteq, :and, :or - left = expr( path_stack.shift, nodeset, context ) #puts "LEFT => #{left.inspect} (#{left.class.name})" - right = expr( path_stack.shift, nodeset, context ) #puts "RIGHT => #{right.inspect} (#{right.class.name})" res = equality_relational_compare( left, op, right ) #puts "RES => #{res.inspect}" @@ -472,8 +470,11 @@ module REXML def descendant_or_self( path_stack, nodeset ) rs = [] d_o_s( path_stack, nodeset, rs ) - #puts "RS = #{rs.collect{|n|n.to_s}.inspect}" document_order(rs.flatten.compact) #rs.flatten.compact end |