Use XPath::Compiler in XML::Querying

This commit is contained in:
Yorick Peterse 2015-08-30 01:22:33 +02:00
parent c6df73d031
commit e4919d7c31
1 changed files with 7 additions and 3 deletions

View File

@ -13,7 +13,10 @@ module Oga
# @see [Oga::XPath::Evaluator#initialize] # @see [Oga::XPath::Evaluator#initialize]
# #
def xpath(expression, variables = {}) def xpath(expression, variables = {})
XPath::Evaluator.new(self, variables).evaluate(expression) ast = XPath::Parser.parse_with_cache(expression)
block = XPath::Compiler.compile_with_cache(ast)
block.call(self, variables)
end end
## ##
@ -36,8 +39,9 @@ module Oga
# #
def css(expression) def css(expression)
ast = CSS::Parser.parse_with_cache(expression) ast = CSS::Parser.parse_with_cache(expression)
block = XPath::Compiler.compile_with_cache(ast)
XPath::Evaluator.new(self).evaluate_ast(ast) block.call(self)
end end
## ##