Switching Gears - XSL-FO, Day 1

by Simon St. Laurent

Related link: http://www.cranesoftwrights.com/schedule.htm#pfux



After three days of intensive XSLT, the training has changed over to Formatting Objects (XSL-FO). Instead of thinking about how best to push or pull information through my logic, I'm thinking about how to make boxes line up, trying to remember my CSS properties (since they mostly work in FO), and thinking about how to integrate the logic of FO with the logic of XSLT. Fortunately each was designed with the other in mind.



XSLT, which can seem pretty alien when you're trying to convert from one XML vocabulary to another completely different vocabulary, works a lot more easily in the context of document-to-document conversions. While there are still times in document processing where document order isn't what you want, converting from one document in a particular order to a formatted representation of the same document in the same order is pretty simple.



(Come to think of it, that's not so far off from what I've done with CSS in the past, but dealing with paginated regions is tricky enough that having XSLT to handle odd cases and insert extra information is sometimes convenient, even when we're processing in document order.)



FO's multi-stage processing model is definitely a challenge for my brain, since I need to keep track of how my XSLT stylesheet generates an instance tree which then becomes an FO tree, which is then refined into a refined FO tree, which then becomes an area tree, which is then rendered. (Processors can combine those steps internally, but I still need to keep this pipeline in my head to get results that resemble what I want.)



Fortunately, Ken Holman has enough diagrams, examples, and good humor to keep us moving forward through the maze. It's a maze I've wandered before, but I suspect I'd have to do this repeatedly for the best practices to seem natural. Exercises during the day help a lot, at least in part because they're an opportunity to get things (sometimes horribly) wrong. As the current slide says, "Risk of overlap is borne by the stylesheet writer" - there are lots of risks like that, not to mention the risks of typos in 35-character attribute names. And then there are those ghost-list labels for ghost-list items...



The niftiest things I've discovered today are the combination of starts-row and ends-row properties in tables, the conditional nature of their processing, and a nice proportional-column-width() function. It's been a long time since I've wrangled tables on a regular basis, but I could feel old problems fading away.



Have you had a chance to play with XSL-FO?