RE: [xsl] Incrementing a Global variable

Subject: RE: [xsl] Incrementing a Global variable
From: Americo Albuquerque <melinor@xxxxxxx>
Date: Wed, 27 Aug 2003 22:38:22 +0100

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Mukul Gandhi
> Sent: Wednesday, August 27, 2003 7:30 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Incrementing a Global variable
> I am not asking to introduce variables as like in
> procedural languages.. We can keep xsl:variable as it
> is, 
> but can we introduce a syntax like xsl:variable2 (say
> in XSLT 2.0 -- in addition to xsl:variable) which can
> be defined at xsl:stylesheet level -- which can be
> allowed to increment. The processing model of XSLT can
> remain same(to maintain functional programming style);

If what you want is increment a variable would be better to have something
like <xsl:incremental name="value" step="2"/> to set the incremental value
and have a <xsl:incremental-value select="value"/> that would copy the
current value to the output and increment it by the defined step.

> the construct (e.g. xsl:variable2 ) can be maintained
> in a global memory (maintained by XSLT processor) and
> can be incremented..
> for e.g. if I define <xsl:variable2 name="a"
> select="0" />
>  and possibly *any no of* other variables for e.g. 
> <xsl:variable2 name="b" .. etc. at xsl:stylesheet level
> and lets assume for e.g. -- this template is being
> processed at some point..
> <xsl:template matche="something">
>   <xsl:variable2 name="a" select="$a + 1" />

This will not work as expected. This means that xslt had to "remember" the
variable state, i. e., the state before the variable setting and the state
after the setting. Xslt hasn't this concept builtin.

> </xsl:template>
> When the processor encounters the statement --
> <xsl:variable2 name="a" select="$a + 1" /> it will
> increment the value of "a" at a global place..
> Would introducing this feature will make XSLT really procedural?

Americo Albuquerque

 XSL-List info and archive:

Current Thread