7. Lists, enumerations and description lists

XSL-FO offers a special concept for list-like structures which helps to create so-called ordered lists (each list item gets an order name, typically a serial number), unordered lists or enumerations (each list item gets the same leading sign, typically an en-dash or a bold bullet or - like in this book - a square) or description lists (each list item gets a description of its content).

The XSL-FO concept for lists consists of four specific elements:

  • <fo:list-block> (list)

  • <fo:list-item> (list item)

  • <fo:list-item-label> (label of list item)

  • <fo:list-item-body> (content of list item)

Within <fo:list-item-label> and <fo:list-item-body> are the normal block elements, typically fo:block.

The following graphic shows the hierarchical relationship of these list-specific elements:

List blocks

List blocks

The XSL-FO code of a simple list looks like the following:

<fo:block>
   <fo:list-block>
      <fo:list-item>
         <fo:list-item-label>
            <fo:block>
               1.
            </fo:block>
         </fo:list-item-label>
         <fo:list-item-body>
            <fo:block>
               The text belonging to the first list element
            </fo:block>
         </fo:list-item-body>
      </fo:list-item>
      <fo:list-item>
         <fo:list-item-label>
            <fo:block>
               2.
            </fo:block>
         </fo:list-item-label>
         <fo:list-item-body>
            <fo:block>
               The text belonging to the second list element
            </fo:block>
         </fo:list-item-body>
      </fo:list-item>
   </fo:list-block>
</fo:block>

However, the typographical implementation of the code introduced in this example is very plain since important information for the design is missing. For example, without any defined spacing attributes the content of the list item label is overlayed by the content of the list item.

In the following graphic the various attributes for the spacing control are displayed:

Spaces in lists

Spaces in lists

provisional-distance-between-starts indicates the distance between the start of the list item label and the start of the content of the list item. As attribute value an absolute value in any supported unit of measurement is expected.

provisional-label-separation indicates the distance between the end of the list item label and the start of the content of the list item. As attribute value an absolute value in any supported unit of measurement is expected.

end-indent=“label-end()” indicates the distance from the end of the list item label to the right margin. The label-end() function automatically determines this distance taking into account the provisional-distance-between-starts and provisional-label-separation values.

start-indent=“body-start()” indicates the distance from the end of the list item label to the start of the content of the list item. The body-start() function automatically determines this distance taking into account the provisional-distance-between-starts and provisional-label-separation values.

start-indent and end-indent of <fo:list-item-label> are also possible when indicating fixed values.

start-indent and end-indent of <fo:list-item-body> are also possible when indicating fixed values.

An example with a list in two levels:

<fo:block text-align="justify" font-size="15pt"> 
<fo:list-block provisional-distance-between-starts="10mm" end-indent="10mm" start-indent="10mm"> (1)
   <fo:list-item> 
      <fo:list-item-label end-indent="label-end()">    (2)
         <fo:block> 1. </fo:block> 
      </fo:list-item-label>
      <fo:list-item-body start-indent="body-start()">  (3)
         <fo:block> Bodytext Bodytext Bodytext Bodytext Bodytext Bodytext 
         Bodytext Bodytext Bodytext </fo:block> 
      </fo:list-item-body> 
   </fo:list-item>   
   <fo:list-item> 
      <fo:list-item-label end-indent="label-end()">    (2)
         <fo:block> 2. </fo:block>
      </fo:list-item-label> 
      <fo:list-item-body start-indent="body-start()">  (3)
         <fo:block> Bodytext Bodytext Bodytext Bodytext Bodytext Bodytext 
         Bodytext Bodytext Bodytext </fo:block> 
      </fo:list-item-body> 
   </fo:list-item>
   <fo:list-item>
      <fo:list-item-label end-indent="label-end()">    (2) 
      </fo:list-item-label> 
      <fo:list-item-body start-indent="body-start()">  (3)
         <fo:list-block provisional-distance-between-starts="10mm"> (4)
            <fo:list-item>
               <fo:list-item-label end-indent="label-end()">   (2)
                  <fo:block> 2.1 </fo:block> 
               </fo:list-item-label> 
               <fo:list-item-body start-indent="body-start()"> (3)
                  <fo:block> Bodytext Bodytext Bodytext Bodytext Bodytext Bodytext 
                  Bodytext Bodytext Bodytext </fo:block>
               </fo:list-item-body>
            </fo:list-item>
         </fo:list-block>   
      </fo:list-item-body> 
   </fo:list-item> 
</fo:list-block>
</fo:block>

 

Formatter view

Formatter view

(1) The provisional-distance-between-starts attribute defines the distance between the start margin of the list item label and the start margin of the content of the list item. The already known attributes end-indent and start-indent generate indents at the left and right margin.

(2) The value of the end-indent attribute is automatically determined by the label-end() function and indicates the distance between the right margin and the end of the list item label.

(3) The value of the start-indent attribute is automatically determined by the body-start() function and indicates the distance between the left margin and the start of the content of the list item.

(4) A nesting of lists is generated by a second list within the <fo:list-item-body> element.

With regard to the numbering of list items it must be noted that there are no XSL-FO elements or attributes which control or generate such a thing. The automatic numbering has to be generated with the <xsl:number> XSLT element.

The characters which are often used in unordered lists can be borrowed from other fonts if they are not included in the typesetting or they can be replaced by using a graphic.

<< back next >>

Copyright © dpunkt.verlag GmbH 2004
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSL-FO in der Praxis" ("XSL-FO in practice") is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

dpunkt.verlag GmbH, Ringstraße 19B, 69115 Heidelberg, fon 06221-14830, fax 06221-148399, hallo@dpunkt.de