Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Re-Assign variable in XSL

Venkatesh RamasamyJul 8 2012 — edited Feb 26 2020
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
This post has been answered by vladodias on Jul 9 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 15 2012
Added on Jul 8 2012
16 comments
1,462 views