Subheadings
In this exampe subheadings with different typographical characteristics (font size, font family, alignment, feed) are generated.
Subheadings are specifically designed text blocks. They can look like real headlines – which are titles for a chapter or a section – but they do not fulfil their functions. So, they do not uniquely identify the content and the boundaries of the given section or chapter. Therefore, they are also unsuitable as running heads. This example shows how already determined typographical characteristics or variations are preset in the DTD and how they have to be implemented in the stylesheet. Furthermore, the concept for vertical feeds above or below subheadings is demonstrated.
Excerpt from the DTD:
<!ELEMENT Section (Title, (P | ... | S-Title)*)>
<!ELEMENT S-Title (#PCDATA | ...)*>
<!ATTLIST S-Title Size (normal | small | large) "normal"
Font (normal | bold | italic) "normal"
Alignment (left | right | center) "left">
Stylesheet:
<xsl:attribute-set name="Subheading"> ❶
<xsl:attribute name="font-family">Arial</xsl:attribute>
<xsl:attribute name="space-before">15mm</xsl:attribute>
<xsl:attribute name="space-after">5mm</xsl:attribute>
<xsl:attribute name="hyphenate">false</xsl:attribute>
<xsl:attribute name="keep-with-next">always</xsl:attribute>
</xsl:attribute-set>
...
<xsl:template match="S-Title">
<fo:block xsl:use-attribute-sets="Subheading"> ❷
<xsl:choose> ❸
<xsl:when test="@Size='large'">
<xsl:attribute name="font-size">14pt</xsl:attribute>
</xsl:when>
<xsl:when test="@Size='small'">
<xsl:attribute name="font-size">10pt</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="font-size">12pt</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="@Font='bold'">
<xsl:attribute name="font-weight">bold</xsl:attribute>
</xsl:when>
<xsl:when test="@Font='italic'">
<xsl:attribute name="font-style">italic</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="font-weight">normal</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="@Alignment='right'">
<xsl:attribute name="text-align">right</xsl:attribute>
</xsl:when>
<xsl:when test="@Alignment='center'">
<xsl:attribute name="text-align">center</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="text-align">left</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
❶ For a better overview, the fixed attributes for subheadings are embedded in a <xsl:attribute-set>.
❷ The fixed attributes defined in the <xsl:attribute-set> are assigned to the block in which the subheadings shall be displayed.
❸ For all in the DTD variably defined characteristics the corresponding attribute values are queried and translated into typographical characteristics. For the details of this specification see the "Text blocks" section.
<< back | next >> |
Copyright © dpunkt.verlag GmbH 2004
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSL-FO in der Praxis" ("XSL-FO in practice") is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19B, 69115 Heidelberg, fon 06221-14830, fax 06221-148399, hallo@dpunkt.de