0% found this document useful (0 votes)
69 views

Xml-Fo: Presented by Nikhil

XSL-FO is a language for formatting XML documents for output to screen, paper, or other media. It uses rectangular boxes and areas to define pages, regions, blocks, lines, and inline elements. XSL-FO documents can be styled using various font properties, borders, backgrounds and more. Common elements in XSL-FO include blocks, lists, tables, and flows to structure the document content into pages for output. XSL-FO works with XSLT to transform XML documents into the XSL-FO format for rendering.

Uploaded by

nikhilsnair88
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views

Xml-Fo: Presented by Nikhil

XSL-FO is a language for formatting XML documents for output to screen, paper, or other media. It uses rectangular boxes and areas to define pages, regions, blocks, lines, and inline elements. XSL-FO documents can be styled using various font properties, borders, backgrounds and more. Common elements in XSL-FO include blocks, lists, tables, and flows to structure the document content into pages for output. XSL-FO works with XSLT to transform XML documents into the XSL-FO format for rendering.

Uploaded by

nikhilsnair88
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

XML-FO

Presented by Nikhil

XML-FO
What is XML-FO ??

XSL-FO is a language for formatting XML data


XSL-FO stands for Extensible Stylesheet Language Formatting Objects
XSL-FO is based on XML
XSL-FO is a W3C Recommendation
XSL-FO is now formally named XSL

in one line
- the formatting of XML data for output to screen, paper or other media.
- Styling is both about transforming and formatting information.

XSL-FO Documents
- XSL-FO documents are stored in files with a .fo or a .fob file extension.
- You can also store XSL-FO documents with an .xml extension (to make them more accessible to
XML editors).

XSL-FO Document Structure

Structure Explained.

..continue
The <fo:root> element is the root element of XSL-FO documents. The root element also declares the
namespace for XSL-FO:

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

Each <fo:simple-page-master> element contains a single page template. Each template must have a
unique name (master-name):

One or more <fo:page-sequence> elements describe the page contents. The master-reference attribute
refers to the simple-page-master template with the same name:

XSL-FO Areas
XSL-FO uses rectangular boxes (areas) to display output.

The XSL formatting model defines a number of rectangular areas (boxes) to display output.
All output (text, pictures, etc.) will be formatted into these boxes and then displayed or printed to a target
media.

Pages

Regions

Block areas

Line areas

Inline areas

XSL-FO Pages
XSL-FO output is formatted into pages. Printed output will normally go into many separate pages. Browser
output will often go into one long page.
XSL-FO Regions
Each XSL-FO Page contains a number of Regions:

region-body (the body of the page)

region-before (the header of the page)

region-after (the footer of the page)

region-start (the left sidebar)

region-end (the right sidebar)


XSL-FO Regions contain Block areas.

..continue
XSL-FO Block Areas
- XSL-FO Block areas define small block elements (the ones that normally starts with a new
line) like paragraphs, tables and lists.

- XSL-FO Block areas can contain other Block areas, but most often they contain Line areas.

XSL-FO Line Areas


- XSL-FO Line areas define text lines inside Block areas.
- XSL-FO Line areas contain Inline areas.

XSL-FO Inline Areas


- XSL-FO Inline areas define text inside Lines (bullets, single character, graphics, and more).

XSL-FO Output
XSL-FO defines output inside <fo:flow> elements.
XSL-FO Page, Flow, and Block
- "Blocks" of content "Flows" into "Pages" and then to the output media.
- XSL-FO output is normally nested inside <fo:block> elements, nested inside
<fo:flow> elements, nested inside <fo:page-sequence> elements:

XSL-FO Example

XSL-FO Flow
Output ---

XSL-FO pages are filled with data from <fo:flow> elements.

XSL-FO Page Sequences


XSL-FO uses <fo:page-sequence> elements to define output pages.
Each output page refers to a page master which defines the layout.
Each output page has a <fo:flow> element defining the output.
Each output page is printed (or displayed) in sequence.

XSL-FO Flow
XSL-FO pages are filled with content from the <fo:flow> element.
The <fo:flow> element contains all the elements to be printed to the page.
When the page is full, the same page master will be used over (and over) again until all the text is printed.

...continue
Where To Flow?
The <fo:flow> element has a "flow-name" attribute.
The value of the flow-name attribute defines where the content of the <fo:flow>
element will go.
The legal values are:

xsl-region-body (into the region-body)

xsl-region-before (into the region-before)


xsl-region-after (into the region-after)

xsl-region-start (into the region-start)


xsl-region-end (into the region-end)

XSL-FO Pages
XSL-FO uses page templates called "Page Masters" to define the layout of pages.
XSL-FO Page Templates
XSL-FO uses page templates called "Page Masters" to define the layout of pages. Each
template must have a unique name:

..continue
XSL-FO Page Size
XSL-FO uses the following attributes to define the size of a page:

page-width defines the width of a page


page-height defines the height of a page

XSL-FO Page Margins


XSL-FO uses the following attributes to define the margins of a page:

margin-top defines the top margin


margin-bottom defines the bottom margin
margin-left defines the left margin
margin-right defines the right margin
margin defines all four margins

XSL-FO Page Regions


XSL-FO uses the following elements to define the regions of a page:

region-body defines the body region


region-before defines the top region (header)
region-after defines the bottom region (footer)
region-start defines the left region (left sidebar)
region-end defines the right region (right sidebar)

..continue

XSL-FO Example

"Simple Page Master Template" with the name "A4".

The width of the page is 297 millimeters and the height is 210 millimeters.

The top, bottom, left, and right margins of the page are all 1 centimeter.

The body has a 3 centimeter margin (on all sides).

The before, after, start, and end regions (of the body) are all 2 centimeters.

The width of the body in the example above can be calculated by subtracting the left
and right margins and the region-body margins from the width of the page itself:

297mm - (2 x 1cm) - (2 x 3cm) = 297mm - 20mm - 60mm = 217mm.

Note that the regions (region-start and region-end) are not a part of the calculation. As described earlier, these
regions are parts of the body.

XSL-FO Blocks
XSL-FO output goes into blocks.

XSL-FO Pages, Flow, and Block


-"Blocks" of content "Flow" into "Pages" of the output media.

- XSL-FO output is normally nested inside <fo:block> elements, nested inside <fo:flow>
elements, nested inside <fo:page-sequence> elements:

Block Area Attributes


Blocks are sequences of output in rectangular boxes:

continue
Since block areas are rectangular boxes, they share many common area properties:

space before and space after

margin

border

Padding

The space before and space after is the empty space separating the block from the other blocks.
The margin is the empty area on the outside of the block.
The border is the rectangle drawn around the external edge of the area. It can have different widths
on all four sides. It can also be filled with different colors and background images.
The padding is the area between the border and the content area.
The content area contains the actual content like text, pictures, graphics, or whatever.

..continue
Block Margin
margin
margin-top
margin-bottom
margin-left
margin-right

Block Border (color)


border-color
border-before-color
border-after-color
border-start-color
border-end-color
border-top-color (same as border-before)
border-bottom-color (same as border-after)
border-left-color (same as border-start)
border-right-color (same as border-end)

Block Border (width )


border-width
border-before-width
border-after-width
border-start-width
border-end-width
border-top-width (same as border-before)
border-bottom-width (same as border-after)
border-left-width (same as border-start)
border-right-width (same as border-end)

Block Border (style)


border-style
border-before-style
border-after-style
border-start-style
border-end-style
border-top-style (same as border-before)
border-bottom-style (same as border-after)
border-left-style (same as border-start)
border-right-style (same as border-end

..continue
Block Padding
padding
padding-before
padding-after
padding-start
padding-end
padding-top (same as padding-before)
padding-bottom (same as padding-after)
padding-left (same as padding-start)
padding-right (same as padding-end)

Block Background
background-color
background-image
background-repeat
background-attachment (scroll or fixed)

Block Styling Attributes


Blocks are sequences of output that can be styled individually:

..continue
Font attributes
font-family
font-weight
font-style
font-size
font-variant

Example

Text attributes font-family


text-align
text-align-last
text-indent
start-indent
end-indent
wrap-option (defines word wrap)
break-before (defines page breaks)
break-after (defines page breaks)
reference-orientation (defines text
rotation in 90" increments)

Result:

XSL-FO Lists
- XSL-FO uses the <fo:list-block> element to define lists.

XSL-FO List Blocks


There are four XSL-FO objects used to create lists:

fo:list-block (contains the whole list)


fo:list-item (contains each item in the list)
fo:list-item-label (contains the label for the list-item - typically an <fo:block> containing a
number, character, etc.)
fo:list-item-body (contains the content/body of the list-item - typically one or more
<fo:block> objects)

..continue
Example :

Output:

XSL-FO Tables
XSL-FO uses the <fo:table-and-caption> element to define tables.
XSL-FO Tables

The XSL-FO table model is not very different from the HTML table model.
There are nine XSL-FO objects used to create tables:

fo:table-and-caption
fo:table
fo:table-caption
fo:table-column
fo:table-header
fo:table-footer
fo:table-body
fo:table-row
fo:table-cell

- XSL-FO uses the <fo:table-and-caption> element to define a table. It contains a


<fo:table> and an optional<fo:caption> element.
- The <fo:table> element contains optional <fo:table-column> elements, an
optional <fo:table-header> element, a <fo:table-body> element, and an
optional <fo:table-footer> element. Each of these elements has one or more
<fo:table-row> elements, with one or more <fo:table-cell> elements:

Continue..
Example :

XSL-FO and XSLT


Result :

XSL-FO and XSLT can help each other.


Example :

Result:

With a Little Help from XSLT


Remove the XSL-FO information from the document:

Add an XSLT transformation:

Result :

XSL-FO Software
XSL-FO needs formatting software to produce output.
XSL-FO Processors

- An XSL-FO processor is a software program for formatting XSL documents for output.
- Most XSL-FO processors can output HTML, PDF documents and quality print.
Antenna House Formatter V5
Antenna House Formatter V5 is a software program to format XML documents for PDF or print.
Visit Antenna House
Altova's StyleVision
StyleVision autogenerates standards-conformant XSLT and XSL:FO stylesheets based on your
design, as well as the corresponding output in HTML, RTF, PDF, Word 2007, and more.
Visit Altova
Ecrion's XF Products
Several products for XSL-FO formatting!
Visit Ecrion

XSL-FO Reference
XSL Formatting Objects Reference

Continue..

Continue

Q&A

You might also like