XMLSerialize: version and explicit XML declaration

Поиск
Список
Период
Сортировка
Искать

XMLSerialize: version and explicit XML declaration

От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Hi,

I'm working on the flags VERSION (X076), INCLUDING XMLDECLARATION, and
EXCLUDING XMLDECLARATION (X078) for XMLSerialize, and I have a question
for SQL/XML experts on the list.

Is there any validation mechanism for VERSION ? The SQL/XML spec says

"The  immediately contained in  shall be '1.0' or '1.1', or it shall identify some successor to
XML 1.0 and XML 1.1."

I was wondering if a validation here would make any sense, since
XMLSerialize is only supposed to print a string --- not to mention that
validating "some successor to XML 1.0 and XML 1.1" can be challenging :)
But again, printing an "invalid" XML string also doesn't seem very nice.

The oracle implementation accepts pretty much anything:

SQL> SELECT xmlserialize(DOCUMENT xmltype('42')
VERSION 'foo') AS xml FROM dual;

XML
--------------------------------------------------------------------------------


  42



In db2, anything other than '1.0' raises an error:

db2 => SELECT XMLSERIALIZE(CONTENT XMLELEMENT(NAME "db2",service_level)
AS varchar(100) VERSION '1.0' INCLUDING XMLDECLARATION) FROM
sysibmadm.env_inst_info;

1                                                                                                 
 
----------------------------------------------------------------------------------------------------
DB2
v11.5.9.0                                      

  1 record(s) selected.


db2 => SELECT XMLSERIALIZE(CONTENT XMLELEMENT(NAME "db2",service_level)
AS varchar(100) VERSION '1.1' INCLUDING XMLDECLARATION) FROM
sysibmadm.env_inst_info;
SQL0171N  The statement was not processed because the data type, length or
value of the argument for the parameter in position "2" of routine
"XMLSERIALIZE" is incorrect. Parameter name: "".  SQLSTATE=42815

Any thoughts on how we should approach this feature?

Thanks!

Best, Jim


Re: XMLSerialize: version and explicit XML declaration

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Jim Jones  writes:
> Is there any validation mechanism for VERSION  literal>?

AFAICS, all we do with an embedded XML version string is pass it to
libxml2's xmlNewDoc(), which is the authority on whether it means
anything.  I'd be inclined to do the same here.

			regards, tom lane


Re: XMLSerialize: version and explicit XML declaration

От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Вложения:

On 30.09.24 10:08, Jim Jones wrote:
> On 25.09.24 18:02, Tom Lane wrote:
>> AFAICS, all we do with an embedded XML version string is pass it to
>> libxml2's xmlNewDoc(), which is the authority on whether it means
>> anything.  I'd be inclined to do the same here.
> Thanks. I used xml_is_document(), which calls xmlNewDoc(), to check if
> the returned document is valid or not. It then decides if an unexpected
> version deserves an error or just a warning.
>
> Attached v1 with the first attempt to implement these features.

rebase

Best regards, Jim

Re: XMLSerialize: version and explicit XML declaration

От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Вложения:
rebase and add missing check for xmlBufferAddHead result


-- 
Jim

Re: XMLSerialize: version and explicit XML declaration

От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Вложения:
rebase

-- 
Jim

Re: XMLSerialize: version and explicit XML declaration

От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Вложения:
rebased

-- 
Jim

Re: XMLSerialize: version and explicit XML declaration

От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Вложения:
rebased

Jim

Re: XMLSerialize: version and explicit XML declaration

От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Вложения:
rebase

Jim

Re: XMLSerialize: version and explicit XML declaration

От:
Jim Jones <jim.jones@uni-muenster.de>
Дата:
Вложения:
rebase

Jim
FAQ