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. 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. Version 1.1 was published as XSL 1.1 in December 2006.
The last update for the 2.0 Working Draft was in January 2012, and its Working Group closed in November 2013.
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.
The following is a minimalist XSL-FO file with only the required markup to show "Hello World".
<?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.
In addition to the information as specified above, the following is supported:
New features:
This section may contain original research. (June 2019) |
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.