更新时间:2023-11-29 13:16:16
这是一个演示如何在XSLT 2.0中做到这一点: p>
Here is a demonstration how to do this in XSLT 2.0:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="vToday" select="current-date()"/>
Today is: <xsl:sequence select="$vToday"/>
30 days ago it was: <xsl:sequence select=
"$vToday -30*xs:dayTimeDuration('P1D')"/>
365 days ago it was: <xsl:sequence select=
"$vToday -365*xs:dayTimeDuration('P1D')"/>
</xsl:template>
</xsl:stylesheet>
结果生成:
when this transformation is applied on any XML document (not used), the wanted, correct result is produced:
Today is: 2010-10-07-07:00
30 days ago it was: 2010-09-07-07:00
365 days ago it was: 2009-10-07-07:00