我在XSLT以下

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/02/xpath-functions" xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:variable name="cDate">
        <xsl:value-of select="current-dateTime()"/>
    </xsl:variable>
    <xsl:variable name="fcDate">
        <xsl:value-of select="format-dateTime($cDate,'[Y0001][M01][D01]')"/>
    </xsl:variable>
    <xsl:template match="/PublisherBooking">
        <dt>
            <xsl:attribute name="date"><xsl:value-of select="$fcDate"/></xsl:attribute>
        </dt>
    </xsl:template>
</xsl:stylesheet>

这使我的输出(给定当前日期为2010年1月12日):

<?xml version="1.0" encoding="UTF-8"?>
<dt date="2010112"/>

我的问题是我需要的格式如下:

<?xml version="1.0" encoding="UTF-8"?>
<dt date="20100112"/>

让我怎么弄的月和日零填充?具体是什么错误的格式画面'[Y0001] [M01] [D01] - 。

FYI我使用XSLT引擎附带的XMLSpy 2005。

有帮助吗?

解决方案

好了,它看起来像在发动机上的错误,随我的版本的XMLSpy(2005和位长的牙齿)。然改造针对撒克逊9.2和根据需要的结果是

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top