RE: [xsl] cross document id idref pair checks

Subject: RE: [xsl] cross document id idref pair checks
From: DPawson@xxxxxxxxxxx
Date: Wed, 10 Jan 2001 09:10:38 -0000
Jeni Tennison 
> I think (?) that DaveP meant duplicated values for @id attributes
> across a document rather than duplicate @id attributes on a particular
> element.
> If there is an element that has the same @id attribute as the current
> element, then:
> You can get elements that have repeated ids with:
>   //*[@id = (preceding::*/@id | following::*/@id)]

but noted comment on efficiency.

> If, for an element, the 'ids' key returns more than one node, then
> it's a repeated id, so you can test whether there are any repeats
> with:
>   //*[key('ids', @id)[2]]

I like the look of that.

> If you want to get a list (without repeats) of the repeated IDs using
> the key() method, then you can use the usual:
>   //*[key('ids', @id)[2] and
>       count(.|key('ids', @id)[1]) = 1]

I'd dispute the use of the word 'usual' here Jeni :-)

> [or actually, by extension to the above aside:
>   //*[key('ids', @id)[2] and
>       not((.|key('ids', @id)[1])[2])]
>  making identity-testing of nodes even more obscure! :)]

I won't disagree with the latter comment!!

> Testing this across documents is harder 

But not required, the test is that no two elements share the same id value
in the document under test (which is the source document)

Thanks Jeni. 

I'll run some timing on those and compare with DC's 'count() method.

Regards DaveP

 XSL-List info and archive:

Current Thread