I don't understand your sample data completely, as in your target you have
Code:
<Delivery>
<DeliveryType>1</DeliveryType>
<DeliveryNum>222</DeliveryNum>
<Amount>200.00</Amount>
<InvNum>111</InvNum>
<Line>
<LineNum>1</LineNum>
<LineType>uu</LineType>
<DeliveryNum>333</DeliveryNum>
</Line>
</Delivery>
Why do you want to insert a 'Line' element with a 'DeliveryNum' child element with value '333' into a 'Delivery' element with 'DeliveryNum' having the value '222'?
Other than that I think you simply want a stylesheet as follows:
Code:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="root">
<xsl:copy>
<xsl:apply-templates select="Invoice"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Invoice">
<xsl:copy>
<xsl:apply-templates select="InvType | InvNum"/>
<xsl:apply-templates select="/root/Delivery[InvNum = current()/InvNum]"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Delivery">
<xsl:copy>
<xsl:apply-templates select="*"/>
<xsl:apply-templates select="/root/Line[DeliveryNum = current()/DeliveryNum]"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen
Microsoft MVP - XML