tags:

views:

512

answers:

1

We're working on a web page that should be able to display prices such that spaces are the grouping separators and commas are the decimal seperators... eg the value 1234567.89 should display as "1 234 567,89". (We're actually using   so we get a non-breaking space.)

This seems like the right XSL to do it, and it almost works, but I get a "." character after the rest of it. So I end up with "1 234 567,89." instead of "1 234 567,89"

<?xml version='1.0' encoding='iso-8859-1'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
xmlns:hsi="http://www.myfakecompany.com/fakey" 
extension-element-prefixes="msxsl hsi">

    <xsl:decimal-format name="euro" 
        decimal-separator="," 
        grouping-separator="&#160;"/>

    <xsl:template match="/">

    <xsl:value-of select="format-number(1234567.89, '#&#160;###.##;(#&#160;###.##)', 'euro')"/>

    </xsl:template>
</xsl:stylesheet>

Any ideas?

+2  A: 

The format string is applied after the decimal separator is set, so you need to change it to:

'#&#160;###,##;(#&#160;###,##)'

I.e. with commas instead of periods.

Greg