Next / Previous / Contents / NM Tech homepage

11.2. Templates for title elements

The next line includes the generated fo-titlepage.xsl that came from the title page customization process; see Section 13, “fo-titlepage.xml: PDF title page templates”.

<!--Use the locally generated title page content-->
<xsl:include href="fo-titlepage.xsl"/>

We want userinput, filename, and several other inlines to have their usual font markup inside the table of contents. This trick is discussed further in Section 7.2, “HTML title page and table of contents”.

<!--Let these elements have their usual appearance in the TOC-->
  <xsl:apply-templates select="." />

11.2.1. The article.title template

This template is invoked from the article title page; see Section 13.3, “Title page for an article.

To produce the standard title page, we want to set up a table with one row and two columns, with the document's title in the left-hand column and the logo in the right-hand column.

As page 161 of Stayton points out, there are three ways to customize titles. In ascending order by precedence:

  1. Customize the title page specification file; see Section 6, “Title page customization: XSLT that builds XSLT”.

  2. Customize the attribute set named

  3. Customize the template named component.title.

Although the this style currently uses only one title element (the article element's title element), customizing component.title affects all title elements, so that approach is a bit too brute-force.

Page 162 of Stayton's book gives the procedure for customizing the title of a particular element:

  1. Copy the stock component.title template from fo/component.xsl to your customization layer, and give it a name. Here, we are customizing the title of an article element, so we'll call our copy article.title. For this template, see Section 11, “zdp_fo.xsl: PDF customization layer”.

  2. Modify the new copy to give the desired format.

  3. In the appropriate part of the title page customization file, replace the reference to component.title with a reference to the new name—in this case, article.title.

So, here is the customized article.title template. The template takes these arguments:


The context node containing the title.


Originally used to specify whether the title should be stretched to the full page width. Not used here.


The unique identifier of the title block. If the title element has no unique ID, one will be generated for it.


The content of the title.

The following code is taken from the original component.title from fo/component.xsl. Some of it is relatively inscrutable, such as the part that mentions the FoTeX extensions (which might matter if we used the PassiveTeX package to produce PDF output).

<!--article.title: Title components--> 
<xsl:template name="article.title">
  <xsl:param name="node" select="."/>
  <xsl:param name="pagewide" select="0"/>
  <xsl:variable name="id">
    <xsl:call-template name="">
      <xsl:with-param name="object" select="$node"/>
  <xsl:variable name="title">
    <xsl:apply-templates select="$node" mode="object.title.markup">
      <xsl:with-param name="allow-anchors" select="1"/>

  <xsl:if test="$passivetex.extensions != 0">
    <fotex:bookmark xmlns:fotex=""
      <xsl:value-of select="$title"/>

The entire title content is wrapped in a fo:block container. The keep-with-next attribute stipulates that we would prefer not to break a page or column right after it. The hyphenate attribute discourages hyphenation in the title block.

  <fo:block keep-with-next.within-column="always"

Here we start the table. Support for the various table models may vary, but table-layout="fixed" definitely works. We use a four-inch column for the title and a two-inch column for the graphic (which was sized for that space).

    <fo:table table-layout="fixed" padding-bottom="0.2in">
      <fo:table-column column-number="1" column-width="4.5in"/>
      <fo:table-column column-number="2" column-width="2.25in"/>

The left-hand column contains the title text, left-justified.

            <fo:block text-align="left">
              <xsl:copy-of select="$title"/>

The right-hand column contains the TCC logo graphic; for the definition of pdf.logo, see Section 12, “The fo_params.xsl file: PDF branding”. The padding-left attribute ensures a separation from the title. And that's the end of the template.


Below the table is the revhistory (revision history) element. Rather than using the RCS timestamp from the DocBook source file, we'll just show the current date and time using the EXSLT date package. This template replaces the stock revhistory template that appears in fo/titlepage.xsl.

<!--revhistory on the title page-->
<xsl:template match="d:revhistory" mode="titlepage.mode">
  <xsl:call-template name="timestamp.block"/>

The timestamp.block template outputs a block containing the current date and time in the format “yyyy-mm-dd HH:MM”.

<xsl:template name="timestamp.block">
  <fo:block text-align="center">
    <xsl:call-template name="datetime.format">
      <xsl:with-param name="date" select="date:date-time()"/>
      <xsl:with-param name="format" select="'Y-m-d H:M'"/>
</xsl:template> <!--timestamp.block-->