Nested List

Fitrio Pakana <[email protected]> Wed, 5 Mar 2003 14:13:06 +0800
Newsgroups gmane.text.xml.jfor.general
Message-ID <[email protected]>
Hello,

I was wondering if anyone could give some examples of XSL-FO templates to
render nested list. I've tried use the following templates, but instead of
output correct nesting lists, all I got was all items rendered as first
level in the list. I was expecting output like this:

List Item A
List Item B
	List Item B.1
	List Item B.2
List Item C


But got output like this:

List Item A
List Item B
List Item C
List Item B.1
List Item B.2

Here are the templates:

	<!-- UNORDERED LIST -->
	<xsl:param name="list-startdist-default" select="string('2em')"/>
	<xsl:param name="list-gap-default" select="string('0.5em')"/>
	<xsl:attribute-set name="list.item">
		<xsl:attribute name="space-before">1em</xsl:attribute>
		<xsl:attribute name="space-after">1em</xsl:attribute>
		<xsl:attribute
name="relative-align">baseline</xsl:attribute>
	</xsl:attribute-set>
	<xsl:template match="ul">
		<xsl:variable name="start-dist-local">
			<xsl:choose>
				<xsl:when test="./@startdist">
					<xsl:value-of
select="./@startdist"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of
select="$list-startdist-default"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="gap-local">
			<xsl:choose>
				<xsl:when test="./@gap">
					<xsl:value-of select="./@gap"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of
select="$list-gap-default"/>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<fo:list-block
provisional-distance-between-starts="{$start-dist-local}"
provisional-label-separation="{$gap-local}">
			<xsl:apply-templates/>
		</fo:list-block>
	</xsl:template>
	<xsl:template match="ul/li">
		<fo:list-item xsl:use-attribute-sets="list.item">
			<fo:list-item-label end-indent="label-end()">
				<fo:block text-align="end">
					<xsl:choose>
						<xsl:when
test="../@type='disc'">
	
<xsl:text>?</xsl:text>
						</xsl:when>
						<xsl:when
test="../@type='circle'">
	
<xsl:text>?</xsl:text>
						</xsl:when>
						<xsl:when
test="../@type='square'">
	
<xsl:text>?</xsl:text>
						</xsl:when>
						<xsl:when
test="../@type='bsquare'">
	
<xsl:text>?</xsl:text>
						</xsl:when>
						<xsl:otherwise>
	
<xsl:text>?</xsl:text>
						</xsl:otherwise>
					</xsl:choose>
				</fo:block>
			</fo:list-item-label>
			<fo:list-item-body start-indent="body-start()"
text-align="justify">
				<fo:block>
					<xsl:apply-templates/>
				</fo:block>
			</fo:list-item-body>
		</fo:list-item>
	</xsl:template>
	<!--END OF UNORDERED LIST-->



Thanks,

Rio


-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com