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

RE: generating ID strings that are both readable and

Subject: RE: generating ID strings that are both readable and unique
From: "Trevor Nicholls" <trevor@xxxxxxxxxxxxxxxxxx>
Date: Tue, 14 Oct 2008 21:23:51 +1300
RE:  generating ID strings that are both readable and
Thanks David & 'Xmlizer', however I would prefer to avoid solutions based on
either generate-id() or xsl:number. Ideally I would like to produce an
output XML document which contains entries like

  <section id="introduction-1"><title>Introduction</title>...</section>
  ...
  <section id="examples"><title>Examples</title>...</section>
  ...
  <section id="introduction-2"><title>Introduction</title>...</section>
  ...

and so on.

I think I could probably manage to do this using keys in XSL 2.0 because I
would be able to construct the key using the existing id attribute if there
was one, or using the translated title child if there wasn't, and I could
create an id attribute based on the number of identical keys. However this
mechanism isn't possible in XSL 1.0, and unfortunately - because this
stylesheet is to be invoked as part of Framemaker's save XML file logic - it
has to be handled by the Xalan processor.

Is there another approach?

Cheers
Trevor

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx] 
Sent: Tuesday, 14 October 2008 9:04 p.m.
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  generating ID strings that are both readable and unique


I tend to avoid generate-id() for this as it makes recreating the same
ids if the source is edited (or even if it is not) very hard, which
means people#s bookmarks get messed up if you regenerte.
One fairly robust way is to go

<xsl:attribute name="id">
  <xsl:text>id.</xsl:text>
  <xsl:number count="*" level="multiple"/>
</xsl:attribute/>

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.