Preface

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.

Who Should Read This Book?

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.

What Does This Book Cover?

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.

Motivation

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.

Organization of This Book

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.

What Else Do You Need?

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.

Conventions Used in This Book

The following font conventions have been used in this book:

Italic

Is used to introduce new terms, as well as for email addresses and URLs.

Constant width

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.

Constant width italic

Is used for replaceable elements in code examples.

Tip

This icon indicates a tip, suggestion, or general note.

Warning

This icon indicates a warning or caution.

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.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly & Associates, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
(800) 998-9938 (in the United States or Canada)
(707) 829-0515 (international/local)
(707) 829-0104 (fax)

There is a web page for this book, which lists errata, examples, or any additional information. You can access this page at:

http://www.oreilly.com/catalog/xslfo/

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:

http://www.oreilly.com

Acknowledgments

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.

Get XSL-FO now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.