[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Ordered lists inheriting section numbers
Hi Luciano,
It can't be done with just stylesheet parameters, but if you know a little
XSL then it can be done with a customization. The template you want to
customize is in fo/lists.xsl:
<xsl:template match="orderedlist/listitem" mode="item-number">
<xsl:variable name="numeration">
<xsl:call-template name="list.numeration">
<xsl:with-param name="node" select="parent::orderedlist"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="type">
<xsl:choose>
<xsl:when test="$numeration='arabic'">1.</xsl:when>
<xsl:when test="$numeration='loweralpha'">a.</xsl:when>
<xsl:when test="$numeration='lowerroman'">i.</xsl:when>
<xsl:when test="$numeration='upperalpha'">A.</xsl:when>
<xsl:when test="$numeration='upperroman'">I.</xsl:when>
<!-- What!? This should never happen -->
<xsl:otherwise>
<xsl:message>
<xsl:text>Unexpected numeration: </xsl:text>
<xsl:value-of select="$numeration"/>
</xsl:message>
<xsl:value-of select="1."/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="item-number">
<xsl:call-template name="orderedlist-item-number"/>
</xsl:variable>
<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:template>
This template generates the number for one list item for FO output. First
it figures out the numeration style from any numeration attribute on the
listitem's parent orderedlist element. Then it figures out the number
format from the numeration name. The it calls the template named
'orderedlist-item-number' to get the number of the current item. That
steps handles any continuation from a previous list.
Then it handles the inheritnum attribute on the orderedlist. Normally that
would generate a prefix number corresponding to the ancestor listitem,
which is how list inheritance usually works. It is here that you would
want to generate a different prefix based on your section number.
To generate a section number, you process it in mode="label.markup". So
you could something like:
<xsl:apply-templates select="ancestor::section [1]" mode="label.markup"/>
<xsl:text>.</xsl:text>
This selects the closest ancestor section element (assuming you are using
section and not sect1 etc.) and processes in mode="label.markup" to
generate the section number. Then add a dot or other punctuation.
I'm a little curious about what happens if you have two orderedlists in a
section, though. Wouldn't they have the same numbering sequence?
Bob Stayton
Sagehill Enterprises
DocBook Consulting
bobs@sagehill.net
----- Original Message -----
From: "Luciano Scavizzi" <feanorelf@gmail.com>
To: <docbook-apps@lists.oasis-open.org>
Sent: Saturday, May 06, 2006 2:44 AM
Subject: [docbook-apps] Ordered lists inheriting section numbers
I would like my ordered lists to inherit their relevant section
number. I guess that it is possible, as I have read qandasets behave
like this by default.
How should I do it?
---------------------------------------------------------------------
To unsubscribe, e-mail: docbook-apps-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: docbook-apps-help@lists.oasis-open.org
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]