Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xslt format-number decimal, number less than one

I have this as input called $material_price:

2.40
1000
0.60

They run through

<!-- setup currency rendering -->
<xsl:decimal-format name="dkk" decimal-separator="," grouping-separator="."/>
<xsl:value-of select="format-number($material_price, '#.###,00', 'dkk')"/>

Output is:

2,40
1.000,00
,60

How can I make changes to the xslt so last output is 0,60 and not ,60 (without the zero)

like image 807
Tillebeck Avatar asked Feb 10 '10 11:02

Tillebeck


1 Answers

Like this:

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

The second parameter (picture string) is described as follows by the documentation.

Required. Specifies the format pattern. Here are some of the characters used in the formatting pattern:

  • 0 (Digit)
  • (Digit, zero shows as absent)

  • . (The position of the decimal point Example: ###.##)
  • , (The group separator for thousands. Example: ###,###.##)
  • % (Displays the number as a percentage. Example: ##%)
  • ; (Pattern separator. The first pattern will be used for positive numbers and the second for negative numbers)
like image 71
Lachlan Roche Avatar answered Sep 18 '22 18:09

Lachlan Roche