根据XSLT中的多个属性识别并删除重复元素

时间:2017-10-16 10:01:54

标签: xslt

我正在尝试执行xslt转换,以便根据多个属性过滤重复的元素。 输入XML:

<rootNode>
<node id="N10102017004" bomHeader="true">
    <request>
       <someText>aaa</someText>
    </request>
</node>
<node id="N10102017004">
    <request>
        <someText>aaa</someText>
    </request>
</node>
<node id="N10102017004">
    <request>
        <someText>aaa</someText>
    </request>
</node>
<node id="N10102017056" bomHeader="true">
    <request>
       <someText>aaa</someText>
    </request>
</node>
<node id="N10102017056">
    <request>
         <someText>aaa</someText>
    </request>
</node>
<node id="N10102017056">
    <request>
        <someText>aaa</someText>
    </request>
</node>
<node id="N10102017089">
    <request>
        <someText>aaa</someText>
    </request>
</node>
<node id="N10102017090">
    <request>
         <someText>aaa</someText>
    </request>
</node>
<node id="N10102017090">
    <request>
        <someText>aaa</someText>
    </request>
</node>

我想要的是当node元素具有id和bomHeader属性时,然后根据id需要删除duplicate元素。如果没有bomHeader属性,则无需删除重复的id元素。

我的XSL返回:

<rootNode>
<node id="N10102017004" bomHeader="true">
    <request>
       <someText>aaa</someText>
    </request>
</node>
<node id="N10102017004">
    <request>
        <someText>aaa</someText>
    </request>
</node>

<node id="N10102017056" bomHeader="true">
    <request>
       <someText>aaa</someText>
    </request>
</node>
<node id="N10102017056">
    <request>
         <someText>aaa</someText>
    </request>
</node>

<node id="N10102017089">
    <request>
        <someText>aaa</someText>
    </request>
</node>
<node id="N10102017090">
    <request>
         <someText>aaa</someText>
    </request>
</node>

预期的OUTPUT XML:

<rootNode>
<node id="N10102017004" bomHeader="true">
    <request>
       <someText>aaa</someText>
    </request>
</node>

<node id="N10102017056" bomHeader="true">
    <request>
       <someText>aaa</someText>
    </request>
</node>

<node id="N10102017089">
    <request>
        <someText>aaa</someText>
    </request>
</node>
<node id="N10102017090">
    <request>
         <someText>aaa</someText>
    </request>
</node>
<node id="N10102017090">
    <request>
        <someText>aaa</someText>
    </request>
</node>

0 个答案:

没有答案