Next in thread →
Next in month →
RE: [docbook-apps] listitems and FO numbering
Title: KCC Stationery
Thanks Bob, works like a charm.
I
wanted to share my resulting code with the list in case someone else would like
to move list item numbers around.
<!-- Template
customization for listitem so that a role can determine where the list item
number is formatted -->
<xsl:template name="listitem_no_number">
<xsl:variable name="id"/>
<fo:list-item id="{$id}"
xsl:use-attribute-sets="list.item.spacing">
<fo:list-item-label/>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates
select="para[1]/preceding-sibling::*"/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
<fo:list-item id="{$id}"
xsl:use-attribute-sets="list.item.spacing">
<fo:list-item-label end-indent="label-end()">
<fo:block>
<xsl:apply-templates select="."
mode="item-number"/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates
select="*/following-sibling::para[1]"/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</xsl:template>
<!-- Determine if first node in listitem is a figure or a
danger/warning/caution, if so call another template -->
<xsl:template match="orderedlist/listitem">
<xsl:variable name="id">
<xsl:call-template name="object.id"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="(para[1]/preceding-sibling::figure) or
(para[1]/preceding-sibling::warning) or
(para[1]/preceding-sibling::caution)">
<xsl:call-template name="listitem_no_number"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="item.contents">
<fo:list-item-label end-indent="label-end()">
<fo:block>
<xsl:apply-templates select="."
mode="item-number"/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</fo:list-item-body>
</xsl:variable>
<xsl:choose>
<xsl:when test="parent::*/@spacing =
'compact'">
<fo:list-item id="{$id}"
xsl:use-attribute-sets="compact.list.item.spacing">
<xsl:copy-of select="$item.contents"/>
</fo:list-item>
</xsl:when>
<xsl:otherwise>
<fo:list-item id="{$id}"
xsl:use-attribute-sets="list.item.spacing">
<xsl:copy-of select="$item.contents"/>
</fo:list-item>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
From: Bob Stayton [mailto:]
Sent: Friday, May 12, 2006 12:02 PM
To: David White;
Cc: David White
Subject:
Re: [docbook-apps] listitems and FO numbering
Hi David,
The mode="item-number" template just returns a number, but
it doesn't place it anywhere. Trying to use float sounds hard,
as you'll have to deal with alignment and such to match your other
listitems.
I would suggest creating a customized copy of
the template for the listitem itself:
<xsl:template
match="orderedlist/listitem[@role='no_number']">
I would have it create two fo:list-items. Put
everything that precedes the first para in the first list-item's list-item-body,
and give it an empty list-item-label. Then put the first para and
everything that follows it in the second list-item's list-body, and put the
number in its list-item-label. That would keep everything lined up the way
you want.
Bob Stayton
Sagehill Enterprises
DocBook Consulting
----- Original Message -----
From:
David White
To:
Cc: David White
Sent: Friday, May 12, 2006 7:37 AM
Subject: [docbook-apps] listitems and FO
numbering
Hello everyone,
I'm looking to control how the listitems
are formatted in XSL-FO. I have XML that is formatted like this for my
list:
<listitem
role="no_number">
<figure>
<title/>
<mediaobject><imageobject><imagedata fileref="A.tif"/></imageobject></mediaobject>
</figure>
<para>some text<para>
</listitem>
What I'm trying to do is
move the listitem number to the <para> tag instead of immediately
rendering after the <listitem> tag.
Below is my XSLT
modification to the <xsl:template match="orderedlist/listitem" mode="item-number"> template:
<xsl:choose>
<xsl:when
test="self::listitem/@role='no_number' and
parent::orderedlist">
<!-- This dosnt render the listitem
immediately after the element tag -->
<!--<xsl:apply-templates
select="child::para[1]" mode="item-number" />-->
<fo:inline
height="15pt" float="left" padding-right="2pt" >
<xsl:apply-templates
select="ancestor::listitem[parent::orderedlist][1]" mode="item-number"/>
</fo:inline>
<xsl:number
value="$item-number" format="{$type}"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="parent::orderedlist/@inheritnum='inherit' and
ancestor::listitem[parent::orderedlist]">
<xsl:apply-templates
select="ancestor::listitem[parent::orderedlist][1]" mode="item-number"/>
</xsl:if>
<xsl:number value="$item-number" format="{$type}"/>
</xsl:otherwise>
</xsl:choose>
Any suggestions as to how I can correct this
code to allow flexiblity in where a list item is rendered?
Thanks,
David White
Ken Cook Co.,
Content Management
http://www.kencook.com
tel: 414.847.1322
--
No virus found in this outgoing message.
Checked by
AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.5.6/337 - Release
Date: 5/11/2006
--
No virus found in this incoming message.
Checked by AVG
Free Edition.
Version: 7.1.392 / Virus Database: 268.5.6/337 - Release Date:
5/11/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.5.6/340 - Release Date: 5/15/2006
Next in thread →
Next in month →