xsl-list
[Top] [All Lists]

for-each within a for-each?

2003-03-06 09:00:36

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(_at_)gbp(_dot_)com


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



<Prev in Thread] Current Thread [Next in Thread>