XML technologies / DocBook / Generating FO (PDF) / Formatting headings / Formatting sections
(Excerpt from "DocBook-XML: Media-neutral and platform-independent publishing" by Thomas Schraitle)
As shown in Formatting sections in the chapter "Generating (X)HTML", for XSL-FO use the same template section.heading. Proceed as follows:
Create a customization file as shown in Creating a customization file for XSL-FO.
Copy the template
section.headingfrom the filefo/sections.xslinto your customization file.Find the following code inside the template:
<xsl:choose>
<xsl:when test="$level=1">
<fo:block xsl:use-attribute-sets="section.title.level1.properties">
<xsl:copy-of select="$title"/>
</fo:block>
</xsl:when>
<!-- Weitere xsl:when-Elemente -->
</xsl:choose>Replace the code in the first
xsl:whenbranch with the following lines:
<xsl:when test="$level=1">
<fo:block xsl:use-attribute-sets="section.title.level1.properties">
<xsl:if test="number($section.autolabel) != 0">
<fo:inline xsl:use-attribute-sets="section.label.level1.properties">
<xsl:apply-templates select=".." mode="label.markup"/>
</fo:inline>
</xsl:if>
<fo:inline>
<xsl:apply-templates select="." mode="title.markup"/>
</fo:inline>
</fo:block>
</xsl:when>Line 2: Wraps the numbering and title.
Line 3: Checks whether the parametersection.autolabelis set to 1. If numbering is enabled, afo:inlineelement containing the number is generated.
Line 8: Generates the title. In thefo:inlineelement, you can add attributes or an attribute set, as with the preceding inline element.
Customize the numbering using the following attribute sets:
<xsl:attribute-set name="section.label.level1.properties">
<xsl:attribute name="color">white</xsl:attribute>
<xsl:attribute name="background-color">gray</xsl:attribute>
<xsl:attribute name="padding-left">0.25em</xsl:attribute>
<xsl:attribute name="padding-right">0.25em</xsl:attribute>
<xsl:attribute name="space-end">1em</xsl:attribute>
</xsl:attribute-set>
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