I'm struggling with XSLT. I need to copy an entire xml file to a new xml file. The input and output should be identical except for the addition of some extra tags around certain elements.
Consider the two versions:
<?xml version="1.0"?>
<document>
<header>
<general>
<version>1.14.2</version>
<form>/XX/ATL_ZI_D007_PURCHASE</form>
<language>EN</language>
<device>PRINTER</device>
</general>
<archive mode="1" mode-modify-enabled="yes"/>
</header>
<data xml:space="preserve">
<window name="MAIN_WINDOW" type="main" page="FIRST" page-id="001">
<table name="DATA" pattern="0001">
<thead/>
<tbody>
<tr ltype="TABLE_POS">
<tc cell="1" />
</tr>
</tbody>
</table>
</window>
</data>
</document>
<?xml version="1.0"?>
<document>
<header>
<general>
<version>1.14.2</version>
<form>/XX/ATL_ZI_D007_PURCHASE</form>
<language>EN</language>
<device>PRINTER</device>
</general>
<archive mode="1" mode-modify-enabled="yes"/>
</header>
<data xml:space="preserve">
<window name="MAIN_WINDOW" type="main" page="FIRST" page-id="001">
<table name="DATA" pattern="0001">
<thead/>
<tbody>
<extra>
<tr ltype="TABLE_POS">
<tc cell="1" />
</tr>
</extra>
</tbody>
</table>
</window>
</data>
</document>
Notice the "extra" tags around the "tr" element. Essentially I want to copy the file, but re-write the "tr" element by surrounding it with additional tags. That's the simplified version.
In actuality, imagine there are multiple "tr" elements, and I wanted the "extra" tags around every group of three:
<table name="DATA" pattern="0001">
<thead/>
<tbody>
<extra>
<tr ltype="TABLE_POS">
<tc cell="1" />
</tr>
<tr ltype="TABLE_POS">
<tc cell="1" />
</tr>
<tr ltype="TABLE_POS">
<tc cell="1" />
</tr>
</extra>
<extra>
<tr ltype="TABLE_POS">
<tc cell="1" />
</tr>
<tr ltype="TABLE_POS">
<tc cell="1" />
</tr>
<tr ltype="TABLE_POS">
<tc cell="1" />
</tr>
</extra>
<extra>
<tr ltype="TABLE_POS">
<tc cell="1" />
</tr>
<tr ltype="TABLE_POS">
<tc cell="1" />
</tr>
<tr ltype="TABLE_POS">
<tc cell="1" />
</tr>
</extra>
</tbody>
</table>
I appreciate any assistance or references.