# File rexml/xpath_parser.rb, line 310 def axe( axis_name, path, nodeset ) #puts "axe #{axis_name}, #{path} #{puta nodeset}" if DEBUG return unless nodeset case axis_name when 'self' axe_helper(path, nodeset) when /^descendant/u results = [] a = "" recurse( nodeset ) { |node| a, b = axe_helper(path, [node]) if node.kind_of? Element results |= b if b } #puts "RESULTS ARE NOW #{puta results}" if DEBUG [a, results] when /^ancestor/u ancestors = [] ancestors += nodeset if axis_name =~ /self$/ nodeset.each do |element| while element.parent element = element.parent ancestors << element end end #puts "ancestors is #{puta ancestors}" if DEBUG axe_helper( path, ancestors) when "child" results = [] #puts "PATH IS '#{path}'" if DEBUG p = path nodeset.each do |element| if element.kind_of? Element #puts "YIELDING CHILDREN OF #{element.name if element.kind_of? Element}" if DEBUG p,r = axe_helper( path, element.to_a ) #puts "P IS NOW '#{p}'" if DEBUG results += r end end #puts "CHILD: P IS NOW '#{p}'" if DEBUG [p, results] when "attribute" results = [] #puts "ATTRIBUTE: NODESET SIZE IS #{nodeset.size}" if DEBUG p = '' nodeset.each do |element| p,r=axe_helper(path,element.attributes.values.flatten) if element.kind_of? Element #puts "#{path} => #{p}" if DEBUG results += r results << nil if r.size < 1 end #puts "ATTRIBUTE: P IS NOW '#{p}'" if DEBUG #puts "results is now #{puta results}" if DEBUG results.collect!{ |a| a.value if a } [p,results] when "parent" axe_helper(path, nodeset.collect{|element| element.parent}.uniq) when "following-sibling" siblings = [] nodeset.each do |el| while el = el.next_sibling siblings << el end end axe_helper(path, siblings.uniq) when "following" axe_helper(path, nodeset.collect{|element| element.next_node}.uniq) when "preceding-sibling" siblings = [] nodeset.each do |el| while el = el.previous_sibling siblings << el end end axe_helper(path, siblings.uniq) when "preceding" axe_helper(path, rnodeset.collect{|element| element.previous_node}.uniq) when "namespace" axe_helper( path, nodeset.collect{|el| el.namespace} ) end end