XSL-FO Document
XSL-FO Document
An XSL-FO document is an XML file that contains output information.
XSL-FO documents are stored in files with the .fo or .fob file extension. You can also store XSL-FO documents as files with the .xml extension, which makes XSL-FO documents easier to access with XML editors.
XSL-FO Document Structure
The document structure of XSL-FO is as follows:
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4">
<!-- Page template goes here -->
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<!-- Page content goes here -->
</fo:page-sequence>
</fo:root>
Structure Explanation
XSL-FO documents are XML documents, so they must also begin with an XML declaration:
The <fo:root> element is the root element of an XSL-FO document. This root element must also declare the XSL-FO namespace:
<!-- The full XSL-FO document goes here -->
</fo:root>
The <fo:layout-master-set> element contains one or more page templates:
<!-- All page templates go here -->
</fo:layout-master-set>
Each <fo:simple-page-master> element contains a single page template. Each template must have a unique name (master-name):
<!-- One page template goes here -->
</fo:simple-page-master>
One or more <fo:page-sequence> elements describe the page content. The master-reference attribute uses the same name to reference the simple-page-master template:
<!-- Page content goes here -->
</fo:page-sequence>
Note:The value "A4" of master-reference does not actually describe a predefined page format. It is just a name. You can use any name, such as "MyPage", "MyTemplate", and so on.
Other Extensions