Xml Transformation Adds The Namespace Twice To The Root Element (Doc ID 1366323.1)

Last updated on FEBRUARY 08, 2017

Applies to:

Oracle Server - Enterprise Edition - Version: 11.1.0.7 to 11.2.0.2 - Release: 11.1 to 11.2
Information in this document applies to any platform.

Symptoms

Using XMLtype.Transform(), the namespace attribute is added twice to the root element.

Code Example

DECLARE
v_xml XMLtype;
v_xsl XMLtype;
v_result XMLtype;
content CLOB;

begin
v_xsl := xmltype(
'<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:copy-of select="."/>
</xsl:template>
</xsl:stylesheet>');

v_xml := xmltype(
'<rootNode xmlns="http://www.europace.ie/xsd/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<testNode>hello World</testNode>
</rootNode>');

v_result := v_xml.transform(xsl => v_xsl);
content := v_result.getClobVal();
dbms_output.put_line(CONTENT);
end;
/

This generates the following output in 11.1.0.7, 11.2.0.1 and 11.2.0.2:
<rootNode xmlns="http://www.europace.ie/xsd/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.europace.ie/xsd/">
<testNode>hello World</testNode>
</rootNode>

while in 10.2.0.5 the output is correct
<rootNode xmlns="http://www.europace.ie/xsd/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<testNode>hello World</testNode>
</rootNode>
 

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms