Ampersand Charecter ('&') do Not Escape in XMLTransform after Upgrade from 10g to 11g or Higher Version (Doc ID 1603633.1)

Last updated on FEBRUARY 08, 2017

Applies to:

Oracle Database - Enterprise Edition - Version and later
Information in this document applies to any platform.


When using XMLTRANSFORM in 11g output characters do not escape properly. Following simple testcase demonstrates the problem -

set serveroutput on
set define off
   l_xsl xmltype;
   l_xml xmltype;
   V_STR_ESCAPE clob;
   V_RESULT varchar2(5000);
   v_str  varchar2(1000):='1.2500.RD.NITROSTEEL.CARBON.TG &
P.288.0000';  BEGIN

   l_xsl := XMLTYPE('<?xml version="1.0"?>
                     <xsl:stylesheet version="1.0"
                     <xsl:output method="text"/>
                     <xsl:template match="/">
                     <xsl:value-of select="//name"/>

   SELECT xmlelement("name", v_str) INTO l_xml FROM dual;

   SELECT xmltransform(l_xml,l_xsl).getClobVal() INTO v_str_escape
FROM dual;

   SELECT DBMS_LOB.SUBSTR(v_str_escape,
NVL(dbms_lob.getlength(v_str_escape),0),1) INTO  v_result FROM dual;

   dbms_output.put_line( v_result) ;

 when OTHERS then

Above code in 10g db handles the escape '&' charecter but not in 11g as shown in below output - Output

1.2500.RD.NITROSTEEL.CARBON.TG &amp; P.288.0000 output

1.2500.RD.NITROSTEEL.CARBON.TG & P.288.0000 output

1.2500.RD.NITROSTEEL.CARBON.TG & P.288.0000

12c output

1.2500.RD.NITROSTEEL.CARBON.TG & P.288.0000


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