<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes" />

<!--  Change parameters here  -->
<xsl:variable name="d1">20010407</xsl:variable>
<xsl:variable name="d2">20010609</xsl:variable>
<xsl:variable name="str1">lamps</xsl:variable>
<xsl:variable name="str2">shelves</xsl:variable>
<!--                          -->

<xsl:template match="/">
  <html>
  <body>

    <h4 align = "center" >
      List all Purchase Orders between certain dates where the purchases 
      include "lamps" or "shelves" 
    </h4>                                      

    <table cellpadding="4" border="1">
      <thead>
        <th>Tracking #                    </th>
        <th>Date                          </th>
        <th>Status                        </th>
        <th>Login Nam                     </th>
        <th>Item                          </th>
      </thead>
      <xsl:apply-templates select= 
        "//PO/Id[substring-after(date,'//') &gt; $d1  and
                 substring-after(date,'//') &lt; $d2]" />
    </table>
  </body>
  </html>
</xsl:template>

<xsl:template match="Id">
  <xsl:for-each select = "ancestor::PO//Description">
    <xsl:if test = "contains(.,$str1) or contains(.,$str2)">
    <tr>
      <td> <xsl:value-of select="ancestor::PO//trackNbr" />   </td>
      <td> <xsl:value-of select="ancestor::PO//date" />       </td>
      <td> <xsl:value-of select="ancestor::PO//status" />     </td>
      <td> <xsl:value-of select="ancestor::PO//login" />      </td>
      <td> <xsl:value-of select="ancestor::PO/Items/Item[1]/Description"/> <br />
           <xsl:value-of select="ancestor::PO/Items/Item[2]/Description"/> <br />
           <xsl:value-of select="ancestor::PO/Items/Item[3]/Description"/> <br />
                                                              </td>
    </tr> 
    </xsl:if> 
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>
