The eXtensible Stylesheet Language, aka XSLT, is actually a collection of specifications for ways to transform and render XML based documents. XSL Formatting Objects (XSL-FO) is designed specifically to take XML content and format it for hard copy printing or other forms of fixed-size page display (such as PDF readers and eBook). Whereas Cascading Style Sheets and various HTML or XHTML transformations handle XML transforms for content display inside a Web browser, when such pages are printed, they seldom look as good on paper as they do on screen (nor, in all fairness, are they designed to handle this kind of thing).
In a nutshell, XSL-FO is designed specifically to take XML format and by applying a specific stylesheet and well-defined transformations, to make content look good in print (at least, within the limits of the stylesheet designer's abilities). Though you can certainly consult the XSL-FO specification if you've a mind to do so, Crane Softwrights Ltd offers a much more approachable and user-friendly set of documentation called Practical Formatting Using XSL-FO for which a sizable free excerpt is available for download, and for which you'll pay $40 for the entire tome (available in print from Prentice-Hall or as an eBook).
Those content developers who want to provide good looking printed forms of their content—particularly those with longer, more complex works to deliver to users—will benefit from learning more about XSL and the various formatting objects that put the FO into XSL-FO. They will also find some tools available to help them deal with the complexities of the kinds of large and complex documents for which printed formatting is most likely to be useful or desirable.
Though there are many tools available that produce portable document format (PDF) or PostScript output from XML documents, potential XSL-FO users are likely to find the following items of greatest interest in their quest create good-looking print formats for their documents:
- The Apache project offers an Open Source engine known as the Formatting Objects Processor, or FOP. For those on tight budgets who don't mind spending time and expending elbow grease to get things working, it's a great solution for documents of all sizes and types.
- RenderX offers what they call a "production quality engine" called XEP that converts XSL-FO into PDF or PostScript files designed for use instead of the Apache FOP, especially to render PDF from documents created using the RenderX Stylus Studio environment.
- Altova's StyleVision 2005 toolset includes XSL-FO viewing and design tools that may be used strictly for stylesheet authoring and editing, or in tandem with the company's XMLSpy 2006 tools for content creation and editing as well.
Interested users will also find a plethora of free and commercial tools designed specifically to transform XML into PDF, should they care to go looking for such things.
Given the existence of an XML document collection and a need to make the content those documents contain look good in print, XSL-FO clearly deserves further investigation. In addition to the items already mentioned in this tip, you'll also find the following items helpful as well:
- Antenna House: How to Develop Stylesheets for XML to XSL-FO Transformation includes a great overview, lots of examples and a manual for their XSL Formatter v3.4 that it itself a tour-de-force illustration of XSL-FO at work).
- Stylesheet Central offers over 100 sample XSLT stylesheets, including numerous example of XSL-FO documents at rest and at work.
- O'Reilly's XML.com has a wonderful piece by Ken Holmann, the primary author of the aforementioned Crane materials entitled What is XSL-FO?
A little digging, a little learning and a little experimentation can lead to good looking XML-based print output, as long as you give yourself a little time to get things working.
About the author
Ed Tittel is a full-time writer and trainer whose interests include XML and development topics, along with IT Certification and information security topics. E-mail Ed with comments, questions, or suggested topics or tools for review.