XSL-FO stands for Extensible Style sheet Language Formatting Objects. It is a language for formatting XML data for output to screen, paper or other media. The general idea behind XSL-FO's use is that the user writes a document in an XML language and then obtains an XSLT transform. This XSLT transform converts the XML into XSL-FO.
<?xml version="1.0" encoding="ISO-8859-1"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4">
<!-- Page template goes here -->
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<!-- Page content goes here -->
</fo:page-sequence>
</fo:root>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="A4">
<!-- Page template goes here -->
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4">
<!-- Page content goes here -->
</fo:page-sequence>
</fo:root>
Structure explained
XSL-FO documents are XML documents and must always start with an XML declaration:
The <fo:root> element is the root element of XSL-FO documents and declares 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:
Working of XSL-FO Transforming XML for print is accomplished by transforming an XML document to a Formatting Objects (FO) document, via XSLT. The formatting objects processor reads the FO document and transforms it for different types of print output. How is XSL-FO related to XSLT? Web designing is all about styling. Hence, the first XSL working draft of World Wide Consortium contained the syntax of both transforming and formatting of XML documents. They had XSLT for transforming and XSL or XSL-FO for formatting XML documents. |
XSL-FO is about formatting the contents on a page or a sequence of pages in a fairly strict fashion. It helps in managing the content which is spread across multiple pages, in specifying the format of a page (or even and odd pages) including headers, footers, borders, columns, etc and have content flow into that. An XSL-FO document is not like a PDF or a PostScript document. Instead, it describes what the pages look like and where the various contents go.
XSLT is a means for transforming XML documents into well structured documents. The XSLT transformation step is exceptionally powerful. It allows for the automatic generation of a table of contents, linked references, an index, and various other possibilities. This transformation step of XSLT turns XML into XSL-FO, the actual XSL-FO document itself.
The combination of XSLT and XSL-FO creates a powerful styling language. XSLT is capable of creating content, such as automatically creating a table of contents just from chapters in a book, or removing/selecting content, such as only generating a glossary from a book. It is capable of generating multiple documents, such as dividing the chapters in a book into their own individual pages.
XSL-FO is unlike CSS in that the XSL-FO document stands alone. CSS modifies a document that is attached to it, while the XSL-FO document contains all of the content to be presented in a purely presentational format. It has a wide range of specification options with regard to paged formatting and higher-quality typesetting. But it does not specify the pages themselves. The XSL-FO document must be passed through an XSL-FO processor utility that generates the final paged media, much like HTML+CSS must pass through a web browser to be displayed in its formatted state.
The complexity of XSL-FO is a problem, largely because implementing an FO processor is very difficult.
No comments:
Post a Comment