I want to modify the following xml using XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<folder>
<CRDATTIM>2012-08-31-08.26.11.805400</CRDATTIM>
<RECORDCD>F</RECORDCD>
</folder>
<case>
<CRDATTIM>2014-03-26-05.22.22.339840</CRDATTIM>
<RECORDCD>C</RECORDCD>
<issue>
<KEY>2014-03-26-05.22.22.193840T01</KEY>
<PRTY>999</PRTY>
</issue>
</case>
<folder>
<CRDATTIM>2012-11-06-23.57.08.089400</CRDATTIM>
<RECORDCD>F</RECORDCD>
</folder>
<case>
<CRDATTIM>2014-04-29-06.58.32.992840</CRDATTIM>
<RECORDCD>C</RECORDCD>
<issue>
<KEY>2014-04-29-06.58.31.305840T01</KEY>
<PRTY>999</PRTY>
</issue>
</case>
</response>
Now, I want to add a new node <sort> to the root node <response> such that the node <sort> will contain two children <field /> and <ascending /> .But, here for each case in the above xml, the two tags <field /> and <ascending /> should be added to the <sort> node.For example in the above xml, there are two cases(<case>). So, the node <sort> should have two <field /> tags and <ascending /> tags. Ultimately, My final xml should look like below:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<folder>
<CRDATTIM>2012-08-31-08.26.11.805400</CRDATTIM>
<RECORDCD>F</RECORDCD>
</folder>
<case>
<CRDATTIM>2014-03-26-05.22.22.339840</CRDATTIM>
<RECORDCD>C</RECORDCD>
<issue>
<KEY>2014-03-26-05.22.22.193840T01</KEY>
<PRTY>999</PRTY>
</issue>
</case>
<folder>
<CRDATTIM>2012-11-06-23.57.08.089400</CRDATTIM>
<RECORDCD>F</RECORDCD>
</folder>
<case>
<CRDATTIM>2014-04-29-06.58.32.992840</CRDATTIM>
<RECORDCD>C</RECORDCD>
<issue>
<KEY>2014-04-29-06.58.31.305840T01</KEY>
<PRTY>999</PRTY>
</issue>
</case>
<sort>
<field />
<ascending />
<field />
<ascending />
<field />
</sort>
</response>
Please share your thoughts on how to achieve the desired functionality. Please let me know if my question is not clear. Thanks in advance.