XML technologies / XSL-FO / Examples of application / Hyphenation

Hyphenation

The hyphenation for blocks is automatically generated in various languages.

In this section the use of the hyphenate and the xml:lang attributes shall be shown by a short example. The attributes control the automatic hyphenation in text blocks.

Excerpt from the DTD:

<!ELEMENT P (#PCDATA | ...)*><!-- Text paragraph -->

Stylesheet:

<xsl:template match="P">
   <fo:block text-align="justify" hyphenate="true" xml:lang="en">    ❶
      <xsl:apply-templates/>
   </fo:block>
</xsl:template>

❶ Whether the hyphenation shall be performed at a line break or not is determined with the hyphenate attribute and its setting to false or true. When setting the value true, the hyphenation is activated. Since the hyphenation may be inherited to given substructures, it can be switched off with the false value if it is not wanted in a lower level. xml:lang indicates which rules or patterns shall be valid for the hyphenation. In this example en is set for the application of the English hyphenation rules.

 

back to top