This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: uniqueID(), childNumber(), and formatIndex()
- To: John Cartwright <jcartwright at ngdc dot noaa dot gov>
- Subject: Re: [xsl] uniqueID(), childNumber(), and formatIndex()
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Tue, 2 Jan 2001 18:37:46 +0000
- CC: xsl-list at lists dot mulberrytech dot com
- Organization: Jeni Tennison Consulting Ltd
- References: <3A51FA8D.98DF0828@ngdc.noaa.gov>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi John,
> I have run across three functions uniqueID(), childNumber(), and
> formatIndex() that seem to be giving problems and I can't find
> descriptions for them.
There are descriptions in the MSXML SDK that you can download from
msdn.microsoft.com.
> <xsl:attribute name="HREF">#
> <xsl:eval>uniqueID(this)</xsl:eval>
> </xsl:attribute>
You can replace this with:
<xsl:attribute name="HREF">
<xsl:text>#</xsl:text>
<xsl:value-of select="generate-id()" />
</xsl:attribute>
or (assuming this attribute is on an 'A' element):
<A HREF="#{generate-id()}">
...
</A>
> Distributor
> <xsl:eval>formatIndex(childNumber(this), "1")</xsl:eval>
I think that the formatIndex is completely superfluous here, but you
can use format-number() in its place if not.
In most cases, I think this will be equivalent to:
<xsl:value-of select="position()" />
But it depends on the context as the position() function works out the
position of the current node based on the context node list, which
could be anything. A safer equivalent would be:
<xsl:value-of select="count(preceding-sibling::node()) + 1" />
This counts the number of preceding siblings to give the index of the
node within its parent's children.
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list