I have to a large xml in the below format.
<First>
<Second Argument="12" Argument2="34" >
<Order InvOrg="123" Identifier="3580456" >
<SupplyDetails Type="TRACK" Quantity="7" Demand="ONHAND" />
</Order>
<Order InvOrg="Test" Identifier="3580457" >
<SupplyDetails Type="TRACK" Quantity="15" Demand="ONHAND" />
</Order>
<Order InvOrg="123" Identifier="3580458" >
<SupplyDetails Type="TRACK" Quantity="17" Demand="ONHAND" />
</Order>
<Order InvOrg="123" Identifier="3580459" >
<SupplyDetails Type="TRACK" Quantity="10" Demand="ONHAND" />
</Order>
<Order InvOrg="123" Identifier="2888144" >
<SupplyDetails Type="TRACK" Quantity="3" Demand="ONHAND" />
</Order>
<Order InvOrg="123" Identifier="2888147" >
<SupplyDetails Type="TRACK" Quantity="9" Demand="ONHAND" />
<Order>
<Order InvOrg="123" Identifier="2749622" >
<SupplyDetails Type="TRACK" Quantity="142" Demand="ONHAND" />
</Order>
</Second>
</First>
I need to convert it into the below format
<First>
<Second Argument="12" Argument2="34" >
<Order InvOrg="123" Identifier="3580456" >
<SupplyDetails Type="TRACK" Quantity="7" Demand="ONHAND" />
</Order>
<Order InvOrg="Test" Identifier="3580457" >
<SupplyDetails Type="TRACK" Quantity="15" Demand="ONHAND" />
</Order>
<Order InvOrg="123" Identifier="3580458" >
<SupplyDetails Type="TRACK" Quantity="17" Demand="ONHAND" />
</Order>
</Second>
</First>
<First>
<Second Argument="12" Argument2="34" >
<Order InvOrg="123" Identifier="3580459" >
<SupplyDetails Type="TRACK" Quantity="10" Demand="ONHAND" />
</Order>
<Order InvOrg="123" Identifier="2888144" >
<SupplyDetails Type="TRACK" Quantity="3" Demand="ONHAND" />
</Order>
<Order InvOrg="123" Identifier="2888147" >
<SupplyDetails Type="TRACK" Quantity="9" Demand="ONHAND" />
<Order>
<Order InvOrg="123" Identifier="2749622" >
<SupplyDetails Type="TRACK" Quantity="142" Demand="ONHAND" />
</Order>
</Second>
</First>
In xslt 2.0, It can be achieved with the below code..
<xsl:stylesheet
version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/First">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Second">
<xsl:for-each-group select="Order" group-starting-with="Order[(position() -1)mod 3 = 0]">
<First>
<Second>
<xsl:copy-of select="current-group()"/>
</Second>
</First>
</xsl:for-each-group>
</xsl:template>
My project uses only xslt 1.0, so i need to change the above logic to 1.0. How can i implement the same logic in xslt 1.0