This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: generating numbers for anchor tabindex
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: Simeon Walker <simeon at sbs dot bangor dot ac dot uk>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Sun, 6 Oct 2002 15:29:07 +0100
- Subject: Re: [xsl] generating numbers for anchor tabindex
- Organization: Jeni Tennison Consulting Ltd
- References: <3DA0434C.2030003@sbs.bangor.ac.uk>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Simeon,
> I am trying to think of a way to automatically generate numbers for
> the tabindex property of html anchors. Since the xml that ends up
> getting transformed into the anchor could be at any level within the
> document I can't use a simple position().
Try using xsl:number with level="any":
<xsl:number level="any" />
That will get you a number for the <a> element amongst *all* the other
<a> elements in the document. If you want to narrow that down, you can
use the 'count' attribute, to for example only count those <a>
elements that have an 'id' attribute:
<xsl:number level="any" count="a[@id]" />
These are essentially the same as:
<xsl:value-of select="count(preceding::a) + 1" />
and:
<xsl:value-of select="count(preceding::a[@id]) + 1" />
respectively.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list