Lists
Lists are created using the fo:list-block element. A fo:list-block in XSL-FO is an area of content divided into two columns. We recommend using tables rather than lists. Any output that can be created using an fo:list can be created with a two-column fo:table. So save yourself the time learning fo:lists and just use fo:tables.
A simple fo:list-block is shown in Figure 13-1. The list created by this FO is shown in Figure 13-2.
<fo:list-block provisional-distance-between-starts=".5cm" provisional-label-separation="0.1cm">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block font='8pt arial'>●</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
item one
</fo:block>
</fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block font='8pt arial'>●</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
item two
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
Features of lists include:
- the fo:list-block is a block-level element which contains the whole list.
- the provisional-distance-between-starts attribute on the fo:list-block defines the distance between the start of the label and the start of the body.
- the provisional-label-separation attribute on the fo:list-block defines the size of the gap between the end of the label and the start of the body. This gap is created by reducing the size of the label. For example, if provisional-distance-between-starts is 5cm and the provisional-label-separation is 1cm, then the start edges of the label and body will be 5cm apart, and the label will be 4cm (5cm - 1cm) wide.
- each item in the list is contained in a fo:list-item element.
- each fo:list-item must contain both a fo:list-item-label and a fo:list-item-body. The fo:list-item-label must come first.
- the fo:list-item-label should have the end-indent attribute set to "label-end()". This is a special function which returns a value derived from provisional-distance-between-starts and provisional-label-separation.
- the fo:list-item-body should have the start-indent attribute set to "body-start()". This is a special function which returns a value derived from provisional-distance-between-starts and provisional-label-separation.
- both the fo:list-item-label and fo:list-item-body contain one or more block-level elements, so a fo:list-item-label or fo:list-item-body can contain other block-level elements such as fo:block, fo:table and fo:list-block.
Bulleted lists
The example in Figure 13-1 also shows how to insert a Unicode character into the FO, using the syntax ●. This table shows some common bullet types for lists:
Unicode | Result |
---|---|
• | • |
‣ | ‣ |
● | ● |
○ | ○ |
■ | ■ |
□ | □ |
◆ | ◆ |
◇ | ◇ |
Note that what is displayed in the document depends on whether the font you are using contains the specified character. If the font does not contain the specified character you will see a warning message like the one in Figure 13-3.
warning:380 No glyph index found for code point 2023 in font ArialMT