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

RE: RE: Setting values for variable

Subject: RE: RE: Setting values for variable
From: cknell@xxxxxxxxxx
Date: Fri, 10 Sep 2004 07:45:01 -0400
xslt calculation variable
Of course, you are correct. pterm1 is out of scope when I tried to access its value. I took my eye off the ball for a second. Nevertheless, you can't change the value of a variable once it has been set. You'll have to stop thinking that XSL is another programming language like C, or Java or Perl or BASIC. You'll need to provide a broader context, more information, before anyone can help you solve the problem. How do you plan to use the value outside the <xsl:for-each>? 

I have often found that the <xsl:for-each> is used by people new to XSLT (this was true of me when I first started) in situations where <xsl:apply-templates> is more appropriate simply because the for-each-next loop is such a familiar programming construct.


-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     john lee <excel_man@xxxxxxxxxxx>
Sent:     Thu, 09 Sep 2004 22:42:06 +0000
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  RE:  Setting values for variable


It's not working.
First of all, if you do it like that, it will generate error, since pterm1 
is out of scope (pterm1 is inside for-each and inside a when)
Secondly, If I place the declaration of pterm1 outside the for-each, as 
follow:
<xsl:variable name="pterm" select="0"/>
<xsl:variable name="pterm1">
<xsl:for-each select="$lstAccount[Account_Type=$grpRecord]">
<xsl:choose>
<xsl:when test="string-length(normalize-space(Payment))!=0">
<xsl:value-of select="$pterm + Payment"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$pterm + 0.02*Balance"/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="$pterm1"/>

The calculation is not correct.
Any other ideas out there ?

Thanks

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE* 
http://join.msn.com/?page=features/junkmail

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.