diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-06 03:56:38 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-03-06 03:56:38 +0000 |
commit | 287a34ae0dfc23e4158f67cb7783d239f202c368 (patch) | |
tree | 5e35d5b41aae961b37cf6632f60c42f51c7aa775 /lib/rexml/xpath_parser.rb | |
parent | 9b52ae2e6491bb5d6c59e1799449f6268baf6f89 (diff) |
* {ext,lib,test}/**/*.rb: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/xpath_parser.rb')
-rw-r--r-- | lib/rexml/xpath_parser.rb | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb index ead5adaf7f..11950ecd93 100644 --- a/lib/rexml/xpath_parser.rb +++ b/lib/rexml/xpath_parser.rb @@ -88,7 +88,7 @@ module REXML case path[0] when :document - # do nothing + # do nothing return first( path[1..-1], node ) when :child for c in node.children @@ -123,7 +123,7 @@ module REXML end - def match( path_stack, nodeset ) + def match( path_stack, nodeset ) #puts "MATCH: path_stack = #{path_stack.inspect}" #puts "MATCH: nodeset = #{nodeset.inspect}" r = expr( path_stack, nodeset ) @@ -136,7 +136,7 @@ module REXML # Returns a String namespace for a node, given a prefix # The rules are: - # + # # 1. Use the supplied namespace mapping first. # 2. If no mapping was supplied, use the context node to look up the namespace def get_namespace( node, prefix ) @@ -187,8 +187,8 @@ module REXML #puts "node.namespace == #{ns.inspect} => #{node.namespace == ns}" end end - !(node.node_type == :element and - node.name == name and + !(node.node_type == :element and + node.name == name and node.namespace == ns ) end node_types = ELEMENTS @@ -205,7 +205,7 @@ module REXML when :processing_instruction target = path_stack.shift nodeset.delete_if do |node| - (node.node_type != :processing_instruction) or + (node.node_type != :processing_instruction) or ( target!='' and ( node.target != target ) ) end @@ -231,7 +231,7 @@ module REXML when :literal return path_stack.shift - + when :attribute new_nodeset = [] case path_stack.shift @@ -481,23 +481,23 @@ module REXML when :function func_name = path_stack.shift.tr('-','_') arguments = path_stack.shift - #puts "FUNCTION 0: #{func_name}(#{arguments.collect{|a|a.inspect}.join(', ')})" + #puts "FUNCTION 0: #{func_name}(#{arguments.collect{|a|a.inspect}.join(', ')})" subcontext = context ? nil : { :size => nodeset.size } res = [] cont = context - nodeset.each_with_index { |n, i| + nodeset.each_with_index { |n, i| if subcontext subcontext[:node] = n subcontext[:index] = i cont = subcontext end arg_clone = arguments.dclone - args = arg_clone.collect { |arg| + args = arg_clone.collect { |arg| #puts "FUNCTION 1: Calling expr( #{arg.inspect}, [#{n.inspect}] )" - expr( arg, [n], cont ) + expr( arg, [n], cont ) } - #puts "FUNCTION 2: #{func_name}(#{args.collect{|a|a.inspect}.join(', ')})" + #puts "FUNCTION 2: #{func_name}(#{args.collect{|a|a.inspect}.join(', ')})" Functions.context = cont res << Functions.send( func_name, *args ) #puts "FUNCTION 3: #{res[-1].inspect}" @@ -515,10 +515,10 @@ module REXML # FIXME # The next two methods are BAD MOJO! # This is my achilles heel. If anybody thinks of a better - # way of doing this, be my guest. This really sucks, but + # way of doing this, be my guest. This really sucks, but # it is a wonder it works at all. # ######################################################## - + def descendant_or_self( path_stack, nodeset ) rs = [] #puts "#"*80 @@ -547,7 +547,7 @@ module REXML # Reorders an array of nodes so that they are in document order # It tries to do this efficiently. # - # FIXME: I need to get rid of this, but the issue is that most of the XPath + # FIXME: I need to get rid of this, but the issue is that most of the XPath # interpreter functions as a filter, which means that we lose context going # in and out of function calls. If I knew what the index of the nodes was, # I wouldn't have to do this. Maybe add a document IDX for each node? @@ -555,7 +555,7 @@ module REXML def document_order( array_of_nodes ) new_arry = [] array_of_nodes.each { |node| - node_idx = [] + node_idx = [] np = node.node_type == :attribute ? node.element : node while np.parent and np.parent.node_type == :element node_idx << np.parent.index( np ) @@ -579,7 +579,7 @@ module REXML # Builds a nodeset of all of the preceding nodes of the supplied node, # in reverse document order - # preceding:: includes every element in the document that precedes this node, + # preceding:: includes every element in the document that precedes this node, # except for ancestors def preceding( node ) #puts "IN PRECEDING" @@ -609,9 +609,9 @@ module REXML #puts "NODE: #{node.inspect}" #puts "PREVIOUS NODE: #{node.previous_sibling_node.inspect}" #puts "PARENT NODE: #{node.parent}" - psn = node.previous_sibling_node + psn = node.previous_sibling_node if psn.nil? - if node.parent.nil? or node.parent.class == Document + if node.parent.nil? or node.parent.class == Document return nil end return node.parent @@ -647,9 +647,9 @@ module REXML end def next_sibling_node(node) - psn = node.next_sibling_node + psn = node.next_sibling_node while psn.nil? - if node.parent.nil? or node.parent.class == Document + if node.parent.nil? or node.parent.class == Document return nil end node = node.parent |