fn:distinct-nodes( $nodes as node()* ) as node()*
[0.9-ml only] Returns the sequence resulting from removing from the input
sequence all but one of a set of nodes that have the same identity as one
another. If the empty sequence is input, fn:distinct-nodes
returns the empty sequence.
Parameters | |
---|---|
nodes | A sequence of nodes from which to eliminate duplicate nodes (nodes with the same identity) so that only one node of each identity remains. |
Note that for a node to have the same identity as another node, it must be exactly the same node (not an equivalent node). For example, for a node bound to the variable $x to have the same identity as a node bound to the variable $y, the following must return true:
$x is $y
(: assume /mydoc.xml has the following contents: <a>hello</a> :) let $x := fn:doc("/mydoc.xml")/a let $y := /a return fn:distinct-nodes(($x, $y)) => <a>hello</a>
(: assume /mydoc.xml has the following contents: <a>hello</a> :) let $x := fn:doc("/mydoc.xml")/a let $y := <a>hello</a> return fn:distinct-nodes(($x, $y)) => (<a>hello</a>, <a>hello</a>) It returns both nodes because they do not have the same identity.