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

generating a repeatable unique id

Subject: generating a repeatable unique id
From: "Sebastian Rahtz" <sebastian.rahtz@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 29 Jul 2001 00:28:45 +0100
unique id div
Consider this skeleton document:

<root>
<front>
<div/><div/><div/>
</front>
<body>
<div/><div/><div/>
</body>
</root>

I want to generate a repeatable ID for any <div> on the fly. 
The idea is to process  the document and return a list of sections;
each will be a link to the same document, with a parameter containing
an ID for the section. So in URI parlance, I'll ask for "index.xml"
now, which will contain generated links to eg "index.xml?ID=div33".

All well and easy, if the <div> elements have ID attributes, but they
don't. And generate-id() is not guarenteed to be the same on the next
iteration (well, it isn't with libxslt, at least). So I thought I'd
make myself a key table, which lets me identify a target <div> quickly
when the key value is passed in:

 <xsl:key name="DIVS" 
   match="div" 
   use="concat(name(..),concat('_',concat(name(.),concat('_',count(preceding-sibling::div)))))"/>

This works, but the procesing cost looks to be silly, doing that
count of preceding-siblings for every div.

Can anyone suggest a better system? or am I simply barking up the
wrong tree?

maybe the best answer is to insist on ID attributes for my <div> elements...

Sebastian


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.