如何在XSLT 2.0中格式化日期

时间:2011-05-04 12:27:07

标签: xslt-2.0

我需要像2011年5月5日星期三那样显示日期 我正在尝试

<xsl:value-of select="format-date(
                         current-date(),
                         '[FNn,*-3], [D01] [MNn,*-3] [Y0001]',
                         'en',
                         '',
                         'US'
                      )" />

另一个我试过

<xsl:value-of select="format-date(
                         current-date(),
                         '[FNn], [MNn] [D1o], [Y]',
                         'en',
                         (),
                         ()
                      )" />

两者都让我跟随。我需要文字,它只提供数字。我使用XSLT 2.0

3, 5 4, 2011

1 个答案:

答案 0 :(得分:7)

此样式表:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:value-of select="format-date(
                                 current-date(),
                                 '[FNn], [D1o] [MNn,*-3], [Y]',
                                 'en',
                                 (),
                                 ()
                              )" />
    </xsl:template>
</xsl:stylesheet>

输出:

Wednesday, 4th May, 2011

对Saxon和Altova进行了测试。

相关问题