You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Kapa, Madhavi" <ma...@marconimed.com> on 2000/10/25 14:31:17 UTC

Global variables in XSL

Hi,

   Can somebody please tell me how to declare and use global variables in
XSL? Any examples?

Thanks,
Madhavi


Re: Global variables in XSL

Posted by Maitreyee Pasad <pa...@gst.com>.
Madhavi,

XSLT has variables that can hold values. you can initialize a variable
to a value. E.g.

<xsl:variable name ="age" select="25"/>

You can then use it as

<xsl:value-of select="$age"/>


If you define this variable before any <xsl:template> in your main xsl
file. then the scope of this variable is the entire stylesheet,
including any stylesheets that are imported or included. Make sure that
you don't have circular definitions

eg. <xsl:variable name ="v1" select="$v2"/>

    Since v1 is defined in terms of variable v2 then you cannot define
v2 in terms of v1.  ie. the folowing statement will generate an error:

  <xsl:variable name="v2" select="$v1"/>


Also, once defined you cannot change the value of an xsl variable. If
you do want to use a variable whose value you want to change then you
may need to use java extensions to XSL.

Hope this helps.

Maitreyee

"Kapa, Madhavi" wrote:

>
>
> Hi,
>
>    Can somebody please tell me how to declare and use global variables
> in XSL? Any examples?
>
> Thanks,
> Madhavi