|
|
|
|
XSL-FO document structure
"Hello, World!"
Here is a traditional "Hello, World!" example in XSL-FO interpretation:
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-first-page">
<fo:region-body margin="15pt"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-first-page">
<fo:flow flow-name="page-body">
<fo:block>Hello, world!</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Explanations of XSL-FO document structure
- Being and XML document XSL-FO document always starts with an XML declaration.
<?xml version="1.0" encoding="utf-8"?>
- The root element
<fo:root> is an obligatiry attribute that declares XSL-FO namespace.
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
- The
<fo:layout-master-set> element defines page structure and contains one or more declarations of
page master. A <fo:simple-page-master> element contains a page template each with its unique master-name. In the example, a simple-page-master is defined with only body area in it. Margins of the area are 15pt from
all sides.
<fo:layout-master-set>
<fo:simple-page-master master-name="my-first-page">
<fo:region-body margin="15pt"/>
</fo:simple-page-master>
</fo:layout-master-set>
- The
<fo:page-sequence> element describe the page contents. The master-reference attribute
selects page-master templates described in <fo:layout-master-set> element.
<fo:page-sequence master-reference="my-first-page">
- The
<fo:flow> element is the container for document's text data.
Flow name links to a region of the page defined in the <fo:simple-page-master>.
<fo:flow flow-name="page-body">
- The
<fo:block> includes a paragraph of text.
<fo:block>Hello, world!</fo:block>
|
|
|
|
|