Вот простое, короткое решение XSLT 1.0.
Ваша основная проблема заключается в том, что вы не можете указать в шаблоне совпадения пространство имен элементов - они не находятся ни в каком пространстве имен"
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:x="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="x:SalesLine[not(x:SalesOrderStatus = 'SalesOrder')]"/>
</xsl:stylesheet>
Когда это преобразование применяется к предоставленному документу XML:
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Message">
<Header>
<MessageId>{9CEDBBC7-5AF3-4A8B-AC68-49F1E0D8402A}</MessageId>
<SourceEndpoint>hwf</SourceEndpoint>
<DestinationEndpoint>HWF_ORDRSP</DestinationEndpoint>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesSalesOrderService/read</Action>
</Header>
<Body>
<MessageParts>
<SalesOrder xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder">
<SalesTable class="entity">
<CustAccount>00003</CustAccount>
<DeliveryDate>2019-10-21</DeliveryDate>
<POMOrderId>0002539819</POMOrderId>
<PurchOrderFormNum>4500143886</PurchOrderFormNum>
<SalesId>QN00000949</SalesId>
<SalesOrderStatus>SalesOrder</SalesOrderStatus>
<SalesLine class="entity">
<ExtLineNum>10</ExtLineNum>
<ItemId>08201</ItemId>
<SalesId>QN00000949</SalesId>
<SalesOrderStatus>SalesOrder</SalesOrderStatus>
<SalesQty>1320.00</SalesQty>
<SalesUnit>st</SalesUnit>
<ShippingDateConfirmed>2019-10-21</ShippingDateConfirmed>
</SalesLine>
<SalesLine class="entity">
<ExtLineNum>20</ExtLineNum>
<ItemId>08236</ItemId>
<SalesId>QN00000949</SalesId>
<SalesOrderStatus>Sent</SalesOrderStatus>
<SalesQty>1296.00</SalesQty>
<SalesUnit>st</SalesUnit>
<ShippingDateConfirmed>2019-10-21</ShippingDateConfirmed>
</SalesLine>
<SalesLine class="entity">
<ExtLineNum>30</ExtLineNum>
<ItemId>08238</ItemId>
<SalesId>QN00000949</SalesId>
<SalesOrderStatus>SalesOrder</SalesOrderStatus>
<SalesQty>1296.00</SalesQty>
<SalesUnit>st</SalesUnit>
<ShippingDateConfirmed>2019-10-21</ShippingDateConfirmed>
</SalesLine>
<SalesLine class="entity">
<ExtLineNum>40</ExtLineNum>
<ItemId>08254</ItemId>
<SalesId>QN00000949</SalesId>
<SalesOrderStatus>CancelledBySales</SalesOrderStatus>
<SalesQty>1320.00</SalesQty>
<SalesUnit>st</SalesUnit>
<ShippingDateConfirmed>2019-10-21</ShippingDateConfirmed>
</SalesLine>
</SalesTable>
</SalesOrder>
</MessageParts>
</Body>
</Envelope>
Требуемый, правильный результат получается :
<Envelope xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/Message">
<Header>
<MessageId>{9CEDBBC7-5AF3-4A8B-AC68-49F1E0D8402A}</MessageId>
<SourceEndpoint>hwf</SourceEndpoint>
<DestinationEndpoint>HWF_ORDRSP</DestinationEndpoint>
<Action>http://schemas.microsoft.com/dynamics/2008/01/services/SalesSalesOrderService/read</Action>
</Header>
<Body>
<MessageParts>
<SalesOrder xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder">
<SalesTable class="entity">
<CustAccount>00003</CustAccount>
<DeliveryDate>2019-10-21</DeliveryDate>
<POMOrderId>0002539819</POMOrderId>
<PurchOrderFormNum>4500143886</PurchOrderFormNum>
<SalesId>QN00000949</SalesId>
<SalesOrderStatus>SalesOrder</SalesOrderStatus>
<SalesLine class="entity">
<ExtLineNum>10</ExtLineNum>
<ItemId>08201</ItemId>
<SalesId>QN00000949</SalesId>
<SalesOrderStatus>SalesOrder</SalesOrderStatus>
<SalesQty>1320.00</SalesQty>
<SalesUnit>st</SalesUnit>
<ShippingDateConfirmed>2019-10-21</ShippingDateConfirmed>
</SalesLine>
<SalesLine class="entity">
<ExtLineNum>30</ExtLineNum>
<ItemId>08238</ItemId>
<SalesId>QN00000949</SalesId>
<SalesOrderStatus>SalesOrder</SalesOrderStatus>
<SalesQty>1296.00</SalesQty>
<SalesUnit>st</SalesUnit>
<ShippingDateConfirmed>2019-10-21</ShippingDateConfirmed>
</SalesLine>
</SalesTable>
</SalesOrder>
</MessageParts>
</Body>
</Envelope>