Re: [xsl] An XPath expression which checks that no two websites have the same username

Subject: Re: [xsl] An XPath expression which checks that no two websites have the same username
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 05 Nov 2012 07:38:56 -0500
At 2012-11-05 10:44 +0000, Costello, Roger L. wrote:
I need a good XPath expression which checks that no two websites have the same username.

Here is a map between websites and usernames:

    <map>
        <singletonMap from="Amazon"             to="BasketballKing" />
        <singletonMap from="Apple"              to="RandomGamer" />
        <singletonMap from="Ebay"               to="CornFoo" />
        <singletonMap from="Google"             to="LatenightRevolution" />
        <singletonMap from="Microsoft"          to="OldTrue" />
        <singletonMap from="VirginAtlantic"     to="TheSinger" />
    </map>

In that example no two websites have the same username.

I created an XPath expression which does the job, but I suspect there is a simpler expression. Here is my attempt:

empty(for $i in map/*/@to return map/*[@to eq $i][2])

Would you provide a simpler (more efficient, more elegant) version please?

Did you try:


count(map/*/@to) = count(distinct-values(map/*/@to))

I hope this helps.

. . . . . . . . Ken

--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

Current Thread