Re: [xsl] generate-id()

Subject: Re: [xsl] generate-id()
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 13 Nov 2001 23:09:30 +0000
Hi David,

> I have an issue w. generating a unique id from a called template in
> an included XSL file. I use the template to create buttons for the
> bottom of a form. Their content is not based on the XML, but values
> such as Save, Delete, etc. The DHTML code that's I'm using requires
> each button the have a unique name.

If the buttons that you're generating aren't based on the source XML,
then you must know what buttons are being generated in advance, such
that you can hard code as unique values within the XSLT document

  <button name="save" value="Save" />
  <button name="delete" value="Delete" />

If they *do* depend on something about the source XML, so effectively
you want several IDs from the same node, then you can get the ID of
the current node at the point where you call the template:

  <xsl:variable name="id" select="generate-id()" />

and then couple that with the unique name for the buttons:

  <button name="save{$id}" value="Save" />
  <button name="delete{$id}" value="Delete" />

(I personally use a matching, moded template rather than a named
template when my code depends on a property (such as the identity) of
the current node, but that's just a matter of preference.)

If this isn't what you're after, do send a snippet of the XSLT that
you have so we can get a better grasp on what you're aiming for.



Jeni Tennison

 XSL-List info and archive:

Current Thread