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

Re: generate-id accross different xsl files

Subject: Re: generate-id accross different xsl files
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sat, 5 May 2001 12:37:37 +0100
heath wilkinson
Hi Heath,

> Will generate-id always produce the same id for a node in an xml
> document with different stylesheets?

No (or rather, it might do, but it's not guaranteed to).

> If not does anyone know a different way to link views in html of an
> xml document when the tags in the xml document are not marked with
> any id's?

You need to construct an ID that reflects something unique and
unchanging about the nodes that provide the information in your source
XML. This has to be a valid ID, so it has to start with a letter and
not contain any spaces, but you can easily just add a letter to the
start and substitute all spaces with hyphens or underscores using
translate().

The easiest thing to use is the value of the node itself, one of its
children or an attribute, or a combination of several of these
concatenated together. The less information you use and the closer it
is to the node, the better, as this reduces the processing that's
needed to generate the IDs.

If there's no way of generating something unique from the information
available around the node, then you can use the fact that it has a
unique position within the XML document to give you the ID.  Two ones
that I might use are the following:

 - element name + count of previous elements with the same name

  <xsl:variable name="name" select="name()" />
  <xsl:value-of select="concat($name, '-',
                               count(preceding::*[name() = $name])" />

 - 'node-' + hierarchical number

  <xsl:text />node-<xsl:number count="*" level="multiple" />

These are both pretty inefficient. Depending on the way you're
constructing your output you might be able to come up with a way of
passing down partial IDs through parameters or something to make it
more efficient.

I hope that 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.