From 74130df40d9156eb4ef71b0af1ba9be797fafeec Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 9 Jul 2014 09:28:00 +0200 Subject: [PATCH] XPath evaluation support for absolute paths. --- lib/oga/xpath/evaluator.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/oga/xpath/evaluator.rb b/lib/oga/xpath/evaluator.rb index 1c5b190..e110788 100644 --- a/lib/oga/xpath/evaluator.rb +++ b/lib/oga/xpath/evaluator.rb @@ -39,6 +39,20 @@ module Oga end end + def process_all(nodes) + nodes.each do |node| + process(node) + end + end + + def on_absolute(node) + if @document.respond_to?(:root_node) + @context = XML::NodeSet.new([@document.root_node]) + end + + process_all(node.children) + end + def on_path(node) test, children = *node