This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: problem with xsl:number
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Bryan Rasmussen" <bry at itnisk dot com>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 27 Mar 2002 13:28:44 +0000
- Subject: Re: [xsl] problem with xsl:number
- Organization: Jeni Tennison Consulting Ltd
- References: <DCEPIHHFOCEMDBGBKIOPAEJOCFAA.bry@itnisk.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Bryan,
> <xsl:number> would give you the position of the element in the source
> tree. Try giving a node value to the count attribute..
> <xsl:number count = "node you wana count"/>
> thanks I'll try that.
> althought I thought as a default it counted the current node?
It does - more importantly, by default it counts at a level of
'single', so it gives you the position of the current node amongst
other nodes of that type (and name) in the same parent. So if you
have:
<ol>
<li>option 1</li>
<li>option 2</li>
...
</ol>
and then match li elements and number them:
<xsl:template match="li">
<xsl:number format="1. " />
<xsl:value-of select="." />
</xsl:template>
then you get the correct numbering of 1 through to however many items
there are in the list.
You seem to want to number images across the *entire document* rather
than within the parent element. If so, you should use the level
attributeof xsl:number with a value of 'any', to say that you want to
count the image amongst other images in the document rather than just
its parent:
<xsl:template match="image">
<xsl:number level="any" />
...
</xsl:template>
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list