Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2007, 05:37 PM
Authorized User
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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>

 
Old December 6th, 2007, 11:52 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Given this simple example XML above, what are you expecting the output to look like exactly?

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping with When Condition pixelheart XSLT 10 December 5th, 2007 05:49 PM
or condition kgoldvas XSLT 1 July 31st, 2007 03:44 AM
if then else condition mateenmohd Classic ASP Basics 0 April 16th, 2005 07:08 AM
Condition mateenmohd SQL Server 2000 6 May 6th, 2004 03:49 AM
Looping through variables, Applying a function tdaustin Classic ASP Basics 0 August 3rd, 2003 07:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.