Drumdivan
Drumdivan

Reputation: 1

XSL version 1.0- Absolute Value

I'm new to XSL and looking for help on returning an absolute value for the following:

xsl:value-of select="inr:distanceFormat(number(@firstOffset), $xslDistancePrecision)"/>

I know someone has posted $vNum*($vNum >=0) - $vNum*($vNum < 0) but I cant get it to work, any help?

Do I substitute all the inr:distanceFormat(number(@firstOffset), $xslDistancePrecision) for Num in the absolute formula?

Thanks Drumdivan

Upvotes: 0

Views: 1099

Answers (2)

Michael Kay
Michael Kay

Reputation: 163458

Simplest (not necessarily fastest) is probably just to strip any minus sign from the string representation: number(translate(string(xxx), '-', ''))

Upvotes: 1

Martin Honnen
Martin Honnen

Reputation: 167696

Define a variable

<xsl:variable name="vNum" select="inr:distanceFormat(number(@firstOffset), $xslDistancePrecision)"/>

then use the suggestion <xsl:value-of select="$vNum*($vNum >=0) - $vNum*($vNum &lt; 0)"/>.

Upvotes: 0

Related Questions