Hi,
This is a PoC that implements XMLCast (SQL/XML X025), which enables
conversions between SQL and XML data type.
It basically does the following:
* When casting an XML value to a SQL data type, XML values containing
XSD literals will be converted to their equivalent SQL data type.
* When casting from a SQL data type to XML, the cast operand will be
translated to its corresponding XSD data type.
SELECT xmlcast(now() AS xml);
xmlcast
----------------------------------
2024-07-02T17:03:11.189073+02:00
(1 row)
SELECT xmlcast('2024-07-02T17:03:11.189073+02:00'::xml AS timestamp with
time zone);
xmlcast
-------------------------------
2024-07-02 17:03:11.189073+02
(1 row)
SELECT xmlcast('P1Y2M3DT4H5M6S'::xml AS interval);
xmlcast
-------------------------------
1 year 2 mons 3 days 04:05:06
(1 row)
SELECT xmlcast('<foo&bar>'::xml AS text);
xmlcast
-----------
<foo&bar>
(1 row)
SELECT xmlcast('1 year 2 months 3 days 4 hours 5 minutes 6
seconds'::interval AS xml) ;
xmlcast
----------------
P1Y2M3DT4H5M6S
(1 row)
SELECT xmlcast('42.73'::xml AS numeric);
xmlcast
---------
42.73
(1 row)
SELECT xmlcast(42730102030405 AS xml);
xmlcast
----------------
42730102030405
(1 row)
Is it starting in the right direction? Any feedback would be much
appreciated.
Best,
Jim