XSL-FO document
XSL-FO document
XSL-FO documents are XML files with output information.
XSL-FO documents stored in .fo .fob file extension or file. You can also XSL-FO document is stored as an .xml file extension, doing so can make XSL-FO documents are easier to access XML editor.
XSL-FO document structure
XSL-FO document structure 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 explained
XSL-FO documents belonging to XML documents, and therefore need to start with an XML declaration:
<Fo: root> element is the root element of XSL-FO documents. The root element must declare 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> element can describe the page content. master-reference attribute with the same name to refer to the simple-page-master template:
<!-- Page content goes here -->
</fo:page-sequence>
NOTE: master-reference value "A4" does not actually describe a predefined page format.It is just a name. You can use any name like "MyPage", "MyTemplate" and so on.