Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is it possible to reference the node index? 1

Status
Not open for further replies.

Crowley16

Technical User
Jan 21, 2004
6,931
GB
basically I've got a XSLT in which I need to use the index number of all the nodes in the xml.

in the xml:
<base>
<sect>
<stuff></stuff>
<sect>
<sect>
<sect>
</base>

in the xslt:
<xsl:template match="sect">
<xsl:value-of select=".[index]"/>
</xsl:template>

where the .[index] would give the index of that node from the base, so in the above example I'd get 1 and 3...

is this at all possible?

Thanks

--------------------
Procrastinate Now!
 
[tt]<xsl:value-of select="[blue]position()[/blue]"/>[/tt]
 
the trouble with that is, it will give the position of the node position within the current tree set

I would like it to give the position from the root node

basically I'm trying to setup a TOC in a wordml and to do that I need to index the bookmarks and can't have any duplicates...

--------------------
Procrastinate Now!
 
after testing, I found I don't actually have to put in the index in order to make the TOC work...

it just means I won't be able to put in bookmarks, but that's not a problem, at lesat for now...

--------------------
Procrastinate Now!
 
I might not get what have in upper level of the tree. But this will serve on the surface at what you seem to suggest.
[tt] <xsl:value-of select="count(./preceding::*[name() = name(current())]) + 1" />[/tt]
 
that's very close to what I wanted...

that counts all the instances of that particular node name, but not all the nodes...

however, after a bit of messing about, I found that if I get rid of the [...] then that works...

thanks...

--------------------
Procrastinate Now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top