XML Developer Tip
(Receive this column in your inbox,
click Edit your Profile to subscribe.)
Format XML output with XSL-FO
I hear from a lot of people interested in XML topics. Two of the most common questions I've been asked lately have a common thread (hint: it's mentioned in the title of this tip), which I'll paraphrase as follows:
- What can I do to create attractive output for my XML data?
- How can I manage page layout, typography, color schemes, and so forth when outputting XML data?
The short answer to both questions can be "Use some kind of XSL Formatting Objects (XSL-FO) enabled rendering engine." A longer answer requires explaining what such an engine is, how you might use it, and what kinds of choices are available to fill this XML processing role. For all three elements of this longer version, you'll probably be surprised at the current state of XSL-FO capabilities and software.
XSL-FO provides object-level controls on how XML objects and their content may be rendered when output through some kind of software program that massages the content with formatting data to manage its appearance. Normally, XSL-FO is used in concert with XSLT (the XML Stylesheet Language for object transformation) to convert XML data from some canonical form in a document to output aimed at a specific rendering engine. This represents a clear-cut case of transforming and rendering data from an extremely generic form (the XML document) to output instructions aimed at a particular rendering engine (and usually, some associated output device like a color laser printer).
Lots of XSL-FO composers and rendering engines are available in today's marketplace, including Open Source and commercial implementations. XEP, IBM, Apache FOP (Formatting Objects Processor), X-Smiles, and Passive TeX (a popular typesetting system originally devised by Donald Knuth for his computer science texts), all offer working XSL-FO processors with various kinds of rendering capabilities that are worth investigating. For more information visit xml.coverpages.org and search on "XSL-FO."
Normally, an XSL-FO Processor is invoked in the form of XSL-FO markup taken as arguments to XSLT functions and markup. In other words, by applying a specific XSLT transform to a class of XML documents, you can use that markup to invoke XSL-FO markup and target a specific processor to create attractively formatted output. The Apache FOP, for example, supports transformation of text and other data from XML documents into attractively formatted Adobe Portable Document Format (.pdf) files, which permits highly structured formatting and layout controls to be applied and managed for document output.
In general, content developers and Web site operators who have large amounts of structured data that they seek to deliver in printed and online forms will find the combination of XML, XSLT, and XSL-FO hard to resist. In fact, the more demanding and stringent your output and layout requirements might be, the more irresistible XSL-FO typically becomes. That's because climbing the learning curve to perform low-level, complex formatting and layout work is time-consuming, demanding, and sometimes difficult. Those for whom the rewards are tangible will appreciate the results; those for whom the rewards are not so great will probably find it to be more trouble than it's worth. Either way, this technology is worth investigating. Chances are pretty good these days, in fact, that if you've got a content management environment with any kind of serious output capabilities, it may already be using this technology under the hood.
About the Author
Ed Tittel is a principal at LANWrights, Inc., a network-oriented writing, training, and consulting firm based in Austin, Texas. He is the creator of the Exam Cram series and has worked on over 30 certification-related books on Microsoft, Novell, and Sun related topics. Ed teaches in the Certified Webmaster Program at Austin Community College and consults. He a member of the NetWorld + Interop faculty, where he specializes in Windows 2000 related courses and presentations.
For More Information:
- Looking for free research? Browse our comprehensive White Papers section by topic, author or keyword.
- Are you tired of technospeak? The Web Services Advisor column uses plain talk without the hype.
- For insightful opinion and commentary from today's industry leaders, read our Guest Commentary columns.
- Hey Codeheads! Start benefiting from other time-saving XML Developer Tips and .NET Developer Tips.
- Visit our huge Best Web Links for Web Services collection for the freshest editor-selected resources.
- Choking on the alphabet soup of industry acronyms? Visit our helpful Glossary for the latest lingo.
- Visit Ask the Experts for answers to your Web services, SOAP, WSDL, XML, .NET, Java and EAI questions.
- Discuss this issue, voice your opinion or just talk with your peers in the SearchWebServices Discussion Forums.