Re: Issue: Deprecation of the XML2 module 'xml_is_well_formed' function - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Issue: Deprecation of the XML2 module 'xml_is_well_formed' function
Date
Msg-id AANLkTinqA1HEdYh92X--iqi3YQA_7uOyAq9aN4HybBEc@mail.gmail.com
Whole thread Raw
In response to Re: Issue: Deprecation of the XML2 module 'xml_is_well_formed' function  (Mike Rylander <mrylander@gmail.com>)
Responses Re: Issue: Deprecation of the XML2 module 'xml_is_well_formed' function  (Mike Fowler <mike@mlfowler.com>)
List pgsql-hackers
On Mon, Jun 28, 2010 at 11:42 AM, Mike Rylander <mrylander@gmail.com> wrote:
> You could do something like this (untested):
>
> CREATE OR REPLACE FUNCTION my_xml_is_valid ( x TEXT ) RETURNS BOOL AS $$
> BEGIN
>  PERFORM XMLPARSE( DOCUMENT x::XML );
>  RETURN TRUE;
> EXCEPTION WHEN OTHERS THEN
>  RETURN FALSE;
> END;
> $$ LANGUAGE PLPGSQL;

This might perform significantly worse, though: exception handling ain't cheap.

It's not a bad workaround, but I think the OP has a point.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: get_whatever_oid, part 1: object types with unqualifed names
Next
From: Tom Lane
Date:
Subject: Re: get_whatever_oid, part 1: object types with unqualifed names