View Single Post
 
Old May 15th, 2009, 12:29 PM
Martin Honnen Martin Honnen is offline
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

The key only uses the date so that is why you get all items. If you change the key to include the program/@id then you should get only the items you are looking for.
I have also cleaned up some stuff:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" indent="yes"/>
 
<xsl:key name="sortdate" match="item" use="concat(docdate, '|', program/@id)"/>
<xsl:param name="project"></xsl:param>
 
 
<xsl:template match="/" name="main">
<xsl:if test="//downloads/item[@category='meeting' or @category='agenda' or @category='summary']/program[@id=$project]">
   <h3 class="sidebar">Meeting Information</h3>
<p style="margin: -8px 0 0 0; font-size: .8em; font-style: italic; color: #887">
   (click on date to view documents)
</p>
 <xsl:for-each select="/downloads/item[@category='meeting' or @category='agenda' or @category='summary'][generate-id(.)=generate-id(key('sortdate', concat(docdate, '|', $project))[1])]">
 <xsl:variable name="myid" select="docdate"/>
   <a style="font-weight: bold" href="javascript:toggleDiv('{$myid}')">
   <h4>
     <xsl:call-template name="format-date">
       <xsl:with-param name="d" select="docdate"/>
     </xsl:call-template>
   </h4>
   </a> 
   <div style="display:none; margin-bottom: 10px" id="{$myid}">
      <table>
         <xsl:for-each select="key('sortdate', concat(docdate, '|', $project))"> 
            <tr>
               <xsl:attribute name="style">
                 <xsl:choose>
                   <xsl:when test="position() mod 2 = 1">
                     <xsl:text>background-color: #fff; border: 0;</xsl:text>
                   </xsl:when>
                   <xsl:otherwise>
                     <xsl:text>background-color: #ede5df; border: 0;</xsl:text>
                   </xsl:otherwise>
                 </xsl:choose>
               </xsl:attribute>
               <td style="padding: 3px">
                  <a href="{xref}">
                    <xsl:value-of select="title"/>
                  </a>
                  <xsl:if test="docsize/mb != ''">
                         <small>
                     <xsl:value-of select="docsize/mb"/>.<xsl:value-of select="docsize/kb"/>Mb
                     </small>
                  </xsl:if>
                  <xsl:call-template name="otrfmt"/>
                  <xsl:if test="comment != ''">
                     <br/>
                     <small> 
                        <xsl:value-of select="comment"/>
                     </small>
                  </xsl:if>
               </td> 
            </tr> 
      </xsl:for-each> 
   </table>
</div> 
</xsl:for-each>
</xsl:if> 
</xsl:template>

<xsl:template name="format-date">
<xsl:param name="d"/>
<xsl:call-template name="long_date"><xsl:with-param name="date" select="$d" /></xsl:call-template>
</xsl:template>

<xsl:template name="long_date">
   <xsl:param name="date" />
   <xsl:variable name="day" select="substring($date, 7, 2)" />
   <xsl:choose>
   <xsl:when test="$day=00"></xsl:when>
   <xsl:when test="$day&lt;32"><xsl:value-of select="substring($date, 7, 2)" /> </xsl:when>
   <xsl:otherwise>INVALID DAY </xsl:otherwise>
  </xsl:choose>   
   <xsl:variable name="month" select="substring($date, 5, 2)" />
   <xsl:choose>
   <xsl:when test="$month=01">January</xsl:when>
   <xsl:when test="$month=02">February</xsl:when>
   <xsl:when test="$month=03">March</xsl:when>
   <xsl:when test="$month=04">April</xsl:when>
   <xsl:when test="$month=05">May</xsl:when>
   <xsl:when test="$month=06">June</xsl:when>
   <xsl:when test="$month=07">July</xsl:when>
   <xsl:when test="$month=08">August</xsl:when>
   <xsl:when test="$month=09">September</xsl:when>
   <xsl:when test="$month=10">October</xsl:when>
   <xsl:when test="$month=11">November</xsl:when>
   <xsl:when test="$month=12">December</xsl:when>
   <xsl:otherwise>INVALID MONTH</xsl:otherwise>
  </xsl:choose> 
   <xsl:value-of select="substring($date, 1, 4)" />
  </xsl:template>
 
 <xsl:template name="otrfmt"> 
 <xsl:choose>
 <xsl:when test="docformat='PDF'">
  <xsl:element name="a">
   <xsl:attribute name="href">http://www.adobe.com/products/acrobat/readstep2.html</xsl:attribute>
   <xsl:element name="img">
    <xsl:attribute name="src">images/pdf_ico.jpg</xsl:attribute>
    <xsl:attribute name="title">Click here to download/install Adobe PDF Reader</xsl:attribute>
    <xsl:attribute name="alt">Click here to download/install Adobe PDF Reader</xsl:attribute>
    <xsl:attribute name="class">dwnldimg</xsl:attribute>
   </xsl:element>
  </xsl:element>
 </xsl:when>
 <xsl:when test="docformat='DOC'">
  <xsl:element name="a">
   <xsl:attribute name="href">http://www.microsoft.com/downloads/details.aspx?FamilyID=3657ce88-7cfa-457a-9aec-f4f827f20cac&amp;DisplayLang=en</xsl:attribute>
   <xsl:element name="img">
    <xsl:attribute name="src">images/word_ico.jpg</xsl:attribute>
    <xsl:attribute name="title">Click here to download/install MS Word Reader</xsl:attribute>
    <xsl:attribute name="alt">Click here to download/install MS Word Reader</xsl:attribute>
    <xsl:attribute name="class">dwnldimg</xsl:attribute>
   </xsl:element> 
  </xsl:element>
 </xsl:when>
 <xsl:when test="docformat='XLS'">
  <xsl:element name="a">
   <xsl:attribute name="href">http://www.microsoft.com/downloads/details.aspx?FamilyID=1cd6acf9-ce06-4e1c-8dcf-f33f669dbc3a&amp;DisplayLang=en</xsl:attribute>
   <xsl:element name="img">
    <xsl:attribute name="src">images/xls_ico.jpg</xsl:attribute>
    <xsl:attribute name="title">Click here to download/install MS Excel Reader</xsl:attribute>
    <xsl:attribute name="alt">Click here to download/install MS Excel Reader</xsl:attribute>
    <xsl:attribute name="class">dwnldimg</xsl:attribute>
   </xsl:element> 
  </xsl:element>
 </xsl:when>
 <xsl:when test="docformat='ZIP'">
  <xsl:element name="a">
   <xsl:attribute name="href">http://www.winzip.com/downwz.htm</xsl:attribute>
   <xsl:element name="img">
    <xsl:attribute name="src">images/zip_ico.jpg</xsl:attribute>
    <xsl:attribute name="title">Click here to download/install WinZip</xsl:attribute>
    <xsl:attribute name="alt">Click here to download/install WinZip</xsl:attribute>
    <xsl:attribute name="class">dwnldimg</xsl:attribute>
   </xsl:element> 
  </xsl:element>
 </xsl:when>
 <xsl:when test="docformat='PPT'">
  <xsl:element name="a">
   <xsl:attribute name="href">http://www.microsoft.com/downloads/details.aspx?FamilyID=048dc840-14e1-467d-8dca-19d2a8fd7485&amp;DisplayLang=en</xsl:attribute>
   <xsl:element name="img">
    <xsl:attribute name="src">images/ppt_ico.jpg</xsl:attribute>
    <xsl:attribute name="title">Click here to install MS Powerpoint Reader</xsl:attribute>
    <xsl:attribute name="alt">Click here to install MS Powerpoint Reader</xsl:attribute>
    <xsl:attribute name="class">dwnldimg</xsl:attribute>
   </xsl:element> 
  </xsl:element>
 </xsl:when>
 <xsl:when test="docformat='JPG'">
  <xsl:element name="img">
   <xsl:attribute name="src">images/jpg_ico.jpg</xsl:attribute>
   <xsl:attribute name="alt"></xsl:attribute>   
   <xsl:attribute name="class">dwnldimg</xsl:attribute>
  </xsl:element>
 </xsl:when>
 <xsl:when test="docformat='MPG'">
  <xsl:element name="img">
   <xsl:attribute name="src">images/mpg_ico.jpg</xsl:attribute>
   <xsl:attribute name="title">This is a MPEG/MPG multimedia file</xsl:attribute>   
   <xsl:attribute name="alt">This is a MPEG/MPG multimedia file</xsl:attribute>   
   <xsl:attribute name="class">dwnldimg</xsl:attribute>
  </xsl:element>
 </xsl:when>
 <xsl:when test="docformat='WMV'">
  <xsl:element name="img">
   <xsl:attribute name="src">images/wmv_ico.jpg</xsl:attribute>
   <xsl:attribute name="title">This is a WMV multimedia file</xsl:attribute>   
   <xsl:attribute name="alt">This is a WMV multimedia file</xsl:attribute>   
   <xsl:attribute name="class">dwnldimg</xsl:attribute>
  </xsl:element>
 </xsl:when>
 <xsl:when test="docformat='TXT'">
  <xsl:element name="img">
   <xsl:attribute name="src">images/txt2_ico.jpg</xsl:attribute>
   <xsl:attribute name="title">This is a Plain Text Format file</xsl:attribute>   
   <xsl:attribute name="alt">This is a Plain Text Format file</xsl:attribute>   
   <xsl:attribute name="class">dwnldimg</xsl:attribute>
  </xsl:element>
 </xsl:when>
 <xsl:when test="docformat='RTF'">
  <xsl:element name="img">
   <xsl:attribute name="src">images/txt_ico.jpg</xsl:attribute>
   <xsl:attribute name="title">This is a Rich Text Format file</xsl:attribute>   
   <xsl:attribute name="alt">This is a Rich Text Format file</xsl:attribute>   
   <xsl:attribute name="class">dwnldimg</xsl:attribute>
  </xsl:element>
 </xsl:when>
 <xsl:when test="docformat='MDB'">
  <xsl:element name="img">
   <xsl:attribute name="src">images/mdb_ico.jpg</xsl:attribute>
   <xsl:attribute name="title">This is a MS Access Database</xsl:attribute>   
   <xsl:attribute name="alt">This is a MS Access Database</xsl:attribute>   
   <xsl:attribute name="class">dwnldimg</xsl:attribute>
  </xsl:element>
 </xsl:when> 
 <xsl:otherwise>
 </xsl:otherwise>
</xsl:choose>
</xsl:template>

</xsl:stylesheet>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog