Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

LPX-00217 invalid character error - Using reference characters in XML file

541466Oct 24 2006 — edited Oct 29 2006
Hi, I hope you will help me to understand and to fix the error I get during insert of an XML file into a table with XML Type field.

*******************************************
I used Oracle documentation for this:

1. Create table
CREATE TABLE XMLDOC
( XMLCOLUMN xmltype);

2. Create external directory
CREATE OR REPLACE DIRECTORY FILESDIR AS 'E:\ora_xml_test\';

3. Create function
CREATE OR REPLACE function DSS.getClobDocument(
filename in varchar2,
charset in varchar2 default NULL)
return CLOB deterministic
is
file bfile := bfilename('FILESDIR',filename);
charContent CLOB := ' ';
targetFile bfile;
lang_ctx number := DBMS_LOB.default_lang_ctx;
charset_id number := 0;
src_offset number := 1 ;
dst_offset number := 1 ;
warning number;
begin
if charset is not null then
charset_id := NLS_CHARSET_ID(charset);
end if;
targetFile := file;
DBMS_LOB.fileopen(targetFile, DBMS_LOB.file_readonly);
DBMS_LOB.LOADCLOBFROMFILE(charContent, targetFile,
DBMS_LOB.getLength(targetFile), src_offset, dst_offset,
charset_id, lang_ctx,warning);
DBMS_LOB.fileclose(targetFile);
return charContent;
end;
/
*******************************************
And now appears the problem when I use different character references - one of them are parsed by the XML parser and another -are not:

----------------------------------------------------------------------------------------
test1.xml - Contains a charachter from Latin language -ă (&#x103)

<?xml version="1.0" encoding="UTF-8"?>
<ROWSET>
<ROW
<IDNO>1</IDNO>
<NAME>aaa (&#x103)</NAME>
</ROW>
</ROWSET>

--a semicolumn must be added after 103

SQL> insert into XMLDOC values(xmltype(getClobDocument('test1.xml','UTF8')));

1 row created.

----------------------------------------------------------------------------------------

test2.xml - Contains a charachter from Cyrillic language -ш (&#x404)

<?xml version="1.0" encoding="UTF-8"?>
<ROWSET>
<ROW>
<IDNO>1</IDNO>
<NAME>aaa (&#x404)</NAME>
</ROW>
</ROWSET>

--a semicolumn must be added after 404

SQL> insert into XMLDOC values(xmltype(getClobDocument('test2.xml','UTF8')));
insert into XMLDOC values(xmltype(getClobDocument('test2.xml','UTF8')))
*
ERROR at line 1:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00217: invalid character 1028 (\u0404)
Error at line 5
ORA-06512: at "SYS.XMLTYPE", line 0
ORA-06512: at line 1
----------------------------------------------------------------------------------------

I am not familiar to Unicode and encoding maybe I ' missing something.

Please help!!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 26 2006
Added on Oct 24 2006
3 comments
10,356 views