XSL-FO Documentation
- Previous Page Introduction to XSLFO
- Next Page XSLFO Region
XSL-FO documents are XML files with output information.
XSL-FO Documentation
XSL-FO documents are XML files with output information. They contain information about the output layout and content.
XSL-FO documents are stored in files with the .fo or .fob extension. It is also common to store XSL-FO documents with the .xml extension, which makes it easier for XML editors to access XSL-FO documents.
Structure of XSL-FO document
The document structure of XSL-FO is similar to this:
<?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>
Structure Explanation
An XSL-FO document is an XML document because it also needs to start with an XML declaration:
<?xml version="1.0" encoding="ISO-8859-1"?>
The <fo:root> element is the root element of an XSL-FO document. This root element also needs to declare the XSL-FO namespace:
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> <!-- This is the content of the XSL-FO document --> </fo:root>
The <fo:layout-master-set> element contains one or more page templates:
<fo:layout-master-set> <!-- This is all the page templates --> </fo:layout-master-set>
The <fo:simple-page-master> element contains a single page template. Each template must have a unique name (master-name):
<fo:simple-page-master master-name="A4"> <!-- This is a page template --> </fo:simple-page-master>
One or more <fo:page-sequence> elements can describe the content of the page. The master-reference attribute uses the same name to refer to the simple-page-master template:
<fo:page-sequence master-reference="A4"> <!-- This is the page content --> </fo:page-sequence>
Note:The value "A4" of master-reference actually does not describe a predefined page format. It is just a name. You can use any name, such as "MyPage", "MyTemplate", and so on.
- Previous Page Introduction to XSLFO
- Next Page XSLFO Region