May 28, 2021 XSL-FO
This section introduces you to the XSL-FO documentation.
An XSL-FO document is an XML file with output information.
XSL-FO documents are stored in files with a .fo or .fob as the file extension. You can also store XSL-FO documents as files with .xml as extensions, which makes XSL-FO documents more accessible to the XML editor.
The document structure for XSL-FO is as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<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>
The XSL-FO document is an XML document, so you also need to start with an XML declaration:
<?xml version="1.0" encoding="ISO-8859-1"?>
The element is the root element of the XSL-FO document. This root element also declares the namespace of XSL-FO:
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!-- The full XSL-FO document goes here -->
</fo:root>
The layout-master-set-gt; element contains one or more page templates:
<fo:layout-master-set>
<!-- All page templates go here -->
</fo:layout-master-set>
Each element contains a single page template. Each template must have a unique name (master-name):
<fo:simple-page-master master-name="A4">
<!-- One page template goes here -->
</fo:simple-page-master>
One or more elements of the page can be described. The master-reference property uses the same name to refer to the simple-page-master template:
<fo:page-sequence master-reference="A4">
<!-- Page content goes here -->
</fo:page-sequence>
Note: The value "A4" of master-reference does not actually describe a predefined page format. I t's just a name. You can use any name, such as "MyPage," "MyTemplate," and so on.