XSL Formatting Objects
This article may need to be rewritten to comply with Wikipedia's quality standards. (July 2026) |
| XSL Formatting Objects | |
|---|---|
| Filename extension |
.xml, .fo |
| Internet media type | application/xml,text/xml (deprecated) |
| Uniform Type Identifier (UTI) | public.xml |
| Developed by | World Wide Web Consortium (W3C) |
| Initial release | October 15, 2001 |
| Latest release | 1.1 December 5, 2006 |
| Type of format | Markup language |
| Contained by | XML |
| Open format? | Yes |
| Website | www |
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.
The XSL-FO specification was originally published under the ambiguous title XSL 1.0 in October 2001 declaring XSLT to be the other half but only linking the 1999 XSLT specification rather than including it.[2] Version 1.1 was published as XSL 1.1 in December 2006.[3]
The last update for the 2.0 Working Draft was in January 2012[4], and its Working Group closed in November 2013.[5]
The XSLT language itself was originally conceived only to transform to XSL-FO but is now used for more general XML transformations.[citation needed]
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.
FO works best for a single flowing span of fairly contiguous text, with various repeating information built into the margins of a page. This is as opposed to complex layouts used in newspapers or magazines.
File structure
[edit]The following is a minimalist XSL-FO file with only the required markup to show "Hello World".[6]
<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="HelloWorld">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="HelloWorld">
<fo:flow flow-name="xsl-region-body">
<fo:block>Hello World!!!</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
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.
<fo:layout-master-set> details a list of named page layouts.
<fo:page-sequence> is a list of document data, with markup, that uses the various page layouts to determine how the content fills the various pages.
Layout masters define the properties of a page sequence. 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 of a book.
Page sequences are divided into flows and flows into blocks. Blocks can contain a contain text data and <fo:inline> elements. Content may also be added to the margins of the document, for page numbers, chapter headings and the like.
Blocks and inline elements function similarly as in CSS, though some of the rules for padding and margins differ between FO and CSS.
XSL-FO's basic content markup is derived from CSS and its cascading rules.
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.
- Text direction for each element
- 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.
- Attribute propagation like in CSS
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]This section may contain original research. (June 2019) |
- 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.
- 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.
- 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.
- Unportable Extensions – Proprietary extensions provided by the different XSL-FO implementations reduce portability. For example, one product adds support for Japanese typographic conventions that the XSL-FO specification does not address.
- 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 not to use XSL-FO
[edit]- Need to restart footnote numbers or symbol sequence on each new page
- Need to run text around both sides of a floated object
- Need to have variable numbers of columns on a single page
- Need to have column-wide footnotes
- 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]- ↑ "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.
- ↑ "Extensible Stylesheet Language (XSL) Version 1.0". www.w3.org. 15 October 2001. Retrieved 2026-08-03.
- ↑ "Extensible Stylesheet Language (XSL) Version 1.1". www.w3.org. 5 December 2006. Retrieved 2026-08-03.
- ↑ "Extensible Stylesheet Language (XSL) Version 2.0". www.w3.org. 17 January 2012. Retrieved 2026-08-03.
- ↑ Quin, Liam (November 2, 2013). "Re: [xsl] xsl 2.0?". XSL-List – Open Forum on XSL (Mailing list).
- ↑ "XML technologies | XSL-FO | XSL-FO introduction | Quickstart". www.data2type.de. Retrieved 2026-08-02.
External links
[edit]- XSL-FO 1.1 Specification on W3C
- XSL-FO 1.0 Specification on W3C
- What is XSL-FO? on XML.com
- FO examples and techniques Archived 2018-05-10 at the Wayback Machine - Reference site set up by Dave Pawson
- XSL-FO Tutorial and Samples Archived 2014-10-05 at the Wayback Machine
- XSL Formatting Objects Tutorial
- aXSL - Open-source API for processing XSL-FO documents
- FOray - Open source and royalty-free implementation of XSL-FO, using the aXSL interfaces
- XSL-FO introduction and examples
- FO.NET Archived 2018-01-02 at the Wayback Machine - XSL-FO to PDF renderer for .NET