xsl-list
[Top] [All Lists]

Re: sequence with same id values

2006-03-06 06:29:49
On 3/6/06, Jeff Sese <jsese(_at_)asiatype(_dot_)com> 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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



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