2

xslt 1.0 を使用しています。現在の日付と時刻をノードに出力しようとしています。以下はサンプルのxsltです

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:tcm="http://www.tridion.com/ContentManager/5.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:em="http://www.emirates.com/tridion/schemas" xmlns:tcmse="http://www.tridion.com/ContentManager/5.1/TcmScriptAssistant" exclude-result-prefixes="em xlink tcmse tcm">
  <xsl:output method="xml" version="1.0" encoding="UTF-16" indent="yes"/>

  <!-- Common XSLT Templates-->
  <xsl:include href="tcm:228-190524-2048"/>
  <!-- root match-->
  <xsl:template match="root">
    <sitedata>
      <resources>        
        <PublishedDate>
          <xsl:value-of select="$publishedDate"/>
        </PublishedDate>
      </resources>     
    </sitedata>
  </xsl:template>

上記の XSLT では、$publishedDateの代わりに、システムの現在の日付と時刻が必要です

提案してください!!

4

2 に答える 2

4

XSLT 1.0 は、現在の日付/時刻を取得するための標準的な方法を提供していません。拡張関数を呼び出してそれを行うことができます (プロセッサによって異なります)、またはパラメーターの値としてスタイルシートに渡すことができます。

于 2011-10-02T13:43:13.917 に答える
1

msxsl.exeコマンドラインユーティリティ(MSXML用)を使用してこれを行う方法は次のとおりです。

XSLTコード(testParams.xsl)

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:param name="vDate" select="xyz"/>

 <xsl:template match="/">
  "<xsl:value-of select="$vDate"/>"
 </xsl:template>
</xsl:stylesheet>

XMLドキュメント(t.xml)(偽物、無視):

<t/>

コマンドライン

msxsl t.xml testParams.xsl -o con vDate='%date%'

結果

"Sun 10/02/2011"
于 2011-10-02T19:48:27.460 に答える