views:

49

answers:

1

I have an XML file that has a number of nodes, each of which contains a <current-fine> node. I need to sum these values but unfortunately they contain white-space so I end up getting NaN as the total.

Is there a way of achieving the following:

<xsl:value-of select="sum(normalize-space(node/sub-node/current-fine))"/>

Many thanks

+3  A: 

Don't try to bend the spoon:

<xsl:template match="/">
    <xsl:value-of 
         select="sum(node/sub-node/current-fine[normalize-space(.) != ''])" />
</xsl:template>

Just sum what you can sum =)

Rubens Farias
+1 for the spoon. ^^
Tomalak
Thanks very much Rubens, that works perfectly!