Home > Software design >  XSL Convert Scientific notation to number
XSL Convert Scientific notation to number

Time:11-13

I'm using XSL 2.0. I have the following $intTOTAL which I'm converting to milliseconds. But the output of this is in scentific notation. How do i convert this to a normal number without scientific notation

<xsl:variable name="intTotal" select="((number($timeINTSEC)*60)*1000   number($timeINTMSEC))"/>
<TEST><xsl:value-of select="number($intTotal)"/></TEST>

Here is the output i'm getting

 <TEST>1.14E6</TEST>

CodePudding user response:

Expanding Martin's comment, the number() function converts to an xs:double, and the default output format for xs:double is scientific notation for values outside the range 1e-6 to 1e6.

You could either do the arithmetic in xs:decimal instead of xs:double, by using the xs:decimal() function in place of number(), or you could override the way xs:double values are formatted by using the format-number() function.

Incidentally the call to number() in number($intTotal) is redundant because the value is already an xs:double. And it's always a good idea to declare the types of your variables with an as attribute so it's clear to the reader what's going on.

  • Related