Basic support for the XPath "parent" axis.

The usage of `parent::node()` is not yet supported.
This commit is contained in:
Yorick Peterse committed 2014-08-05 09:34:57 +02:00
1 parent c0a6610d65
commit 375f3d7870
2 files changed
+63

No files matched your search

+21
View File
@@ -307,6 +307,27 @@ module Oga
return nodes
end
##
# Evaluates the `parent` axis.
#
# @param [Oga::XPath::Node] ast_node
# @param [Oga::XML::NodeSet] context
# @return [Oga::XML::NodeSet]
#
def on_axis_parent(ast_node, context)
nodes = XML::NodeSet.new
context.each do |context_node|
next unless has_parent?(context_node)
parent = context_node.parent
nodes << parent if node_matches?(parent, ast_node)
end
return nodes
end
##
# Returns a node set containing all the child nodes of the given set of
# nodes.