Subject: Re: [xsl] Setting values for variable From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx> Date: 10 Sep 2004 07:03:54 +0100 |
>>>>> "john" == john lee <excel_man@xxxxxxxxxxx> writes: john> Dear All, How do you set a value for a variable without john> declaring the name of the variable twice. This is what I john> intend to do. john> <xsl:variable name="pterm" select="0"/> <xsl:for-each john> select="$lstAccount[Account_Type=$grpRecord]"> <xsll:choose> john> <xsl:when test="string-length(normalize-space(Payment))!=0"> john> <xsl:variable name="pterm" select="$pterm + Payment"/> john> </xsl:when> <xsl:otherwise> <xsl:variable name="pterm" john> select="$pterm + 0.02*Balance"/> </xsl:otherwise> john> </xsl:choose> </xsl:for-each> <xsl:value-of john> select="$pterm"/> john> But this will generate error since pterm is declared more john> than once. Anybody know what's the other way around this ? You don't need a variable at all. Just code the xsl:value-of within each when/otherwise branch. Variables in functional languages such as XSLT are like variables in mathmatices. They are declarations of values, not assignments. Just as in mathmatics: x = x + 1 for instance, makes no sense - rather you would say y = x + 1. -- Colin Paul Adams Preston Lancashire
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Setting values for variable, john lee | Thread | Re: [xsl] Setting values for variab, Colin Paul Adams |
RE: [xsl] Setting values for variab, john lee | Date | Re: [xsl] XSLT - Multiple Level Gro, Arun Sinha |
Month |