Tables in XSL-FO

Tables in XSL-FO are created with the following formating objects:

  • fo:table-and-caption,
  • <fo:table> is used to model the visual layout of a table. An XSL-FO table may have the same attributes as <fo:block> does, except for padding.
  • fo:table-column,
  • fo:table-caption,
  • fo:table-header,
  • fo:table-footer,
  • fo:table-body,
  • fo:table-row,
  • fo:table-cell.

Table in XSL-FO are compared with HTML tables: tables are made of cells that are grouped into rows.

Here is a simple example:

   <fo:table>
     <fo:table-column column-width="20%"/>
     <fo:table-column column-width="80%"/>
     <fo:table-body>
       <fo:table-row>
         <fo:table-cell>
           <fo:block margin="12pt" font-weight="bold" font-size="8pt">
		     Serif 8pt:
           </fo:block>
         </fo:table-cell>
         <fo:table-cell>
           <fo:block margin="12pt" font-size="8pt">
		     The quick brown fox jumps over the lazy dog!
           </fo:block>
         </fo:table-cell>
       </fo:table-row>
       <fo:table-row>
         <fo:table-cell>
           <fo:block margin="12pt" font-weight="bold" font-size="8pt">
		     Serif 36pt:
           </fo:block>
         </fo:table-cell>
         <fo:table-cell>
           <fo:block margin="12pt" font-size="36pt">
		     The quick brown fox jumps over the lazy dog!
           </fo:block>
         </fo:table-cell>
       </fo:table-row>
     </fo:table-body>
   </fo:table>

This example shows how to make a table with 2 rows and 2 collumns where the second column is 4 times wider that the first one.