内のタグに値として現在の日付を追加:は、私は以下のようなXMLを持っているISO 8601形式のXSLT
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<properties>
<entry key="user">1234</entry>
</properties>
私は1つは、ISO 8601形式で現在の日付の値が含まれており、他の二つの新しいタグを追加しますISO 8601形式で現在の日付+ 10年に設定し、XSLTを使用して新しいXMLファイルに変換した日付と1は、出力XMLは、この
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<properties>
<entry key="user">1234</entry>
<entry key="doc:uploadDate">2017-07-04T22:18:08Z</entry>
<entry key="doc:deleteDate">2027-07-04T22:18:08Z</entry>
</properties>
のように、私は以下のXSLTを使用していなければなりません。
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:variable name="currentDate">
<xsl:value-of select="current-dateTime()" />
</xsl:variable>
<xsl:template match="entry[@key='doc:uploadDate']">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:value-of
select="replace(normalize-space($currentDate),
'^(\d{2})-(\d{2})-(\d{4})\s+(.*)','$3-$1-$2T$4Z')" />
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:transform>
誰かがこれで私を助けてもらえ..
MM-DD-YYYYの日付をYYYY-MM-DD形式に変換するように見えるコードがありますが、日付はfn:current-dateTimeから来ていますy YYYY-MM-DDフォーマット。それは実際にxs:dateTimeとして返されます。これは、xsl:value-ofを使って文字列に変換し、次に解析します。なぜこのすべての複雑さ? –