The DocBook stylesheets generate HTML heading elements H1, H2, H3, etc. according to the hierarchy of elements in the document. However, you may want to alter which HTML heading level gets assigned to a particular element. Keep in mind that you need not customize the XSL just to change the styling, because an external CSS stylesheet can handle that. But if you need to change the heading level elements, the following are some guidelines.
Unless otherwise specified, the title of the document's root element, such as book, is handled by the template that starts with this line in html/titlepage.xsl:
<xsl:template match="title" mode="titlepage.mode">
This template outputs an H1 element. You could add a customized template to match on book/title in that mode to change just book titles.
A part title is handled by the template named division.title in the stylesheet module html/division.xsl. That template was specified in the titlepage spec file. You could customize that template, or customize the titlepage spec file to use a new named template instead for part title elements.
A chapter or appendix title is handled by a template named component.title in the stylesheet module html/component.xsl. That template is used for other component-level elements such as bibliography that might appear inside a section. So it first computes a level variable based on its ancestry, and then adds 1 to that to use in an HTML heading element. Since chapter cannot appear inside a section, the level value is 1, and so an H2 heading is produced.
A section title is handled by a template named section.heading in the stylesheet module html/sections.xsl. That template is called from a template named section.title with a template parameter named level computed by using the template named section.level.
| DocBook XSL: The Complete Guide - 4th Edition | PDF version available | Copyright © 2002-2007 Sagehill Enterprises |