Home arrow XML arrow Page 3 - Using XSL Formatting Objects

Using XSL Formatting Objects

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.

Author Info:
By: Peyton McCullough
Rating: 4 stars4 stars4 stars4 stars4 stars / 7
February 04, 2009
  1. · Using XSL Formatting Objects
  2. · Creating a Hello world document
  3. · Processing a document
  4. · Page masters

print this article

Using XSL Formatting Objects - Processing a document
(Page 3 of 4 )

Of course, by itself, the document is worth nothing. Recall that a processor such as Apache FOP is needed to process the document into a more meaningful format. Let's make our "Hello world" example into a PDF document. Go ahead and download the latest version of Apache FOP:


Converting the raw XSL-FO file into a PDF file is incredibly simple. Simply run the following command; a PDF file named helloworld.pdf will be created:

fop helloworld.fo helloworld.png

The document can be processed in a number of other ways as well. We could, for example, output a file in rich text format:

fop helloworld.fo -rtf helloworld.rtf

Or we could generate an image:

fop helloworld.fo -png helloworld.png

To view a more complete list of possible output formats, check the documentation or type "fop" without any arguments at the command line. Just keep in mind that some of these formats won't take advantage of all the functionality that XSL-FO provides. A PDF file is a lot more suited to paged data than a PNG image.

One of the most useful things to do, however, is to immediately display the resulting document on the screen. This can easily be done using Apache FOP:

fop helloworld.fo -awt

The processor isn't limited to simple FO-to-output operations. Recall that formatting objects were designed to be used with XSLT and XML data. It's possible to use another program such as Saxon to generate formatting objects from an XML document and an XSLT stylesheet, but Apache FOP can actually combine these steps. That is, you can specify an XML file and an XSLT stylesheet, and it can output a PDF file. We'll take a look at this later.

blog comments powered by Disqus

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials