I have a XML I am wanting to transform it with xslt.
The input looks like this.
<xmeml>
<Doc>
<Test>
<Unit>abc</Unit>
<Unit2>1234</Unit2>
<Unit3>tuvw</Unit3>
</Test>
<Test>
<Unit>bcd</Unit>
<Unit2>2345</Unit2>
<Unit3>wxyz</Unit3>
</Test>
</Doc>
<Doc>
<Test>
<Unit>abc</Unit>
<Unit2>3456</Unit2>
<Unit3>wxyz</Unit3>
</Test>
<Test>
<Unit>cde</Unit>
<Unit2>3456</Unit2>
<Unit3>wxyz</Unit3>
</Test>
</Doc>
<Doc>
<Test>
<Unit>abc</Unit>
<Unit2>1234</Unit2>
<Unit3>wxyz</Unit3>
</Test>
<Test>
<Unit>def</Unit>
<Unit2>4567</Unit2>
<Unit3>wxyz</Unit3>
</Test>
</Doc>
<Doc>
<Test>
<Unit>abc</Unit>
<Unit2>1234</Unit2>
<Unit3>uvwx</Unit3>
</Test>
<Test>
<Unit>efg</Unit>
<Unit2>2345</Unit2>
<Unit3>wxyz</Unit3>
</Test>
</Doc>
</xmeml>
the output should look like this.
<xmeml>
<Doc>
<Test>
<Unit>bcd</Unit>
<Unit2>2345</Unit2>
<Unit3>wxyz</Unit3>
</Test>
</Doc>
<Doc>
<Test>
<Unit>abc</Unit>
<Unit2>3456</Unit2>
<Unit3>wxyz</Unit3>
</Test>
<Test>
<Unit>cde</Unit>
<Unit2>3456</Unit2>
<Unit3>wxyz</Unit3>
</Test>
</Doc>
<Doc>
<Test>
<Unit>abc</Unit>
<Unit2>1234</Unit2>
<Unit3>wxyz</Unit3>
</Test>
<Test>
<Unit>def</Unit>
<Unit2>4567</Unit2>
<Unit3>wxyz</Unit3>
</Test>
</Doc>
<Doc>
<Test>
<Unit>efg</Unit>
<Unit2>2345</Unit2>
<Unit3>wxyz</Unit3>
</Test>
</Doc>
</xmeml>
I am wanting to remove any Test nodes that match the following criteria.
– The Unit3 child node starts-with tuv or uvw.
– AND Where both the Unit AND Unit2 vales are both found repeated/duplicated in another Test node
Thanks in advance for your help.
How about this tweak of Dimitre’s solution …
As I understand it, the rules of transformation are:
2.1 There exists another Test node (call it Test(other)) in the document such that:
2.2 The Unit3 child of the reference Test node starts with tuv or uvw
The output for this is exactly as the OP posted. Interestly, if I have understood the problem correctly, Dimitre has just recently provided a solution to almost the same problem as yours here XSL comparison of nodes . Again, if I have understood your problem correctly, the title is misleading. “Removing duplicates” is generally taken to mean de-duping, as in (1,2,2,3) –> (1,2,3) ; whereas what you want, like (1,2,2,3) –> (1,3) is generally described as “selecting unique nodes/values”.