Re: [xsl] XQuery/XPath 3.1: Node List to Node Set ("distinct nodes")

Subject: Re: [xsl] XQuery/XPath 3.1: Node List to Node Set ("distinct nodes")
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 28 Dec 2021 21:56:02 -0000
On 28.12.2021 20:28, Priscilla Walmsley pwalmsley@xxxxxxxxxxx wrote:

$nodes/. would re-order them in document order if that matters.

As the question says XQuery/XPath 3.1, if the order in the original sequence / node list matters, generate-id made it from XSLT into newer versions of XPath and XQuery I think so you could use grouping by generate-id() plus sorting (as the normal XQuery group by clause doesn't preserve the order necessarily)

for $node at $pos in $nodes
group by $id := generate-id($node)
order by $pos[1]
return $node[1]

Current Thread