[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Incrementing a Global variable

Subject: RE: Incrementing a Global variable
From: Mukul Gandhi <mukulw3@xxxxxxxxx>
Date: Wed, 27 Aug 2003 11:30:02 -0700 (PDT)
xslt global var
I am not asking to introduce variables as like in
procedural languages.. We can keep xsl:variable as it

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);

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

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" />

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

Thanks for your reference about <xsl:for-each
select="20 to 30"> ... but I could not see it on the
XSLT 2.0 site -- http://www.w3.org/TR/xslt20/


--- Michael Kay <mhk@xxxxxxxxx> wrote:
> > 
> > Though the issue about incrementing the variables
> has
> > been discussed a lot on this list, I feel if there
> is
> > a feature where some sort of variable incrmenting
> is
> > possible in XSLT, it will save lot of programming
> > hours producing a trivial thing as generating
> serial
> > nos. I am not suggesting to deviate from the
> viewpoint
> > that XSLT should be a functional language.
> But it would deviate from that principle. It would
> change it from a
> functional language to a procedural one, in which
> instructions have to
> be executed in a fixed order.
> > Also if we can have looping constructs
> > which can iterate over number ranges for e.g.
> > 
> > for (int i=0; i < n; i++) , it will facilitate
> > processing loops in a diffrent way. 
> XSLT 2.0 allows you to do this:
> <xsl:for-each select="20 to 30">
>   <xsl:value-of select="."/>
> </xsl:for-each>
> You can simulate this in 1.0 with
> <xsl:for-each select="//node()[position() &lt;=
> 10]">
>   <xsl:value-of select="position() + 20"/>
> </xsl:for-each>
> Michael Kay
>  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

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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.