简体   繁体   English

如何在版本 2.0 的 XSLT 中计算数字的绝对值

[英]How can I calculate the absolute value of a number in XSLT with version 2.0

I want to take absolute value of TaxAmount but I tried ABS function it is not working.Do you have any idea?我想取 TaxAmount 的绝对值,但我尝试了 ABS 功能它不起作用。你有什么想法吗?

My version is 2.0.我的版本是2.0。 I try xml file on the Internet Explorer.我在 Internet Explorer 上尝试 xml 文件。

I want to display it as positive sometimes it can be negative or positive我想把它显示为正面有时它可以是负面的或正面的

<div style="float:left; width:100pt">
        <h2>                                           
        :<xsl:value-of select="format-number(cbc:TaxAmount,'#,##0.00', 'us')"/>
        </h2>
</div>

You can use abs() function您可以使用 abs() 函数

<xsl:value-of select="format-number(abs(cbc:TaxAmount),'#,##0.00', 'us')"/>

You can use if statement您可以使用 if 语句

<xsl:choose>
     <xsl:when test="cbc:TaxAmount < 0">
       <xsl:value-of select="format-number(cbc:TaxAmount * -1,'#,##0.00', 'us')"/>
     </xsl:when>
     <xsl:otherwise>
      <xsl:value-of select="format-number(cbc:TaxAmount,'#,##0.00', 'us')"/>
     </xsl:otherwise>
   </xsl:choose>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM