我看到您正在尝试使用Java扩展来做到这一点。我不知道它是否可以工作以及如何工作,但是我可以建议一个(几乎)XSLT 1.0解决方案。以下样式表:
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:date="http://exslt.org/dates-and-times"extension-element-prefixes="date"><xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/><xsl:variable name="today" select="date:date()" /><xsl:template match="/"> <output> <start> <xsl:value-of select="concat(substring($today, 6, 2), '-', substring($today, 9, 2), '-', substring($today, 1, 4))" /> </start> <end> <xsl:call-template name="add-days-to-today"> <xsl:with-param name="days-to-add" select="90" /> </xsl:call-template> </end> </output></xsl:template><xsl:template name="add-days-to-today"> <xsl:param name="days-to-add"/> <xsl:param name="year" select="substring($today, 1, 4)"/> <xsl:param name="month" select="substring($today, 6, 2)"/> <xsl:param name="day" select="substring($today, 9, 2)"/> <xsl:param name="a" select="floor((14 - $month) div 12)"/> <xsl:param name="y" select="$year + 4800 - $a"/> <xsl:param name="m" select="$month + 12*$a - 3"/> <xsl:param name="JDN" select="$day + floor((153*$m + 2) div 5) + 365*$y + floor($y div 4) - floor($y div 100) + floor($y div 400) - 32045 + $days-to-add" /> <xsl:param name="f" select="$JDN + 1401 + floor((floor((4 * $JDN + 274277) div 146097) * 3) div 4) - 38"/> <xsl:param name="e" select="4*$f + 3"/> <xsl:param name="g" select="floor(($e mod 1461) div 4)"/> <xsl:param name="h" select="5*$g + 2"/> <xsl:param name="D" select="floor(($h mod 153) div 5 ) + 1"/> <xsl:param name="M" select="(floor($h div 153) + 2) mod 12 + 1"/> <xsl:param name="Y" select="floor($e div 1461) - 4716 + floor((14 - $M) div 12)"/> <xsl:param name="MM" select="format-number($M, '00')"/> <xsl:param name="DD" select="format-number($D, '00')"/> <xsl:value-of select="concat($MM, '-', $DD, '-', $Y)" /></xsl:template></xsl:stylesheet>
当应用于任何XML输入(2014年12月11日)时,返回:
<?xml version="1.0" encoding="UTF-8"?><output> <start>12-11-2014</start> <end>03-11-2015</end></output>



