I had to modify your input to make it well formed, but something like
this works, in practice, you may need position() or some such as part of
your "same element" criterion, but as you posted it, just using unique
names, this seems to work:
<docA>
<a></a>
<b>fred</b>
<c att="value1"/>
<e>e</e> <!-- no "override" in docB, so it comes forward into the
result-->
</docA>
<docB>
<a/> <!-- no need to change docA-->
<b>ethel</b> <!-- "fred" in docA would have to be changed to
"ethel"-->
<c att="value2"/> <!-- "value1" in docA has to become "value2"-->
<d att="foo"> doesn't match </d> <!-- dropped on floor, no element
name-->
match
</docB>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[key('b',name(),doc('docB.xml'))]">
<xsl:copy-of select="key('b',name(),doc('docB.xml'))"/>
</xsl:template>
<xsl:key name="b" match="*" use="name()"/>
</xsl:stylesheet>
$ saxon8 docA.xml doc.xsl
<?xml version="1.0" encoding="UTF-8"?><docA>
<a/>
<b>ethel</b>
<c att="value2"/>
<e>e</e>
</docA>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--