A formatting feature that is commonly used in longer HTML output is a link at each section title that enables the reader to return to the top of the page. If you are using section
elements, then the following customization will do it. Versions are provided for both chunked and non-chunked HTML. Put the appropriate version in your customization stylesheet.
Use this version for section in chunked output: <xsl:template name="section.titlepage.before.recto"> <xsl:variable name="level"> <xsl:call-template name="section.level"/> </xsl:variable> <xsl:variable name="chunkfn"> <xsl:apply-templates mode="chunk-filename" select="."/> </xsl:variable> <xsl:if test="$level > $chunk.section.depth"> <p class="returntotop"> <a href="{$chunkfn}"> <xsl:text>Return to top</xsl:text> </a> </p> </xsl:if> </xsl:template> Use this version for section in non-chunked output: <xsl:template name="section.titlepage.before.recto"> <xsl:variable name="top-anchor"> <xsl:call-template name="object.id"> <xsl:with-param name="object" select="/*[1]"/> </xsl:call-template> </xsl:variable> <p class="returntotop"> <a href="#{$top-anchor}"> <xsl:text>Return to top</xsl:text> </a> </p> </xsl:template>
They both make use of the placeholder template named
section.titlepage.before.recto
.
This template is called just before the template that generates a section
title, so it will put
the link to the top just before each section title. You can customize the
look with
CSS applied to the class="returntotop"
selector.
If you are using sect1
, sect2
, etc. instead of section
, you will need to
create customized
templates for sect1.titlepage.before.recto
, and the same for sect2, sect3,
etc.
DocBook XSL: The Complete Guide - 4th Edition | PDF version available | Copyright © 2002-2007 Sagehill Enterprises |