Re: [xsl] Get the duplicates in a list

Subject: Re: [xsl] Get the duplicates in a list
From: "Dimitre Novatchev dnovatchev@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 3 Jan 2025 14:16:56 -0000
Hi Roger,

This is a short and simple solution - just 19 characters:

   $f[index-of($f,.)[2]]

Just try it :)

Can also be found here, and was answered in 2008:
https://stackoverflow.com/questions/133092/how-do-you-identify-duplicate-valu
es-in-a-numerical-sequence-using-xpath-2-0/287360#287360



On Fri, Jan 3, 2025 at 2:52b/AM 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

Current Thread