首页 > 解决方案 > Xslt 1.0 将日期转换为 dateTime 格式

问题描述

我是 xslt 的新手。所以这可能是一个基本问题。我正在尝试将以 xs:date 格式接收的日期转换为 xs:dateTime 收到的输入是: <tns:receivedDate>2017-06-27</tns:receivedDate> 我想将其转换为2017-06-27T00:00:00.000-05:002017-06-27T00:00:00.000

我尝试了下面的语句但不起作用

<tns:receivedDate>xs:date(<xsl:value-of select="//ns0:receivedDate"/>)cast as xs:dateTime</tns:receivedDate>

请让我知道缺少什么。谢谢

标签: xsltxslt-1.0

解决方案


在 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>

推荐阅读