Hi Paul,
I haven't worked with the FO stylesheets at all, only HTML/XHTML. However, I
recently (with Bob's help, after much circling-running myself) wrote a
customization to accomplish something similar. I imagine the customization for
FO would be fairly similar in structure. So perhaps this will get you started.
Fair warning, others may have more sound/efficient ways of doing this, as I'm
still fairly new to XSLT.
In my customization layer, I created a new parameter called chapter.label.text.
<xsl:param name="chapter.label.text">Chapter </xsl:param>
In this parameter, you can put any text that you want to function as the
autolabel text (usually "Chapter"). You can also empty this parameter to
generate no chapter label. (By doing this, I'm foregoing the gentext label, but
this customization allows my non-XSLT partners to more easily customize this
label from project to project.)
Also, it was important to me to be able to style the chapter-label and
autolabel number separately from the chapter title. I'm not sure how you do
this in FO, but in HTML I put the chapter label in its own h-tag, separate from
the chapter title.
Here's the final customization I used in XHTML1.1, picking up and changing the
component.title template.
<xsl:template name="component.title">
<xsl:param name="node" select="."/>
<!-- This handles the case where a component (bibliography, for example)
occurs inside a section; will we need parameters for this? -->
<!-- This "level" is a section level. To compute <h> level, add 1. -->
<xsl:variable name="level">
<xsl:choose>
<!-- chapters and other book children should get <h1> -->
<xsl:when test="$node/parent::d:book">0</xsl:when>
<xsl:when test="ancestor::d:section">
<xsl:value-of select="count(ancestor::d:section)+1"/>
</xsl:when>
<xsl:when test="ancestor::d:sect5">6</xsl:when>
<xsl:when test="ancestor::d:sect4">5</xsl:when>
<xsl:when test="ancestor::d:sect3">4</xsl:when>
<xsl:when test="ancestor::d:sect2">3</xsl:when>
<xsl:when test="ancestor::d:sect1">2</xsl:when>
<xsl:otherwise>1</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="local-name($node) = 'chapter'">
<h1 class="chapter-label">
<xsl:copy-of select="$chapter.label.text"/>
<xsl:apply-templates select="$node" mode="label.markup"/>
</h1>
<h1 class="title">
<xsl:apply-templates select="$node" mode="title.markup"/>
</h1>
</xsl:when>
<xsl:otherwise>
<xsl:element name="h{$level+1}"
namespace="http://www.w3.org/1999/xhtml">
<xsl:attribute name="class">title</xsl:attribute>
<xsl:call-template name="id.attribute"/>
<xsl:call-template name="anchor">
<xsl:with-param name="node" select="$node"/>
<xsl:with-param name="conditional" select="0"/>
</xsl:call-template>
<xsl:apply-templates select="$node" mode="object.title.markup">
<xsl:with-param name="allow-anchors" select="1"/>
</xsl:apply-templates>
<xsl:apply-templates select="$node" mode="label.markup">
<xsl:with-param name="allow-anchors" select="1"/>
</xsl:apply-templates>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
________________________________
From: Paul Hoadley [[email protected]]
Sent: Tuesday, October 02, 2012 6:20 AM
To: Docbook Apps
Subject: [docbook-apps] Creating a chapter title page with chapter number and
title on different lines
Hello,
I'm trying to create a chapter title page (with the FO stylesheets) that's
reminiscent of some of the O'Reilly books. Something like this, say:
---
14
Troubleshooting
---
That is, chapter number, absence of the "Chapter" generated text, and then
chapter title in a new block. I've been out of the DocBook loop for a few
years, but I've done title page customisations before—with this, though, I seem
to be running around in circles through the template system. Could someone
give me the briefest outline on how to customise the output for the chapter
'title' element like this? I'm looking at the 'component.title' template in
component.xsl, but I can't see where the title text itself is being generated
('<xsl:apply-templates select="$node" mode="object.title.markup">'?), or how I
would go about customising it very specifically like this just for chapters.
--
Paul Hoadley
http://logicsquad.net/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]