Search code examples
xslttomcatxslt-2.0apache-fopsaxon

xslt 2.0 month name in French or German


I’m using xslt fn:formate-dateTime() to get the current date and time, for English it’s works fine.

But everytime I try to get the month name in different languages (fr, de, etc), I will just get the current date and time with [Language: en] in the front and couldn’t get the month name in that language.

Date Created: [Language: en] 06/April/2011

Here is my code, Could someone tell me what I’m doing wrong here.

<xsl:value-of select="format-dateTime(current-dateTime(),
                                      '[D01]/[MNn]/[Y0001]',
                                      ’de’,
                                      ’AD’,
                                      ’DE’)"/>

Or

<xsl:value-of select="format-dateTime(current-dateTime (),
                                      '[D01]/[MNn]/[Y0001]',
                                      ’fr’,
                                      ’AD’,
                                      ’FR’)"/>

I’m using Saxon 9 with Fop 1.0 running on tomcat 7


Solution

  • Actually that information about Saxon is a little out of date (as is the information at http://www.saxonica.com/documentation/extensibility/localizing.xml - embarrassing).

    But we need to know which specific Saxon release you are using: it changed between 9.1 and 9.2, and it's different between Home Edition and Professional Edition. In the current release, 9.3, support for a number of common languages such as de and fr is available "out of the box" with Saxon-PE and Saxon-EE, but has to be configured manually from source code with Saxon-HE, by writing a LocalizerFactory and registering it with the Configuration.