Using key() and <xsl:key>
Hi all!
I'm trying to use the key() function together with <xsl:key> element in the following way: I have the input document:
################################################## ##################
<A>
<B>
<C1 atr1="_10">
<D1>name1</D1>
</C1>
</B>
</A>
............
<A>
<B>
<C2>
<D2>name</D2>
<E2>
<F2 atr2="_10"/>
</E2>
</C2>
</B>
</A>
################################################## ###################
So when I process this document, when I reach <C2>, I need to insert the "name" value that corresponds to the key "_10" from "atr2", which is the one from "atr1" of tag "C1"; so that would be the name from <D1>.
I tried with:
<xsl:key name="id_to_name" match="A/B/C1" use="@atr1"/>
and call it like this:
<xsl:template match="B/C2">
<myTag>
<xsl:value-of select="key('id_to_name', @atr2)/D1"/>
</myTag>
</xsl:template>
but I get no results.
If anybody can help me it would be great.
Best regards,
Fred
|