Adding Links from the Table of Contents

Here's the new template for the composition

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

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

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

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

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

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