Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove duplicates in xml based on attributes values and several nodes' innertext
    text
    copied!<p>I have the below input XML which needs to be transformed with an xslt</p> <p>Input Xml:</p> <pre><code>&lt;element&gt; &lt;childelement xml:type="base" id="645"&gt; &lt;seg1&gt;a&lt;/seg1&gt; &lt;seg2&gt;A&lt;/seg2&gt; &lt;seg3&gt;0&lt;/seg3&gt; &lt;/childelement &gt; &lt;childelement xml:type="level1" id="646"&gt; &lt;seg1&gt;a&lt;/seg1&gt; &lt;seg2&gt;B&lt;/seg2&gt; &lt;seg3&gt;1&lt;/seg3&gt; &lt;/childelement&gt; &lt;childelement xml:type="level2" id="656"&gt; &lt;seg1&gt;a&lt;/seg1&gt; &lt;seg2&gt;C&lt;/seg2&gt; &lt;seg3&gt;0&lt;/seg3&gt; &lt;/childelement&gt; &lt;/element&gt; &lt;element&gt; &lt;childelement xml:type="base" id="647"&gt; &lt;seg1&gt;a&lt;/seg1&gt; &lt;seg2&gt;A&lt;/seg2&gt; &lt;seg3&gt;0&lt;/seg3&gt; &lt;/childelement&gt; &lt;childelement xml:type="level1" id="648"&gt; &lt;seg1&gt;a&lt;/seg1&gt; &lt;seg2&gt;B&lt;/seg2&gt; &lt;seg3&gt;0&lt;/seg3&gt; &lt;/childelement&gt; &lt;childelement xml:type="level2" id="649"&gt; &lt;seg1&gt;a&lt;/seg1&gt; &lt;seg2&gt;D&lt;/seg2&gt; &lt;seg3&gt;0&lt;/seg3&gt; &lt;/childelement&gt; &lt;/element&gt; </code></pre> <p>Expected output:</p> <pre><code>&lt;element&gt; &lt;childelement xml:type="base" id="645"&gt; &lt;seg1&gt;a&lt;/seg1&gt; &lt;seg2&gt;A&lt;/seg2&gt; &lt;seg3&gt;0&lt;/seg3&gt; &lt;/childelement &gt; &lt;childelement xml:type="level1" id="646"&gt; &lt;seg1&gt;a&lt;/seg1&gt; &lt;seg2&gt;B&lt;/seg2&gt; &lt;seg3&gt;1&lt;/seg3&gt; &lt;/childelement&gt; &lt;childelement xml:type="level2" id="656"&gt; &lt;seg1&gt;a&lt;/seg1&gt; &lt;seg2&gt;C&lt;/seg2&gt; &lt;seg3&gt;0&lt;/seg3&gt; &lt;/childelement&gt; &lt;/element&gt; &lt;element&gt; &lt;childelement xml:type="base" id="647"&gt; &lt;seg1&gt;a&lt;/seg1&gt; &lt;seg2&gt;A&lt;/seg2&gt; &lt;seg3&gt;0&lt;/seg3&gt; &lt;/childelement&gt; &lt;childelement xml:type="level2" id="649"&gt; &lt;seg1&gt;a&lt;/seg1&gt; &lt;seg2&gt;D&lt;/seg2&gt; &lt;seg3&gt;0&lt;/seg3&gt; &lt;/childelement&gt; &lt;/element&gt; </code></pre> <p>So what I'd like to do is identifying all the childelements which have the same attribute but base (i.e. here level1 and level2 potentially higher levels) and the same innertext for seg1 and seg2, keep only the first one with the highest seg3 (in this case the one with id = 646 and filter out the one with id = 648).</p> <p>Is such a processing possible with xml / xlst (matching duplicates based on attributes and innertext)?</p> <p>Thanks for reading</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload