Proper support for the XPath "following" axis.

This commit is contained in:
Yorick Peterse 2014-08-04 18:57:21 +02:00
parent 57fcbbd0fc
commit 211caf00c6
1 changed files with 15 additions and 8 deletions

View File

@ -252,15 +252,22 @@ module Oga
nodes = XML::NodeSet.new
context.each do |context_node|
current = context_node
check = false
# TODO: implement me properly this time.
#
# Step 1: gather *all* the nodes that come after the current node,
# regardless of their nesting.
#
# Step 2: compare all those nodes with the given test, only return
# those that match.
@document.each_node do |doc_node|
# Skip child nodes of the current context node, compare all
# following nodes.
if doc_node == context_node
check = true
throw :skip_children
end
next unless check
if can_match_node?(doc_node) and node_matches?(doc_node, node)
nodes << doc_node
end
end
end
return nodes