I have following XML:
<?xml version="1.0" encoding="utf-8"?>
<Rowsets>
<Rowset>
<Columns>
<Column Description="DrilldownDepth" MaxRange="1" MinRange="0" Name="DrilldownDepth" SQLDataType="4" SourceColumn="DrilldownDepth"/>
<Column Description="ABC" MaxRange="1" MinRange="0" Name="ABC" SQLDataType="4" SourceColumn="ABC"/>
<Column Description="DEF" MaxRange="1" MinRange="0" Name="DEF" SQLDataType="-1" SourceColumn="DEF"/>
<Column Description="PQR" MaxRange="1" MinRange="0" Name="PQR" SQLDataType="-1" SourceColumn="PQR"/>
</Columns>
<Row>
<DrilldownDepth>1</DrilldownDepth>
<ABC>25</ABC>
<DEF>DDD</DEF>
<PQR>PPP</PQR>
</Row>
<Row>
<DrilldownDepth>1</DrilldownDepth>
<ABC>16</ABC>
<DEF>AAA</DEF>
<PQR>BBB</PQR>
</Row>
<Row>
<DrilldownDepth>1</DrilldownDepth>
<ABC>19</ABC>
<DEF>SEE</DEF>
<PQR>HELP</PQR>
</Row>
</Rowset>
</Rowsets>
Now I need to add in every Row. hence my XML will look like following:
<?xml version="1.0" encoding="utf-8"?>
<Rowsets>
<Rowset>
<Columns>
<Column Description="DrilldownDepth" MaxRange="1" MinRange="0" Name="DrilldownDepth" SQLDataType="4" SourceColumn="DrilldownDepth"/>
<Column Description="ABC" MaxRange="1" MinRange="0" Name="ABC" SQLDataType="4" SourceColumn="ABC"/>
<Column Description="DEF" MaxRange="1" MinRange="0" Name="DEF" SQLDataType="-1" SourceColumn="DEF"/>
<Column Description="PQR" MaxRange="1" MinRange="0" Name="PQR" SQLDataType="-1" SourceColumn="PQR"/>
</Columns>
<Row>
<DrilldownDepth>1</DrilldownDepth>
<ABC>25</ABC>
<DEF>DDD</DEF>
<PQR>PPP</PQR>
<XYZ></XYZ>
</Row>
<Row>
<DrilldownDepth>1</DrilldownDepth>
<ABC>16</ABC>
<DEF>AAA</DEF>
<PQR>BBB</PQR>
<XYZ></XYZ>
</Row>
<Row>
<DrilldownDepth>1</DrilldownDepth>
<ABC>19</ABC>
<DEF>SEE</DEF>
<PQR>HELP</PQR>
<XYZ></XYZ>
</Row>
</Rowset>
</Rowsets>
How can I achive this using transform / XSLT?
I tried various XSLT but somehow I am not able to achieve it.
Soham
This simple XSLT:
…when applied to the original XML:
…produces the desired result:
Explanation:
<row>element, processes its children (via the Identity Template), and adds the desired<XYZ>node.