XSLT 1.0 решения, протестированные с Saxon-HE 9.2.1.1
Решение с циклом:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="byAttribute21" match="Node1/Node2" use="@Attribute21"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Node1">
<Node1>
<xsl:copy-of select="@*"/>
<xsl:for-each select="Node2[generate-id()=generate-id(key('byAttribute21', @Attribute21)[1])]">
<Node3 Attribute21="{@Attribute21}">
<xsl:apply-templates select="key('byAttribute21', @Attribute21)"/>
</Node3>
</xsl:for-each>
</Node1>
</xsl:template>
</xsl:stylesheet>
Решение без зацикливания:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="byAttribute21" match="Node1/Node2" use="@Attribute21"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Node1">
<Node1>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="*" mode="node3"/>
</Node1>
</xsl:template>
<xsl:template match="Node2[generate-id()=generate-id(key('byAttribute21', @Attribute21)[1])]" mode="node3">
<Node3 Attribute21="{@Attribute21}">
<xsl:apply-templates select="key('byAttribute21',@Attribute21)" mode="node2"/>
</Node3>
</xsl:template>
<xsl:template match="Node2" mode="node2">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>