Reputation: 5727
I am trying to format a number in XSLT, but I always get NaN
as a result.
Original example number is: 1 321.94
Code:
<xsl:value-of select="format-number(number(string(.)), '### ##0,00', 'format1')"/>
Seems like number(string(.))
doesn't work. How can I remove the space from the original number to cope with NaN
?
Upvotes: 0
Views: 258
Reputation: 52888
Using translate()
should work for both XSLT 1.0 and 2.0. You could also use replace()
in 2.0.
Here's an example of translate()
(broken up into multiple lines for readability):
<xsl:value-of
select="format-number(
number(translate(.,' ','')),
'### ##0,00','format1')"/>
Upvotes: 1