Re: Issue: Deprecation of the XML2 module 'xml_is_well_formed' function

Поиск
Список
Период
Сортировка
От Mike Fowler
Тема Re: Issue: Deprecation of the XML2 module 'xml_is_well_formed' function
Дата
Msg-id 4C28D05F.8030005@mlfowler.com
обсуждение исходный текст
Ответ на Re: Issue: Deprecation of the XML2 module 'xml_is_well_formed' function  (Robert Haas <robertmhaas@gmail.com>)
Ответы Re: Issue: Deprecation of the XML2 module 'xml_is_well_formed' function  (Mike Fowler <mike@mlfowler.com>)
Список pgsql-hackers
Robert Haas wrote:
> 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.
>
>   
Should the IS DOCUMENT predicate support this? At the moment you get the 
following:

template1=# SELECT 
'<towns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns>' 
IS DOCUMENT;?column?
----------t
(1 row)

template1=# SELECT 
'<towns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns' 
IS DOCUMENT;
ERROR:  invalid XML content
LINE 1: SELECT '<towns><town>Bidford-on-Avon</town><town>Cwmbran</to...              ^
DETAIL:  Entity: line 1: parser error : expected '>'
owns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns
                                     
 
^
Entity: line 1: parser error : chunk is not well balanced
owns><town>Bidford-on-Avon</town><town>Cwmbran</town><town>Bristol</town></towns
                                     
 
^
I would've hoped the second would've returned 'f' rather than failing. 
I've had a glance at the XML/SQL standard and I don't see anything in 
the detail of the predicate (8.2) that would specifically prohibit us 
from changing this behavior, unless the common rule  'Parsing a string 
as an XML value' (10.16) must always be in force. I'm no standard 
expert, but IMHO this would be an acceptable change to improve 
usability. What do others think?

Regards,

-- 
Mike Fowler
Registered Linux user: 379787

"I could be a genius if I just put my mind to it, and I,
I could do anything, if only I could get 'round to it"
-PULP 'Glory Days'



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: get_whatever_oid, part 1: object types with unqualifed names
Следующее
От: Robert Haas
Дата:
Сообщение: Re: get_whatever_oid, part 1: object types with unqualifed names