我有一个格式为YYYYMMDD的日期字符串,例如xsl 1.0中的20140330,我想将日期字符串转换为YYYY-MM-DD格式,例如2014-03-30。
我试过使用几个日期函数,但没有工作。有人能帮我改一下日期吗?
发布于 2014-12-11 10:34:59
您可以使用子字符串函数。给定以下输入XML:
<root>20140330</root>以及以下样式表:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="root">
<xsl:value-of select="concat(substring(., 1, 4), '-', substring(., 5, 2), '-', substring(., 7, 2))"/>
</xsl:template>
</xsl:stylesheet>它的产出如下:
2014-03-30https://stackoverflow.com/questions/27420468
复制相似问题