1
我試圖使用下面的代碼來循環10天,但日期沒有采取。因爲我做錯了任何幫助,將不勝感激:使用日期作爲遞歸參數,直到1日期小於或等於另一日期
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
<xsl:output indent="yes" method="xml" omit-xml-declaration="yes"/>
<xsl:template match="/">
<Hi>
<Start><xsl:value-of select="'Start Here'"/></Start>
<xsl:call-template name="DayFunction"/>
<End><xsl:value-of select="'End Here'"/></End>
</Hi>
</xsl:template>
<xsl:template name="DayFunction">
<xsl:param name="EndDate" select="2017-05-10"/>
<xsl:variable name="StartDate" select="2017-05-01"/>
<xsl:choose>
<xsl:when test="$EndDate >= $StartDate">
<ok><xsl:value-of select="$EndDate"/></ok>
<xsl:call-template name="DayFunction">
<xsl:with-param name="EndDate" select="$EndDate - 1"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<ohno><xsl:value-of select="'Stuck Here'"/></ohno>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
請注意,我沒加我的XML,因爲我真的只是想看看爲什麼我的日期不能正確比較和減少。 – Derek