To process ch14_03.po and create a formatted document, I'll use James Tauber's FOP (Formatting Objects Processor), which has now been donated to the Apache XML Project. (The alphaWorks XML for Java parsers that I've been using for several chapters are based on the Apache XML project's Xerces XML parser.) Here's how the Apache XML Project describes FOP:
Here's how the objectives of FOP are described:
You can get FOP at http://xml.apache.org/fop; just click the Download button to download it. The FOP package, including documentation, comes zipped , so you have to unzip it. The current version as of this writing is 0.20.4 and it's written in Java; the compressed file that you download is fop-0.20.4-bin.tar.gz (even though it's a .tar.gz file, even Windows unzip utilities, such as WinZip, can unzip it). To convert ch14_03.fo into a PDF file, ch14_04.pdf, you can navigate to the fop-0.20.4 directory created when you unzip fop-0.20.4-bin.tar.gz and enter this command (this assumes that ch14_03.fo is in the fop-0.20.4 directory also): %java -cp build\fop.jar;lib\batik.jar;lib\xalan-2.3.1.jar;lib\xercesImpl-2.0.1.jar;lib\ xml-apis.jar;lib\avalon-framework-cvs-20020315.jar;lib\logkit-1.0.jar;lib\jimi-1.0.jar org.apache.fop.apps.Fop ch14_03.fo ch14_04.pdf That's quite a mouthful, so FOP comes with a script for most shells , including a .bat file for Windows. This means that you only have to enter this command in the fop-0.20.4 directory to do the same thing: %fop ch14_03.fo ch14_04.pdf And that's it. You can see the final results, ch14_04.pdf, in the Adobe Acrobat PDF reader (which you can get for free at www.adobe.com/products/acrobat/readermain.htmlcurrently, the download process starts at www.adobe.com/products/acrobat/readstep.html) in Figure 14-1. The ch14_01.xml document appears in that figure formatted exactly as it should be. The PDF format is a good one for formatting object output, although it has some limitations. For example, it can't handle dynamic tables that can expand or collapse at the click of a mouse, or interactive multiple-target links, both of which are part of the formatting objects specification. Figure 14-1. A PDF document created with formatting objects.
Now you've seen how the process works; it's time to get to the details, starting with an overview. |