和荣笔记 - XSL-FO 与 XHTML
杨和荣, 版本 2.03, 2007年

XSL-FO - Lists and Tables

"list-block" Statements

"list-block": An XSL-FO element serving as an action statement to generate one block area with list of pairs of list label and list item.

<fo:list-block provisional-distance-between-starts="1.0in"
 provisional-label-separation="0.1in">
 <fo:list-item>
  <fo:list-item-label start-indent="0.1in">
  symbol or label
  </fo:list-item-label>
  <fo:list-item-body start-indent="1.5in" end-indent="0.1in">
  text
  </fo:list-item-body>
 </fo:list-item>
 ...
</fo:list-block>

Note that:

  • A list block is made of list item areas. And there are two sub areas in each list item area: label area and body area.
  • The provisional-distance-between-starts="1.0in" attribute specifies the distance from the start edge of the label area to the start edge of the body area.
  • The provisional-label-separation="0.1in" attribute specifies the distance from the end edge of the label area to the start edge of the body area.
  • The start-indent="0.1in" attribute is used for the label area to give extra indention for a specific list item.
  • The start-indent="1.5in" attribute specifies the distance from the start edge of the list block area to the start edge of the body area.

The following FO file, list.fo, shows how to use list-block statements:

<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
 <fo:layout-master-set>
  <fo:simple-page-master master-name="page" margin="1in">
   <fo:region-body/>
  </fo:simple-page-master>
 </fo:layout-master-set>
 <fo:page-sequence master-reference="page">
  <fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:list-block>
 <fo:list-item>
  <fo:list-item-label>
   <fo:block>Term 1</fo:block>
  </fo:list-item-label>
  <fo:list-item-body start-indent="1.0in">
   <fo:block>Description 1</fo:block>
  </fo:list-item-body>
 </fo:list-item>
 <fo:list-item>
  <fo:list-item-label>
   <fo:block>Term 2</fo:block>
  </fo:list-item-label>
  <fo:list-item-body start-indent="1.0in">
   <fo:block>Description 2</fo:block>
  </fo:list-item-body>
 </fo:list-item>
</fo:list-block>
</fo:block>
  </fo:flow>
 </fo:page-sequence>
</fo:root>

Note that:

  • The provisional_* attributes is not used in list-block statement, because it doesn't do anything with FOP.
  • start-indent="1.0in" is used in list-item-body to push the body area to go beyond the label area.

"table-and-caption" Statements

"table-and-caption": An XSL-FO element serving as an action statement to generate one block area with a table and its caption.

<fo:table-and-caption caption-side="after">
 <fo:table-caption>
  caption text
 </fo:table-caption>
 <fo:table>
  <fo:table-header>
   cells in the header
  </fo:table-header>
  <fo:table-footer>
   cells in the footer
  </fo:table-footer>
  <fo:table-column>
  </fo:table-column>
  ...
  <fo:table-body>
   <fo:table-row>
    <fo:table-cell>
     text of the cell
    </fo:table-cell>
    ...
   </fo:table-row>
   ...
  </fo:table-body>
 </fo:table>
</fo:table-and-caption>

Note that:

  • The caption-side="after" attribute specifies that the caption text goes to the bottom of the table.
  • "table-header" is usually the first row, which serves as the column headers.
  • "table-footer" is usually the last row of the table.

"leader" Statements

"leader": An XSL-FO element serving as a special statement to generate one inline area filled with specified pattern. The pattern can be space, dots or rule, and length of the pattern can be fixed or extendable based on the inline stacking constrains. The following code shows two examples:

<fo:block">
Your name [<fo:leader leader-pattern="space" leader-length="2in"/>]
</fo:block>
<fo:block" text-align-last="justify">
Author <fo:leader leader-pattern="dots"/> Herong yang
</fo:block>
杨和荣,修改于2007年
和荣笔记 - XSL-FO 与 XHTML - XSL-FO - Lists and Tables