Subject: Re: sequence with same id values
From: "andrew welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 6 Mar 2006 13:29:49 +0000
|
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)
&& generate-id(.) =
generate-id(key('anchor-by-id', @id)[1])"
cheers
andrew
|