Table of Contents
The design of title pages is one area where customization is often needed. You may want to customize both the content and the format of your book, article, chapter, or section title pages. DocBook provides a wide range of metadata elements that can be entered in *info
elements such as bookinfo
or chapterinfo
. You may want to output some metadata elements such as author
, but not display others such as revhistory
. Also, a title page for a book would likely contain different information from the title page for an article.
A “title page” in DocBook may not be a separate page. The stylesheets use the term “titlepage” to mean the presentation of an element's title
and other info element content, such as author
and copyright
. The “titlepage” mechanism in the stylesheets
is designed to be very general, so that it handles many different output styles.
Page breaking after the title and info is just one possible feature.
Sometimes it generates separate title pages, as in the FO output
for a book, and sometimes it just prints the title and
info elements without a page break, as in HTML output.
The DocBook XSL stylesheets provide a complete subsystem for customizing title pages. This chapter describes the overall process. Specific details for HTML or FO titlepages are covered in subsequent chapters. Also covered later are certain attribute-sets that can override the properties for some titles.
With the titlepage mechanism described here, you can:
Add or remove information elements on a titlepage.
Change the order that elements appear on a titlepage.
Add formatting attributes to titlepage elements.
Assign a custom template for processing a titlepage element.
The steps for customizing titlepages are listed here, and are further described in the sections that follow.
Create or modify a title page specification file, which is written in XML with its own special element names.
Run a special XSL stylesheet on the spec file to generate your customized title page XSL templates. That's right, you use XSL to generate XSL.
Include the generated templates in your stylesheet customization layer.
Modify templates in mode="titlepage.mode"
to customize how individual elements are handled.
To create your title page spec file for FO output, you can copy fo/titlepage.templates.xml
from the XSL stylesheet distribution. An annotated version of the top of that file follows. To modify title pages for HTML output, you would copy the html/titlepage.templates.xml
instead.
Example 10.1. Title page specification file for FO output
<!DOCTYPE t:templates [ <!ENTITY hsize0 "10pt"> <!ENTITY hsize1 "12pt"> <!ENTITY hsize2 "14.4pt"> <!ENTITY hsize3 "17.28pt"> <!ENTITY hsize4 "20.736pt"> <!ENTITY hsize5 "24.8832pt"> <!ENTITY hsize0space "7.5pt"> <!-- 0.75 * hsize0 --> <!ENTITY hsize1space "9pt"> <!-- 0.75 * hsize1 --> <!ENTITY hsize2space "10.8pt"> <!-- 0.75 * hsize2 --> <!ENTITY hsize3space "12.96pt"> <!-- 0.75 * hsize3 --> <!ENTITY hsize4space "15.552pt"> <!-- 0.75 * hsize4 --> <!ENTITY hsize5space "18.6624pt"> <!-- 0.75 * hsize5 --> ]> <t:templates xmlns:t="http://nwalsh.com/docbook/xsl/template/1.0" xmlns:param="http://nwalsh.com/docbook/xsl/template/1.0/param" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- =============================================================== --> <t:titlepage t:element="article" t:wrapper="fo:block" font-family="{$title.fontset}" > <t:titlepage-content t:side="recto" text-align="center"> <title t:named-template="component.title" param:node="ancestor-or-self::article[1]" font-size="&hsize5;" font-weight="bold" keep-with-next="always" /> <subtitle/> <corpauthor space-before="0.5em" font-size="&hsize2;"/> <authorgroup space-before="0.5em" font-size="&hsize2;"/> <author space-before="0.5em" font-size="&hsize2;"/> ... </t:titlepage-content> <t:titlepage-content t:side="verso"> </t:titlepage-content> <t:titlepage-before t:side="recto"> </t:titlepage-before> <t:titlepage-before t:side="verso"> </t:titlepage-before> <t:titlepage-separator> </t:titlepage-separator> </t:titlepage>
The titlepage specifcation file for HTML output is similar to the one for FO output. It uses the same element names in the t:
namespace, and you can add, remove, or move information elements for any of the titlepages.
These are some of the main differences for the HTML spec file:
Formatting properties are generally left out of the HTML spec file. That's because an external CSS stylesheet is the preferred method for formatting HTML.
To assist in applying CSS styles, each element's titlepage gets a class
attribute so that CSS class selectors can be used. The value is titlepage
by default, but can be changed to be more specific.
The terms recto
and verso
are meaningless in a pageless presentation like HTML. So all content is specified on the recto
titlepage.
The titlepage spec files include a few special titlepage elements that don't correspond to actual DocBook elements. For example:
<t:titlepage t:element="table.of.contents" t:wrapper="fo:block">
This set of specs handles the formatting for the title in the table of contents. Since that title is generated by the stylesheets, it does not actually come from a DocBook element. But the stylesheet lets you add properties to control its formatting.
DocBook XSL: The Complete Guide - 3rd Edition | PDF version available | Copyright © 2002-2005 Sagehill Enterprises |