xslt - Xslt 1.0 将日期转换为 dateTime 格式
问题描述
我是 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 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>
推荐阅读
- mysql - Spring Data JPA - 如何查询没有实体类的表?
- material-ui - useTranslation 钩子(i18next 包)和材料 ui 选项卡指示器错误
- xml - 我如何在我的颤振应用程序中使用 xml 图标
- node.js - 使用 NodeJS / Mocha 进行单元测试时如何引用函数
- python - 使用 BeautifulSoup 查找和删除内容
- c++ - 存储上一个模板参数
- python - 将日期和日期时间的熊猫列转换为日期
- javascript - 我想打印页面并默认选中背景图形复选框
- python - 在 Python 中使用 Dedupe 时无法导入名称“TypedDict”错误
- r - converting to date format in dataframe in R