The content (as opposed to markup) of an XSL-FO document is mostly text. Non-XML content such as GIF and JPEG images can be included in a fashion similar to the IMG element of HTML. Other forms of XML content, such as MathML and SVG, can be embedded directly inside the XSL-FO document. This content is stored in several kinds of elements including: |
• Block-level formatting objects • Inline formatting objects • Table formatting objects • Out-of-line formatting objects |
All of these different kinds of elements are descendants of either a fo:flow or a fo:static-content element. They are never placed directly on page masters or page sequences. |
Block-level formatting objects |
A block-level formatting object is drawn as a rectangular area separated by a line break and possibly extra white space from any content that precedes or follows it. Blocks may contain other blocks, in which case the contained blocks are also separated from the containing block by a line break and perhaps extra white space. Block-level formatting objects include: |
• fo:block • fo:block-container • fo:table-and-caption • fo:table • fo:list-block |
The fo:block element is the XSL-FO equivalent of display: block in CSS or DIV in HTML. Blocks may be contained in fo:flow elements, other fo:block elements, and fo:static-content elements. fo:block elements may contain other fo:block elements, other block-level elements such as fo:table and fo:list-block, and inline elements such as fo:inline and fo:page-number. Block-level elements may also contain raw text. |
For example: |
<fo:block>The Periodic Table, Page <fo:page-number/></fo:block> |
The block-level elements generally have attributes for both area properties and text-formatting properties. The text-formatting properties are inherited by any child elements of the block unless overridden. |
Inline formatting objects |
An inline formatting object is also drawn as a rectangular area that may contain text or other inline areas. However, inline areas are most commonly arranged in lines running from left to right. When a line fills up, a new line is started below the previous one. |
The exact order in which inline elements are placed depends on the writing mode. For example, when working in Hebrew or Arabic, inline elements are first placed on the right and then fill to the left. Inline formatting objects include: |
• fo:bidi-override • fo:character • fo:external-graphic • fo:initial-property-set • fo:instream-foreign-object • fo:inline • fo:inline-container • fo:leader • fo:page-number • fo:page-number-citation |
Caution |
As of version 0.20.4, FOP does not support fo:bidi-override, fo:initial-property-set, or fo:inline-container. |
Table formatting objects |
The table formatting objects are the XSL-FO equivalents of CSS2 table properties. However, tables do work somewhat more naturally in XSL-FO than in CSS. For the most part, an individual table is a block-level object, while the parts of the table aren’t really either inline or block level. However, an entire table can be turned into an inline object by wrapping it in a fo:inline-container. |
There are nine XSL table formatting objects: |
• fo:table-and-caption
• fo:table • fo:table-caption • fo:table-column • fo:table-header • fo:table-footer • fo:table-body • fo:table-row • fo:table-cell |
The root of a table is either a fo:table or a fo:table-and-caption that contains a fo:table and a fo:caption. The fo:table contains a fo:table-header, fo:table-body, and fo:table-footer. The table body contains fo:table-row elements that are divided up into fo:table-cell elements. |
Caution |
FOP 0.20.4 has limited support for the table formatting objects, and none at all for fo:table-and-caption and fo:table-caption. |
Out-of-line formatting objects |
There are three “out-of-line” formatting objects: |
• fo:float • fo:footnote • fo:footnote-body |
Out-of-line formatting objects “borrow” space from existing inline or block objects. On the page, they do not necessarily appear between the same elements that they appeared between in the input formatting object XML tree. |