The first customization is to force userinput, filename, and several other inlines to have their usual font markup inside the table of contents. This trick is discussed further in Section 6.2, “HTML title page and table of contents”.
<xsl:template
match="filename|sgmltag|userinput|varname|application"
mode="no.anchor.mode">
<xsl:apply-templates select="." />
</xsl:template>
|
To produce the standard TCC 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 TCC 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:
Customize the title page specification file; see Section 5, “Title page customization: XSLT that builds XSLT”.
Customize the attribute set named component.title.properties.
Customize the template named component.title.
Although the TCC 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:
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 8, “tcc_fo.xsl: PDF customization layer”.
Modify the new copy to give the desired format.
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).
<xsl:template name="component.title">
<xsl:param name="node" select="."/>
<xsl:param name="pagewide" select="0"/>
<xsl:variable name="id">
<xsl:call-template name="object.id">
<xsl:with-param name="object" select="$node"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="title">
<xsl:apply-templates select="$node" mode="object.title.markup">
<xsl:with-param name="allow-anchors" select="1"/>
</xsl:apply-templates>
</xsl:variable>
<xsl:if test="$passivetex.extensions != 0">
<fotex:bookmark xmlns:fotex="http://www.tug.org/fotex"
fotex-bookmark-level="2"
fotex-bookmark-label="{$id}">
<xsl:value-of select="$title"/>
</fotex:bookmark>
</xsl:if>
|
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"
hyphenate="false">
|
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="4in"/>
<fo:table-column column-number="2" column-width="2in"/>
<fo:table-body>
<fo:table-row>
|
The left-hand column contains the title text, left-justified.
<fo:table-cell>
<fo:block text-align="left">
<xsl:copy-of select="$title"/>
</fo:block>
</fo:table-cell>
|
The right-hand column contains the TCC logo graphic. And that's the end of the template.
<fo:table-cell>
<fo:block>
<fo:external-graphic src="url(logo.jpg)"
content-width="2in"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</xsl: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.
<xsl:template match="revhistory" mode="titlepage.mode">
<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:call-template>
</fo:block>
</xsl:template>
|