xsl-list
[Top] [All Lists]

RE: Incrementing a Global variable

2003-08-27 18:50:48
Hi Americo,
  I guess such a construct will make certain tasks
easier(e.g. generating serial nos). As Dimitre
explained(and we all feel), side effect is bad for a
programming language ; unless we can deviate from the
notion of side effect free language, what you have
suggested and I wrote (xsl:variable2 ..) might not be
possible in XSLT.

Regards,
Mukul

--- Americo_Albuquerque <melinor(_at_)sapo(_dot_)pt> wrote:
Hi

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On
Behalf Of 
Mukul Gandhi
Sent: Wednesday, August 27, 2003 7:30 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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?

(...)

Regards,
Americo Albuquerque


 XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list



__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list