Re: XML validation of whitespace values - Mailing list pgsql-general

From Peter Eisentraut
Subject Re: XML validation of whitespace values
Date
Msg-id 5370180E.7010301@gmx.net
Whole thread Raw
In response to XML validation of whitespace values  (Tim Kane <tim.kane@gmail.com>)
List 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.



pgsql-general by date:

Previous
From: Rafał Pietrak
Date:
Subject: Re: Re: Partitioning such that key field of inherited tables no longer retains any selectivity
Next
From: David G Johnston
Date:
Subject: Re: XML validation of whitespace values