Upstream contribution · antchfx/xpath
xpath · Counting the actual following-axis nodes in XPath
Problem
The last() predicate counted siblings of a candidate node even when the expression selected through the following or following-sibling axis. That count could prevent the final matching node from being returned.
Engineering response
The following query supplies the positional filter with the size of its own selected node set, cached for the current context node.
Evidence and scope
The PR reports an axis-specific mutation that reproduces the incorrect result, passing Go tests and agreement with lxml on a separate XML fixture.