Hi,
I am trying to sum up a value using a published algorithm. The algoritm seems to get the correct value, but I cannot seem to format the value without getting NaN. Could anyone help.
Here is the XML.
<client name='Joe Bloggs'>
<supplier name='A'>
<product name='C'>
<investment name='D='1200' price='5.50'/>
<investment name='E' units='1200' price='3.50'/>
<investment name='F' units='1345' price='6.55'/>
</product>
</supplier>
<supplier name='B'>
<product name='E'>
<investment name='T' units='1200' price='5.50'/>
<investment name='W' units='1200' price='3.50'/>
<investment name='S' units='1345' price='6.55'/>
</product>
</supplier>
</client>
And here is the xslt.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-m
icrosoft-c
om:xslt"
xmlns:palantir="
http://www.palantir.co.za"
version="1.0">
<xsl:output
method = "xml"
version = "1.0"
encoding = "UTF-8"
indent = "yes"/>
<msxsl:script language="VBScript" implements-prefix="palanti
r">
<![CDATA[
Function Format(value)
Format = value
'Format = FormatCurrency(value)
End Function
]]>
</msxsl:script>
<xsl:template match="/">
<table>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match='client'>
<tr>
<td><xsl:value-of select='@name'/></td>
<td>
<xsl:call-template name='total-investment'>
<xsl:with-param name='investment-set' select='//investment'/>
</xsl:call-template>
</td>
</tr>
</xsl:template>
<xsl:template name='total-investment'>
<xsl:param name='investment-set'/>
<xsl:choose>
<xsl:when test='$investment-set'>
<xsl:variable name='first-node'>
<xsl:apply-templates select='$investment-set[1]
' mode='investment-price'/>
</xsl:variable>
<xsl:variable name='other-nodes'>
<xsl:call-template name='total-investment'>
<xsl:with-param name='investment-set' select='$investment-set[po
sition()!=
1]'/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select='palantir:Format(nu
mber(numbe
r($first-n
ode) + number($other-nodes)))'/>
</xsl:when>
<xsl:otherwise>0</xsl:othe
rwise>
</xsl:choose>
</xsl:template>
<xsl:template match='investment' mode='investment-price'>
<xsl:value-of select='@units * @price'/>
</xsl:template>
</xsl:stylesheet>
The above xslt works, except when I comment back in the format code it doesn't work.
I have tried the xslt built in functions, and I am getting the same result.
Please help.
Regards
-craig.
Start Free Trial