Quote:
quote:Originally posted by Chamkaur
Hi Michael,
Thanks for the pointer but it still doesnt seem to be matching.
I even tried using the axes of ancestor and ancestor-or-self
<xsl:copy-of select="/root/secondary [@relatedID=ancestor::main/@id]/a/@*"/>
but it doesnt work.
I created two attributes to see if my expression equates. The result of both attribute matches but I dont seem to see the problem why it doesnt copy the attributes from secondary to main. Your feedback is much appreciated. thanks
<xsl:attribute name="secondaryID"><xsl:value-of select="/root/secondary/@relatedID"/></xsl:attribute>
<xsl:attribute name="MainID"><xsl:value-of select="ancestor::main/@id"/></xsl:attribute>
|
Because the current() node is the a element and not the main element the id will not be found, also you don't pass the id attribute on your main element still, so also <xsl:copy-of select="@*"/> pass that after <main>
when you add ../../ to your path like this: /root/secondary[@relatedID=current()/../../@id]/a/@*
you will get:
<root>
<secondary relatedID="1">
<a a4="apple" a5="pear"/>
</secondary>
<main id="1"><fruits><gg a1="orange" a2="grape" a4="apple" a5="pear"/><gg a1="lime" a3="lemon" a4="apple" a5="pear"/></fruits></main>
</root>
is that what you want?
you will have to filter out the secondary element if you don't want that, because now the element will be copied through the template <xsl:template match="@*|node()|comment()"> for instance by adding <xsl:template match="secondary"/>