XML technologies / DocBook / The DocBook XSL stylesheets / Indirectly customizing a title page
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
In DocBook, a title page presents a title or subtitle element, for example for a book, chapter, or section, with related metadata such as authors and legal notices. DocBook supports many elements that can appear on a title page:
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
Why customize a title page?
To change the order of elements on the title page.
To show certain elements on the title page and hide others.
To make displayed and suppressed elements depend on context, so that a chapter title page can show different information from a book part.
To include company-specific features such as logos, links, and addresses as part of a corporate identity.
To distinguish a draft from a final document. Version information and other details may be useful in a draft but hidden in the final version.
There are two ways to customize a title page:
Customize a title page specification file. Its contents depend on the output format. This method is described in the following procedure.
Customize the relevant templates directly, as described in Customizing a title page directly.
A specification file is an XML file with entries for left-hand (verso) and right-hand (recto) pages. This distinction is irrelevant to (X)HTML, so all entries are made on a recto page.
The specification file contains DocBook elements and elements from the namespace "http://nwalsh.com/docbook/xsl/template/1.0". For an overview of all elements, see Titlepage Template Stylesheet Reference. The following example shows the basic structure:
Example: Excerpt from an article specification file, (X)HTML output
<t:templates xmlns:t="http://nwalsh.com/docbook/xsl/template/1.0" xmlns:param="http://nwalsh.com/docbook/xsl/template/1.0/param" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<t:titlepage t:element="article" t:wrapper="div" class="titlepage">
<t:titlepage-content t:side="recto">
<title/>
<subtitle/>
<corpauthor/>
<authorgroup/>
<author/>
<othercredit/>
<releaseinfo/>
<copyright/>
<legalnotice/>
<pubdate/>
<revision/>
<revhistory/>
<abstract/>
</t:titlepage-content>
<t:titlepage-content t:side="verso"></t:titlepage-content>
<t:titlepage-separator><hr/></t:titlepage-separator>
<t:titlepage-before t:side="recto"></t:titlepage-before>
<t:titlepage-before t:side="verso"></t:titlepage-before>
</t:titlepage>
<!-- Weitere t:titlepage-Elemente... -->
</t:templates>Line 1: Root element with namespace declarations. All processing elements and attributes use t — the namespace prefix.
Line 2: A t:titlepage contains the structure of a title page, here for the element article. t:wrapper: Target element wrapping the title page; for (X)HTML, this is div. The attribute class and its value are inserted into the element specified in t:wrapper. This example creates an element <div class="titlepage">.
Line 3: Contents of an article’s recto title page. The order of DocBook elements matches the output order.
Line 18: Contents of an article’s verso title page. Irrelevant for (X)HTML, so the contents are empty.
Line 19: A t:titlepage-separator separates the title page from the rest of the contents.
Lines 20 and 21: These elements contain material inserted before the recto and verso pages respectively. Their contents are empty for (X)HTML.
Each t:titlepage element has two t:titlepage-content with recto and verso in the attribute t:side, two t:titlepage-before (also with the corresponding attributes), and one t:titlepage-separator. The output order is as follows:
t:titlepage-before t:side="recto"
t:titlepage-content t:side="recto"
t:titlepage-before t:side="verso"
t:titlepage-content t:side="verso"
t:titlepage-separatorThe following procedure creates an article title page for (X)HTML output:
Creating the specification file
Copy the filehtml/titlepage.template.xmland remove all entries fort:titlepagethat are irrelevant to your customization. However, keep thet:titlepageelement with an attributet:elementwith the valuearticle(see the example “Excerpt from an article specification file, (X)HTML output”).Customizing the title page
Add new DocBook elements insidet:titlepage-content, reorder them, or remove those you do not need. Add only DocBook elements allowed insidearticleinfoorinfo.Generating the stylesheet
Apply the stylesheettemplate/titlepage.xslto your specification file:
xsltproc --output mytitlepage.xsl \
DB/template/titlepage.xsl \
mytitlepage.spec.xmlReplace the placeholder
DBwith the DocBook stylesheet installation path. The transformation produces a stylesheet containing exactly the DocBook elements and order specified in your specification file.
Including the stylesheet in a customization file
Include the stylesheet generated in step 3 in your customization file:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="DBBASISURI/html/docbook.xsl"/>
<xsl:include href="mytitlepage.xsl"/>
<!-- weitere Einträge -->
</xsl:stylesheet>Replace the placeholder
DBBASISURIwith the corresponding official URI.
Copyright © 2009 Millin Verlag
You may print the online version for your private use.
Otherwise, this chapter from "DocBook-XML: Medienneutrales und plattformunabhängiges Publizieren" is subject to the same provisions as the printed edition: the work, including all its parts, is protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Millin Verlag, Siebengebirgsring 36, 53797 Lohmar, info(at)millin.de
back to top