Welcome to WebmasterWorld Guest from 23.22.19.253

Forum Moderators: httpwebwitch

Message Too Old, No Replies

Why can I not get back a number from any of these methods

XSL adding two numbers

   
2:12 pm on Oct 24, 2006 (gmt 0)

5+ Year Member



Why can I not get back a number from any of these methods adding the two variables defined here.

Since the first example returns values, I know my variables are not null.

<!--VARIBALE1 -->
<xsl:variable name="CountedSubTotal">
<xsl:value-of select="format-number(sum(SummaryReportSection1/Counted), '$##########0.00')"></xsl:value-of>
</xsl:variable>

<--!VARIABLE2 -->
<xsl:variable name="CountedTotal">
<xsl:value-of select="format-number(sum(SummaryReportSection2/Counted), '$##########0.00')"></xsl:value-of>
</xsl:variable>

<!--This returns the two numbers but as a string - example: $1689.19 + $859.37 -->
<xsl:copy-of select="$CountedTotal"/> + <xsl:copy-of select="$CountedSubTotal"/>

<!--All these other return NaN -->
<xsl:variable name="CountedTotalLine">
<xsl:value-of select="$CountedTotal + $CountedSubTotal"/>
</xsl:variable>
<xsl:copy-of select="$CountedTotalLine"/>

<xsl:value-of select="format-number($CountedTotal + $CountedSubTotal, '$##########0.00')" />

<xsl:variable name="CountedTotalLine" select="$CountedTotal + $CountedSubTotal"/>
<xsl:value-of select="$CountedTotal + $CountedSubTotal"></xsl:value-of>
<xsl:copy-of select="$CountedTotalLine"/> -->

2:28 pm on Oct 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm. How about the expression:

"substring-after($CountedTotal,'$')+substring-after($CountedTotalLine,'$')"

2:36 pm on Oct 24, 2006 (gmt 0)

5+ Year Member



Wow do I feel like the idiot. That did it. I was considering taking off the $ in the format statement, but like usuall I made an assumption about XSL.

Warning to all never think XSL is very smart. :)

m

2:40 pm on Oct 24, 2006 (gmt 0)

5+ Year Member



BTW - Thank you so much. I was getting very frustrated, couldn't see the tree because of the forrest syndrom.

m

5:51 pm on Oct 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, it is the most syntactically tedious programming language ever created by man, so it's kinda custom made to encourage not being able to see the forest for the trees :-).