[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Duplicates in a sequence ?


Subject: Re: [xsl] Duplicates in a sequence ?
From: "Leo Studer leo.studer@xxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 25 Mar 2015 17:07:10 -0000

thanks !

> On 25.03.2015, at 12:24, Martin Honnen martin.honnen@xxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Leo Studer leo.studer@xxxxxxxxxxx wrote:
>
>> I have a sequence and want to know whether there are duplicate values in
it.
>>
>> I came out with the following and think there must be an easy solution. Any
suggestion?
>>
>> let $sequence :=(1,12,14,17,22,12) return
(count(distinct-values($sequence)) ne count($sequence))
>
> I think is fine to compare the count, and
http://www.xsltfunctions.com/xsl/functx_are-distinct-values.html has the same
idea basically
>
> <xsl:function name="functx:are-distinct-values" as="xs:boolean"
>              xmlns:functx="http://www.functx.com">
>  <xsl:param name="seq" as="xs:anyAtomicType*"/>
>
>  <xsl:sequence select="
>   count(distinct-values($seq)) = count($seq)
> "/>
>
> </xsl:function>


Current Thread