XSL FO get "Real"
Those XML cognoscenti who've been following the XML Stylesheet Language, or XSL, for any length of time already know that there are two flavors of style for XML documents:
- XSL-Transformations: this set of specifications permits XML documents to be transformed from one XML document definition to another, or in a variety of alternate forms including HTML, XHTML, ASCII-text, and more. Often written as XSLT (and sometimes as XSL(T)), these specifications are further along and therefore better known than the next item. In essence, XSLT exists to transform XML documents into some other form or format.
- XSL-Formatting Objects: this set of specifications is still under development, but permits formatting controls to be associated with XML markup elements, in much the same way that Cascading Style Sheets (or CSS) work with HTML, XHTML, and XML. Often written as XSL-FO (and only seldom as XSL(FO)), as is the case with many native XML-based markup applications, XSL-FO is more powerful and sophisticated than its CSS predecessor.
One problem with using CSS and XML together is that the syntax is pretty cumbersome. It's also not a well-supported combination in various editing tools and environments available on the market. And finally, CSS uses a substantially different form of markup from XML, with its own unique syntax rules and structures. Learning CSS involves climbing an entirely separate
By contrast, using XSL-FO with XML applications uses the same syntax for the basic markup of documents as it does for formatting those documents -- and transforming them with XSLT as well. Most experts believe that XSLT and XSL-FO adumbrations to basic XML documents will become increasingly prevalent in the years ahead. A single learning curve for notation makes the burden of learning various forms of style less onerous than it might otherwise be.
My reason for claiming that XSL-FO is getting more real in the title of this piece hangs on a small but growing number of tools that support XSL-FO. Probably most important is the inclusion of the FOP (or formatting objects processor) into the latest release of the Apache XML project code base, which gives many sites the ability to format XML in PDF, PCL, SVG, Print, ASCII text, and other forms. This makes it easy to "serve up" XML, yet format it into a variety of legible or printable formats. I might point out, perhaps tangentially, that without an XSL-FO processor, use of this style language is an entirely academic exercise -- that's why I give this development a "most important" status.
From a tools perspective on the authoring side, XML-Spy just added support for XML-FO to its already formidable bag of tricks (which includes support for XSLT, XML Schema, XHTML, and a bunch more interesting stuff) on October 19, 2001. Be sure to look for version 4.1 or a higher-numbered version to get this support. Likewise, Novosoft offers an RTF2FO converter program that auto-generates XSL-FO templates from Rich Text Format (RTF) files, which in turn work with files output from all kinds of editors, word processors, and other text and layout tools.
Finally, for those who learn best by example (including me), be sure to check out the great XSL and FOP examples in the Example Repository at http://www.zvon.org/HowTo/Output/index.html (be sure to expand the example hierarchy in the left-hand column beneath XSL-FO to see those examples, or you might miss them altogether). If you're anything like me, a well-documented example is worth as much as any number of specification pages when it comes time to understanding how this stuff really works!
In closing, here are pointers to other resources and tools mentioned elsewhere in this tip:
- W3C XSL specifications are available through http://www.w3.org/Style/XSL/. This page also includes great tool pointers (and meta-pointers) as well as recently updated and very welcome pointers to some great tutorials. (Hint: check the XSL specification for the best standards documentation on XSL-FO.)
- Miloslav Nic of Zvon.org has published a good XSL-FO reference at http://zvon.org/xxl/xslfoReference/Output/index.html.
- You'll find FOP information, documents, and downloads at http://xml.apache.org/fop/.
- Visit www.xml-spy.com for more information about XML Spy 4.1.
- Visit Novosoft at http://www.novosoft-us.com/ns2b.nsf/w1/RTF2FO for more information about the RTF2FO conversion tool and its uses.
Have questions, comments, or feedback about this or other XML-related topics? Please e-mail me care of email@example.com; I'm always glad to hear from my readers.
Ed Tittel is a principal at LANWrights, Inc., a wholly owned subsidiary of LeapIt.com. LANWrights offers training, writing, and consulting services on Internet, networking, and Web topics (including XML and XHTML), plus various IT certifications (Microsoft, Sun/Java, and Prosoft/CIW).
This was first published in November 2001