RE: [xsl] Global variable

Subject: RE: [xsl] Global variable
From: <Jarno.Elovirta@xxxxxxxxx>
Date: Mon, 21 Feb 2005 12:58:40 +0200

> I have a stylesheet with several templates in it. In every template I
> need the same variable, so I think the best is to make it
> global!

XSLT spec uses the term top-level variable.

> But I
> have one problem with it: I do not know the value of the
> variable at the
> beginning of the stylesheet. I get it in my first template.
> So in this
> template I have a local variable and I need to make it global.
> Is this possible?


If you have

<xsl:template match="foo">
  <xsl:variable name="bar" select="@baz" />

you can rewrite it to

<xsl:variable name="bar" select="foo/@baz" />
<xsl:template match="foo">

but without seeing your stylesheet it's hard to advice more.


Jarno - Eufex: If It Skips... Tough Shit!

Current Thread