Re: [REVIEW] Re: Fix xpath() to return namespace definitions
От | Ali Akbar |
---|---|
Тема | Re: [REVIEW] Re: Fix xpath() to return namespace definitions |
Дата | |
Msg-id | CACQjQLotP6K+HcnZk9PbPzQc6HUo8mDZDHoY8zEGkoVdDHbuBg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [REVIEW] Re: Fix xpath() to return namespace definitions (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: [REVIEW] Re: Fix xpath() to return namespace definitions
|
Список | pgsql-hackers |
Peter Eisentraut <peter_e@gmx.net> writes:
> committed version 7
Thanks!
Isn't that a back-patchable bug fix?
Upthread, i noted:
For back versions, i think because this patch changes xpath() behavior, we will only apply this to future versions. The old behavior is wrong (according to XPath standard) for not including namespaces, but maybe there are some application that depends on the old behavior.
Reviewing the behavior on 9.3, now i think the old behavior isn't usable (the resulting xml is not even processable in postgres):
# select unnest(xpath('//a:b', '<b:a xmlns:b="http://test.com/a"><b:b>1</b:b><b:b>2</b:b></b:a>'::xml, array[array['a','http://test.com/a']]));
unnest
--------------
<b:b>1</b:b>
<b:b>2</b:b>
(2 rows)
# select xpath('//b:b', unnest(xpath('//a:b', '<b:a xmlns:b="http://test.com/a"><b:b>1</b:b><b:b>2</b:b></b:a>'::xml, array[array['a','http://test.com/a']])));
ERROR: could not parse XML document
DETAIL: line 1: Namespace prefix b on b is not defined
<b:b>1</b:b>
# select unnest(xpath('//a:b', '<b:a xmlns:b="http://test.com/a"><b:b>1</b:b><b:b>2</b:b></b:a>'::xml, array[array['a','http://test.com/a']]));
unnest
--------------
<b:b>1</b:b>
<b:b>2</b:b>
(2 rows)
# select xpath('//b:b', unnest(xpath('//a:b', '<b:a xmlns:b="http://test.com/a"><b:b>1</b:b><b:b>2</b:b></b:a>'::xml, array[array['a','http://test.com/a']])));
ERROR: could not parse XML document
DETAIL: line 1: Namespace prefix b on b is not defined
<b:b>1</b:b>
Maybe some application uses the result directly, but correct xml-using applications should handle namespace correctly, so if '<b:b>1</b:b>' becomes '<b:b xmlns:b="http://test.com/a' >1</b:b>', there should be no issue in those applications.
So now +1 for back-patching this.
Regards,
--
Ali Akbar
В списке pgsql-hackers по дате отправления: