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]
|