Extensible Style Language-Formatting Objects, or XSL-FO, is a set of tools developers and web designers use to describe page printouts of their XML (including XHTML) documents. XSL-FO teaches you how to think about the formatting of your documents and guides you through the questions you'll need to ask to ensure that your printed documents meet the same high standards as your computer-generated content.
Copyright 2002 O'Reilly & Associates, Inc. All rights reserved.
Printed in the United States of America.
Published by O'Reilly & Associates, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O'Reilly & Associates books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://safari.oreilly.com). For more information contact our corporate/institutional sales department: 800-998-9938 or firstname.lastname@example.org.
Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered trademarks of O'Reilly & Associates, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O'Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. The association between the image of a pennant-winged nightjar and the topic of XSL-FO is a trademark of O'Reilly & Associates, Inc.
While every precaution has been taken in the preparation of this book, the publisher and the author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
Certain parts of this document are taken from the Extensible Stylesheet Language (XSL) Version 1.0 W3C Proposed Recommendation 28 August 2001, found at http://www.w3.org/TR/xsl/, which has a copyright statement at http://www.w3.org/Consortium/Legal/ipr-notice-20000612#Copyright. These are Copyright August 2001, World Wide Web Consortium (Massachusetts Institute of Technology, Institut National de Recherche en Informatique et en Automatique, and Keio University).
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with the Invariant Sections being no invariant sections, with the Front-Cover Texts being no invariant sections, and with the Back-Cover Texts being no invariant sections. A copy of the license is included in Appendix H, GNU Free Documentation License. All images are to be included verbatim when the document is copied, distributed, or modified under the terms of the GFDL.
This book is an introduction to Extensible Stylesheet Language Formatting Objects (XSL-FO). The Extensible Stylesheet Language (XSL) provides a means of producing high-quality print output from your XML documents. XSL describes how to use XSL Transformations (XSLT) to generate XSL-FO documents that represent page layouts. Using XSL, you can create standard print representations of XML documents using XSL-FO to specify how information should appear on pages.
This book is for people who want to create print versions of their XML documents. It provides an introduction to the XSL as specified by the World Wide Web Consortium (W3C) at http://www.w3.org/Style/XSL. It focuses, in particular, on the XSL-FO aspect of XSL, an XML vocabulary targeted at expressing how source content should be laid out and paginated for presentation.
This book should be useful to everyone from technical authors who have moved into stylesheet design to software developers engaged in media design to those exploring the developing XML family of standards. If you are curious about XSL-FO or want to produce print output from XML, read on. When you stop enjoying the chase, stop reading. When you reach an "Aha!" moment, smile with me. I'm not saying it's easy, but this avenue of learning can be fun. You'll be rewarded quickly by the feedback of visual output, although there are a few dead ends.
I make few assumptions about the audience other than a familiarity with basic XML and an awareness of XSLT processing. You won't enjoy this book until you can process XML with an XSLT processor. With that in mind, my recommendation for a companion volume is Mike Kay's XSLT Programmer's Reference (Wrox Press). It's an excellent reference book that has never failed to explain to me how to use the W3C recommendation.
The intended audience of this book is users of the recommendation, not implementors. If you want to implement the specification then the specification is your primary reading matter, though this book may be of some assistance.
This book covers the same content found in the published recommendation. The focus throughout this book is to help users of XSL-FO. It is not a theoretical discourse on the recommendation, but a complement to the recommendation. I have tried to write something that bridges the gap between implementor and user, with a bias towards the user.
A large part of my motivation for writing this book was my experience with Document Style Semantics and Specification Language (DSSSL), an SGML style language. I had approached DSSSL within weeks of learning that SGML existed and that it was supported by accessible tools. The tools were not well explained, however. My struggles with DSSSL, SGML, Scheme, and Emacs, all in one go, were very nearly too much. Very few technologies can gain support without sufficient explanatory material available to the end user. So with that in mind, and my reaction to XSL-FO similar to what I had with DSSSL, I decided to do something about it.
Chapter 1 provides a brief explanation of what XSL-FO is good for and how it can fit into your XML print production processes.
Chapter 2 introduces the big picture of XSL-FO, its foundations, and its capabilities.
Chapter 3 explores XSL-FO's notions of pages, page masters, and page sequences.
Chapter 4 explains how to define areas, which hold content within pages.
Chapter 5 introduces blocks, the units of the document that fill areas, which may be split across areas and pages, and reflect document components such as paragraphs, tables, and figures.
Chapter 6 explains the special inline formatting that may occur inside block elements.
Chapter 7 explores XSL-FO's facilities for presenting information using graphics and color.
Chapter 8 explores XSL-FO's text-specific capabilities.
Chapter 9 examines how XSL-FO lets you create links for use with chapters, cross-references, indexes, and similar structures so you may present documents that feel complete.
Chapter 10 examines how all the different pieces interact and combine when XSLT and XSL-FO are used to produce formatted renderings.
Chapter 11 examines different types of stylesheets and issues of inclusion and reuse.
Appendix A provides a quick reference for common formatting tasks and the best ways to support them in XSL-FO.
Appendix B provides you with a basic framework for reading the W3C's XSL Recommendation in detail, as it isn't exactly light reading.
Appendix C lists a variety of XSL-FO tools available at the time of writing.
Appendix D explains the compliance levels that XSL-FO permits processors to support. This appendix should help you determine which implementation is appropriate to your needs.
Appendix E provides a quick guide to which properties are inherited among formatting objects.
Appendix F provides a full listing of the XSLT stylesheet created in Chapter 10.
Appendix G helps you pick the property or trait you need for a given task.
Appendix H provides the most updated version of the license at the time of this printing.
The Glossary lists terms you'll need to use XSL-FO effectively.
As mentioned earlier, you'll need some level of understanding of how to obtain an XML document compliant to the XSL-FO vocabulary from an XML document. Plenty of examples are provided, but use of XSLT is necessary, because I do not believe that authoring directly in XSL-FO is either viable or especially worthwhile. I always assume your starting point is an XML instance and that the resultant XSL-FO is a temporary intermediary file that will be thrown away once the final form document is available.
Next, you'll want a processor to convert the XSL-FO into its final form, either a printed document on paper or a PDF document for web delivery. Appendix C addresses the options, covering tools available from the Web as part of the open source movement through to commercial offerings and embedded tools.
The following font conventions have been used in this book:
Is used to introduce new terms, as well as for email addresses and URLs.
Is used for code examples and fragments, as well as for functions and properties.
Constant width bold
Is used to highlight a section of code being discussed in the text.
Is used for replaceable elements in code examples.
I have, when discussing the elements and attributes of XSL-FO, frequently omitted the namespace prefix, as it should be clear from the context. Where examples are included inline, I have attempted to keep them reasonably short. Most examples are accompanied by images taken from the final output to show their actual appearance. If your processor does not produce identical output, there are two possibilities: you've created your code slightly differently than the example or your processor is interpreting the specification differently than the one I've used. The latter case will happen until a far wider experience is fed back to the Working Group for resolution. Even then, there are places where implementations will differ and both will be correct in the strictest terms. Implementation dependencies are, for now, a fact of life.
Please address comments and questions concerning this book to the publisher:
There is a web page for this book, which lists errata, examples, or any additional information. You can access this page at:
To comment or ask technical questions about this book, send email to:
For more information about books, conferences, Resource Centers, and the O'Reilly Network, see the O'Reilly web site at:
First, I'd like to thank Norman Walsh (http://nwalsh.com) and predecessors for docbook, without whom this book would have been written in Word. For his stylesheets, now gaining even wider adoption, and his support over the last four years.
To Nikolai Grigoriev of RenderX and Arved Sandstrom of e-plicity and FOP, and Karen Lease, also a member of the FOP team, for their contributions, and also for their early support of the belief that we could write a book.
To the reviewers for their valuable contributions: Paul Grosso, Norman Walsh, Jeni Tennison, and David Eisenberg. It's far better for their input.
To Sue, my wife, for her patience and understanding when I'm on the computer instead of doing other things on my to-do list.
To my current employer, Royal National Institute of the Blind in the United Kingdom, who gave me the opportunity to get some way along the path to understanding the XML family, thank you Keith.
Last but not least to Simon and Len at O'Reilly, who made it a real treat to deal with a publisher, thank you.