Walking the Tree
I'm trying to ensure all the shipment header and lines display in order. I've nested the application of templates of the child elements in the templates of the parent elements. I'm not getting my shipment lines to output at all. What is wrong with the code below? Any help would be appreciated.
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1">
<xsl:output method="html" omit-xml-declaration="yes"/>
<!-- *********************************
****
****
-->
<xsl:template match="/">
<xsl:apply-templates select="OrderShipments/OrderInformation"/>
<xsl:apply-templates select="OrderShipments/Shipment/Header"/>
</xsl:template>
<!-- *********************************
****
****
-->
<xsl:template match="OrderInformation" xml-space="preserve">
<table width="100%" cellpadding="2" cellspacing="0" border="0" bgcolor="black"><tr><td>
<table width="100%" cellpadding="4" cellspacing="0" border="0">
<tr>
<td valign="top">
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<td valign="top"><b>Reference#xa;Number:#xa;</b></td>
<td valign="top"><xsl:value-of select="Reference"/></td>
</tr>
<tr>
<td valign="top"><b>Order#xa;Number:#xa;</b></td>
<td valign="top"><xsl:value-of select="OrderNumber"/></td>
</tr>
<tr>
<td valign="top"><b>PO/Req #:#xa;</b></td>
<td valign="top"><xsl:value-of select="CustomerPO"/></td>
</tr>
<tr>
<td valign="top"><b>Current Status:#xa;</b></td>
<td valign="top"><xsl:value-of select="Status"/></td>
</tr>
</table>
</td>
<td align="right" valign="top">
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<td valign="top">
<b>Requestor:#xa;</b>
</td>
<td valign="top">
<xsl:value-of select="AppUser"/>#xa;
</td>
</tr>
<tr>
<td valign="top"><b>Order#xa;Date:#xa;</b></td>
<td valign="top"><xsl:value-of select="OrderDate"/></td>
</tr>
<tr>
<td valign="top"><b>Requested Ship Date:#xa;</b></td>
<td valign="top"><xsl:value-of select="RequestedShipDate"/></td>
</tr>
</table>
</td>
</tr>
</table>
</td></tr></table>
<p><center><b>
***** SHIPMENT INFORMATION FOR THIS ORDER *****
</b></center></p>
</xsl:template>
<xsl:template match="Header" xml-space="preserve">
<table width="100%" cellpadding="2" cellspacing="0" border="0">
<tr>
<td bgcolor="black"><b>Shipment Information</b></td>
</tr>
<tr>
<td>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="top"><b>Shipment ID:</b>#xa;</td>
<td valign="top"><xsl:value-of select="ShipmentID"/></td>
</tr>
<tr>
<td valign="top"><b>Tracking Number(s):</b>#xa;</td>
<td valign="top"><a href="/"><xsl:value-of select="TrackingNum"/></a></td>
</tr>
<tr>
<td valign="top"><b>Current Status:</b>#xa;</td>
<td valign="top"><xsl:value-of select="Status"/> (as of <xsl:value-of select="StatusDate"/>)</td>
</tr>
<tr>
<td valign="top"><b>Carrier:</b>#xa;</td>
<td valign="top"><xsl:value-of select="Carrier"/></td>
</tr>
<tr>
<td valign="top"><b>Shipment Date:</b>#xa;</td>
<td valign="top"><xsl:value-of select="DateShipped"/></td>
</tr>
<tr>
<td valign="top"><b>Tracking URL:</b>#xa;</td>
<td valign="top"><xsl:value-of select="TrackingURL"/></td>
</tr>
</table>
</td>
</tr>
</table>
<xsl:apply-templates select="OrderShipments/Shipment/Lines"/>
<p/>#xa;
<!--<xsl:for-each select="OrderShipments/Shipment/Lines">
<xsl:apply-templates />
</xsl:for-each> -->
</xsl:template>
<xsl:template match="Lines" xml-space="preserve">
<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td bgcolor="#999999">
<table width="100%" cellpadding="2" cellspacing="1" border="1">
<tr bgcolor="black">
<td width="1%">#xa;</td>
<td><b>Item#xa;Number</b></td>
<td><b>Req.#xa;Ship#xa;Date</b></td>
<td align="right"><b>Order Quantity</b></td>
<td align="right"><b>*Ship Quantity</b></td>
</tr>
<xsl:apply-templates select="OrderShipments/Shipment/Lines/LineItem"/>
</table>
</td></tr></table>
#xa;*Items that have not shipped will not appear
</xsl:template>
<xsl:template match="LineItem" xml-space="preserve">
<tr>
<td bgcolor="#E7E7D1" width="1%" rowspan="2" valign="top"><xsl:value-of select="position()"/></td>
<td bgcolor="#E7E7D1" width="%49"><xsl:value-of select="Item"/></td>
<td bgcolor="#E7E7D1" align="right" width="%16">
<xsl:apply-templates select="OrderQuantity"/>#xa;
<xsl:value-of select="SalesUnit"/>
</td>
<td bgcolor="#E7E7D1" width="%18"><xsl:value-of select="ShippedQuantity"/></td>
</tr>
<tr>
<td bgcolor="#E7E7D1" width="50%" valign="top">
<table border="0" cellpadding="0" cellspacing="0">
<tr><td colspan="2" valign="top"><b>Description:</b>#xa;<xsl:value-of select="ItemDescription"/></td></tr>
</table>
</td>
</tr>
</xsl:template>
<xsl:template match="ShippedQuantity" xml-space="preserve">
<xsl:value-of select="format-number(., '#,###,###')"/>
</xsl:template>
<xsl:template match="OrderQuantity" xml-space="preserve">
<xsl:value-of select="format-number(., '#,###,###')"/>
</xsl:template>
</xsl:stylesheet>
|