xsl-list
[Top] [All Lists]

RE: generating numbers for anchor tabindex

2002-10-06 09:58:03
Jeni's solution will work, but using generate-id() is likely to be more
efficient. This generates an identifier for a particular node in the XML
source tree, which can often be used as a unique identifier for a node
in the HTML result tree.

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 

-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com 
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of 
Jeni Tennison
Sent: 06 October 2002 15:29
To: Simeon Walker
Cc: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] generating numbers for anchor tabindex


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[(_at_)id]" />

These are essentially the same as:

  <xsl:value-of select="count(preceding::a) + 1" />

and:

  <xsl:value-of select="count(preceding::a[(_at_)id]) + 1" />

respectively.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>