Subject:retreiving ancestors Author:Sushant Prabhu Date:16 Nov 2006 04:01 AM
Hi All
I have a scenario where i am retrieving all the ancestors for a particular node.
Here is my code
----
<xsl:for-each select="ancestor::*">
<xsl:value-of select="node_name"/>
<xsl:text>/</xsl:text>
</xsl:for-each>
----
Here though it retrieves all but not in the order I want. I mean the output is correct but fetch is in the opposite direction.
I want something like this
A
A-B
A-B-C
A-B-C-D
but what i am getting in return is the opposite
A-B-C-D
A-B-C
A-B
A
How can I get all the top parent listing first & then subsequent nested ones.
Subject:retreiving ancestors Author:James Durning Date:17 Nov 2006 09:41 AM Originally Posted: 17 Nov 2006 09:37 AM
The outer loop surrounding that is important.
How do you get to that point?
Eg, this is one possible solution, but probably does not use the same method you use.
Subject:retreiving ancestors Author:James Durning Date:21 Nov 2006 10:34 AM
Move the apply-templates after the rest. You want the children's output after your own output.
<xsl:template match="node">
<xsl:for-each ....
</xsl:for-each>