Re: [xsl] Get the duplicates in a list

Subject: Re: [xsl] Get the duplicates in a list
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 3 Jan 2025 12:50:19 -0000
Am 03.01.2025 um 13:38 schrieb Bauman, Syd s.bauman@xxxxxxxxxxxxxxxx:
> Martin & Liam b
> Are there significant advantages to your suggestions over the following?
>
> (
> B  ( for $f in $fieldnames returnB if ( count( $fieldnames[ . eq $f ] )
> gt 1 ) then $f else '' )
> B  => distinct-values()
> )[. ne '']
>
> I admit it is not simple, but strikes me as simpler. (Note that
> instead of the null string, one could use any string that is
> guaranteed not to be a value. I often like bbb (U+241C) or bbb
> (U+2205) for this kind of thing. One could also probably use a test on
> that bifb that only looked at preceding or following values of
> $fieldnames, which some folks might find more readable.)
>

I would hope that the map:merge is ensured to be more efficient than
that count($fieldnames[. eq $f]) gt 1 but I am not good at expression
complexity in O.. terms. And in the end with advanced XQuery engines it
is all thrown at a query optimizer/rewriter that might optimize the
expression in a way not comparable to the originable one anyway.


I don't get the

 B  else ''

part to later have to get rid of those with [. ne ''], why can't you
simply use

 B  else ()

to return the empty sequence?

Current Thread