Re-Assign variable in XSL
Hello,
I am trying to check for a condition in an XSL transform and reassign a variable, I have understood that reassigning a variable is not an option in functional programming. However the need is that I need to check for a condition and then reassign a variable with a new value, is there any other option or ways of doing this. I have given the part of the code below. The variable varBoxID is initialized to "0", the If the Box# != varBoxID, then re-assign the variable varBoxID to the value of the variable "TempBoxID".
Any ideas / suggestions are greatly appreciated.
*<xsl:variable name="varBoxID">0</xsl:variable>* (Initializing a value to a variable)
<xsl:variable name="TempBoxId"
select="/tns:OrderDetails/tns:Order/tns:BoxNo"/>
<xsl:if test="/tns:OrderDetails/tns:Order/tns:BoxNo != $varBoxID">
<ns2:package_Data>
<ns0:package_id>
<xsl:value-of select="/tns:OrderDetails/tns:Order/tns:BoxNo"/>
</ns0:package_id>
<xsl:for-each select="/tns:OrderDetails/tns:Order">
<xsl:if test="tns:BoxNo != $varBoxID">
*<xsl:variable name="varBoxID"*
select="/tns:OrderDetails/tns:Order/TempBoxID"/> (Re-assigning a value to the previously declared variable)
<ns0:package_Items>
<ns0:vendor_item_number>
<xsl:value-of select="tns:SKU"/>
</ns0:vendor_item_number>
<ns0:quantity_shipped>
<xsl:value-of select="tns:QtyShipped"/>
</ns0:quantity_shipped>
</ns0:package_Items>
</xsl:if>
</xsl:if>
</xsl:for-each>
Thanks,
Venkatesh