<?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">20010508</xsl:variable>
<xsl:variable name="d2">20010512</xsl:variable>
<xsl:variable name="str1">packing-slip</xsl:variable>
<!--                          -->

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

    <h4 align = "center">
      Abbreviated list of Purchase Orders that have a packing slip 
      attachment
    </h4>                                                   

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

<xsl:template match="PO"> 
   <xsl:variable name = "dt" select = 
     "concat(substring(Id/date,5,6), substring(Id/date,24,5))" />

  <xsl:for-each select = "Attachments/attachment" >
    <xsl:if test = "@type = $str1" >
      <tr>
      <td> <xsl:value-of select="ancestor::PO//trackNbr" />  </td>
      <td> <xsl:value-of select="$dt"/>                      </td>
      <td> <xsl:value-of select="ancestor::PO//status" />    </td>
      <td> <xsl:value-of select="ancestor::PO//login" />     </td>
      <td> Packing slip:
           <xsl:element name="a">
             <xsl:attribute name="href">
               <xsl:value-of select = "link" />             
             </xsl:attribute>
             <xsl:value-of select = "link" />
           </xsl:element>                        </td> 
      </tr>           
    </xsl:if>  
  </xsl:for-each>
      
</xsl:template>

</xsl:stylesheet>
