This is my input xml:
<root>
<node1/>
<node2/>
<node3/>
<node4/>
<othertags/>
</root>
The output must be:
<root>
<othertags/>
</root>
if any of the 4 nodes isn't null then none of the tags must be dropped.
example:
<root>
<node1/>
<node2/>
<node3/>
<node4>sample_text</node4>
<othertags/>
</root>
Then the output must be same as input xml.
<root>
<node1/>
<node2/>
<node3/>
<node4>sample_text</node4>
<othertags/>
</root>
This is the XSL code I have designed ::
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="/root/node1[.='' and ../node2/.='' and ../node3/.='' and ../node4/.='']
|/root/node2[.='' and ../node1/.='' and ../node3/.='' and ../node4/.='']
|/root/node3[.='' and ../node1/.='' and ../node2/.='' and ../node4/.='']
|/root/node4[.='' and ../node1/.='' and ../node2/.='' and ../node3/.='']"/>
As you can see the code requires more effort and becomes more bulky as the number of nodes increase. Is there any alternative way to overcome this bottleneck?