Append the suffix to predecessor element if all its following elements
have the suffix in them
I would like to, move(remove from item and append to group) suffix if ALL
the tr(item) in that group have that suffix in their td(index=1) element's
value. That means '[s2]' should be move to Group A and [s1] to Group B
This XML should be:
<table xmlns="MyNamespaceUri">
<tr type="group"> <td index="1">Group A</td> </tr>
<tr type="item">
<td index="1"> Item Type A1 [s1],[s2],[s3]</td>
<td index="2">11</td>
</tr>
<tr type="item">
<td index="1"> Item Type A2 [s1],[s2]</td>
<td index="2">21</td>
</tr>
<tr type="item">
<td index="1"> Item Type A3 [s2],[s4]</td>
<td index="2">31</td>
</tr>
<tr type="total"> <td index="2">63</td> </tr>
<tr type="group">
<td index="1">Group B</td>
</tr>
<tr type="item">
<td index="1"> Item Type B1 [s1],[s2],[s3]</td>
<td index="2">12</td>
</tr>
<tr type="item">
<td index="1"> Item Type B2 [s1],[s3]</td>
<td index="2">22</td>
</tr>
<tr type="item">
<td index="1"> Item Type B3 [s1],[s4]</td>
<td index="2">32</td>
</tr>
<tr type="total"> <td index="2">66</td> </tr>
</table>
Transformed like this:
<table xmlns="MyNamespaceUri">
<tr type="group"> <td index="1">Group A [s2]</td> </tr>
<tr type="item">
<td index="1"> Item Type A1 [s1],[s3]</td>
<td index="2">11</td>
</tr>
<tr type="item">
<td index="1"> Item Type A2 [s1]</td>
<td index="2">21</td>
</tr>
<tr type="item">
<td index="1"> Item Type A3 [s4]</td>
<td index="2">31</td>
</tr>
<tr type="total"> <td index="2">63</td> </tr>
<tr type="group">
<td index="1">Group B [s1]</td>
</tr>
<tr type="item">
<td index="1"> Item Type B1 [s2],[s3]</td>
<td index="2">12</td>
</tr>
<tr type="item">
<td index="1"> Item Type B2 [s3]</td>
<td index="2">22</td>
</tr>
<tr type="item">
<td index="1"> Item Type B3 [s4]</td>
<td index="2">32</td>
</tr>
<tr type="total"> <td index="2">66</td> </tr>
</table>
Thanks a ton in advance.
No comments:
Post a Comment