Extensible Stylesheet Language Formatting Objects - Introduction to XSLFO
XSLFO is Extensible Stylesheet Language Formatting Objects which is an XML document by itself. This is a language for formatting XML data and is a W3C recommendation. This is interchangeably also called as XSL.
The XSLFO documents are more complex when compared to XSLT. The XSLFO documents contain formatting information that is used to format the XML data in the desired format. For example, the pagination, layout and other formats required for the XML documents are found in the XSLFO document. Since XSLFO documents are more complex, usually XML documents are initially transformed into formatting documents and then finally using some tools available, the XSLFO document is converted to give an output format.
The XSLFO documents will usually have a file extension of .fo or .fob. To make it easier to open them in the XML editors some developers used to have these files extension as .xml itself. But it is a practice to have their extension as .fo or .fob. The code given below is an example of an XSLFO document.
The XSLFO document has a root element called the <fo:root> which is the starting element of the document. Since this is an xml document, it is proper to start the document with the xml declaration. You can specify the xml namespace for the xslfo document in the root node itself, i.e., in the <fo:root> itself as an attribute. After this root element you have the layout-master-set element which contains the simle-page-master element. Within the layout-master-set element you can have any no of simple-page-master elements. These simple-page-master elements contain the page template that is required to give the desired output to the xml data.
The simple-page-master will have an master-name attribute which identifies the simple-page-master. It contains the page formatting details in the form of attributes. The code given below gives a sample of the simple-page-master with those attributes.
<!-- The page template can be given here -->
The attributes that are given in the above code are page-height, page-width, margin-left, margin-right, margin-top, and margin-bottom which are specified in cms. These attributes are self describing and does not need explanations.
Apart from the layout-master-set in the root element, there is another element called the page-sequence which contains the page contents in it. The page sequence has an attribute called master-reference which refers to the master-name of any page template. The following code gives the structure of the page-sequence element.
The formatting model of XSLFO defines different areas for the output of the document. The output is split into different areas. The areas are: Pages, Regions, Block Areas, Line Areas, and Inline Areas. The output of any document in this formatting model has many pages. Pages are split into Regions and Regions are split into Block Areas. A Block Area can have other block areas or Line Areas. Line Areas contain Inline Areas, which contain the actual text or image of the document.
The code given above gives the actual structure, where the page content is given. Within the page-sequence element, there is an element called the flow. This flow element has a block element which contains the actual content that comes in the page.
element can also have many <fo:inline> elements within them as given
in the above code. It is also possible that the inline elements can contain
other inline elements. As we have said earlier the block elements can
also contain other block elements and the structure of the document can
be more complex. XSLT is combined with XSLFO to produce quality and fast
output. An XSLFO document needs programs to convert the document into
a quality ouput like pdf document or html document. There are many software
available for this purpose. Softwares like XSL Formatter, Xinc, and Scriptura
are used to convert the XSLFO documents to other types of document outputs.
Software such as XML2PDF (Microsoft .Net Framework based engine) and Sigmagis
are also used for the conversion of XSLFO documents.
Visit XML Training Material Guide Homepage
Amazon and the Amazon logo are trademarks of Amazon.com, Inc. or its affiliates.Copyright - © 2004 - 2020 - All Rights Reserved.