Next / Previous / Contents / NM Tech homepage

7.3.2. The top.nav.bar template

The top.nav.bar template generates the standard HTML page-top navigation bar. It takes three parameters:

prev

Previous page's node, or empty if this is the first page.

next

Next page's node, or empty if this is the last page.

home

Node for the home page.

zdp_html.xsl
<!--top.nav.bar: Top-of-page navigational features-->
<xsl:template name="top.nav.bar">
  <xsl:param name="prev"/>
  <xsl:param name="next"/>
  <xsl:param name="home"/>

The nav bar is wrapped in a div element to put it all in a separate block. This element has class topnavbar so that a CSS stylesheet can change the appearance of this element.

zdp_html.xsl
  <div class="topnavbar">

The word “Next” always appears: it is a link if there is a next page, or a placeholder if not.

zdp_html.xsl
    <!--"Next" link-->
    <xsl:choose>
      <xsl:when test="count($next) &gt; 0">  <!-- Is there a prev? -->
        <a>
          <xsl:attribute name="href">
            <xsl:call-template name="href.target">
              <xsl:with-param name="object" select="$next"/>
            </xsl:call-template>
          </xsl:attribute>
          <xsl:text>Next</xsl:text>
        </a>          
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>Next</xsl:text>
      </xsl:otherwise>
    </xsl:choose>

Next we output a slash, with spaces around it, to separate “Next” from “Previous”.

zdp_html.xsl
    <xsl:text> / </xsl:text>

Generation of the “Previous” link is similar: it is an actual link if there is a previous page, otherwise it is the word “Previous” as a placeholder.

zdp_html.xsl
    <!--"Prev" link-->
    <xsl:choose>
      <xsl:when test="count($prev) &gt; 0">  <!-- Is there a prev? -->
        <a>
          <xsl:attribute name="href">
            <xsl:call-template name="href.target">
              <xsl:with-param name="object" select="$prev"/>
            </xsl:call-template>
          </xsl:attribute>
          <xsl:text>Previous</xsl:text>
        </a>          
      </xsl:when>
      <xsl:otherwise>
        <xsl:text>Previous</xsl:text>
      </xsl:otherwise>
    </xsl:choose>

Again, we output a slash to set off following elements.

zdp_html.xsl
    <xsl:text> / </xsl:text>

The “home” link here is called “Contents.” Again, it is followed by a slash.

zdp_html.xsl
    <a>
      <!--"Contents" link-->
      <xsl:attribute name="href">
        <xsl:call-template name="href.target">
          <xsl:with-param name="object" select="$home"/>
        </xsl:call-template>
      </xsl:attribute>
      <xsl:text>Contents</xsl:text>
    </a>
    <xsl:text> / </xsl:text>

Lastly we output links to the help system and the homepage.

zdp_html.xsl
    <!--"Help" link (optional)-->
    <xsl:if test="$help.url">
      <a href="{$help.url}" >
        <xsl:value-of select="$help.short.name" />
        <xsl:text> / </xsl:text>
      </a >
    </xsl:if>
    
    <!--"Home" link-->
    <a href="{$home.url}" >
      <xsl:value-of select="$home.short.name" />
    </a>
  </div>
</xsl:template>  <!--End of top.nav.bar-->