I have
<xsl:value-of select="DifferenceInDays" />
DifferenceInDays
has a value that can be a negative or a positive number, I want to display its absolute value. How can I do this?
In XPath 2.0 (XSLT 2.0) use the abs() function.
You can use the built-in entities ' and " In XSLT 1.0: Alternatively, you can define your $Q and $APOS variables (put the content (the literal " or the literal ' character) in the body of the xsl:variable , not in the select attribute).
In XPath 1.0 use the following expression:
$vNum*($vNum >=0) - $vNum*($vNum < 0)
In case this expression is embedded in an XSLT (XML) attribute, the <
character must be escaped:
$vNum*($vNum >=0) - $vNum*($vNum < 0)
In XPath 2.0 (XSLT 2.0) use the abs()
function.
This can be achieved using the xpath abs function.
<xsl:value-of select="abs(DifferenceInDays)"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With