Xml XSLT选择值存在于子节点中的父节点

Xml XSLT选择值存在于子节点中的父节点,xml,xslt,Xml,Xslt,如何选择任何子节点值为“EXCEPTION”的“Message”节点 <?xml version="1.0" encoding="UTF-8"?> <Envelope> <Message> <MessageId>1</MessageId> <Merchant> <Type>Supplier</Type> <Id>23</Id>

如何选择任何子节点值为“EXCEPTION”的“Message”节点

<?xml version="1.0" encoding="UTF-8"?>
<Envelope>
<Message>
    <MessageId>1</MessageId>
    <Merchant>
        <Type>Supplier</Type>
        <Id>23</Id>
    </Merchant>
    <Operation>Create</Operation>
    <SKU>AVRCD_002</SKU>
    <Attribute>
        <country>South Africa</country>
        <artist>Anneli Van Rooyen</artist>
        <composer>Anneli Sale</composer>
    </Attribute>
</Message>
<Message>
    <MessageId>2</MessageId>
    <Merchant>
        <Type>Supplier</Type>
        <Id>EXCEPTION</Id>
    </Merchant>
    <Operation>Create</Operation>
    <SKU>AVRCD_002</SKU>
    <Attribute>
        <country>EXCEPTION</country>
        <artist>Anneli Van Rooyen|Lorenzo Tieghi</artist>
        <composer>Sale Anneli</composer>
    </Attribute>
</Message>
</Envelope>

1.
供应商
23
创造
AVRCD_002
南非
安妮莉·范鲁延
安妮莉销售
2.
供应商
例外情况
创造
AVRCD_002
例外情况
Anneli Van Rooyen | Lorenzo Tieghi
赛尔·安内利
您需要在下面的列表中指定确切的子项。我不想那样做。我只想要/Message,如果其中有“EXCEPTION”的值

<xsl:copy-of select="/Envelope/Message[Attribute/country = 'EXCEPTION' or Merchant/Id = 'EXCEPTION']"/>

试试这个,它检查所有子代文本节点是否等于“EXCEPTION”



非常感谢,我很接近,但无法100%实现,但要小心,@LorenzoTieghi,因为作为字符串值为
'EXCEPTION'
的文本节点父节点的节点不一定与该节点自身的字符串值为
'EXCEPTION'
相同。具有混合内容的元素可能会出现区别。前者可能正是你想要的,但你应该对此感到满意。
<xsl:copy-of select="/Envelope/Message[.//text() = 'EXCEPTION']"/>