Creating Lists

Contact Us or call 1-877-932-8228
Creating Lists

Creating Lists

Lists are created with the list-block FO, which contains one or more list-item FOs. Each list-item FO must contain two child FOs: list-item-label and list-item-body. The syntax is shown below.

<fo:list-block start-indent="20pt"> <fo:list-item> <fo:list-item-label end-indent="label-end()"> <fo:block font-weight="bold"> <!--bullet character or number--> </fo:block> </fo:list-item-label> <fo:list-item-body start-indent="body-start()"> <fo:block> <!--list item content--> </fo:block> </fo:list-item-body> </fo:list-item> <fo:list-item> <fo:list-item-label end-indent="label-end()"> <fo:block font-weight="bold"> <!--bullet character or number--> </fo:block> </fo:list-item-label> <fo:list-item-body start-indent="body-start()"> <fo:block> <!--list item content--> </fo:block> </fo:list-item-body> </fo:list-item> </fo:list-block>

Below is a different view of how these tags are nested. The plus sign (+) indicates that list-item can be repeated.

list-block

The list-block FO contains the entire list. It can take many formatting attributes. A common one is start-indent, which can be used to indent the entire list. The list-block FO contains one or more list-item FOs.

list-item

The list-item FOs each contain two child FOs: list-item-label and list-item-body.

list-item-label

The list-item-label FO contains the symbol or character used to label the list; for example, a bullet or a number. It often takes the end-indent attribute with a value of label-end(), indicating that the label should not be indented more than its natural width.

character

The character FO is used to output a character using its character code. For example, the following would output a standard bullet.

<fo:character character="&#x2022;"/>

list-item-body

The list-item-body FO contains the actual content of the list item. It often takes the start-indent attribute with the value of body-start(), indicating that the body of the list item should start at the beginning of the list-item-body box.

Let's take a look at an example.

Code Sample:

BlocksAndInlines/Demos/ShoppingList.fo
<?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="List" page-height="11in" 
			page-width="8.5in" margin-top="1in" margin-bottom="1in" 
			margin-left="1in" margin-right="1in">
			<fo:region-body margin-top="1in" margin-bottom=".5in"/>
		</fo:simple-page-master>
	</fo:layout-master-set>
	<fo:page-sequence master-reference="List">
		<fo:flow flow-name="xsl-region-body">
			<fo:block space-after="24pt" font-weight="bold">
				Shopping List
			</fo:block>
			<fo:list-block start-indent="2in">
				<fo:list-item>
					<fo:list-item-label end-indent="label-end()">
						<fo:block font-weight="bold">
							<fo:character character="&#x2022;"/>
						</fo:block>
					</fo:list-item-label>
					<fo:list-item-body start-indent="body-start()">
						<fo:block>Pizza</fo:block>
					</fo:list-item-body>
				</fo:list-item>
				<fo:list-item>
					<fo:list-item-label end-indent="label-end()">
						<fo:block font-weight="bold">
							<fo:character character="&#x2022;"/>
						</fo:block>
					</fo:list-item-label>
					<fo:list-item-body start-indent="body-start()">
						<fo:block>Coke</fo:block>
					</fo:list-item-body>
				</fo:list-item>
			</fo:list-block>
		</fo:flow>
	</fo:page-sequence>
</fo:root>

The example above will render as follows.

Note that lists can be nested. For an example see BlocksAndInlines/Demos/ShoppingListNested.fo.

Next