xsl-list
[Top] [All Lists]

Re: [xsl] Duplicates in a sequence ?

2015-03-25 12:07:15
thanks !

On 25.03.2015, at 12:24, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Leo Studer leo(_dot_)studer(_at_)varioweb(_dot_)ch 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>
--~----------------------------------------------------------------
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
--~--

<Prev in Thread] Current Thread [Next in Thread>