RE: [xsl] XPatch: ancestor and count

Subject: RE: [xsl] XPatch: ancestor and count
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 1 Oct 2004 11:56:25 +0100
> >    <xsl:for-each select="child::menuitem">
> >     <tr><td><xsl:value-of select="count(.//ancestor::*)"/></td><td>
> >     <xsl:value-of select="@title"/></td></tr>
> >    </xsl:for-each>
> >  
> >
> In this context, './/' means 'descendant-or-self::*', right? 

Well spotted, I missed that.

.//ancestor::* means

./descendant-or-self::node()/ancestor::*

so you are counting how many distinct ancestors you and all your descendants
have. This is one for you, one for each of your ancestors, and one for each
of your descendants that has at least one child.

Michael Kay
http://www.saxonica.com/

Current Thread