Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL with looping for loop within xml??hmmm??

Status
Not open for further replies.

msturges

Programmer
Mar 29, 2001
32
0
0
ZA
Hi everybody,

I have an xml file that looks like this:


<?xml version=&quot;1.0&quot;?>
<?xml-stylesheet href=&quot;WAstylesheet.xsl&quot; type=&quot;text/xsl&quot;?>
<order no=&quot;809819&quot;>
<Sender>Karim Abdul Jabbar</Sender>
<orderNo>809819</orderNo>
<orderDate>2002/01/22</orderDate>
<orderPoint>6004930005005</orderPoint>
<invoicePoint>6004930001575</invoicePoint>
<supplierPoint>6004931241000</supplierPoint>
<deliveryDates>
<earliest>2002/01/22</earliest>
<latest>2002/01/31</latest>
</deliveryDates>
<transactionCode>Transaction Code</transactionCode>
<narrative>
<styleID>40:03:02:01:99:13</styleID>
<desc>GIRLS UNDERWEAR</desc>
<buyerName>RENSKE KRUGER</buyerName>
<totalOrderQty>2000</totalOrderQty>
<reqNo>809819</reqNo>
<daysToPay>90 DAYS</daysToPay>
<distributionDiscount>4.00</distributionDiscount>
<fabric>SINGLE JERSEY</fabric>
<packSize>5</packSize>
<packing>SOLID COLOUR, SOLID SIZE</packing>
</narrative>
[red] <Product id=&quot;555-000004&quot;>
<Prod_Code>555-000004</Prod_Code>
<Colour>Blue</Colour>
<Qty_Ordered>4</Qty_Ordered>
<Size>Large</Size>
<Price>R40.00</Price>
<sellPrice>R46.00</sellPrice>
<prTotal>R160.00</prTotal>
</Product>
<Product id=&quot;777-000004&quot;>
<Prod_Code>777-000004</Prod_Code>
<Colour>Green</Colour>
<Qty_Ordered>12</Qty_Ordered>
<Size>36cm</Size>
<Price>R40.00</Price>
<sellPrice>R46.00</sellPrice>
<prTotal>R160.00</prTotal>
</Product>
<Product id=&quot;888-000004&quot;>
<Prod_Code>888-000004</Prod_Code>
<Colour>Assorted</Colour>
<Qty_Ordered>100</Qty_Ordered>
<Size>11/12</Size>
<Price>R40.00</Price>
<sellPrice>R46.00</sellPrice>
<prTotal>R160.00</prTotal>
</Product> [/red]
<orTotal>210</orTotal>
</order>


Now, for each occurance of the Product element, I have an xsl to represent it. The problem I'm experiencing is that I need to create a display that pertains to that specific Product element, however, I also need to incorporate info which comes from sibling elements.(hope that makes sense).

Can anyone tell me how I can 'loop' through the Product elements and create a seperate representation of each??

heres my xsl as it stands now:


<?xml version='1.0'?><xsl:stylesheet version=&quot;1.0&quot; exclude-result-prefixes=&quot;xsl msxsl&quot; xmlns:xsl=&quot; xmlns:msxsl=&quot;urn:schemas-microsoft-com:xslt&quot; xmlns:sql=&quot;urn:schemas-microsoft-com:xml-sql&quot; xmlns:xsi=&quot; <xsl:template match=&quot;/&quot;> <HTML>
<HEAD>
<link rel=&quot;stylesheet&quot; href=&quot;textStyles.css&quot; type=&quot;text/css&quot;/>
</HEAD> <BODY BGCOLOR=&quot;#FFFFFF&quot; TEXT=&quot;black&quot; LINK=&quot;#FF0000&quot; VLINK=&quot;#0000FF&quot; >

<xsl:for-each select=&quot;order&quot;>
<CENTER>
<table width=&quot;100%&quot; border=&quot;0&quot; align=&quot;center&quot;>
<tr>
<td align=&quot;left&quot;>
<h1><font face=&quot;Times New Roman, Times, serif&quot;><b>P/O : <xsl:value-of select=&quot;orderNo&quot;/></b></font></h1>
</td>
</tr>
<tr>
<td height=&quot;99&quot;>
<h3>STYLE : <xsl:value-of select=&quot;narrative/styleID&quot;/></h3>
<br/>
<h4><xsl:value-of select=&quot;narrative/desc&quot;/></h4>
</td>
</tr>
<tr>
<td>
<h2>SKU : <xsl:value-of select=&quot;Product/Prod_Code&quot;/></h2>
<h2>SIZE : <xsl:value-of select=&quot;Product/Size&quot;/></h2>
<h2>COLOUR : <xsl:value-of select=&quot;Product/Colour&quot;/></h2>
<h2>QTY : <xsl:value-of select=&quot;Product/Qty_Ordered&quot;/></h2>
</td>
</tr>
<tr>
<td>
<table width=&quot;80%&quot; align=&quot;left&quot;>
<tr>
<td rowspan=&quot;2&quot; width=&quot;40%&quot;>barcode</td>
<td width=&quot;70%&quot; align=&quot;center&quot;>
<h4>Carton Number : </h4>
</td>
<td width=&quot;100&quot; align=&quot;center&quot;>
<table width=&quot;75&quot; border=&quot;1&quot; height=&quot;75&quot;>
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align=&quot;center&quot;>
<h4>Quality Checked :</h4>
</td>
<td align=&quot;center&quot; width=&quot;100&quot;>
<table width=&quot;75&quot; border=&quot;1&quot; height=&quot;75&quot;>
<tr>
<td></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan=&quot;3&quot;></td>
</tr>
</table>
<br/>
</td>
</tr>
<tr>
<td align=&quot;left&quot;>
<table width=&quot;80%&quot; border=&quot;0&quot;>
</table>
</td>
</tr>
</table>
</CENTER>
</xsl:for-each>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>


Any assistance would be a great help.

Thank you

God Bless

Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top