Example 17-30: Library stylesheet to handle formatting of breadcrumbs

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <!--
   | UtilBreadCrumbs.xsl: Transform <breadcrumbs> structural info
   |                      into HTML breadcrumbs presentation.
   +-->
  <xsl:template match="breadcrumbs">
    <center>
      <span class="breadcrumbs">
        <xsl:choose>
          <xsl:when test=".//forumname">
            <!--
             | Even though we're only expecting one row, this moves the current
             | node to allow XPath's inside to use shorter relative paths
             +-->
            <a href="Forums.xsql">Forums</a>
            <xsl:text> > </xsl:text>
            <xsl:choose>
              <xsl:when test=".//topicname">
                <a>
                  <xsl:attribute name="href">
                    <xsl:choose>
                      <xsl:when test="..//forumname/@url">
                        <xsl:value-of select=".//forumname/@url"/>
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:text>ForumTopics.xsql?id=</xsl:text>
                        <xsl:value-of select=".//forumid"/>
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:attribute>
                  <xsl:value-of select=".//forumname"/>
                </a>
                <xsl:text> > </xsl:text>
                <xsl:value-of select=".//topicname"/>
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select=".//forumname"/>
              </xsl:otherwise>
            </xsl:choose>
          </xsl:when>
          <xsl:otherwise>
            <xsl:text>Forums</xsl:text>
          </xsl:otherwise>
        </xsl:choose>
      </span>
    </center>
    <hr/>
  </xsl:template>
</xsl:stylesheet>