xsl-list
[Top] [All Lists]

RE: [xsl] generating ID strings that are both readable and unique

2008-10-14 04:32:01
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(_at_)nag(_dot_)co(_dot_)uk] 
Sent: Tuesday, 14 October 2008 9:04 p.m.
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] 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/>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--