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

Re: generating a repeatable unique id

Subject: Re: generating a repeatable unique id
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Mon, 30 Jul 2001 10:03:00 +0100
passing unique id in div
Hi Sebastian,

> Hmm, interesting idea. My real problem with that is that I am inside
> a web server at transformation time, and I dont really want it
> scribbling temporary files. Apart from anything else, it *could* be
> weeks before someone hits the link button which activates the
> request for a section. Of course, this screws me anyway, as the
> original document might have changed... oh yuck.

Since you're dealing with documents that might change, perhaps you
could generate links that look like XPaths. These would be more stable
than a count of all preceding elements of the same name. For example:

  <xsl:for-each select="ancestor-or-self::*">
    <xsl:value-of select="name()" />
    <xsl:text />[<xsl:number />]<xsl:text />
    <xsl:if test="position() != last()">/</xsl:if>
  </xsl:for-each>

(or, more efficiently, pass down path as you journey down the tree
rather than creating it from scratch for each element.)

This would create things like:

  chapter[1]/section[2]/div[3]

Of course you should use different separators to make it a valid ID so
that it can be an HTML anchor, e.g.:

  chapter1.section2.div3

Another idea would be to only use these kind of paths from the nearest
available element with an ID attribute. So if section[2] actually has
an ID of "PartII" then you could have:

  id('PartII')/div[3]

or (again) something similar that could be a valid ID. This would make
the IDs more stable over time.

Cheers,

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.