Hi All,
I had a requirement of adding the namespaces to the input XML using XSLT. I am novice to XSLT and with the knowledge from the XSLT2.0 book, i came up with following XSLT to achieve the same.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:param name="uri" />
<xsl:template match="comment()|processing-instruction()|/">
<xsl:copy>
<xsl:apply-templates />
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="fnz1:{local-name()}" namespace="{$uri}">
<xsl:apply-templates />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
But because of this namespace is coming on each element.
input XML is shown below and uri variable is
http://www.namspace.com
<RootElement>
<element1> </element1>
<element2> </element2>
</RootElement>
<RootElement xmlns:fnz1="http://www.namspace.com">
<element1 xmlns:fnz1="http://www.namspace.com"> </element1>
<element2 xmlns:fnz1="http://www.namspace.com"> </element2>
</RootElement>
Please let me know how can i resolve this issue and i had to use only XSLT1.0.
Thanks & Regards
Siva