[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Adding numbers in xsl loop


Subject: Re: [xsl] Adding numbers in xsl loop
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 25 Jun 2002 11:54:03 +0100

> Apparently, this does not work in xsl. I can't figure out, how to use
> a basic programming issue like i = i + 1 in a loop??????????? 

You should think in terms of mathematical functions not the strange (but
noe familiar) imperative operations of procedural programing languages.

i = i + 1
would mean 0 = 1 which is clearly a contradiction. variables do not
change their value once bound in XSLT (or other functional programming
languages). You should think of all the items in a for-each being
executed in parallel, there is no sense in which one executed first.

Just select the nodes that you want to sum with an Xpath and then apply
sum() to those.

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

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



Current Thread
Keywords