Specifying Patterns for the match Attribute (2)


Example:

XSL Style Sheet
   <?xml version="1.0"?> 
   <xsl:stylesheet version="1.0" 
                   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:template match="/">
         <HTML>
         <HEAD>
            <TITLE>Names</TITLE>
         </HEAD>
         <BODY>
            <xsl:apply-templates/>
         </BODY>
         </HTML>
      </xsl:template>

      <xsl:template match="text()">
      </xsl:template>

      <xsl:template match="course/name">
         <H2>
            <xsl:value-of select="."/> 
         </H2>
      </xsl:template>

      <xsl:template match="course/*/name">
         <H3>
            <xsl:value-of select="."/> 
         </H3>
      </xsl:template>
   </xsl:stylesheet>

HTML output file:
   <HTML>
   <HEAD>
   <TITLE>Names</TITLE>
   </HEAD>
   <BODY>
   <H2>Programming XML in Java</H2> 
   <H3>John Smith</H3>
   <H3>George Lucas</H3>
   <H3>Elizabeth Roberts</H3>
   </BODY>
   </HTML>