This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: 'interleaved' numbering
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 21 Aug 2002 17:20:33 +0100
- Subject: Re: [xsl] 'interleaved' numbering
- Organization: Jeni Tennison Consulting Ltd
- References: <63C4AD0365821F4291ACF76C0672FA3506EF26@piper6.piper-group.int>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Andrew Welch wrote:
> Anyway, the problem you have is that <theorem> exist within
> <subSect>, therefore <xsl:number> is no good. Also, counting
> preceding-sibling::theorem's is no good as you want only those that
> are in the current <section>.
>
> So I would recommend creating a variable with the values you need, and
> then referencing that variable when you need the number. So as a
> top-level-element (child of the root) you would want a variable like:
[snip]
A simpler solution is to use two xsl:number instructions, one counting
theorems at "any" level, from the nearest section. I don't have the
actual example since attachments don't come through to the list, but
with the source:
<doc>
<section>
<subSect>
<theorem>1.1</theorem>
<theorem>1.2</theorem>
</subSect>
<subSect>
<theorem>1.3</theorem>
</subSect>
</section>
<section>
<subSect>
<theorem>2.1</theorem>
</subSect>
</section>
</doc>
and the template:
<xsl:template match="theorem">
<theorem>
<xsl:number count="section" />.<xsl:number level="any"
from="section" />
<xsl:text /> (<xsl:value-of select="." />)<xsl:text />
</theorem>
</xsl:template>
I get:
<theorem>1.1 (1.1)</theorem>
<theorem>1.2 (1.2)</theorem>
<theorem>1.3 (1.3)</theorem>
<theorem>2.1 (2.1)</theorem>
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list