Subject: RE: [xsl] Adding numbers in xsl loop From: "Ard Schrijvers" <Ard@xxxxxxxx> Date: Tue, 25 Jun 2002 12:19:08 +0200 |
Thanks a lot. This helps me a lot. I still don't understand, why in xsl simple programming code ( like for loops , not on the xml, but just like i=0 to 10) is not included. Also like date function, etc. regards ard -----Oorspronkelijk bericht----- Van: James Fuller [mailto:james.fuller@xxxxxxxxxx] Verzonden: 25 June 2002 11:50 Aan: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Onderwerp: Re: [xsl] Adding numbers in xsl loop ----- Original Message ----- From: "Ard Schrijvers" <Ard@xxxxxxxx> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Sent: Tuesday, June 25, 2002 10:27 AM Subject: [xsl] Adding numbers in xsl loop > > Perhaps somebody can help me with the following: > > I want in an xsl:for-each loop to add a found value to a certain variable. Something like this: > > <xsl:for-each select="projects/project[medewerker[login=$loginMatch]]"> > <xsl:variable name="currentPro" select="name"/> > <xsl:variable name="totaalX" select="sum(../../hours/entry[login=$loginMatch][date/year=$jaarX][date/mont h=$maandX][projectname=$currentPro]/duration)"/> > (now i want something like, so that absTotal get's in the loop everytime the value of totaalX plus the value of itself:) > <xsl:variable name="absTotal" select="$absTotal + $totaalX"/> > </xsl:for-each> > > 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??????????? hehe, another customer ! u cant do x=x+1 loops with XSLT, because once u set a var it cannot change ! u can get around this quite easily by having a named template and call it recursively eg. taken straight from cooktop <!-- Use: include this call with the number of iterations This sample will loop from 1 to 10 including 1 and 10 --> <xsl:call-template name="for.loop"> <xsl:with-param name="i">1</xsl:with-param> <xsl:with-param name="count">10</xsl:with-param> </xsl:call-template> <!-- Rename "old name" elements to "new name" --> <xsl:template name="for.loop"> <xsl:param name="i"/> <xsl:param name="count"/> <xsl:if test="$i <= $count"> <!-- body of the loop goes here --> </xsl:if> <xsl:if test="$i <= $count"> <xsl:call-template name="for.loop"> <xsl:with-param name="i"> <!-- Increment index--> <xsl:value-of select="$i + 1"/> </xsl:with-param> <xsl:with-param name="count"> <xsl:value-of select="$count"/> </xsl:with-param> </xsl:call-template> </xsl:if> </xsl:template> hth, jim fuller XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Adding numbers in xsl lo, David Carlisle | Thread | Re: [xsl] Adding numbers in xsl lo, Antonio Fiol |
Re: [xsl] Adding numbers in xsl lo, Jeni Tennison | Date | Re: [xsl] Adding numbers in xsl loo, Vasu Chakkera |
Month |