如何在XSLT中删除尾随零

joe*_*joe 5 xslt

我有一个节点元素为1.0123000.我正在使用XSLT进行转换.我需要输出为1.0123.任何人都知道如何在1.0版本的XSLT中做到这一点?

提前谢谢,

Per*_*r T 9

这比你想象的要容易!只需使用number()它将在XSLT 1.0 中将字符串1.0123000作为数字返回1.0123:

<xsl:value-of select="number('1.0123000')"/>
Run Code Online (Sandbox Code Playgroud)

将返回

1.0123
Run Code Online (Sandbox Code Playgroud)

该函数number()可以在XPath 1.0规范中找到.