well done dualsoul
Gasper
Main Topics
Browse All TopicsHello
I need to get the position of the ancestor when i am in a grand-child.
Say i am in <item2> within the <submenu>
I need to go a find the position of its <item1>
How do i do this?
<themenu>
<item>
<title>Home</title>
<link>www.xtra.co.nz</link
</item>
<item1>
<title>Joana</title>
<link>www.xtra.co.nz</link
</item1>
<item1>
<title>Craig</title>
<link>www.xtra.co.nz</link
</item>
<item1>
<title subNo="Yes">Jim</title>
<link>www.xtra.co.nz</link
<submenu>
<item2>
<title>Mic</title>
<link>www.xtra.co.nz</link
</item2>
<item2>
<title>Grant</title>
<link>www.xtra.co.nz</link
</item2>
<item2>
<title>Dave</title>
<link>www.xtra.co.nz</link
</item2>
</submenu>
</item1>
<themenu>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: dualsoulPosted on 2005-05-04 at 04:43:01ID: 13925548
hm...do you mean count item1, if you are in context of item2?
eding-sibl ing::item1 )
rg/1999/XS L/Transfor m">
em1/preced ing-siblin g::item1)" />
you can do it for instance this way: count(ancestor::item1/prec
check this XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.o
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:for-each select="//item2">
Item2=<xsl:value-of select="." /><br/>
Ancestor Position is <xsl:value-of select="count(ancestor::it
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>