HairyTeeth
05-30-2003, 02:52 AM
Hi,
I probably can't see the woods for the trees but...
I just started using XML yesterday. Everything is going ok thus far except I'm having trouble displaying 2 digits after the decimal point when I sum() a prices element in the stylesheet (xsl).
For example...
If the price total equals $57.50, the sum(//price) returns $57.5
If the price total equals $57.00, the sum(//price) returns $57
I am trying to return $57.50 and $57.00.
I have converted the sum(//price) value to a string and stuffed that value into a variable (strTotal), in the hope of using one of the xpath string functions to manipulate the appropriate number of '0''s after the decimal point in the strTotal variable, but I'm a bit lost from there. Heres the code snippet I'm working with:
<tr>
<th colspan="2">Total</th>
<xsl:variable name="strTotal" select="string(sum(//price))" />
<td>$<xsl:value-of select="$strTotal" /></td>
</tr>
I've had a look around the net but didn't find anything of use. Suggestions, comments much appreciated.
I probably can't see the woods for the trees but...
I just started using XML yesterday. Everything is going ok thus far except I'm having trouble displaying 2 digits after the decimal point when I sum() a prices element in the stylesheet (xsl).
For example...
If the price total equals $57.50, the sum(//price) returns $57.5
If the price total equals $57.00, the sum(//price) returns $57
I am trying to return $57.50 and $57.00.
I have converted the sum(//price) value to a string and stuffed that value into a variable (strTotal), in the hope of using one of the xpath string functions to manipulate the appropriate number of '0''s after the decimal point in the strTotal variable, but I'm a bit lost from there. Heres the code snippet I'm working with:
<tr>
<th colspan="2">Total</th>
<xsl:variable name="strTotal" select="string(sum(//price))" />
<td>$<xsl:value-of select="$strTotal" /></td>
</tr>
I've had a look around the net but didn't find anything of use. Suggestions, comments much appreciated.