posted 18 years ago
Hi All,
I am using xsl:key for searching a specified element by its attribute value match. When i find, i try to get its parent node. Can anybody help me. The code for xml is given below.
suppose i create a key as
<xsl:key name="mykey" match="child" use="@id">
and
<xsl:template match="A">
<!-- here i have selected a variable var which has tag child with id=a -->
<xsl:variable name="var" select="key('mykey','a')"/>
<!-- now i want to display two label elemnts -->
<!-- 1. one is of this child element(that i am able to do -->
<xsl:value-of select="$var/label"/>
<!-- 2. and lable of its parent element (Fig1) -->
<!-- HOW TO GET THIS LABEL OF PARENT ELEMENT -->
<!--Finally i need to display : -->
Fig1a
<!-- currently i am able to display only 'a' and not 'Fig1a' -->
</xsl:template>
Edit comment: when posting such XML please use the [ code ] opening and closing tags (without the spaces ofcourse). You described parent and child nodes, but unless it is formatted properly we can't really tell which is the parent and which is the child (your element names do help, but formatting make a lot more meaning.
Thanks.
- m
[ February 08, 2006: Message edited by: Madhav Lakkapragada ]