Xslt 1.0将日期转换为dateTime格式

时间:2019-08-20 20:44:46

标签: xslt xslt-1.0

我是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>

请让我知道缺少的内容。谢谢

2 个答案:

答案 0 :(得分:2)

在XSLT 2.0+中,您可以使用

xs:dateTime(xs:date('2017-06-27'))

Check it

但是您已将其标记为XSLT 1.0,只剩下一个字符串串联:

<tns:receivedDate>
     <xsl:value-of select="concat(//ns0:receivedDate,'T00:00:00.000')"/>
</tns:receivedDate>

答案 1 :(得分:1)

XSLT 1.0没有日期概念。您需要使用字符串操作来执行此操作-例如:

<tns:receivedDate>
    <xsl:value-of select="//ns0:receivedDate"/>
    <xsl:text>T00:00:00.000</xsl:text>
</tns:receivedDate>
相关问题