This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How to round number values



Moritz Walther writes:

>the XSL - part is
>.....<xsl:value-of select="lipr"/>...
>
>with this I get "48064.63999" but I need "48.064,64".
>How could I format the number ?

There are two operations in question, but you may find
that format-number does what you want with the rounding.
Your instruction would change to something like
<xsl:value-of select="format-number(lipr,'##.##0,00')"/>
and you would have to make a couple declarations in an
xsl:decimal-format element to swap the two separators.
Read section 12.3 of the XSLT spec for the whole story.
You'll want to set the number of #s and 0s to fit the
largest allowable number, and you may need to deal
with negative values as well.

To round manually to two decimal places, do this
<xsl:value-of select="round(100*lipr) div 100"/>
.................David Marston


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]