Thursday, 22 August 2013

Add new element/attribute to both Parent and its child elements using single XSLT

Add new element/attribute to both Parent and its child elements using
single XSLT

I am trying to add new elements and attributes to both Parent and its
child elements using template copy and using one XSLT but am not able see
the result I am expecting.
I am very new to XSLT and in the multiple templates only the template that
matches to the root element is working. Other template matching the child
element is not working.
Any help and techniques would be really helpful.
Original XML
<?xml version="1.0" encoding="UTF-8"?>
<Order>
<OrderLines Type="Text">
<OrderLine Type="Fine Print">
</OrderLine>
</OrderLines>
</Order>
Expected XML after XSLT transformation
<?xml version="1.0" encoding="UTF-8"?>
<Order>
<Instructions>
<Instruction InstructionType="Valid" InstructionText="See me" />
</Instructions>
<OrderLines Type="Text" Value="9">
<OrderLine Type="Fine Print" Value="3">
</OrderLine>
</OrderLines>
</Order>

No comments:

Post a Comment