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]
#
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
##
@ -35,9 +38,10 @@ module Oga
# @see [Oga::XPath::Evaluator#initialize]
#
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
##