XML validation of whitespace values

From: Tim Kane <tim(dot)kane(at)gmail(dot)com>
To: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: XML validation of whitespace values
Date: 2014-03-14 15:12:59
Message-ID: CF48CCFB.65A9D%tim.kane@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

HI all,

I’ve had an interesting problem trying to perform an UPDATE based on the
results of processing an xpath against a field of type xml.
Specifically, my query would fail with:

> ERROR: could not parse XML document
> DETAIL: line 1: Start tag expected, '<' not found

I thought this strange, since the xml type is (I believe) supposed to
guarantee that the value is well formed (wether it’s a document or content).

After some amount of digging to locate the rogue entry, it turns out the
field value is actually a single whitespace character – which apparently is
well formed..

Thus I’m left with the following situation…

clone=# select xml_is_well_formed(' ');
xml_is_well_formed
--------------------
t
(1 row)

clone=# select xpath_exists (‘//test', ' ');
ERROR: could not parse XML document
DETAIL: line 1: Start tag expected, '<' not found

clone=# create temp table xml_test (document xml);
CREATE TABLE
clone=# insert into xml_test values (' ');
INSERT 0 1
clone=# select xml_is_well_formed(document::text) from xml_test;
xml_is_well_formed
--------------------
t
(1 row)

clone=# select xpath_exists ('test', document) from xml_test;
ERROR: could not parse XML document
DETAIL: line 1: Start tag expected, '<' not found

This is confusing, since… if the xml is well formed – it probably shouldn’t
cause the parser to error. And if it isn’t well formed, then the
instantiation of the value as an xml type should fail.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daryl Foster 2014-03-14 16:58:55 Re: Cannot insert to 'path' field using EclipseLink
Previous Message Jakub Can 2014-03-14 14:58:07 Re: pg_dump fails pg_rewrite entry not found