This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: uniqueID(), childNumber(), and formatIndex()


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]