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

Re: How can I bend generate-id()?

Subject: Re: How can I bend generate-id()?
From: "Charles Knell" <cknell@xxxxxxxxxx>
Date: Fri, 26 Jul 2002 14:04:01 -0700
emily letella
First let me apologize to those whose email rendered the included HTML
output. I wasn't thinking and I hope it has not inconvenienced anyone
terribly.

Second, in the words of Gilda Radner as Emily Letella, "Never mind."
I was able to solve the problem with twelve keystrokes and the realization
that my template would only output a maximum of three nodes for each
input node, and I know in advance which kind they might be, so I simply
appended a dash and a three-letter code to the return value of generate-id().
That way, even though the output of generate-id() doesn't change with
multiple calls from the same context node, the value stored in the each
element's id attribute will be unique.

-- 
Charles Knell
cknell@xxxxxxxxxx - email


---- "Charles Knell" <cknell@xxxxxxxxxx> wrote:
> I have a transformation which produces multiple output nodes for each
> input node. I need to place an id attribute into each output node.
> At
> first I thought, "I'll just use the generate-id() function!", but after
> doing that I found that I had identical values for the id attributes
> of those output nodes generated from the same input node. 
> 
> Referring to XSLT Programmer's Reference 2nd Edition, page 492, I read
> "If the argument is omitted, the target node is the context node."
> by
> which I understand that the since the context node is not changing
> between
> emissions of the generated-id function, each return value of generate-id()
> will be identical until I change context nodes.
> 
> Is there some way in which I could "bend" generate-id() so as to produce
> two or more unique id's from the same context node? Will I have to
> use
> some baroque recursive template call, passing a number as a parameter
> which will be incremented with each recursion and then appended to
> the
> value returned by generate-id() so as to achive more than one unique
> id from multiple calls to generate-id() from the same context node?
> (Please
> tell me there is an easier way!)
> 
> Here is the template and the output:
> template
> ===================================================
> <xsl:template match="node">
>   <xsl:param name="depth" select="0" />
>   <xsl:param name="tabSize" select="1" />
>   <div id="{generate-id()}" drag="enable" style="position:relative;left:{$tabSize
> * $depth}px;">
>     <xsl:variable name="level">
>       <xsl:value-of select="$depth + 1" />
>     </xsl:variable>
>     <xsl:if test="$depth != 0">
>       <img src="{$bulletURL}" id="{generate-id()}" />
>     </xsl:if>
>     <textarea id="{generate-id()}" class="editableNode" onfocus="Sink()"
> onblur="Sink()">
>       <xsl:value-of select="normalize-space(text()[position()=1])"
> />
>      

 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.