I am working on XML to XML transformations through XSLT. I want to remove the name spaces in output xml. For that I have used Exclude result prefix option, but in the output i still see the namespaces.
Sorce XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<aaa>
hello
</aaa>
XSLT written:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:simple="aaaa" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:tcm="http://www.tridion.com/ContentManager/5.0" exclude-result-prefixes="msxsl simple wireframe widget tcdl tcm xlink" xmlns:wireframe="bbb" xmlns:widget="ccc" xmlns:tcdl="tcdl">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<wireframe:wireframe>
<wireframe:si>
<widget:ah>
<xsl:value-of select="aaa" />
</widget:ah>
</wireframe:si>
</wireframe:wireframe>
</xsl:template>
</xsl:stylesheet>
OUTPUT produced:
<?xml version="1.0" encoding="utf-8"?>
<wireframe:wireframe xmlns:wireframe="aaaa">
<wireframe:si>
<widget:ah xmlns:widget="bbb">
hello
</widget:ah>
</wireframe:si>
</wireframe:wireframe>
Output Expexcted:
<?xml version="1.0" encoding="utf-8"?>
<wireframe:wireframe>
<wireframe:si>
<widget:ah>
hello
</widget:ah>
</wireframe:si>
</wireframe:wireframe>
Please tell me how to avoid namespace appearance in output XML.
Thank you in advance.
You could leave out the two used namespaces in the exclude attribute as follows:
exclude-result-prefixes="msxsl simple xlink tcm tcdl"
which will make sure that the two namespaces which are used appear in the root element, not in the element where they are first used; the result will be:
<?xml version="1.0" encoding="UTF-8"?>
<wireframe:wireframe xmlns:widget="ccc" xmlns:wireframe="bbb">
<wireframe:si>
<widget:ah>
hello
</widget:ah>
</wireframe:si>
</wireframe:wireframe>