Я думаю, вам нужно OrderLineNum
из Lines
в вашем ключе вместе с Text
<xsl:key name="line_text" match="LineText" use="concat(../OrderLineNum, '|', Text)"/>
Тогда матч становится таким ...
<xsl:template match="LineText[generate-id() != generate-id(key('line_text', concat(../OrderLineNum, '|', Text))[1])]" />
Попробуйте это XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" standalone="yes" indent="yes"/>
<xsl:strip-space elements="*" />
<xsl:key name="header_text" match="HeaderText" use="Text"/>
<xsl:key name="line_text" match="LineText" use="concat(../OrderLineNum, '|', Text)"/>
<!-- Identity-Template für die nicht explizit benannten Elemente -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="HeaderText[generate-id() != generate-id(key('header_text', Text)[1])]" />
<xsl:template match="LineText[generate-id() != generate-id(key('line_text', concat(../OrderLineNum, '|', Text))[1])]" />
<!-- delete empty nodes -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[not(@*|*|comment()|processing-instruction()) and normalize-space()='']"/>
</xsl:stylesheet>