In a previous article, we discussed XSL-FO documentation structure. In this article, we would discuss the Area attribute and the output format of XSL-FO.
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. Some of the areas such as pages, regions, block areas and line areas would be discussed here.
1- 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 Pages contain Regions.
2- Each XSL-FO Page contains a number of Regions. The body of the page is known as region-body, header of the page is known as region-before, footer of the page is known as region-after, and the left and right sidebars are known as region-start and region-end respectively.
3- XSL-FO Block areas define small block elements (the ones that normally start 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.
4- XSL-FO Line areas define text lines inside Block areas. XSL-FO Line areas contain Inline areas.
Now, we would talk a bit about XSL-FO output formats. Basically, XSL-FO defines output inside <fo:flow> elements.
“Blocks” of content “Flows” into “Pages” and then to the output media. XSL-FO output is normally nested inside <fo:block> elements, which is nested inside <fo:flow> elements, which is further nested inside <fo:page-sequence> elements:
1 2 3 4 5 6 7 |
<fo:page-sequence> <fo:flow flow-name="xsl-region-body"> <fo:block> <!-- Output goes here --> </fo:block> </fo:flow> </fo:page-sequence> |
In real coding, an XSL-FO example would be like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?xml version="1.0" encoding="ISO-8859-1"?> <fo:root xmlns:fo="http://www.coding.com/1999/XSL/Format"> <fo:layout-master-set> <fo:simple-page-master master-name="A4"> <fo:region-body /> </fo:simple-page-master> </fo:layout-master-set> <fo:page-sequence master-reference="A4"> <fo:flow flow-name="xsl-region-body"> <fo:block>Hello Coding</fo:block> </fo:flow> </fo:page-sequence> </fo:root> |
The simple output of the above code would be “Hello Coding”.
In next article, we would discuss other important details of XSL-FO.