Adding Links from the Table of Contents

Here's the new template for the composition

  <xsl:template match="composition">
    <h3>
      <a name="{generate-id()}">
        <xsl:value-of select="title"/>
      </a>
    </h3>

    <ul>
     <xsl:if test="string(date)">
       <li><xsl:value-of select="date"/></li>
     </xsl:if>
     <xsl:if test="string(length)">
       <li><xsl:value-of select="length"/></li>
     </xsl:if>
     <xsl:if test="string(instruments)">
       <li><xsl:value-of select="instruments"/></li>
     </xsl:if>
     <xsl:if test="string(publisher)">
       <li><xsl:value-of select="publisher"/></li>
     </xsl:if>    
    </ul>

    <p><xsl:apply-templates select="description"/></p>    
    
  </xsl:template>

Here's the new template for the tabel of contents link

   <xsl:template match="catalog">
    <head>
       <title><xsl:value-of select="category"/></title>      
    </head>
    <body>
       <!-- Header -->            
       <h1><xsl:value-of select="category"/></h1>
       <ul>
         <xsl:for-each select="composition">
           <xsl:sort select="title"/>
           <li>
             <a href="#{generate-id()}">
               <xsl:value-of select="title"/>
             </a>
           </li>
         </xsl:for-each>
       </ul>
       
       <!-- Body -->            
       <xsl:apply-templates select="composer">
         <xsl:sort select="name/last_name"/>
         <xsl:sort select="name/first_name"/>
         <xsl:sort select="name/middle_name"/>
       </xsl:apply-templates>
       
       <!-- Signature -->      
       <hr/>
       Copyright <xsl:value-of select="copyright"/><br/>
       Last Modified: <xsl:value-of select="last_updated"/><br/>
       <xsl:apply-templates select="maintainer"/>
    </body>
  </xsl:template> 

Although the ID is generated in two separate places, it is generated for the same node. Consequently, they are the same.


View Transformed Document in Netscape
Previous | Next | Top | Cafe con Leche

Copyright 1999-2001 Elliotte Rusty Harold
Elliotte Rusty Harold
Last Modified March 17, 2000