I have multiple XML files which consists of change tracking attribute <atict:add>
or <atict:del>
.
Objective:
- if XML file consists of an element
CT="ACCEPT"
then accept/print all tags with<atict:add>
and ignore<atict:del>
- if XML file consits of an element
CT="REJECT"
then accept/print all tags with<atict:del>
and ignore<atict:accept>
Sample XML:
<?xml version="1.0" encoding="UTF-8"?>
<DM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:atict="http://www.arbortext.com/namespace/atict" **CT="ACCEPT"**>
<PARA>abcd <atict:del>efghi</atict:del><atict:add>1456790
</atict:add></PARA>
<?xml version="1.0" encoding="UTF-8"?>
<DM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:atict="http://www.arbortext.com/namespace/atict" **CT="ACCEPT"**>
<PARA>abcd <atict:del>efghi</atict:del><atict:add>1456790
</atict:add></PARA>
Output XML after processing:
<?xml version="1.0" encoding="UTF-8"?>
<DM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:atict="http://www.arbortext.com/namespace/atict" **CT="ACCEPT"**>
<PARA>abcd <atict:add>1456790
</atict:add></PARA>
<?xml version="1.0" encoding="UTF-8"?>
<DM xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:atict="http://www.arbortext.com/namespace/atict" **CT="ACCEPT"**>
<PARA>abcd <atict:add>1456790
</atict:add></PARA>
How can I add the CT in the XSLT with an if condition to satisfy the criteria?
The sample stylesheet below does the job. See the comments for explanations.
Or simply: