Creating Tables

Some of the most useful constructs that you can format with XSL are tables. A table in XSL is much like one in HTML—a rectangular grid of rows and columns of cells. You can use nine formatting objects to create tables:

  • fo:table-and-caption

  • fo:table

  • fo:table-column

  • fo:table-caption

  • fo:table-header

  • fo:table-footer

  • fo:table-body

  • fo:table-row

  • fo:table-cell

Creating tables is a little involved in XSL. You create a fo:table object and then format each column with a fo:table-column object. Then you create a table-body object, as well as table-row objects for each row and table-cell objects for each cell in each row. Here's an example creating a 3×3 table with the words Tic, Tac, and Toe repeated on each line:

Listing . ch14_08.fo
 <?xml version="1.0" ...

Get Real World XML 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.