[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: cross document id idref pair checks
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: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|