I have got stuck with minor change for XSLT, because i would like to replace the Top root node with different name. I have tried with below XSLT to add new root, but unable to delete the initial root of input xml. Can someone please let me know what i am missing here. Thank you.
Below is the XSLT code tried.
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8"/>
<xsl:template match="root">
<ns:NewParent xmlns:ns="http://test.com/user">
<xsl:copy-of select="." />
</ns:NewParent>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
Input XML :
<root>
<root>
<a>TestA</a>
<b>Testb</b>
<c>Testc</c>
</root>
<root>
<a>TestA1</a>
<b>Testb1</b>
<l>Testl1</l>
</root>
<root>
<a>TestA12</a>
<b>Testb12</b>
<l>Testl2</l>
</root>
</root>
Output/Desired XML :
<ns:NewParent xmlns:ns="http://test.com/user">
<root>
<a>TestA</a>
<b>Testb</b>
<c>Testc</c>
</root>
<root>
<a>TestA1</a>
<b>Testb1</b>
<l>Testl1</l>
</root>
<root>
<a>TestA12</a>
<b>Testb12</b>
<l>Testl2</l>
</root>
</ns:NewParent>