summaryrefslogtreecommitdiff
path: root/lib/rexml/xpath_parser.rb
diff options
context:
space:
mode:
-rw-r--r--lib/rexml/xpath_parser.rb53
1 files changed, 45 insertions, 8 deletions
@@ -160,8 +160,13 @@ module REXML
node_types = ELEMENTS
return nodeset if path_stack.length == 0 || nodeset.length == 0
while path_stack.length > 0
#puts "Path stack = #{path_stack.inspect}"
#puts "Nodeset is #{nodeset.inspect}"
case (op = path_stack.shift)
when :document
nodeset = [ nodeset[0].root_node ]
@@ -235,9 +240,11 @@ module REXML
name = path_stack.shift
for element in nodeset
if element.node_type == :element
- #puts element.name
- attr = element.attribute( name, get_namespace(element, prefix) )
- new_nodeset << attr if attr
end
end
when :any
@@ -299,8 +306,10 @@ module REXML
#puts "Adding node #{node.inspect}" if result == (index+1)
new_nodeset << node if result == (index+1)
elsif result.instance_of? Array
- #puts "Adding node #{node.inspect}" if result.size > 0
- new_nodeset << node if result.size > 0
else
#puts "Adding node #{node.inspect}" if result
new_nodeset << node if result
@@ -381,9 +390,25 @@ module REXML
node_types = ELEMENTS
when :namespace
- new_set = []
for node in nodeset
- new_nodeset << node.namespace if node.node_type == :element or node.node_type == :attribute
end
nodeset = new_nodeset
@@ -404,6 +429,18 @@ module REXML
#puts "RES => #{res.inspect}"
return res
when :div
left = Functions::number(expr(path_stack.shift, nodeset, context)).to_f
right = Functions::number(expr(path_stack.shift, nodeset, context)).to_f
@@ -477,7 +514,7 @@ module REXML
# 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
- # it took me three days to get it to work at all.
# ########################################################
def descendant_or_self( path_stack, nodeset )