Getting parent's parent from current node in Xpath 2.0

Viewed 41887

I always seem to have trouble with xpath axis expressions...

In some expressions I have used ../ to refer to the parent node, but is that not valid for test expressions? Or is my syntax just wrong?

<xsl:when test="../../[@status='current']">

My goal is to apply an attribute inside the xsl:when IF the parent's parent has a status attribute with a value of 'current'.

EDIT: self::parent/parent[@status='current'] is a valid xpath expression and may be what I want, can anyone confirm? I might not be going far enough.

4 Answers
Related