Edge Rewrite
// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a233277a5dc8b071

Jump to content

XSL Formatting Objects

From Wikipedia, the free encyclopedia
XSL Formatting Objects
Filename extension
.xml, .fo
Internet media typeapplication/xml,
text/xml (deprecated)
Uniform Type Identifier (UTI)public.xml
Developed byWorld Wide Web Consortium (W3C)
Latest release
1.1
December 5, 2006; 19 years ago (2006-12-05)
Type of formatMarkup language
Contained byXML
Open format?Yes
Websitewww.w3.org/TR/xsl11/

XSL-FO (XSL Formatting Objects) is a markup language for XML document formatting that is most often used to generate PDF files. It has largely been superseded by the CSS3 but is still maintained for legacy systems.

It is an intermediary file format with the purpose of generating paged, printed media. The intended workflow is to transform an XML file into XSL-FO by writing and running a script in the XSLT programming language and then transform the XSL-FO file into PDF or other formats with a software called XSL-FO processor.[1] The XSLT script only needs to be written once for each document type.

XSL-FO is part of XSL (Extensible Stylesheet Language), a set of W3C languages designed for the transformation and formatting of XML data. The other parts of XSL are XSLT and XPath. Version 1.1 of XSL-FO was published in 2006.

The last update for the Working Draft was in January 2012, and its Working Group closed in November 2013.[2]

The XSLT language itself was originally conceived only to transform to XSL-FO but is now used for more general XML transformations.

The XSL-FO specification allows different FO processors to have varying responses with regard to the resultant generated pages.

For example, different processors may even use different hyphenation algorithms, ranging from very simple to more complex hyphenation algorithms that take into account whether the previous or next line also is hyphenated. This can substantially change the layout.

Language concepts

[edit]

The XSL-FO language was designed for paged media; as such, the concept of pages is an integral part of XSL-FO's structure.

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.

Document structure

[edit]

XSL-FO documents are XML documents, but they do not have to conform to any DTD or schema. Instead, they conform to a syntax defined in the XSL-FO specification.

XSL-FO documents contain two required sections. The first section details a list of named page layouts. The second section is a list of document data, with markup, that uses the various page layouts to determine how the content fills the various pages.

Page layouts define the properties of the page. They can define the directions for the flow of text, so as to match the conventions for the language in question. They define the size of a page as well as the margins of that page. More importantly, they can define sequences of pages that allow for effects where the odd and even pages look different. For example, one can define a page layout sequence that gives extra space to the inner margins for printing purposes; this allows more space to be given to the margin where the book will be bound.

The document data portion is broken up into a sequence of flows, where each flow is attached to a page layout. The flows contain a list of blocks which, in turn, each contain a list of text data, inline markup elements, or a combination of the two. Content may also be added to the margins of the document, for page numbers, chapter headings and the like.

Blocks and inline elements function in much the same way as for CSS, though some of the rules for padding and margins differ between FO and CSS. The direction, relative to the page orientation, for the progression of blocks and inlines can be fully specified, thus allowing FO documents to function under languages that are read different from English. The language of the FO specification, unlike that of CSS 2.1, uses direction-neutral terms like start and end rather than left and right when describing these directions.

XSL-FO's basic content markup is derived from CSS and its cascading rules. As such, many attributes in XSL-FO propagate into the child elements unless explicitly overridden.

XSL-FO 1.0

[edit]

In addition to the information as specified above, the following is supported:

  • Pages with multiple columns
  • Lists
  • Pagination controls: The user can specify Widow and Orphan for blocks or for the flow itself, and allow the attributes to cascade into child blocks. Additionally, blocks can be specified to be kept together on a single page. For example, an image block and the description of that image can be set to never be separated. The FO processor will do its best to adhere to these commands, even if it requires creating a great deal of empty space on a page.
  • Footnotes
  • Tables
  • Text orientation controls: One can, in the middle of a page, designate a block of text to be oriented in a different orientation.
  • Page number citations. A page that contains a special tag can be cited in text, and the FO processor will fill in the actual page number where this tag appears.
  • Block borders, in a number of styles.
  • Background colors and images.
  • Font controls and weighting, as in CSS.
  • Side floats.
  • Miscellaneous Inline Elements.

XSL-FO 1.1

[edit]

New features:

  • Multiple flows and flow mapping: XSL-FO 1.0 was fairly restrictive about what text was allowed to go in what areas of a page. Version 1.1 loosens these restrictions significantly, allowing flowing text to be mapped into multiple explicit regions on a page. This allows for more newspaper-like typesetting.
  • Named Bookmarks: Many output formats for XSL-FO processors, specifically PDF, have bookmarking features. These allow the format to specify a string of text in a separate window that can be selected by the user. When selected, the document window scrolls immediately to a specific region of the document.
  • Indexing: features that support the generation of an index that might be found at the back of a book. This is done through referencing of properly marked-up elements in the FO document.
  • Last page citation: The last page can be generated without providing an explicit in-document reference to a specific anchor in the FO document. The definition of "last page" can be restricted to within a specific set of pages or to cover the entire document. This allows the user to specify something like, "Page 2 out of 15", where page 15 is the page number of a last page definition.
  • Table markers: Table markers allow the user to create dynamic content within table headers and footers, such as running totals at the bottom of each page of a table or "table continued" indicators.
  • Inside/outside floats: adds the keywords "inside" and "outside" for side floats, which makes it possible to achieve page layouts with marginalia positioned on the outside or inside edges of pages. Inside refers to the side of the page towards the book binding, and outside refers to the side of a page away from the book binding.
  • Refined graphic sizing: adds the ability to shrink graphics to fit (but not grow to fit), as well as the ability to define specific scaling steps. In addition, the resulting scaling factor can be referenced for display (for example, to say in a figure caption, "image shown is 50% actual size").

Limitations

[edit]
  • Limited capabilities – XSL-FO was specifically designed to meet the requirements of "lightly designed" documents typified by technical manuals, business documents, invoices, and so on. While it can be and is used for more sophisticated designs, it is inherently limited in what it can do from a layout and typographic perspective. In particular, XSL-FO does not provide a direct way to get formatting effects that depend on knowing the page position relationship of two formatting objects. For example, there is no direct way to say "if this thing is on the same page as that thing, then do X, otherwise do Y". This is an explicit design decision reflecting the two-stage, transform-based abstract processing model used by XSL-FO. This limitation can be addressed by implementing a multi-pass process. Unfortunately, there is currently no standard for how the result of the first pass would be communicated back to the second pass. Most, if not all, implementations provide some form of processable intermediate result format that can be used for this, but any such process implemented today would, by necessity, be implementation specific.
  • By the same token, there are important layout features that are simply not in XSL-FO, either because they were not of high enough priority or because designing them was too difficult to allow inclusion in version 1.1, or because there were insufficient implementations to allow their inclusion in the final specification per W3C rules.
  • In addition to these architectural limitations, the current XSL-FO implementations, both commercial and open source, do not provide the same level of typographic sophistication provided by high-end layout tools like QuarkXPress or InDesign, or by programmable typesetting systems like LaTeX. For example, no current implementation provides features for ensuring that text lines on facing pages are lined up vertically. There is nothing in the XSL-FO specification that prevents it but nothing that requires it either. For most documents for which a completely automated composition solution is sufficient, that level of typographic sophistication is not needed. However, for high-end publications and mass-market books, it usually is; in some cases this can be met by using XSLT to generate a LaTeX document instead.
  • Extension dependency – When considering the applicability of XSL-FO to a particular document or document design, one must consider proprietary extensions provided by the different XSL-FO implementations. These extensions add features that are not part of the core specification. For example, one product adds support for Japanese typographic conventions that the XSL-FO specification does not address. However, use of these features makes such an XSL-FO system a little more bound to a specific implementation (but not completely bound as it would be when using a totally proprietary composition system.)
  • Impractical manual editing – It is generally impractical to edit XSL-FO instances by hand (XSL-FO was designed for clarity and completeness, not ease of editing.). Visual editing tools such as XFDesigner can alleviate the task, although not all XSL-FO tags are accessible (most notably markers and footnotes). XF Designer is no longer a supported product from Ecrion Software.

When trying to decide whether or not XSL-FO will work for a given document, the following typographic and layout requirements usually indicate that XSL-FO will not work (although some of these may be satisfied by proprietary extensions):

  • Need to restart footnote numbers or symbol sequence on each new page (however, some implementations provide extensions to support automatic footnote numbering.)
  • Need to run text around both sides of a floated object (XSL-FO can run text around one side and the top and/or bottom, but not both sides; however, some implementations provide support for such complex layouts via proprietary extensions.)
  • Need to have variable numbers of columns on a single page (however, at least two commercial implementations provide extensions for creating multi-column blocks within a page.)
  • Need to have column-wide footnotes (several implementations provide column footnote extensions.)
  • Need to have marginalia that are dynamically placed relative to other marginalia (for example, marginal notes that are evenly spaced vertically on the page). XSL-FO only provides features for placing marginalia so that it is vertically aligned with its anchor.
  • Need to create content that spreads across two pages as a float or "out of line" object in an otherwise homogeneous sequence of repeating page masters (this can be done in XSL-FO 1.1 using multiple body regions and flow maps, but it requires being able to control the page masters used for those pages.)
  • Need both bottom-floated content and footnotes on the same page.
  • Need to be able to run text against an arbitrary curve (though some implementation support SVG, which can be used to get around this limitation).
  • Need to be able to constrain lines to specific baseline grids (for example, to achieve exact registration of lines on facing pages.)
  • Anything that requires page-aware layout, such as ensuring that a figure always occurs on the page facing its anchor point.

See also

[edit]
  • XHTML
  • Apache FOP - Open source and royalty free implementation of XSL-FO
  • XEP - Commercial and proprietary rendering engine
  • Antenna House Formatter - XSL-FO and CSS formatting software - Commercial and proprietary rendering engine

References

[edit]
  1. "Extensible Stylesheet Language (XSL) Version 2.0". www.w3.org. 17 January 2012. Retrieved 2026-07-29. It is intended that people first transform their XML documents into XSL-FO, for example using XSLT, and then use an XSL-FO formatter to generate a rendered result, for example in PDF.
  2. Quin, Liam (November 2, 2013). "Re: [xsl] xsl 2.0?". XSL-List – Open Forum on XSL (Mailing list).
[edit]