Inserting a node into XML



I am wondering if anyone can help me with a problem I am having.


I am using XSLT version 1 to transform some source XML, part of which looks like this:



<tr parent="ID0E4B" zylevel="3" type="categoryhead">
<td colname="1">Utilities 1.61%</td>
<td colname="2">1.61</td>
<td colname="3">300,000</td>
</tr>
<tr parent="ID0EOB" zylevel="2" type="categorytotal" >
<td colname="1">Total </td>
<td colname="2"/>
<td colname="3">17,567,240</td>
</tr>


I would like to be able to create a tr node similar to the tr node in the source xml and insert it between the two tr nodes in the above example. The node to insert should like this:



<tr parent="ID0EGWAE" zylevel="4" type="detail">
<td colname="1">Other securities</td>
<td colname="2">1.61</td>
<td colname="3">335,207</td>
</tr>


Right now the XSLT processor is about to print the second tr node in the topmost example. The desired output should look like this:



<tr parent="ID0E4B" zylevel="3" type="categoryhead">
<td colname="1">Utilities 1.61%</td>
<td colname="2">1.61</td>
<td colname="3">300,000</td>
</tr>
<tr parent="ID0EGWAE" zylevel="4" type="detail">
<td colname="1">Other securities</td>
<td colname="2">1.61</td>
<td colname="3">335,207</td>
</tr>
<tr parent="ID0EOB" zylevel="2" type="categorytotal" >
<td colname="1">Total </td>
<td colname="2"/>
<td colname="3">17,567,240</td>
</tr>


Any help that anyone has would be much appreciate it. I have to admit to being clueless on this one .


Thanks, Alex Irwin.


No comments:

Post a Comment