Contents | < Tables | Pagination >
XSL-FO lists are created using fo:list-block element. A list can contain one or more items (fo:list- item). Each item has a label (fo:list-item-label) usually used to display a bullet or a number, and a body (fo:list-item-body).
<fo:flow color="rgb(0,0,128)" flow-name="xsl-region-body" font-size="20pt">
<fo:block>To do list:</fo:block>
<fo:list-block >
<fo:list-item >
<fo:list-item-label end-indent="label-end()" >
<fo:block>
1)
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()" >
<fo:block>
Very very important stuff
</fo:block>
</fo:list-item-body>
</fo:list-item>
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>
2)
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
Very important stuff
</fo:block>
</fo:list-item-body>
</fo:list-item>
...
</fo:list-block>
</fo:flow>
![]() | For the complete source code for this code example see "Tutorial/List.fo" located under XML Documents Samples/Tutorial folder. |
The rendering result is displayed in the next figure.

Figure 1
The important points in this document are:
The list is created using fo:list-block.
A list can have one or multiple items.
Each item has a label, usually used to display a bullet or number, and a body.
XSL-FO does not provide an element to create numbered lists like HTML does; you have to generate the numbers using XSL techniques.
Considering the following source XML document:
<products>
<product>Fuji FinePix F700</product>
<product>Nikon CoolPix 5700</product>
<product>Cannon Powershot A310</product>
</products>
We can create an XSL template that uses xsl:number element to generate numbers for each fo:list-item-label:
<?xml version="1.0" encoding="utf-8" ?>
<?xsl-test-case type="text/xml" href=".\Numbered List.xml"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<xsl:template match="/">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="all">
<fo:region-body region-name="xsl-region-body" margin="1in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="all">
<fo:flow flow-name="xsl-region-body">
<fo:list-block>
<xsl:for-each select="products/product">
<fo:list-item>
<fo:list-item-label end-indent="label-end()">
<fo:block>
<xsl:number/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:value-of select="." />
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:for-each>
</fo:list-block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>.
![]() | For the complete source code for this code example see "Tutorial/Numbered List.xml" and "Tutorial/Numbered List.xsl" located under XML Documents Samples/Tutorial folder. |
Contents | < Tables | Pagination >