Re: [xsl] How to use generate-id() inside an xsl:function without a node available?

Subject: Re: [xsl] How to use generate-id() inside an xsl:function without a node available?
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Tue, 27 Feb 2007 22:58:14 +0100
Dimitre Novatchev wrote:
I think in this case generate-id() will be applied on the same node
again and again and will return the same string -- this is why I want
always to have a new copy of it -- or am I wrong?

I am honoured with so much attention for such a seemingly simple question ;)


Inside a function, apparently, the node is recreated on each function call. Whether it is this:

<xsl:function name="my:getNode"><node /></xsl:function>
<xsl:function name="my:getId"><xsl:value-of select="generate-id(my:getNode())" /></xsl:function>


or whether you use variables to achieve the same result. Apparently, the node need not be part of the result tree to achieve this effect (maybe it is, I don't know, but it is never output at least).

The variable-inside-one-function (like David's solution) is the one I currently employ, but any variant is likely to succeed if I understand Michael Kay correctly.

-- Abel Braaksma

Current Thread