There's a lot of references in the internet that has the same problem with me. It is the adding of namespace, I have the same as this one that I saw: Adding namespace in inner parent group in xslt v2.0. But in my case, I don't have a namespace in the parent tag and insert the namespace in the inner level group. I tried to copied the solutions but I can't get the expected output. For example, I have this sample file,
INPUT:
<Record>
<Data>
<Section>
<ID>111222</ID>
</Section>
</Data>
</Record>
EXPECTED:
<Record>
<Data>
<Section xmlns="www.hdgd.co">
<ID>111222</ID>
</Section>
</Data>
</Record>
XSLT:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="Section">
<Section xmlns="www.hdgd.co">
<xsl:copy-of select="*"/>
</Section>
</xsl:template>
The generated output populated an empty namespace in the ID element. And, I need to remove that empty xmlns. Look like this:
<Record>
<Data>
<Section xmlns="www.hdgd.co">
<ID xmlns="">111222</ID>
</Section>
</Data>
</Record>