xslt 1.0 将 dateTime 转换为 YYYY/MM/DD
xslt1.0 to convert dateTimeto YYYY/MM/DD
我正在尝试将收到的 xs:dateTime 格式的日期转换为 YYYY/MM/DD 收到的输入是:2002-05-30T09:00:00
预期输出 2002/05/30
您可以结合使用 substring-before()
和 translate()
...
translate(substring-before(normalize-space(),'T'),'-','/')
完整示例...
XML 输入
<doc>2002-05-30T09:00:00</doc>
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="doc">
<xsl:copy>
<xsl:value-of select="translate(substring-before(normalize-space(),'T'),'-','/')"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
输出
<doc>2002/05/30</doc>
我正在尝试将收到的 xs:dateTime 格式的日期转换为 YYYY/MM/DD 收到的输入是:2002-05-30T09:00:00 预期输出 2002/05/30
您可以结合使用 substring-before()
和 translate()
...
translate(substring-before(normalize-space(),'T'),'-','/')
完整示例...
XML 输入
<doc>2002-05-30T09:00:00</doc>
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="doc">
<xsl:copy>
<xsl:value-of select="translate(substring-before(normalize-space(),'T'),'-','/')"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
输出
<doc>2002/05/30</doc>