Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove trailing zeros in XSLT

Tags:

xslt

I have a node element as 1.0123000. I am using an XSLT for transformation. I need the output as 1.0123. Any one have any idea how to do it in 1.0 version of XSLT?

Thanks in advance,
jo

like image 297
joe Avatar asked Aug 23 '10 04:08

joe


1 Answers

This is easier than you think! Just use number() and it will return the string 1.0123000 as a number 1.0123 in XSLT 1.0:

<xsl:value-of select="number('1.0123000')"/>

will return

1.0123

The function number() can be found in the XPath 1.0 specification.

like image 166
Per T Avatar answered Nov 15 '22 07:11

Per T