In my last article on XSL Formatting Objects (XSL-FO), we took a look at the basics. We created a simple page master with one body region and then wrote some text onto the page. However, XSL-FO offers a lot more functionality and flexibility. In this article, we'll take a closer look at regions.
Using Regions with XSL Formatting Objects (Page 1 of 4 )
XSL-FO defines several levels of areas with which we can work. The highest level is the page, and the next level after this is the region. A region is, in the simplest terms, a section of a page. Each page contains five regions, which correspond to different areas of the page. Using regions, it's possible to place content appropriately.
For example, consider a page of a book. The page could be divided up into multiple regions, each containing different bits of information. The text of the page, for instance, would go into one region, and the page number would go into another. Later, we'll be able to use the various regions to design the page of a book.
Regions are defined inside of the page master to which they belong. In the last article, we examined the body region, defined using the region-body tag. There are more region types, but we'll start by looking at the body region, since it's the most important. A body region definition might look something like this:
Note that the name "xsl-region-body" is traditionally used for body regions. In fact, it's the default value, so there's no need to explicitly state the name like we did above. You're free to use whatever name you want, but if you're lacking in creativity, then this value will do. Besides, when the region is referenced elsewhere in the XSL-FO document, the region's type will be unambiguous. The other regions also have default names like this.
This region contains, as the name suggests, the body of the page. This is where the page's primary content is contained. In the case of a page out of a book, the actual text would go here. In order to actually place the text within the region, the flow element is used. For example, to flow content into the body region we created earlier, we'd do something like this: