How to use xsl:template set conditional templates for same element

Suppose you have two types of section element, it can be a text node or a hyperlink.

 
      <section type="internal" title="Lucene Scoring">
        <leaf title="How Lucene scoring works" seotitle="how-lucene-scoring-works">
        </leaf>
      </section>    
      <section type="terminal" title="foo" seotitle="bar">
        <leaf title="hello world" seotitle="how-lucene-scoring-works">
        </leaf>
      </section>
 

When the node is text, we display the title attribute in a h3. Otherwise we will make it a link that can jump to another url.

The match attribute of xsl:template can be any XPath, include conditional one. We can create two different template by set conditional XPath in match attribute.

 
     <xsl:template match="section[@type='internal']">
         <li>
             <div class="toc-section">
             <h3><xsl:value-of select="@title"/></h3>
             <ul>
                 <xsl:apply-templates select="leaf"/>
             </ul>
             </div>
         </li>
     </xsl:template>
     <xsl:template match="section[@type='terminal']">
         <li>
             <div class="toc-section">
             <h3><a>
             <xsl:attribute name="href">http://makble.com/<xsl:value-of select="@seotitle"/>
            </xsl:attribute>    
             <xsl:value-of select="@title"/></a></h3>
             <ul>
                 <xsl:apply-templates select="leaf"/>
             </ul>
             </div>
         </li>
     </xsl:template>
 

You can achieve the same goal using if statement of XSLT, but it will make the code hard to understand. Use different template for each conditional is more clear.