I'm in a situation where I can only test for the child node, but I have to apply tags to the grandparent of this child node.
I've tried using:
<xsl:call-template name="grandparent" select="parent::parent::node()"/>
and:
<xsl:call-template name="grandparent" select="ancestor::node [@nameofgrandparentnode]"/>
But neither works.
The level of the grandparent node is not fixed, so I figure I can't use [@level=#] either. Any ideas on how to select it would be greatly appreciated.
EDIT: -- This part has been posted as a new question:
Selecting the node using the suggestions from below worked. Thanks! However I also need to test by the attribute of the grandparent or grandchild node.
I've tried:
<xsl:template name"one" match="grandparentnode">
<Tag1>
<xsl:apply-templates select="parentNode" />
</Tag1>
</xsl:template>
<xsl:template name="two" match="grandparentnode[*/*/@grandchildattr='attrValue']">
<Tag2>
<xsl:apply-templates select="parentNode" />
</Tag2>
</xsl:template>
However template "two" always gets called, and "" is always inserted. Even for grandchild nodes whose attribute value is not equal to 'attrValue'.
Am I missing something here?