An Introduction to XSLT - Page Masters
(Page 5 of 6 )
In addition to this, there is the Formatting-Objects language, XSL (formerly know as XSL-FO) that we have not yet explored. These are reserved XML elements that are defined in the FO namespace. XSL documents contain an fo:root element which acts as the document root:
<fo:root xmlns:fo="http://www.w3.org/XSL/Format">
</fo:root>
This document root then contains a layout element that defines the page layout (known as page masters):
<fo:layout-master-set>
</fo:layout-master-set>
Nested within the layout-master are the page master elements:
<fo:simple-page-master page-master-name="Intro">
</fo:simple-page-master>
The page master element can be used to set the size of the outputted document using the following syntax:
<fo:simple-page-master page-master-name="Intro" height="10.0in"
width="8.0in">
</fo:simple-page-master>
If these values are omitted, the processor will assign pre-defined values depending on the media the outputted document is displayed to. The page-master element can also be used to set page margins:
<fo:simple-page-master page-master-name="Intro" height="10.00in"
width="8.00in" margin-top="1.0in"
margin-bottom="1.0in" margin-left="1.0in" margin-right="1.0">
</fo:simple-page-master>
XSL-FO documents position content on a page according to the following hierarchy of areas:
- Pages
- Regions
- Block Areas
- Line Areas
- Inline Areas
Area Containers contain either additional Area Containers or Block Areas. Block Areas contain either additional Block Areas or Line Areas. Area containers define the basic structure in which your XML is displayed. Block Areas are used to define paragraphs and lists, and they can contain text. Line Areas contain Inline Areas and Inline Spaces. Line Areas are used to contain elements for graphics, mathematical equations or links. Inline Areas are rectangular areas used to format and contain content such as graphics, text and horizontal rules. The page-masters that we examined a moment ago are constructed using area containers in the following way:
<fo:region-start extent="0.5in"/> Left edge of the page
<fo:region-before extent="0.5in"/> Top edge of the page
<fo:region-body/> Main body of the page
<fo:region-end extent="0.5in"/> Right edge of the page
<fo:region-after extent="0.5in"/> Bottom edge of the page
These region elements also have attributes to set properties, including:
- Borders
- Background
- Padding
- Margins
- Overflow
- Columns
- Text orientation and direction
Page-masters can be applied to the content of your document using the page-sequence element:
<fo:page-squence>
</fo:page-sequence>
This element can then contain a further two elements:
<fo:static content>
<fo:flow>
The static content element is optional and can be used to display content that appears on every page in a sequence, such as headings. The fo:flow element contains a list of the elements that appear in your document, in the order in which they appear.
If your page is not big enough to contain all of the elements, additional pages are created. This is how the overflow of elements is handled as fo:static elements cannot overflow.
Next: Block Level Elements >>
More XML Articles
More By Dan Wellman