XPath compiler support for the namespace axis

This commit is contained in:
Yorick Peterse 2015-08-05 22:48:31 +02:00
parent 07b52fb48a
commit 67bc338474
1 changed files with 17 additions and 0 deletions

View File

@ -359,6 +359,23 @@ module Oga
.followed_by(each_node)
end
# @param [AST::Node] ast
# @param [Oga::Ruby::Node] input
# @return [Oga::Ruby::Node]
def on_axis_namespace(ast, input)
underscore = literal('_')
node = node_literal
name = string(ast.children[1])
star = string(STAR)
input.is_a?(XML::Element).if_true do
input.available_namespaces.each.add_block(underscore, node) do
node.name.eq(name).or(name.eq(star)).if_true { yield node }
end
end
end
# @param [AST::Node] ast
# @param [Oga::Ruby::Node] input
# @return [Oga::Ruby::Node]