I have a document that looks something like this:
<test>
<testOne>
<testTwo>AAA</testTwo>
<testOne>
<testOne>
<testTwo>BBB</testTwo>
<testOne>
<testOne>
<testTwo>CCC</testTwo>
<testOne>
<testOne>
<testTwo>DDD</testTwo>
<testOne>
<testOne>
<testTwo>EEE</testTwo>
<testOne>
</test>
Now in xsl it's easy to get this nodeset by doing:
<xsl:variable name="testOnes" select="//test/testOne">
However the issue I have is that there are conditions I have to meet to form the nodeset, such as
if testOne[testTwo='AAA'] exists select all nodes except those of form testOne[testTwo='BBB']
and if testOne[testTwo='CCC'] exists then select all nodes except those of form testOne[testTwo='DDD']
So for example according to those rules above we should get this result from any specific xpath:
<test>
<testOne>
<testTwo>AAA</testTwo>
<testOne>
<testOne>
<testTwo>CCC</testTwo>
<testOne>
<testOne>
<testTwo>EEE</testTwo>
<testOne>
</test>
Is there any way of writing an xpath with an if statement in that can achieve this or some xsl code that can check the nodesets contents and remove one node if it finds another?