diff options
| author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-18 07:07:11 +0000 |
|---|---|---|
| committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-18 07:07:11 +0000 |
| commit | 2f1fa7e402b626fb066798bae91220da8f328fee (patch) | |
| tree | 52b50dd6c5b280998b3b699e5290ff3990d46c24 /lib/rexml/xpath_parser.rb | |
| parent | 40e77949935b5bd43cc4bfac8e055d75519e7da7 (diff) | |
* lib/rexml: Merge fixes since 1.8.6 made solely on the ruby_1_8_6
branch.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/xpath_parser.rb')
| -rw-r--r-- | lib/rexml/xpath_parser.rb | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb index 3393113d6a..eb608fdb34 100644 --- a/lib/rexml/xpath_parser.rb +++ b/lib/rexml/xpath_parser.rb @@ -160,6 +160,7 @@ module REXML node_types = ELEMENTS return nodeset if path_stack.length == 0 || nodeset.length == 0 while path_stack.length > 0 + #puts "#"*5 #puts "Path stack = #{path_stack.inspect}" #puts "Nodeset is #{nodeset.inspect}" if nodeset.length == 0 @@ -351,7 +352,8 @@ module REXML when :following_sibling #puts "FOLLOWING_SIBLING 1: nodeset = #{nodeset}" results = [] - for node in nodeset + nodeset.each do |node| + next if node.parent.nil? all_siblings = node.parent.children current_index = all_siblings.index( node ) following_siblings = all_siblings[ current_index+1 .. -1 ] @@ -362,13 +364,14 @@ module REXML when :preceding_sibling results = [] - for node in nodeset + nodeset.each do |node| + next if node.parent.nil? all_siblings = node.parent.children current_index = all_siblings.index( node ) - preceding_siblings = all_siblings[ 0 .. current_index-1 ].reverse - #results += expr( path_stack.dclone, preceding_siblings ) + preceding_siblings = all_siblings[ 0, current_index ].reverse + results += preceding_siblings end - nodeset = preceding_siblings || [] + nodeset = results node_types = ELEMENTS when :preceding @@ -389,15 +392,21 @@ module REXML node_types = ELEMENTS when :namespace + #puts "In :namespace" new_nodeset = [] prefix = path_stack.shift for node in nodeset if (node.node_type == :element or node.node_type == :attribute) - if (node.node_type == :element) + if @namespaces + namespaces = @namespaces + elsif (node.node_type == :element) namespaces = node.namespaces else namespaces = node.element.namesapces end + #puts "Namespaces = #{namespaces.inspect}" + #puts "Prefix = #{prefix.inspect}" + #puts "Node.namespace = #{node.namespace}" if (node.namespace == namespaces[prefix]) new_nodeset << node end |
