If you need to control where lines are breaking in certain text, you will find that DocBook does not provide much support. There is no line break element or attribute in the DocBook schemas, because line breaking is considered a formatting feature that should be kept separate from the XML source. In most cases, wrapping the text in
literallayout will allow you to control line breaking, because line breaks in that element are preserved in the output.
But there may be situations where you need to force a line break and
literallayout is not suitable. You can create an XML processing instruction to indicate a line break, and add a stylesheet customization to enact it. A template like the following can be added to a customization layer:
<xsl:template match="processing-instruction('linebreak')"> <fo:block/> </xsl:template>
With this template in place, you can add a processing instruction
<?linebreak?> in your text where you want to break a line. For example:
<para>This line should break right here <?linebreak?>if the template works.
The template will insert an empty
fo:block element at that point, which will cause the line to break there. If you want the line break to appear in HTML output as well, then add a similar template to your HTML customization layer but replace
<br/> to insert the HTML line break element. If you do not add such a template to your HTML stylesheet, then be sure to include a space between the words in addition to the processing instruction, so that the words do not run together in HTML output.
If you need to insert one or more blank lines, then see the section “Extra blank lines”.
|DocBook XSL: The Complete Guide - 4th Edition||PDF version available|
Copyright © 2002-2007 Sagehill Enterprises