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: Wed, 29 Dec 2021 08:21:44 -0000 |
Am 29.12.2021 um 00:32 schrieb Dimitre Novatchev dnovatchev@xxxxxxxxx: > > > On Tue, Dec 28, 2021 at 3:29 PM Dimitre Novatchev > <dnovatchev@xxxxxxxxx> wrote: > > A pure XPath solution: > > let $ids := distinct-values($nodes ! generate-id(.)) > B B return B $ids ! (function($id) {$nodes[generate-id(.) eq > $id][1]})(.) > > Happy New Year to all ! > > > > Hit Send too early: > > Do notice: this seems the only solution of all presented so far, that > preserves the original sequence order (not document order) of the nodes. Why is the original sequence order preserved? https://www.w3.org/TR/xpath-functions/#func-distinct-values clearly says "The function returns the sequence that results from removing from|$arg|all but one of a set of values that are considered equal to one another. [...] The order in which the sequence of values is returned isB7implementation-dependentB7 <https://www.w3.org/TR/xpath-functions/#implementation-dependent>. Which value of a set of values that compare equal is returned isB7implementation-dependentB7 <https://www.w3.org/TR/xpath-functions/#implementation-dependent>." So while B B $nodes ! generate-id(.) gives you the generated ids in the order of the nodes in $nodes after the call to distinct-values there is no order defined, it is implementation dependent.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XQuery/XPath 3.1: Node Li, Dimitre Novatchev dn | Thread | Re: [xsl] XQuery/XPath 3.1: Node Li, Dimitre Novatchev dn |
Re: [xsl] XQuery/XPath 3.1: Node Li, Dimitre Novatchev dn | Date | Re: [xsl] XQuery/XPath 3.1: Node Li, Michael Kay mike@xxx |
Month |