且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何计算 XSLT 中数字的绝对值?

更新时间:2023-11-23 23:04:52

在 XPath 1.0 中使用以下表达式:

   $vNum*($vNum >=0) - $vNum*($vNum < 0)

如果此表达式嵌入在 XSLT (XML) 属性中,则必须对 < 字符进行转义:

In case this expression is embedded in an XSLT (XML) attribute, the < character must be escaped:

   $vNum*($vNum >=0) - $vNum*($vNum &lt; 0)

在 XPath 2.0 (XSLT 2.0) 中使用 abs() 函数.