DBMS_XMLQUERY Gives XML Document Which Contains Invalid Character

(Doc ID 397671.1)

Last updated on AUGUST 29, 2010

Applies to:

Oracle Server - Enterprise Edition - Version: 10.2.0.2 and later   [Release: 10.2 and later ]
Information in this document applies to any platform.
Checked for Relevance on 30-Aug-2010

Goal

Running the following, where chr(25) is an invalid character per W3 standard, gives back an XML
document:

select DBMS_XMLQUERY.getxml('select ''Illegal Character: '' || CHR(25) as TEXTCOL from dual') from
dual;

<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<TEXTCOL>Illegal Character: </TEXTCOL>
</ROW>
</ROWSET>

If a valid character is used in the query it is replaced with a character entity as expected:

select DBMS_XMLQUERY.getxml('select ''Illegal Character: '' || CHR(38) as TEXTCOL from dual') from
dual;

<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<TEXTCOL>Illegal Character: &</TEXTCOL>
</ROW>
</ROWSET>

Solution

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