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.