Looping with When Condition along with Variables
Sorry for the hugepost . I am making it clear with small example here.
E1EDL37 is one of segment contains RFID_PALL or RFID_CASE Like example
If it is RFID_PALL, E1EDL44 Segment contains RFID_CASE Numbers. In my input i will have all the cases first and follows Pallet's at the bottom. I am trying to write Pallet first and correspondent CASE, follows by PALLET and Cases.
The Initial statement works fine. If the source has PALLET's. Now i have the problem when Only CASE exists with out PALLET. The First WHEN condition will not be satisfied. So it will skip writing CASE's. I am trying to put another OTHERWISE condition, so that first condition will check if the pallet exists or else skip to OTHERWISE condition and write all the cases and come out of the loop
1. RFID_PALL
<E1EDL37 SEGMENT="1">
<EXIDV>00000000003000008370</EXIDV>
<VHILM>RFID_PALL</VHILM>
<E1EDL44 SEGMENT="1">
<EXIDV>00000000003000008363</EXIDV>
</E1EDL44>
<E1EDL44 SEGMENT="1">
<EXIDV>00000000003000008364</EXIDV>
</E1EDL44>
</E1EDL37>
<E1EDL37 SEGMENT="1">
<EXIDV>00000000003000008363</EXIDV>
<VHILM>RFID_CASE</VHILM>
</E1EDL37>
<E1EDL37 SEGMENT="1">
<EXIDV>00000000003000008364</EXIDV>
<VHILM>RFID_CASE</VHILM>
</E1EDL37>
2. RFID_CASE's only
<E1EDL37 SEGMENT="1">
<EXIDV>00000000003000008380</EXIDV>
<VHILM>RFID_CASE</VHILM>
</E1EDL37>
<E1EDL37 SEGMENT="1">
<EXIDV>00000000003000008381</EXIDV>
<VHILM>RFID_CASE</VHILM>
</E1EDL37>
<E1EDL37 SEGMENT="1">
<EXIDV>00000000003000008382</EXIDV>
<VHILM>RFID_CASE</VHILM>
</E1EDL37>
<E1EDL37 SEGMENT="1">
<EXIDV>00000000003000008383</EXIDV>
<VHILM>RFID_CASE</VHILM>
</E1EDL37><E1EDL37 SEGMENT="1">
<EXIDV>00000000003000008384</EXIDV>
<VHILM>RFID_CASE</VHILM>
</E1EDL37>
<E1EDL37 SEGMENT="1">
<EXIDV>00000000003000008385</EXIDV>
<VHILM>RFID_CASE</VHILM>
</E1EDL37>
Here is my code which is not working with CASE'S
<xsl:variable name="RFIDPALLET" select="E1EDL37[VHILM='RFID_PALL']"/>
<xsl:choose>
<xsl:when test="$RFIDPALLET">
<xsl:for-each select="E1EDL37[VHILM='RFID_PALL']">
<xsl:copy-of select="." />
<xsl:for-each select="E1EDL44">
<xsl:variable name="Case" select="EXIDV" />
<xsl:copy-of select="../../E1EDL37[EXIDV=$Case]" />
</xsl:for-each>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="../E1EDL37" />
</xsl:otherwise>
</xsl:choose>
|