XSL-FO document
XSL-FO document
XSL-FO document is an XML file with output information.
XSL-FO documents are stored in files with a .fo or .fob file extension. You can also save the XSL-FO document as a file with an .xml extension, which makes the XSL-FO document more accessible to 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
The XSL-FO document is an XML document, so it also needs to start with an XML declaration:
<fo:root> element is the root element of the XSL-FO document. This root element must also declare the XSL-FO namespace:
<!-- The full XSL-FO document goes here -->
</fo:root>
<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 certain predefined page format. It's just a name. You can use any name, such as "MyPage", "MyTemplate", etc.