Re: [xsl] Are these equivalent XPath expressions for determining that there are no duplicates in a list of items?

Subject: Re: [xsl] Are these equivalent XPath expressions for determining that there are no duplicates in a list of items?
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Thu, 1 Nov 2012 20:51:53 +0530
Hi Roger,
   Sometimes, I use an XPath 2.0 expression like following to check if
a list of values do not contain duplicates,

count(Websites/Website/distinct-values()) = count(Websites/Website)

(this is not tested)

Btw, this doesn't answer your question :)

On Thu, Nov 1, 2012 at 6:31 PM, Costello, Roger L. <costello@xxxxxxxxx> wrote:
> Hi Folks,
>
> Are there no duplicate websites in this list:
>
>     <Websites>
>         <Website id="Amazon"> http://www.amazon.com </Website>
>         <Website id="Apple"> http://www.apple.com </Website>
>         <Website id="Ebay"> http://www.ebay.com </Website>
>         <Website id="Google"> http://www.google.com </Website>
>         <Website id="Microsoft"> http://www.microsoft.com </Website>
>         <Website id="VirginAtlantic"> http://www.virgin-atlantic.com </Website>
>     </Websites>
>
> Here is an XPath 2.0 expression to answer that question (thanks to Dimitre):
>
>     empty(Websites/*[index-of(../*,.)[2]])
>
> Here is an XPath 1.0 expression to answer that question:
>
>     not(//Websites/*[. = preceding-sibling::*])
>
> Are there any situations where those two XPath expressions differ in their answer?
>
> /Roger




-- 
Regards,
Mukul Gandhi

Current Thread