XSL-FO Tutoriallogin
XSL-FO Tutorial
author:php.cn  update time:2022-04-21 16:29:33

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:

<?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

The XSL-FO document is an XML document, so 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 the XSL-FO document. This root element must also declare the XSL-FO namespace:

<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!-- The full XSL-FO document goes here -->
</fo:root>

<fo:layout-master-set> element Contains one or more page templates:

<fo:layout-master-set>
<!-- 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):

<fo:simple-page-master master-name="A4">
<!-- 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:

<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 certain predefined page format. It's just a name. You can use any name, such as "MyPage", "MyTemplate", etc.


php.cn