Next / Previous / Contents / NM Tech homepage

7.3. HTML headers and footers

We completely replace the header.navigation and footer.navigation templates. See page 140 of Stayton for a description of when these templates are called.

7.3.1. The header.navigation template

The first template we define is header.navigation, which sets up the top-of-page features in HTML. This template is a customized copy of the stock header.navigation template from html/chunk-common.xsl.

The template takes three parameters:

prev

The previous page's node, or empty if this is the first child of its parent.

next

The next page's node, or empty if there is none.

nav.context

Not used by this template. If you're curious about what it does in the stock template, see the stock template in html/chunk-common.xsl.

zdp_html.xsl
<!--header.navigation: Navigational links in the page header-->
<xsl:template name="header.navigation">
  <xsl:param name="prev" select="/foo"/>
  <xsl:param name="next" select="/foo"/>
  <xsl:param name="nav.context"/>

Next are two variables internal to this template:

home

The root element of the DocBook document. The XPath expression "/*[1]" selects the first child of the document root, which is probably an article.

up

The parent element of this node. The XPath expression "parent::*" selects the parent node.

zdp_html.xsl
  <xsl:variable name="home" select="/*[1]"/>
  <xsl:variable name="up" select="parent::*"/>

The first HTML header element is the top-of-page navigational bar, containing the links “Next / Prev / ...” and so forth. This is produced by calling the top.nav.bar template, and passing our prev, next, and home nodes to it.

zdp_html.xsl
  <xsl:call-template name="top.nav.bar">
    <xsl:with-param name="prev" select="$prev"/>
    <xsl:with-param name="next" select="$next"/>
    <xsl:with-param name="home" select="$home"/>
  </xsl:call-template>

Next is a small table, with one row and two columns, that positions the title on the top left and the logo on the top right. This is wrapped in a div element with class navheader so that a CSS stylesheet can customize the appearance of this area.

zdp_html.xsl
  <!--Navigational links in the page header-->
  <div class="navheader">
    <table width="100%" summary="Navigation header">
      <tr valign="top">
        <td align="left" valign="top">
          <h1>
            <xsl:apply-templates select="$home"
                mode="object.title.markup"/>
          </h1>
        </td>
        <td>
          <img alt="logo" src="{$html.logo}"/>
        </td>
      </tr>
    </table>

The mode="object.title.markup" template call causes the title text to be inserted as content of the HTML h1 element.

Lastly, we add a horizontal rule to set off the header from the page body.

zdp_html.xsl
    <hr/>
  </div>
</xsl:template>