Next / Previous / Contents / TCC Help System / NM Tech homepage

9. fo-titlepage.xml: PDF title page template

Here is the fo-titlepage.xml template file. This file is a modified copy of file fo/titlepage.templates.xml in the stock DocBook XSL Stylesheets distribution.

The fo-titlepage.xml file starts with the usual DOCTYPE declaration. This declaration contains a number of entity declarations used to specify a series of font sizes, each 20% larger than the one before, and also a series of three-quarter-em spaces.

<!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 -->
]>

Next comes the root element, which contains declarations for the various namespaces.

<!--File fo-titlepage.xml.  For documentation, see:
 !    http://www.nmt.edu/tcc/doc/docbook42xep/ims/ 
 !-->
<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">

Most of these namespaces are the same ones used in the HTML titlepage template (see Section 7, “html-titlepage.xml: HTML title page template”). The one new namespace, “fo:”, is the Formatting Objects namespace.

Next comes a t:titlepage element that specifies the title page layout for the DocBook article element.

t:element="article"

Specifies the DocBook element to which this format applies.

t:wrapper="fo:block"

The content of this title page will be wrapped in a FO block element.

font-family="{$title.fontset}"

Specifies a set of font attributes to be used to display the title. Defined in fo/pagesetup.xsl in the DocBook XSL Stylesheets.

<t:titlepage t:element="article" t:wrapper="fo:block"
             font-family="{$title.fontset}">

The t:titlepage-content element specifies what to put on the right-hand (recto) page, and also specifies centering for the titles.

  <t:titlepage-content t:side="recto"
             text-align="center">

Next is the title element, which describes how to format the DocBook title element.

t:named-template="article.title"

This attribute tells the XSL processor to use the template named article.title to format the title. This is a local customization; see Section 8.2, “Templates for title elements”. The stock template calls the uncustomized component.title here.

param:node="ancestor-or-self::article[1]"

The created template will match the first (and typically the only) article element in the DocBook source.

keep-with-next="always"

This XSL-FO attribute specifies that there should be no page break after the title.

font-size="&hsize5;"

Set the title in the largest-size font.

font-weight="bold"

Set the title in boldface font.

    <title t:named-template="article.title"
        param:node="ancestor-or-self::article[1]"
        keep-with-next="always"
        font-size="&hsize5;"
        font-weight="bold"/>

The remainder of this file is exactly as it looks in the stock fo/titlepage.templates.xml file.

    <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;"/>

    <othercredit space-before="0.5em"/>
    <releaseinfo space-before="0.5em"/>
    <copyright space-before="0.5em"/>
    <legalnotice text-align="start"
                 margin-left="0.5in"
                 margin-right="0.5in"
                 font-family="{$body.fontset}"/>
    <pubdate space-before="0.5em"/>
    <revhistory space-before="0.5em"/>
    <revision space-before="0.5em"/>
    <abstract space-before="0.5em"
        text-align="start"
        margin-left="0.5in"
        margin-right="0.5in"
        font-family="{$body.fontset}"/>
  </t:titlepage-content>

  <t:titlepage-content t:side="verso">
  </t:titlepage-content>

  <t:titlepage-separator>
  </t:titlepage-separator>

  <t:titlepage-before t:side="recto">
  </t:titlepage-before>

  <t:titlepage-before t:side="verso">
  </t:titlepage-before>
</t:titlepage>

</t:templates>

As in Section 7, “html-titlepage.xml: HTML title page template”, the many other title elements are omitted here. If it is later necessary to add titlepage content for other DocBook elements such as book, they can be added here, copied from the stock fo/titlepage.templates.xml file.