【问题标题】:How to remove Z from xml timestamp input using XSLT 2.0如何使用 XSLT 2.0 从 xml 时间戳输入中删除 Z
【发布时间】:2017-09-12 09:00:22
【问题描述】:

我的输入 XML:

<chatTranscript startAt="2017-06-28T20:00:17Z">
<message>hai</message>
</chatTranscript>

在输入时间戳中它包含 Z。但 Z 应该在输出 XML 中删除,如下所示:

<chat>
<time>2017-06-28T20:00:17</time>
</chat>

【问题讨论】:

    标签: xml xslt xslt-2.0


    【解决方案1】:

    XPath 2.0 有一个功能:

    XSLT 2.0

    <xsl:stylesheet version="2.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    
    <xsl:template match="/chatTranscript">
        <chat>
            <time>
                <xsl:value-of select="adjust-dateTime-to-timezone(@startAt, ())"/>
            </time>
        </chat>
    </xsl:template>
    
    </xsl:stylesheet>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-13
      • 2017-12-06
      • 2015-12-31
      • 1970-01-01
      • 2015-11-16
      • 1970-01-01
      相关资源
      最近更新 更多