xsl-list
[Top] [All Lists]

[xsl] Conditional Setting of a locale

2008-05-15 10:05:57
Hi All

I'm stuck with decimal formatting in my XSL stylesheet (XSLT 1.0 only).

My users are based in UK (so locale is en-GB), but they need to output 
documents with figures in Euro's, US$ and GBP. The latter two are no problem, 
but I can't figure out a way to change the decimal format for documents being 
sent to Europe.

I have an XML element called <currency> that tells me the target currency. 
Conceptually, I want to do this:

<xsl:choose>
        <xsl:when test="currency = 'Euro'">
        <xsl:decimal-format name="standard" decimal-separator="," 
grouping-separator="."/>
            <xsl:variable name="number" select="#.,00"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:decimal-format name="standard" decimal-separator="." 
grouping-separator=","/>
            <xsl:variable name="number" select="#,.00"/>
        </xsl:otherwise>
</xsl:choose>

Unfortunately, it's not possible as xsl:decimal-format needs to be at the top 
level and xsl:choose, etc. must be in the template body.

So, is there a way to set the decimal format based on the content of the XML 
with all docs being generated in an single locale?

I'd like to extend this to date formatting too if possible.

TIA

Mark


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>