Reputation: 631
Is there a way I can get the absolute value of a number in xslt-1.0? abs() function works but in xslt-2.0.
But I need a way the same abs() functionality but for xslt-1.0
e.g => input -1.5, expected output 1.5
Any advise would be much appreciated.
<xsl:value-of select="concat('-', abs(salesPrice/ns2:BelopFelt))"/>
possibly something to replace abs(salesPrice/ns2:BelopFelt)
Cheers
Upvotes: 0
Views: 806
Reputation: 117073
You can use:
translate($input, '-', '')
Or, if you prefer:
(2*($input > 0) - 1)*$input
Note that some XSLT 1.0 processors support the EXSLT math:abs()
extension function.
Upvotes: 2