|By themselves, formatting objects say relatively little about how content is formatted. They merely put content in abstract boxes, which are placed in particular parts of a page. Attributes on the various formatting objects determine how the content in those boxes is styled.|
|As already mentioned, there are more than 200 different formatting properties. Not all properties can be attached to all elements. For instance, there isnâ€™t much point to specifying the font-style of a fo:external-graphic. Most properties, however, can be applied to more than one kind of formatting object element.|
|(The few that canâ€™t, such as src and provisional-label-separation, were discussed above with the formatting objects they apply to.) When a property is common to multiple formatting objects, it shares the same syntax and meaning across the objects. For example, you use identical code to format a fo:title in 14-point Times bold as you do to format a fo:block in 14-point Times bold.|
|Many of the XSL-FO properties are similar to CSS properties. The value of a CSS font-family property is the same as the value of an XSL-FO font-family attribute. If youâ€™ve read about CSS in Chapters 14through 16, youâ€™re already more than half finished learning XSL–FO properties.|
|The id property|
|The id property can be applied to any element. This is an XML ID-type attribute. The value of this property must, therefore, be an XML name thatâ€™s unique within the style sheet and within the output formatting object document. The last requirement is a little tricky because it’s possible that one template rule in the style sheet may generate several hundred elements in the output document. The generate-id() function of XSLT can be useful here.|
|The language property|
|The language property specifies the language of the content contained in either a fo:block or a fo:character element. Generally, the value of this property is an ISO 639 language code such as en (English) or la (Latin). It may also be the keyword none or use-document. The latter means to simply use the language of the input as specified by the xml:lang attribute. For example, consider the first verse of Caesarâ€™s Gallic Wars:|
|<fo:block id=”verse1.1.1″ language=”la”>
Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur
|Although the language property has no direct effect on formatting, it may have an indirect effect if the formatter selects layout algorithms depending on the language. For instance, the formatter should use different default writing modes for Arabic and English text. This carries over into determination of the start and end regions and the inline and block progression directions.|
|Paragraph properties are styles that normally are thought of as applying to an entire block of text in a traditional word processor, although perhaps block-level text properties is a more appropriate name here. For example, indentation is a paragraph property, because you can indent a paragraph, but you canâ€™t indent a single word.|
|The break properties specify where page breaks are and are not allowed. There are seven loosely related break properties:|
|The keep-with-next property determines how much effort the formatter will expend to keep this formatting object on the same page as the following formatting object. The keep-with-previous property determines how much effort the formatter will expend to keep this formatting object on the same page as the preceding formatting object.|
|And the keep-together property determines how much effort the formatter will expend to keep the contents of this formatting object on one page. These are not hard and fast rules because it’s always possible that a formatting object is just too big for one page.|
|Each of these properties can be set to an integer giving the strength of the effort to keep the objects on the same page (larger integers are stronger) or to the keywords always or auto. always means maximum effort; auto means let the breaks fall where they may.|
|By contrast, the break-before property and break-after properties mandate some kind of break. What exactly is broken is determined by the value of the property. This can be one of these five values:|
|• column: Break the current column and move to the next column.
• page: Break the current page and move to the next page.
• even-page: Break the current page and move to the next even-numbered page, inserting a blank page if the current page is itself an even-numbered page.
• odd-page: Break the current page and move to the next odd-numbered page, inserting a blank page if the current page is itself an odd-numbered page.
• auto: Let the formatter decide where to break; the default.
|For example, this template rule ensures that each ATOM of sufficiently small size is printed on a page of its own:|
<fo:block break-before=”page” break-after=”page”>
|Finally, the inhibit-line-breaks property is a boolean that can be set to true to indicate that not even a line break is allowed, much less a page break.|
|XSL-FO also defines three shorthand page-break properties: page-break-after, page-break-before, and page-break-inside. These are not absolutely necessary because their effects can be achieved by appropriate combinations of the keep and break properties.|
|For example, to specify a page break after an element, you’d set break-before to page and keep-with-previous to auto.|
|The hyphenation properties determine where hyphenation is allowed and how it should be used. These properties apply only to soft or â€œoptionalâ€ hyphens such as the ones sometimes used to break long words at the end of a line.|
|They do not apply to hard hyphens such as the ones in the word mother-in-law, although hard hyphens may affect where soft hyphens are allowed. There are six hyphenation properties. They are:|
|• hyphenate: Automatic hyphenation is allowed only if this property has the value true.|
|• hyphenation-character: The Unicode character used to hyphenate words, such as – in English.|
|• hyphenation-keep: One of the four keywords (column, none, page, inherit) that specify where and whether hyphenation is allowed. The default is not to hyphenate.|
|• hyphenation-ladder-count: A nonnegative integer that specifies the maximum number of hyphenated lines that may appear in a row.|
|• hyphenation-push-character-count: A nonnegative integer that specifies the minimum number of characters that must follow an automatically inserted hyphen. (Short syllables look bad in isolation.)|
|• hyphenation-remain-character-count: A nonnegative integer specifying the minimum number of characters that must precede an automatically inserted hyphen.|
<fo:block hyphenate="true" hyphenation-character="-" hyphenation-keep="none" hyphenation-ladder-count="2" hyphenation-push-character-count="4" hyphenation-remain-character-count="4" > some content... </fo:block>
|XSL-FO does not specify a word-breaking algorithm to determine where a soft hyphen may be applied. Even when these properties allow hyphenation, itâ€™s still completely up to the formatter to figure out how to hyphenate individual words. Indeed, basic formatters may not attempt to hyphenate words at all.|
|The indent properties specify how far lines are indented from the edge of the text. There are four of these:|
|The start-indent property offsets all lines from the start edge (left edge in English). The end-indent property offsets all lines from the end edge (right edge in English). The text-indent property offsets only the first line from the start edge.|
|The last-line-end-indent property offsets only the last line from the start edge. Values are given as a signed length. For example, a standard paragraph with a half-inch, first-line indent might be formatted this way:|
The first line of this paragraph is indented
|A block quote with a one-inch indent on all lines on both sides is formatted like this:|
|<fo:block start-indent=”1.0in” end-indent=”1.0in”>
This text is offset one inch from both edges.
|Because the text-indent is added to the start-indent to get the total indentation of the first line, using a positive value for start-indent and a negative value for text-indent creates hanging indents. For example, all lines except the first in this paragraph are indented by one inch. The first line is only indented half an inch:|
|<fo:block text-indent=”-0.5in” start-indent=”1.0in”>
This paragraph uses a hanging indent.