Re: [xsl] Key to select all same nodes(same @id) except current node

Subject: Re: [xsl] Key to select all same nodes(same @id) except current node
From: Tech Guru <tech_gr@xxxxxxxxx>
Date: Wed, 7 Mar 2007 11:09:08 -0800 (PST)
Thanks Michael. :)

<xsl:for-each
select="key('ParentKey',@id)[not(generate-id()=generate-id(current()))]">
<xsl:variable name="parentvar" select="."> <!-- it selects current node, Needs
to check whether its grand parent is 'category or not' -->
</xsl:variable>
                    <xsl:if
test="name(ancestor::$parentvar[2]) = 'category'">
<samenode>
                            <xsl:value-of
select="ancestor::$parentvar[2]/@id"></xsl:value-of>
</samenode>
                    </xsl:if>
                </xsl:for-each>
Could you please tell me what is wrong in xpath "ancestor::$parentvar[2]" . It
gives error saying it is not a valid xpath.

- R

----- Original Message ----
From: Michael Kay <mike@xxxxxxxxxxxx>
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Wednesday, March 7, 2007 1:52:51 PM
Subject: RE: [xsl] Key to select all
same nodes(same @id) except current node

> I need a clarification on
child::category. Does it returns 
> all child category elements of current
element?

Yes.

> If my structure is
> <category>
>     <list>
>
<category>
>         </category>
>     </list
> </category>
> 
> so will it
return inner category element?

Yes, if the current element is "list".
Michael Kay
http://www.saxonica.com/
_____________________________________________________________________________
_______
Don't pick lemons.
See all the new 2007 cars at Yahoo! Autos.
http://autos.yahoo.com/new_cars.html

Current Thread