0
我希望能夠對XSLT中的變量做一些基本的重新分配。這怎麼能實現?如何在XSLT中重新分配變量?
我只是希望能夠將其轉換爲XSLT(忽略appendMonthWithZero()函數):
if(currentMonth + count > 12) //If we get past December onto a new year we need to reset the current month back to 01
{
currentMonth = (currentMonth + count) - 12; //e.g. 9 + 4 = 13, 13 - 12 = 1 (January). Or 9 + 11 = 20, 20 - 12 = 8 (August)
if(currentMonth < 10)
{
currentMonth = appendMonthWithZero();
}
}
到目前爲止,我有這個在XSLT,但它不工作。我通過這12次循環,所以我要不斷修改currentMonth
除其他變量:
<xsl:if test="$currentMonth + $count > 12">
<xsl:param name="currentMonth" select="($currentMonth + $count) - 12"/>
</xsl:if>
實際上,這就是我想要的僞整體做(http://pastebin.com/WsaZaKnC):
currentMonth = getCurrentMonth();
actualDateWithZero = appendMonthWithZero();
docs = getFlightResults();
monthsArray = ['Jan', 'Feb', 'Mar'.......];
for(count = 0; count < 12; count++)
{
outboundMonth = subString(doc[count+1].getOutboundMonth());
if(currentMonth + count > 12) //If we get past December onto a new year we need to reset the current month back to 01
{
currentMonth = (currentMonth + count) - 12; //e.g. 9 + 4 = 13, 13 - 12 = 1 (January). Or 9 + 11 = 20, 20 - 12 = 8 (August)
if(currentMonth < 10)
{
currentMonth = appendMonthWithZero();
}
}
//A price is available.
//Second check is for when we get past a new year
if(currentMonth + count == outboundBoundMonth || currentMonth == outboundMonth)
{
//Get rest of data from doc etc etc
//Set up divs etc etc
//Get string month with displayed Month [Jan, Feb, Mar....]
}
//Else no price available for this month
else
{
//display price not available
//Get string month with displayed Month [Jan, Feb, Mar....]
}
}
當我將m2添加到m2時,是否需要再次分配不同的值? –
如果你爲一個值附加一個零,那麼你正在創建一個新值,是的。 –