[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: sequence with same id values

Subject: Re: sequence with same id values
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 6 Mar 2006 13:29:49 +0000
select with same id
On 3/6/06, Jeff Sese <jsese@xxxxxxxxxxxx> wrote:
> Hi all,
>
> I have this variable:
>
> <xsl:variable name="anchor" as="element()*"
> select="document('source.xml')//anchor[parent::xref]/@id"/>
>
> How can I get all the id values that are not unique?

Create a key:

<xsl:key name="anchor-by-id" match="anchor[parent::xref]" use="@id"/>

Then for each anchor, count how many occurances are in the key:

select="count(key('anchor-by-id', @id) > 1)"

If there is more than one occurrance then the id is not unique.

If you don't want an entry for each non-unique @id, then only generate
output for the first occurrance:

select="count(key('anchor-by-id', @id) > 1)
               &amp;&amp; generate-id(.) =
generate-id(key('anchor-by-id', @id)[1])"

cheers
andrew

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.