fn:outermost
Returns every node within the input sequence that has no ancestor that is itself a member of the input sequence; the nodes are returned in document order with duplicates eliminated.
Signature
fn:outermost($nodes as node()*) as node()*
Properties
This function is deterministic, context-independent, and focus-independent.
Rules
The effect of the function call fn:outermost($nodes)
is defined to be
equivalent to the result of the expression:
$nodes[not(ancestor::node() intersect $nodes)]/.
That is, the function takes as input a sequence of nodes, and returns every node within the sequence that does not have another node within the sequence as an ancestor; the nodes are returned in document order with duplicates eliminated.
Notes
The formulation $nodes except $nodes/descendant::node()
might appear to be
simpler, but does not correctly account for attribute nodes, as these are not
descendants of their parent element.
The motivation for the function was based on XSLT streaming use cases. There are cases
where the [XSLT 3.0] streaming rules allow the construct
outermost(//section)
but do not allow //section
; the
function can therefore be useful in cases where it is known that sections will not
be
nested, as well as cases where the application actually wishes to process all sections
except those that are nested within another.
Examples
If the source document contains nested sections represented by div
elements, the expression outermost(//div)
returns those div
elements that are not contained within further div
elements.