Use XPath::Compiler in XML::Querying
This commit is contained in:
parent
c6df73d031
commit
e4919d7c31
|
@ -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
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
Loading…
Reference in New Issue