亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

通過XSLT以XML格式格式化日期

通過XSLT以XML格式格式化日期

守候你守候我 2019-11-28 12:42:49
當我使用XML序列化程序序列化時DateTime,它以以下格式編寫:<Date>2007-11-14T12:01:00</Date>當通過XSLT樣式表傳遞它以輸出HTML時,如何格式化?在大多數情況下,我只需要日期,而當我需要時間時,我當然不希望其中包含“有趣的T”。
查看完整描述

3 回答

?
不負相思意

TA貢獻1777條經驗 獲得超10個贊

以下是幾個您可以使用的1.0模板:


<xsl:template name="formatDate">

    <xsl:param name="dateTime" />

    <xsl:variable name="date" select="substring-before($dateTime, 'T')" />

    <xsl:variable name="year" select="substring-before($date, '-')" />

    <xsl:variable name="month" select="substring-before(substring-after($date, '-'), '-')" />

    <xsl:variable name="day" select="substring-after(substring-after($date, '-'), '-')" />

    <xsl:value-of select="concat($day, ' ', $month, ' ', $year)" />

</xsl:template>


<xsl:template name="formatTime">

    <xsl:param name="dateTime" />

    <xsl:value-of select="substring-after($dateTime, 'T')" />

</xsl:template>

致電給他們:-


    <xsl:call-template name="formatDate">

        <xsl:with-param name="dateTime" select="xpath" />

    </xsl:call-template>


    <xsl:call-template name="formatTime">

        <xsl:with-param name="dateTime" select="xpath" />

    </xsl:call-template>

其中xpath是具有標準日期時間格式的元素或屬性的路徑。


查看完整回答
反對 回復 2019-11-28
  • 3 回答
  • 0 關注
  • 799 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號