Home arrow XML arrow Using XSL Formatting Objects
XML

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
TABLE OF CONTENTS:
  1. · Using XSL Formatting Objects
  2. · Creating a Hello world document
  3. · Processing a document
  4. · Page masters

print this article
SEARCH DEVARTICLES

Using XSL Formatting Objects
(Page 1 of 4 )

Formatting content or data is for many reasons a key process. Content may be wonderful alone, but if the content isn't formatted, then, to most people, it's worth very little because, to them, it's less welcoming and less accessible. When dealing with formatting content for use on a computer screen, HTML comes to mind. It's one of the most popular and easy-to-use tools available for presenting content on a computer screen.

However, some things need to be formatted for use on paper, and that presents a challenge. When formatting content for use on a computer screen, the content can simply run down the screen. The formatter doesn't have to worry about page breaks or anything like that. However, with pages, this is different. Only so much content can fit on one page before a new page is needed.

For this, another technology is needed. There are, of course, various ways to format content for use in print, but one technology really stands out: XSL Formatting Objects, or XSL-FO. XSL-FO is part of the XSL family of technologies, recommended by W3C, and because it's XML-based, it's easy to use, and it's easy to work with alongside other powerful technologies. Using XSL-FO, it's possible to format content for page-based presentation using a familiar XML-based syntax.

In this article, we'll take a look at using XSL-FO to format content for page-based media.

The basics of XSL-FO

As mentioned, XSL-FO is one of the technologies in the XSL (Extensible Stylesheet Language) family. The other two technologies are XSLT for transformations and XPath for addressing the nodes and attributes of an XML document.

It's perfectly possible to use XSL-FO by itself to create a formatted, page-based document. This is how we're going to initially approach XSL-FO in this article. However, one of the neat things about XSL-FO is that it can be easily used (and was designed to be used) in conjunction with XSLT. Using these technologies together, it's possible to take a regular XML document and transform it into an XSL-FO document using XSLT.

An XSL-FO document alone, however, does nothing. It simply describes how the formatted page should look. In order to make it useful, you need to use an XSL-FO processor. The processor takes the XSL-FO file and converts it into a format that is immediately useful. You can process it into all sorts of formats, such as images or rich text documents, but the most fitting result is probably a PDF file.

There are a number of XSL-FO processors available, some free and some commercial. Apache FOP (Formatting Objects Processor) is a popular option. We'll cover using Apache FOP in a bit.


blog comments powered by Disqus
XML ARTICLES

- 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 
Support 

Developer Shed Affiliates

 




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