anantarora
10-07-2005, 10:47 AM
Hi,
I want to write an xslt wherein I take an input xml and remove all the null elements from it in the output xml and their parent elements if they are empty too.
Note: Elements having non-empty attributes are not empty and hence, should be reflected in the output.
Example: Input
<?xml version="1.0" encoding="UTF-8"?>
<Orders>
<Order>
<name>
<firstname>anant</firstname>
<lastname></lastname>
</name>
<address>
<firstline>
<sub1></sub1>
<sub2></sub2>
</firstline>
<secondline>
<sub1 index="1"></sub1>
<sub2/>
</secondline>
</address>
</Order>
</Orders>
Output XML
<?xml version="1.0" encoding="UTF-8"?>
<Orders>
<Order>
<name>
<firstname>anant</firstname>
</name>
<address>
<secondline>
<sub1 index="1"></sub1>
</secondline>
</address>
</Order>
</Orders>
I want to write an xslt wherein I take an input xml and remove all the null elements from it in the output xml and their parent elements if they are empty too.
Note: Elements having non-empty attributes are not empty and hence, should be reflected in the output.
Example: Input
<?xml version="1.0" encoding="UTF-8"?>
<Orders>
<Order>
<name>
<firstname>anant</firstname>
<lastname></lastname>
</name>
<address>
<firstline>
<sub1></sub1>
<sub2></sub2>
</firstline>
<secondline>
<sub1 index="1"></sub1>
<sub2/>
</secondline>
</address>
</Order>
</Orders>
Output XML
<?xml version="1.0" encoding="UTF-8"?>
<Orders>
<Order>
<name>
<firstname>anant</firstname>
</name>
<address>
<secondline>
<sub1 index="1"></sub1>
</secondline>
</address>
</Order>
</Orders>