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

Re: Generating IDs for each element

Subject: Re: Generating IDs for each element
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 04 Sep 2000 20:25:46 +0100
what is in each element
Mal,

>I want to be able to generate a unique ID for each element that I will then
>be able to access in another parse invocation.

How to do this really depends on whether and in what way your source
document is going to change across invocations.  A simple approach is to
generate an id that uniquely identifies the element within the document by
numbering all the elements of a certain type:

  <xsl:value-of select="name()">-<xsl:number level="any" />

will generate para-1, para-2, para-3 and so on throughout the document.
The xsl:number with level="any" numbers instances of the element across the
entire document.  This is enough if your source document is not going to
change at all across invocations.

Otherwise you need something a bit more complex, and that relies on asking
the question: what is it that uniquely identifies this element?  It could
be its content, the combination of values of attributes, its position, or
anything.  Once you've answered that question, you can use the answer to
generate the unique id. 

I hope that this helps,

Jeni

Jeni Tennison
http://www.jenitennison.com/


 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.