views:

393

answers:

1

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)

Br. Anders

+4  A: 

Like this:

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

The second parameter (picture string) is described a follows by http://www.w3schools.com/XSL/func_formatnumber.asp.

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)
Lachlan Roche
Bingo! I have the feeling I ought to have figured that out my self, but couldn't. Thanks for your help.
Tillebeck