Am 29.12.2021 um 00:32 schrieb Dimitre Novatchev
dnovatchev(_at_)gmail(_dot_)com:
On Tue, Dec 28, 2021 at 3:29 PM Dimitre Novatchev
<dnovatchev(_at_)gmail(_dot_)com> wrote:
A pure XPath solution:
let $ids := distinct-values($nodes ! generate-id(.))
return $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
is·implementation-dependent·
<https://www.w3.org/TR/xpath-functions/#implementation-dependent>.
Which value of a set of values that compare equal is returned
is·implementation-dependent·
<https://www.w3.org/TR/xpath-functions/#implementation-dependent>."
So while
$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.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--