I want to be able to do some basic reassignments to variables in XSLT. How can this be achieved?
I just want to be able to convert this to XSLT (ignoring the appendMonthWithZero() function):
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();
}
}
So far I have this in XSLT but it doesn't work. I am looping through this 12 times so I want to keep modifying currentMonth
amongst other variables:
<xsl:if test="$currentMonth + $count > 12">
<xsl:param name="currentMonth" select="($currentMonth + $count) - 12"/>
</xsl:if>
This is essentially what I'm trying to do overall in pseudocode (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....]
}
}