| Subject: RE: [xsl] for-each within a for-each? From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx> Date: Thu, 6 Mar 2003 16:46:41 -0000 | 
Hi,
I would change your xsl:for-each approach ('pull processing') to an xsl:apply-templates ('push approach').  This basically means instead of populating your skeletal html with <xsl:value-of>'s, you will build it by matching the source xml against templates that you specify.
So, output the first part of your html:
<xsl:template match="POR">
  <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>
     	    
        <xsl:apply-templates/>
  </TABLE>
</xsl:template>
Then, each <ITEM_DETAIL> can be a row in the table:
<xsl:template match="ITEM_DETAIL">
  <tr>
    <xsl:apply-templates/>
  </tr>
</xsl:template>
By calling apply-templates, the processor will find the best matching template for each child of <ITEM_DETAIL>, so you need to write a template to output the code for each child:
<xsl:template match="PO_LINE_ITEM_NUM">
  <TD ALIGN="CENTER"><xsl:value-of select="PO_LINE_ITEM_NUM"/></TD>
</xsl:template>
You will have a load of templates, but this is A Good Thing and will provide you with a stylesheet thats scalable, importable etc... 
Up there with <xsl:variable> in the list of all-time-confusing-things for beginners is the use of xsl:for-each, it really doesnt help anyone understand the idea of how a processor applies a stylesheet.  
(IMHO it shouldnt be taught before apply-templates, but always is)
cheers
andrew
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.458 / Virus Database: 257 - Release Date: 24/02/2003
 
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] for-each within a for-each?, Mike Rudolph | Thread | RE: [xsl] for-each within a for-eac, Mike Rudolph | 
| [xsl] xsl:variable, Laurence Mossuz | Date | RE: [xsl] for-each within a for-eac, Yates, Danny (ANTS) | 
| Month |