如何转换xslt中的日期格式。我已经创建了如下所示的应用程序
我使用了 xml:
2015-01-06T17:51:01.67+05:30
我的 xslt 文件:
select="format-dateTime(TravellerRequest/RequestDate,'[M01]/[D01]/[Y0001]')"/>
在 html 页面中出现错误:
异常详细信息:System.Xml.Xsl.XsltException:“format-dateTime()”是未知的 XSLT 函数。
来源错误:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
我需要这样的输出:01/06/2015
如何将上述日期时间格式转换为 mm/dd/yyyy。
请指导我。
谢谢, 拉姆...
最佳答案
format-dateTime()
是一个 XSLT 2.0 函数。您的错误消息表明您正在使用 XSLT 1.0 处理器。 XSLT 1.0 本身无法识别日期 - 但您可以使用字符串函数将日期重新排列为所需的格式:
<xsl:value-of select="substring(TravellerRequest/RequestDate, 9, 2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring(TravellerRequest/RequestDate, 6, 2)"/>
<xsl:text>/</xsl:text>
<xsl:value-of select="substring(TravellerRequest/RequestDate, 1, 4)"/>
注意: 如果您使用的是 Microsoft 处理器(按照 Martin Honnen 的建议),请参阅: https://msdn.microsoft.com/en-us/library/ms256099%28v=vs.110%29.aspx
关于xml - 如何转换xslt中的日期格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29842418/