aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rexml/xpath_parser.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rexml/xpath_parser.rb')
-rw-r--r--lib/rexml/xpath_parser.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb
index 453d57a88d..eb608fdb34 100644
--- a/lib/rexml/xpath_parser.rb
+++ b/lib/rexml/xpath_parser.rb
@@ -352,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 ]
@@ -363,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