In xsl, is there a way to next a normalize-space call inside a sum?
-
06-07-2019 - |
Question
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
Solution
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 =)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow