[英]xslt 2.0 how to round number? 1.45632 => 1.46
How to round number in xslt 2.0 如何在xslt 2.0中舍入数字
So for example it will work like this: 例如,它将像这样工作:
1.4367 => 1.44
1.3218 => 1.32
尝试使用圆函数:
<xsl:value-of select="round(NUMBER_TO_ROUND*100) div 100"/>
You are probably looking for format-number() function. 您可能正在寻找format-number()函数。
Also in In XSLT 2.0/XPath 2.0 one can use the xs:decimal
type to work without loss of precision. 同样在In XSLT 2.0 / XPath 2.0中,可以使用xs:decimal
类型来工作而不会损失精度。
Something like this: 像这样的东西:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/*">
<MyTable>
<xsl:value-of select="xs:decimal(MyValue)"/>
</MyTable>
</xsl:template>
</xsl:stylesheet>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.