Friday, March 15, 2013

LPX-00209: PI names starting with XML are reserved

Always check out the original article at http://www.oraclequirks.com for latest comments, fixes and updates.

I don't know why it took me more than the necessary to understand where was the problem when I hit the following error.

ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00209: PI names starting with XML are reserved

At any rate, in my case the reason was not the same as reported in other sites (like having a duplicate XML declaration).
The trouble was caused by a simple blank character located before the initial XML file declaration.
The error occurred on Oracle 10.2 (XE), while on Oracle 11.2.0.3.0 EE the blanks seem to give no concerns whatsoever to the parser.
I ignore the results on the Oracle versions in between.

You can easily simulate the problem with the following query in SQL Developer:

select xmltype(' ' || dbms_xmlgen.getxml('select 1 from dual')) x from dual;

If you have a clob object containing an xmlfile with extra blanks at the beginning of the file and attempting to parse it you get this error, you may easily fix the problem by TRIMming it first. 

See message translations for ORA-19202, LPX-00209 and search additional resources.

7 comments:

  1. Thank you. I had this problem with an XML file from a customer. I don't think that I would have figured out the answer to this puzzle.

    ReplyDelete
  2. You saved my day ... thanks, Flavio!

    Cheers,
    ~Dietmar.

    ReplyDelete
  3. Dietmar,
    I am glad to know it helped.

    Frohes Weihnachten!
    Flavio

    ReplyDelete
  4. Thank you for this post, saved my day too :-)

    I meet this today on Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production (AIX machine).

    ReplyDelete
  5. grazie mille! u saved my day

    ReplyDelete
  6. great, it works, i had an chr(10) at the begining by mistake, i removed it and then it works perfect, thanks a lot

    ReplyDelete
  7. Thank you so much, I spent a lot of time trying to debug this error and the solution listed in this article finally resolved it.

    ReplyDelete

I appreciate your comment however bear in mind that I might not have the time to reply soon.
Normally I do not reply to all comments but I am glad if you found something useful or if you learned something new, in that case I strongly encourage you to promote the article with the +1 google button.
Flavio