Re: XML validation of whitespace values

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Tim Kane <tim(dot)kane(at)gmail(dot)com>, pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: XML validation of whitespace values
Date: 2014-05-12 00:38:38
Message-ID: 5370180E.7010301@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 3/14/14, 11:12 AM, Tim Kane wrote:
> 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

There are several issues at work here:

- contrib/xml2 has a slightly different notion of what is an OK xml
value than the built-in xml type.

- A string consisting of whitespace is well-formed XML content, but not
a well-formed XML document. Compare xmlparse(document ' ') vs
xmlparse(content ' '). contrib/xml2 (apparently) follows the latter
interpretation.

- xpath queries only work properly on XML documents.

It might be better if you wrote your code without using contrib/xml2,
and instead caught any parse exceptions in, say, plpgsql code.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G Johnston 2014-05-12 01:18:41 Re: XML validation of whitespace values
Previous Message Rafał Pietrak 2014-05-11 22:05:15 Re: Re: Partitioning such that key field of inherited tables no longer retains any selectivity