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.