codingManiac
codingManiac

Reputation: 1700

How to add to the result of a template call in XSLT

Suppose the following template call generates and outputs a result of $20,000 and given that I have another element called sCost which occurs only once and has a value of 385, how could I add to the result of the template call?

<xsl:call-template name="totalCost">
   <xsl:with-param name="list" select="/delivery/manifest/item" /> 
</xsl:call-template>

When I try to do the following I get NaN...

<xsl:variable name="myVar">
    <xsl:call-template name="totalCost">
        <xsl:with-param name="list" select="/delivery/manifest/item" /> 
    </xsl:call-template>    
</xsl:variable>
<xsl:value-of select="$myVar + ../sCost" />

Upvotes: 1

Views: 52

Answers (1)

Pekka
Pekka

Reputation: 3654

If the result contains the ‘$‘ character, then it is not considered to be a number. Perform the currency formatting only as the last step in the process.

Upvotes: 3

Related Questions