0

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]'の何が問題になっていますか。

参考までに、XMLSpy2005に同梱されているXSLTエンジンを使用しています。

4

1 に答える 1

0

まあ、それは私のバージョンのXMLSpy(2005と少し長い歯)に同梱されているエンジンのバグのように見えます。Saxon 9.2に対して変換を実行し、結果は必要に応じて行われました。

于 2010-01-15T15:00:39.953 に答える