RE: variable incrementing problems

Subject: RE: variable incrementing problems
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Tue, 29 Jun 1999 10:35:01 -0600
> On Mon, 28 Jun 1999, Kay Michael wrote:
> > You cannot use xsl:variable to assign a new value to
> > an existing variable
> Ok. Thanks for answer. I am solved my problem now.
> But how can I increment value already existing variable?
> Another question: I am declare variable (DebubOpts) in
> template that should match root element. This template
> call another templates. But there is no variable
> DebugOpts in "child's" templates that called from main
> template....??

The child template is treated specially; it is outside the scope of the
calling template. To pass a variable to a called template, you need to use
param and param-variable, like this:

<xsl:template match="/">
    <xsl:variable name="DebugOpts" expr="abc123"/>
    <xsl:call-template name="childTemplate">
        <xsl:param name="DebugOpts" expr="$DebugOpts"/>

<xsl:template name="childTemplate">
    <xsl:param-variable name="DebugOpts"/>
    <xsl:text>The value of $DebugOpts is: </xsl:text>
    <xsl:value-of select="$DebugOpts"/>

This technique can be used to pass parameters back and forth between
templates. An increment function could be simulated this way.

 XSL-List info and archive:

Current Thread