Transcript Document
XSL formatting objects
"Formatting objects" (FO)
for example a block, character, table cell, etc. (FO
elements)
formatting features like the width of a border, font
size, etc. (attributes for FO elements)
part of XSL
XSLT - transformations
FO - formatting objects (FO-DTD)
both comply to the XML recommendation!
21.7.2015
Jaana Holvikivi
1
Formatting objects
Formatting objects describe the layout of the document
in detail
the FO file is often automatically generated
a typical process:
XSLT-processor generates the FO file (XML) from an
XML document and an XSLT style sheet
XSL processor generates a pdf file (or some other
highly formatted file) from the FO file
21.7.2015
Jaana Holvikivi
2
Area model
In XSL, one creates a tree of formatting objects that
serve as inputs or specifications to a formatter
The formatter generates an ordered tree, the area tree,
which describes a geometric structuring of the output
medium.
The terms child, sibling, parent, descendant, and
ancestor refer to this tree structure. The tree has a
root node
Each area tree node other than the root is called an area
and is associated to a rectangular portion of the output
medium
21.7.2015
Jaana Holvikivi
3
Areas, area traits
21.7.2015
Jaana Holvikivi
4
Formatting objects: areas
Areas: rectangular areas
block-areas and inline-areas
inline areas
all children inline areas
special case: glyph area
21.7.2015
Jaana Holvikivi
5
Common traits
formatting object's writing-mode and referenceorientation properties:
the block-progression-direction is the direction for
stacking block-area descendants of the area:
according to writing system: English top-to-bottom;
Japanese: right-to-left
the inline-progression-direction is the direction for
stacking inline-area descendants of the area
English: left-to-right
21.7.2015
Jaana Holvikivi
6
Line areas: Nominal and Maximum Line
Rectangles
21.7.2015
Jaana Holvikivi
7
21.7.2015
Jaana Holvikivi
8
XSL-FO and CSS
XSL and CSS have common objects and properties
CSS: emph { font-weight: bold }
XSL: <fo:inline font-weight="bold">
fonts, text styles, background, colors, borders, tables
very similar to those in CSS
there are also differences in expression
CSS uses ‘left’ ‘right’
XSL has generic words like before, after, start, end
padding-before (not padding-left)
formatting objects tree (XML)
descendants inherit values from parents
21.7.2015
Jaana Holvikivi
9
Declarations, pagination and layout formatting
objects
<?xml version="1.0"?>
<fo:root> ...
<fo:layout-master-set>...</fo:layout-master-set>
<fo:page-sequence>...</fo:page-sequence>
<fo:page-sequence>...</fo:page-sequence>
</fo:root>
fo:root must be the root node
• fo:layout-master-set is a wrapper around all masters used in the
document
• the regions on the page are analogous to "frames" in an HTML
document: region body and “margins”
• pages, flow
"
21.7.2015
Jaana Holvikivi
10
Sample area tree
21.7.2015
Jaana Holvikivi
11
Layout-master-set
Includes page definitions (page masters)
<fo:layout-master-set>
<fo:simple-page-master
page-master-name=”Cover">
...
</fo:simple-page-master>
<fo:simple-page-master
page-master-name="Bodytext">
...
</fo:simple-page-master>
</fo:layout-master-set>
21.7.2015
Jaana Holvikivi
12
Simple-page-master
Defines the page type and its layout (cover page, table of
contents, body text, etc.)
<fo:simple-page-master ...>
<region-body .../>
<region-before .../>
<region-after .../>
<region-start .../>
<region-end .../>
<!-<!-<!-<!-<!--
main flow -->
header -->
footer-->
left margin -->
right margin -->
</fo:simple-page-master>
21.7.2015
Jaana Holvikivi
13
Simple-page-master
21.7.2015
Jaana Holvikivi
14
Simple-page-master
Example
<fo:simple-page-master
margin-right="2.5cm"
margin-left="2.5cm"
margin-bottom="2cm"
margin-top="1cm"
page-width="21cm"
page-height="29.7cm"
master-name="single">
<fo:region-body margin-top="3cm"/>
<fo:region-before extent="3cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
21.7.2015
Jaana Holvikivi
15
Page content, page-sequence
<fo:page-sequence master-name="single">
<fo:static-content flow-name="xsl-regionbefore">
<fo:block>
The Loch Ness Monster
</fo:block>
</fo:static-content>
<fo:flow>
<fo:block></fo:block>
<fo:block></fo:block>
<fo:block></fo:block>
...
</fo:flow>
</fo:page-sequence>
21.7.2015
Jaana Holvikivi
16
Page content, static-content
<fo:static-content flow-name="xsl-region-before">
<fo:block
padding-top="3pt"
text-align="center"
color="white"
background-color="blue"
space-after.optimum="15pt"
line-height="24pt"
font-family="sans-serif"
font-size="18pt"
>The Loch Ness Monster
</fo:block>
</fo:static-content>
21.7.2015
Jaana Holvikivi
17
Page content, flow
<fo:flow flow-name="xsl-region-body">
<fo:block
padding-top="3pt"
text-align="start"
space-after.optimum="10pt"
space-before.optimum="10pt"
line-height="20pt"
font-family="sans-serif"
font-size="16pt"
>Nessie protection plan drawn up
</fo:block>
21.7.2015
Jaana Holvikivi
18