summaryrefslogtreecommitdiff
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.rb28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb
index 8aadb8ef86..5a976d5e82 100644
--- a/lib/rexml/xpath_parser.rb
+++ b/lib/rexml/xpath_parser.rb
@@ -43,8 +43,6 @@ module REXML
@variables[ variable_name ] = value
end
- private
-
def match( path_stack, nodeset )
while ( path_stack.size > 0 and nodeset.size > 0 )
#puts "PARSE: #{path_stack.inspect} '#{nodeset.collect{|n|n.class}.inspect}'"
@@ -55,6 +53,8 @@ module REXML
nodeset
end
+ private
+
def internal_parse path_stack, nodeset
#puts "INTERNAL_PARSE RETURNING WITH NO RESULTS" if nodeset.size == 0 or path_stack.size == 0
return nodeset if nodeset.size == 0 or path_stack.size == 0
@@ -151,13 +151,14 @@ module REXML
end
end
when :any
+ #puts "ANY"
for element in nodeset
if element.node_type == :element
- attr = element.attributes
+ new_nodeset += element.attributes.to_a
end
end
end
- #puts "RETURNING #{new_nodeset.collect{|n|n.to_s}.inspect}"
+ #puts "RETURNING #{new_nodeset.collect{|n|n.to_s}.inspect}"
return new_nodeset
when :parent
@@ -182,7 +183,7 @@ module REXML
new_nodeset << node
while ( node.parent )
node = node.parent
- new_nodeset << node unless new_nodeset.includes? node
+ new_nodeset << node unless new_nodeset.include? node
end
end
end
@@ -423,17 +424,15 @@ module REXML
current_index = all_siblings.index( node )
preceding_siblings = all_siblings[ 0 .. current_index-1 ]
- preceding_siblings.reverse!
preceding = []
- recurse( preceding_siblings ) { |node| preceding << node }
- preceding.reverse
+ recurse( preceding_siblings ) { |node| preceding.unshift( node ) }
+ preceding
end
def equality_relational_compare( set1, op, set2 )
- #puts "EQ_REL_COMP: #{set1.to_s}, #{op}, #{set2.to_s}"
- #puts "#{set1.class.name} #{op} #{set2.class.name}"
+ #puts "#"*80
if set1.kind_of? Array and set2.kind_of? Array
- #puts "#{set1.size} & #{set2.size}"
+ #puts "#{set1.size} & #{set2.size}"
if set1.size == 1 and set2.size == 1
set1 = set1[0]
set2 = set2[0]
@@ -451,6 +450,7 @@ module REXML
return false
end
end
+ #puts "EQ_REL_COMP: #{set1.class.name} #{set1.inspect}, #{op}, #{set2.class.name} #{set2.inspect}"
#puts "COMPARING VALUES"
# If one is nodeset and other is number, compare number to each item
# in nodeset s.t. number op number(string(item))
@@ -459,7 +459,7 @@ module REXML
# If one is nodeset and other is boolean, compare boolean to each item
# in nodeset s.t. boolean op boolean(item)
if set1.kind_of? Array or set2.kind_of? Array
- #puts "ISA ARRAY"
+ #puts "ISA ARRAY"
if set1.kind_of? Array
a = set1
b = set2.to_s
@@ -486,8 +486,10 @@ module REXML
return true if compare( v, op, b )
end
else
+ #puts "Functions::string( #{b}(#{b.class.name}) ) = #{Functions::string(b)}"
b = Functions::string( b )
for v in a
+ #puts "v = #{v.class.name} #{v.inspect}"
v = Functions::string(v)
return true if compare( v, op, b )
end
@@ -530,7 +532,7 @@ module REXML
end
def compare a, op, b
- #puts "COMPARE #{a.to_s} #{op} #{b.to_s}"
+ #puts "COMPARE #{a.to_s}(#{a.class.name}) #{op} #{b.to_s}(#{a.class.name})"
case op
when :eq
a == b