In pure XPath 3.1 you could also try:
let $s := sort($in)
return distinct-values(for-each-pair($s, tail($s), function($a, $b){$a[. =
$b]) )
It's pretty obscure but it's likely to be quite efficient.
Michael Kay
> On 3 Jan 2025, at 10:52, Roger L Costello costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hi Folks,
>
> $fieldnames is a list of strings, e.g.,
>
> ('TYPE', 'USAGE_CD', 'DIR', 'WGS_LAT', 'TYPE', 'WGS_LONG', 'TURN_DIR',
'DIR', 'TYPE')
>
> I want a list of the duplicates in $fieldnames:
>
> ('TYPE', 'DIR') <-- I don't want any duplicates in this list
>
> Is there a simple XPath expression to obtain the list of duplicates in
$fieldnames?
>
> /Roger
|