[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

for-each within a for-each?

Subject: for-each within a for-each?
From: "Mike Rudolph" <mrudolph@xxxxxxx>
Date: Thu, 6 Mar 2003 10:00:36 -0600
for each within for each
All,

Newbie here.  Avidly reading FAQs, glossaries, etc.  I have a 'how-to'
question.  If you could point to a website addressing this particular
situation, that would be great.  I am not looking for anyone to write my
code.  Please forgive the layman's description that follows.  I may have
prostituted the term 'node' for my own purposes. :-)

I am using simple XSL to transform an XML files into HTML.  Several of these
have been completed by working from an original and making simple changes to
accommodate the new application.  The next one to complete is a purchase
order, and it's a head scratcher for this newbie.  The challenge is to
display multiple line item notes and charges (which can repeat) within a
line item node (which can also repeat - see sample XML input).  Basically
the line item level can contain this type of info:  Line item qty, price,
etc.); line item notes; line item charges; line item shipto.  Some of these
can repeat.  I already learned my tags are a bit long (tsk - old COBOL
habit).

</POR>
.
.
.
 <ITEM_DETAIL>
   <PO_LINE_ITEM_NUM>1</PO_LINE_ITEM_NUM>
   <QUANTITY>19</QUANTITY>
   <UNIT_OF_MEASURE_DESC>THOUSAND</UNIT_OF_MEASURE_DESC>
   <UNIT_PRICE>1050.18</UNIT_PRICE>
   <CUSTOMER_PART_NUM>06-77-9999</CUSTOMER_PART_NUM>
   <ITEM_DETAIL_NOTES>
     <ITEM_DETAIL_NOTES_TEXT>BOGUS LINE #1</ITEM_DETAIL_NOTES_TEXT>
   </ITEM_DETAIL_NOTES>
   <ITEM_DETAIL_NOTES>
     <ITEM_DETAIL_NOTES_TEXT>BOGUS LINE #2</ITEM_DETAIL_NOTES_TEXT>
   </ITEM_DETAIL_NOTES>
   <ITEM_MISC_CHARGES>
     <ITEM_MISC_CHG_DESC>SETUP CHARGE</ITEM_MISC_CHG_DESC>
     <ITEM_MISC_CHG_AMT>150.00</ITEM_MISC_CHG_AMT
   </ITEM_MISC_CHARGES>
   <ITEM_MISC_CHARGES>
     <ITEM_MISC_CHG_DESC>SHRINK WRAP CHARGE</ITEM_MISC_CHG_DESC>
     <ITEM_MISC_CHG_AMT>75.00</ITEM_MISC_CHG_AMT
   </ITEM_MISC_CHARGES>
 </ITEM_DETAIL>
   <PO_LINE_ITEM_NUM>2</PO_LINE_ITEM_NUM>
   <QUANTITY>20</QUANTITY>
   <UNIT_OF_MEASURE_DESC>THOUSAND</UNIT_OF_MEASURE_DESC>
   <UNIT_PRICE>1050.00</UNIT_PRICE>
   <CUSTOMER_PART_NUM>06-77-0000</CUSTOMER_PART_NUM>
   <ITEM_DETAIL_NOTES>
     <ITEM_DETAIL_NOTES_TEXT>BOGUS LINE #1</ITEM_DETAIL_NOTES_TEXT>
   </ITEM_DETAIL_NOTES>
   <ITEM_DETAIL_NOTES>
     <ITEM_DETAIL_NOTES_TEXT>BOGUS LINE #2</ITEM_DETAIL_NOTES_TEXT>
   </ITEM_DETAIL_NOTES>
   <ITEM_MISC_CHARGES>
     <ITEM_MISC_CHG_DESC>BOGUS CHARGE</ITEM_MISC_CHG_DESC>
     <ITEM_MISC_CHG_AMT>150.00</ITEM_MISC_CHG_AMT
   </ITEM_MISC_CHARGES>
   <ITEM_MISC_CHARGES>
     <ITEM_MISC_CHG_DESC>BOGUS CHARGE</ITEM_MISC_CHG_DESC>
     <ITEM_MISC_CHG_AMT>75.00</ITEM_MISC_CHG_AMT
   </ITEM_MISC_CHARGES>
 </ITEM_DETAIL>
.
.
.
</POR>

I can display any and all line items using xsl:for-each but have trouble
when it comes to the nodes subordinate to the line item level (example:
notes, misc charges).  I can get the very first note by specifying it, but
no more than that.  Tried all manners of putting another xsl:for-each within
the one shown, but that did not work.  Now that you know the situation, can
you point me to a FAQ or website which might handle this.


     <TABLE BORDER="4" WIDTH="100%" VALIGN="TOP" CELLPADDING="5">
     	  <COLGROUP ALIGN="CENTER"><TH>LINE</TH><TH>QUANTITY</TH><TH>UOM</TH>
     	  <TH>PART NUMBER</TH><TH COLSPAN="2">SPEC/DATE</TH>
     	  <TH>PRICE</TH><TH>BASIS OF UNIT PRICE</TH></COLGROUP>
     	    <TR>
     	      <xsl:for-each select="POR/ITEM_DETAIL" >
     	      <TR><TD ALIGN="CENTER"><xsl:value-of select="PO_LINE_ITEM_NUM"
/></TD>
              <TD ALIGN="CENTER"><xsl:value-of select="QUANTITY" /></TD>
              <TD ALIGN="CENTER"><xsl:value-of select="UNIT_OF_MEASURE_DESC"
/></TD>
     	        <TD ALIGN="CENTER"><xsl:value-of select="CUSTOMER_PART_NUM"
/></TD>
     	        <TD ALIGN="CENTER"><xsl:value-of select="UNIT_PRICE" /></TD>
     	        <TD ALIGN="CENTER"><xsl:value-of select="BASIS_PRICE_DESC"
/></TD></TR>

              <looking for technique to display notes and charges for the
line item>

              </xsl:for-each>
            </TR>
     </TABLE>


----------

Mike Rudolph - EDI Coordinator
Green Bay Packaging Inc.
Phone: 920.433.5426
Fax:   920.438.5426
Email: mrudolph@xxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.