<xsl:call-template name="SetNetTemplate">
<xsl:with-param name="xyz" select="$node1value
+ $node2value
+ $node3value
- $node4value
- $node5value
- $node6value"/>
</xsl:call-template>
If nodevalue is empty or blank, i want to replace that value with 0 (zero). Problem is that in this calculation if any nodevalue is empty or blank, it is giving NaN result. e.g. select "10-2+5-2- -4"
Try it this way:
<xsl:with-param name="xyz" select="translate(number($node1value), 'aN', '0')
+ translate(number($node2value), 'aN', '0')
+ translate(number($node3value), 'aN', '0')
...
- translate(number($node6value), 'aN', '0')"/>
EDIT
Note that the above is just a "cute trick" designed to avoid the verbosity of the proper and straightforward solution that would do this:
<xsl:choose>
<xsl:when test="number($node1value)">
<xsl:value-of select="$node1value" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="0" />
</xsl:otherwise>
</xsl:choose>
to each and every one of your operands before trying to treat them as numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With