使用 XSLT 2.0(或 3),它可以像将 dateTime 值评估为 xs:dateTime 并使用 format-dateTime() 和所需图片一样简单:
format-dateTime(xs:dateTime(UserValue/@value), '[M01][MN,*-3][Y]:[H01]:[m01]:[s01]')
但是,对于 XSLT 1.0,您没有可用的 dateTime 方法,只能进行字符串解析:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="1.0">
<xsl:output method="text"/>
<xsl:variable name="MONTHS">
<month>JAN</month>
<month>FEB</month>
<month>MAR</month>
<month>APR</month>
<month>MAY</month>
<month>JUN</month>
<month>JUL</month>
<month>AUG</month>
<month>SEP</month>
<month>OCT</month>
<month>NOV</month>
<month>DEC</month>
</xsl:variable>
<xsl:template match="/">
<xsl:variable name="val" select="//UserValue/@value"/>
<xsl:variable name="month" select="substring($val, 6, 2)"/>
<xsl:variable name="month-name" select="document('')/*/*/month[position() = number($month)]"/>
<xsl:variable name="year" select="substring($val, 1, 4)"/>
<xsl:variable name="time" select="substring($val, 12, 8)"/>
<xsl:value-of select="concat($month, $month-name, $year, ':', $time)"/>
</xsl:template>
</xsl:stylesheet>