xsl:copy

Right now the descriptions in the output document are pure text. The descriptions in the input document are somewhat more styled and include paragraphs, unordered lists and citations; e.g.

    <description>
      <p>Premiered at Queens College in April, 1996 by Sue Ann Kahn, 
      Christine Ims, and Susan Jolles. In 3 movements :</p>
      <ul>
        <li>mvt. 1: 5:01</li>
        <li>mvt. 2: 4:11</li>
        <li>mvt. 3: 4:26</li>
      </ul>  
    </description>

But all this is stripped by the default template rule used for the description. We can use xsl:copy to move these elements into the output more or less as is. Here are the necessary rules for the four HTML elements found in compositions.xml:

  <xsl:template match="p">
    <xsl:copy>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>  
  
  <!-- pass HTML along unchanged -->
  <xsl:template match="ul">
    <xsl:copy>
      <xsl:apply-templates"/>
    </xsl:copy>
  </xsl:template>  
  
  <xsl:template match="li">
    <xsl:copy>
      <xsl:apply-templates"/>
    </xsl:copy>
  </xsl:template>  
  
  <xsl:template match="cite">
    <xsl:copy>
      <xsl:apply-templates"/>
    </xsl:copy>
  </xsl:template>  

We also have to apply templates to the description element rather than taking its value:

  <xsl:template match="composition">
    <h3><xsl:value-of select="title"/></h3>

    <ul>
     <li><xsl:value-of select="date"/></li>
     <li><xsl:value-of select="length"/></li>
     <li><xsl:value-of select="instruments"/></li>
     <li><xsl:value-of select="publisher"/></li>    
    </ul>

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

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

Copyright 1999 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified September 23, 1999