Using XSL Formatting Objects
(Page 1 of 4 )
If you need to format content not just for web pages, but for pages that will actually be printed out, keep reading. There is a technology called XSL Formatting Objects that can help you get the job done. In this article, we'll explain how to use it to format your content appropriately.
Formatting content or data is for many reasons a key process. Content may be wonderful alone, but if the content isn't formatted, then, to most people, it's worth very little because, to them, it's less welcoming and less accessible. When dealing with formatting content for use on a computer screen, HTML comes to mind. It's one of the most popular and easy-to-use tools available for presenting content on a computer screen.
However, some things need to be formatted for use on paper, and that presents a challenge. When formatting content for use on a computer screen, the content can simply run down the screen. The formatter doesn't have to worry about page breaks or anything like that. However, with pages, this is different. Only so much content can fit on one page before a new page is needed.
For this, another technology is needed. There are, of course, various ways to format content for use in print, but one technology really stands out: XSL Formatting Objects, or XSL-FO. XSL-FO is part of the XSL family of technologies, recommended by W3C, and because it's XML-based, it's easy to use, and it's easy to work with alongside other powerful technologies. Using XSL-FO, it's possible to format content for page-based presentation using a familiar XML-based syntax.
In this article, we'll take a look at using XSL-FO to format content for page-based media.
The basics of XSL-FO
As mentioned, XSL-FO is one of the technologies in the XSL (Extensible Stylesheet Language) family. The other two technologies are XSLT for transformations and XPath for addressing the nodes and attributes of an XML document.
It's perfectly possible to use XSL-FO by itself to create a formatted, page-based document. This is how we're going to initially approach XSL-FO in this article. However, one of the neat things about XSL-FO is that it can be easily used (and was designed to be used) in conjunction with XSLT. Using these technologies together, it's possible to take a regular XML document and transform it into an XSL-FO document using XSLT.
An XSL-FO document alone, however, does nothing. It simply describes how the formatted page should look. In order to make it useful, you need to use an XSL-FO processor. The processor takes the XSL-FO file and converts it into a format that is immediately useful. You can process it into all sorts of formats, such as images or rich text documents, but the most fitting result is probably a PDF file.
There are a number of XSL-FO processors available, some free and some commercial. Apache FOP (Formatting Objects Processor) is a popular option. We'll cover using Apache FOP in a bit.
Next: Creating a Hello world document >>
More XML Articles
More By Peyton McCullough