Xslt 1.0 将日期转换为日期时间格式
Xslt 1.0 to convert date to dateTime format
我是 xslt 新手。所以这可能是一个基本问题。我正在尝试将收到的 xs:date 格式的日期转换为 xs:dateTime
收到的输入是:
<tns:receivedDate>2017-06-27</tns:receivedDate>
我想将其转换为 2017-06-27T00:00:00.000-05:00
或 2017-06-27T00:00:00.000
我尝试了下面的语句,但没有用
<tns:receivedDate>xs:date(<xsl:value-of select="//ns0:receivedDate"/>)cast as xs:dateTime</tns:receivedDate>
请让我知道缺少什么。谢谢
XSLT 1.0 没有日期概念。您需要使用字符串操作来执行此操作 - 例如:
<tns:receivedDate>
<xsl:value-of select="//ns0:receivedDate"/>
<xsl:text>T00:00:00.000</xsl:text>
</tns:receivedDate>
在 XSLT 2.0+ 中,您可以只使用
xs:dateTime(xs:date('2017-06-27'))
但是您已将其标记为 XSLT 1.0,这让您只剩下一个字符串连接:
<tns:receivedDate>
<xsl:value-of select="concat(//ns0:receivedDate,'T00:00:00.000')"/>
</tns:receivedDate>
我是 xslt 新手。所以这可能是一个基本问题。我正在尝试将收到的 xs:date 格式的日期转换为 xs:dateTime
收到的输入是:
<tns:receivedDate>2017-06-27</tns:receivedDate>
我想将其转换为 2017-06-27T00:00:00.000-05:00
或 2017-06-27T00:00:00.000
我尝试了下面的语句,但没有用
<tns:receivedDate>xs:date(<xsl:value-of select="//ns0:receivedDate"/>)cast as xs:dateTime</tns:receivedDate>
请让我知道缺少什么。谢谢
XSLT 1.0 没有日期概念。您需要使用字符串操作来执行此操作 - 例如:
<tns:receivedDate>
<xsl:value-of select="//ns0:receivedDate"/>
<xsl:text>T00:00:00.000</xsl:text>
</tns:receivedDate>
在 XSLT 2.0+ 中,您可以只使用
xs:dateTime(xs:date('2017-06-27'))
但是您已将其标记为 XSLT 1.0,这让您只剩下一个字符串连接:
<tns:receivedDate>
<xsl:value-of select="concat(//ns0:receivedDate,'T00:00:00.000')"/>
</tns:receivedDate>