Home > Enterprise >  Need to get exact decimal value in the output in XSLT
Need to get exact decimal value in the output in XSLT

Time:11-21

I'm having two kind of decimal numbers as a value in the input xml

Input:

<sets>
  <set>
    <total>0.00</total>
  </set>
  <set>
   <total>5787.43</total>
  </set>
</sets>

XSL I'm having:

<xsl:value-of select="concat('$', format-number(number($cur_value), '###,###.00'))"/>

When I'm trying the above XSL I'm getting the output for the first set is

$.00
$5,787.43

When I have tried:

<xsl:value-of select="concat('$', format-number(number($cur_value), '###,###0.00'))"/>

Output I'm getting:

$0.00
$5787.43

On the first try the '0' is missing in the output, on the 2nd try comma is getting missing. Expected output is

$0.00
$5,787.43

Can anyone suggest a code that should cover both the scenario

CodePudding user response:

Try:

#,##0.00

as the picture argument.

Even better, make it:

$#,##0.00

and get rid of the concat() part. And I don't think you need the number() part either.

  • Related