XSL Formatting Objects

XSL Formatting Objects (XSL-FO) are the second half of the Extensible Stylesheet Language (XSL). XSL-FO is an XML application that describes how pages will look when presented to a reader. A style sheet uses the XSL transformation language to transform an XML document in a semantic vocabulary into a new XML document that uses the XSL-FO presentational vocabulary.
While one can hope that Web browsers will one day know how to directly display data marked up with XSL formatting objects, for now an additional step is necessary in which the output document is further transformed into some other format, such as Adobe’s PDF.
Unlike the combination of HTML and CSS, XSL-FO is a unified presentational language. It has no semantic markup in the way it is meant in HTML. And, unlike CSS which modifies the default presentation of an external XML or HTML document, it stores all of the document’s data within itself.
The general idea behind XSL-FO’s use is that the user writes a document, not in FO, but in an XMLlanguage. XHTML, DocBook, and TEI are all possibilities, but it could be any XML language. Then, the user obtains an XSLT transform, either by writing one themselves or by finding one for the document type in question. This XSLT transform converts the XML into XSL-FO.
Once the XSL-FO document is generated, it is then passed to an application called a FO processor. FOprocessors convert the XSL-FO document into something that is readable, printable or both. The most common output of XSL-FO is a PDF file or as PS, but some FO processors can output to other formats like RTF files or even just a window in the user’s GUI displaying the sequence of pages and their contents.
The XSLT language itself was originally conceived only for this purpose; it has obviously now been supplanted for more general XML transformations. This transformation step is taken so much for granted in XSL-FO that it is not uncommon for people to call the XSLT that turns XML into XSL-FO the actual XSL-FO document itself. Even tutorials on XSL-FO tend to be written with XSLT commands around the FO processing instructions.
The XSLT transformation step is exceptionally powerful. It allows for the automatic generation of a table of contents, linked references, an index, and various other possibilities.
An XSL-FO document is not like a PDF or a PostScript document. It does not fully describe the layout of the text on various pages. Instead, it describes what the pages look like and where the various contents go.
From there, a FO processor determines how to position the text within the boundaries described by the FO document. The XSL-FO specification even allows different FO processors to have varying responses with regard to the resultant generated pages.
For example, some FO processors can hyphenate words to minimize space when breaking a line, while others choose not to. Different processors may even use different hyphenation algorithms, ranging from very simple to more complex hyphenated algorithms that take into account whether the previous or next line also is hyphenated.
These will change, in some borderline cases quite substantially, the layout of the various pages. There are other cases where the XSL-FO specification explicitly allows FO processors some degree of choice with regard to layout.
This differentiation between FO processors, creating inconsistent results between processors is often not a concern. This is because the general purpose behind XSL-FO is to generate paged, printed media.XSL-FO documents themselves are usually used as intermediaries, mostly to generate either PDF files or a printed document as the final form to be distributed.
This is as opposed to how HTML is generated and distributed as a final form directly to the user. As such, a person wanting to generate a printed document only has to select the FO processor that fulfills their needs, usually in the realm of layout quality and reduction of unnecessary whitespace, rather than having to test their XSL-FO document on multiple processors.
XSL-FO Language Concepts
The XSL-FO language was designed for paged media, in much the same way that HTML and CSS were designed for unpaged (or screen-based) media. As such, the concept of pages is an integral part of XSL-FO’s structure, and FO gives the user significant power in dealing with how information is displayed on a page.
FO works best for what could be called “content-driven” design. This is the standard method of layout for books, articles, legal documents, and so forth. It involves a single flowing span of fairly contiguous text, with various repeating information built into the margins of a page.
This is as opposed to “layout-driven” design, which is used in newspapers or magazines. If content in those documents does not fit in the required space, some of it is trimmed away until it does fit. XSL-FO does not easily handle the tight restrictions of magazine layout; indeed, in many cases, it lacks the ability to express some forms of said layout.
Despite the basic nature of the language’s design, it is capable of a great deal of expressiveness. Tables, lists, side floats, and a variety of other features are available. These features are comparable to CSS’s layout features, though some of those features are expected to be built by the XSLT.
Scroll to Top