XMLEXISTS on legacy XML with malformed xmlns

From: Edson Richter <edsonrichter(at)hotmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: XMLEXISTS on legacy XML with malformed xmlns
Date: 2016-02-12 00:53:59
Message-ID: BLU437-SMTP55F7744BA6848E0C7EB994CFA90@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!

I've some (about 1M records) containing legacy XML I would like to parse
and apply XMLEXISTS.

This is the query:

select * from xmllog
where xpath_exists(('//MyDocument[(at)DocNum = ''000411828'']'::text),
xmlparse(document cdataout));

This is the error:

ERRO: could not parse XML document
SQL state: 2200M
Detail: line 2: xmlns:leg: 'LEGACYAPP - SEND MSG EVENTS ABOUT' is not a
valid URI
<leg:sendmsgeventsabout xmlns:leg="LEGACYAPP - SEND MSG EVENTS ABOUT">
^

This is the sample XML with malformed xmlns (I've shortenet the data,
but the important thing here is the malformed xmlns):

"<?xml version="1.0" encoding="utf-8" ?>
<leg:sendmsgeventsabout xmlns:leg="LEGACYAPP - SEND MSG EVENTS ABOUT">
<carrier xmlns="" controlnum="04503660000146">
<MyDocument DocNum="000511852">
<other_info>0</other_info>
<complement info (...)"

I can easly read this XML in Notepad++, and also in Java - but
PostgreSQL always throw error.

Can you plase tell me how can make PostgreSQL ignore this malformed
xmlns and proceed processing the XML?

Thanks,

--
Atenciosamente,

Edson Carlos Ericksson Richter

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2016-02-12 02:10:57 Re: Unrecognized configuration parameter in bdr 0.9.3
Previous Message Tom Lane 2016-02-12 00:29:02 Re: Transaction ID not logged if no explicit transaction used