1 CREATE SCHEMA testxmlschema;
2 CREATE TABLE testxmlschema.test1 (a int, b text);
3 INSERT INTO testxmlschema.test1 VALUES (1, 'one'), (2, 'two'), (-1, null);
4 CREATE DOMAIN testxmldomain AS varchar;
5 CREATE TABLE testxmlschema.test2 (z int, y varchar(500), x char(6), w numeric(9,2), v smallint, u bigint, t real, s time, r timestamp, q date, p xml, o testxmldomain, n bool, m bytea, aaa text);
6 ALTER TABLE testxmlschema.test2 DROP COLUMN aaa;
7 INSERT INTO testxmlschema.test2 VALUES (55, 'abc', 'def', 98.6, 2, 999, 0, '21:07', '2009-06-08 21:07:30', '2009-06-08', NULL, 'ABC', true, 'XYZ');
8 SELECT table_to_xml('testxmlschema.test1', false, false, '');
10 ---------------------------------------------------------------
11 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
31 SELECT table_to_xml('testxmlschema.test1', true, false, 'foo');
33 ---------------------------------------------------------------------------
34 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo">+
55 SELECT table_to_xml('testxmlschema.test1', false, true, '');
57 ---------------------------------------------------------------
58 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
63 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
68 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
75 SELECT table_to_xml('testxmlschema.test1', true, true, '');
77 ---------------------------------------------------------------
78 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
83 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
88 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
96 SELECT table_to_xml('testxmlschema.test2', false, false, '');
98 ---------------------------------------------------------------
99 <test2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
110 <r>2009-06-08T21:07:30</r> +
121 SELECT table_to_xmlschema('testxmlschema.test1', false, false, '');
123 -----------------------------------------------------------------------------------------------------------------
125 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
127 <xsd:simpleType name="INTEGER"> +
128 <xsd:restriction base="xsd:int"> +
129 <xsd:maxInclusive value="2147483647"/> +
130 <xsd:minInclusive value="-2147483648"/> +
134 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
135 <xsd:restriction base="xsd:string"> +
139 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
141 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
142 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element> +
146 <xsd:complexType name="TableType.regression.testxmlschema.test1"> +
148 <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
152 <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/> +
157 SELECT table_to_xmlschema('testxmlschema.test1', true, false, '');
159 -----------------------------------------------------------------------------------------------------------------
161 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
163 <xsd:simpleType name="INTEGER"> +
164 <xsd:restriction base="xsd:int"> +
165 <xsd:maxInclusive value="2147483647"/> +
166 <xsd:minInclusive value="-2147483648"/> +
170 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
171 <xsd:restriction base="xsd:string"> +
175 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
177 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
178 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element> +
182 <xsd:complexType name="TableType.regression.testxmlschema.test1"> +
184 <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
188 <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/> +
193 SELECT table_to_xmlschema('testxmlschema.test1', false, true, 'foo');
195 ----------------------------------------------------------------------------------------------
197 xmlns:xsd="http://www.w3.org/2001/XMLSchema" +
198 targetNamespace="foo" +
199 elementFormDefault="qualified"> +
201 <xsd:simpleType name="INTEGER"> +
202 <xsd:restriction base="xsd:int"> +
203 <xsd:maxInclusive value="2147483647"/> +
204 <xsd:minInclusive value="-2147483648"/> +
208 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
209 <xsd:restriction base="xsd:string"> +
213 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
215 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
216 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
220 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/> +
225 SELECT table_to_xmlschema('testxmlschema.test1', true, true, '');
227 ------------------------------------------------------------------------------------------------
229 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
231 <xsd:simpleType name="INTEGER"> +
232 <xsd:restriction base="xsd:int"> +
233 <xsd:maxInclusive value="2147483647"/> +
234 <xsd:minInclusive value="-2147483648"/> +
238 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
239 <xsd:restriction base="xsd:string"> +
243 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
245 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
246 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
250 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/> +
255 SELECT table_to_xmlschema('testxmlschema.test2', false, false, '');
257 -----------------------------------------------------------------------------------------------------------------
259 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
261 <xsd:simpleType name="INTEGER"> +
262 <xsd:restriction base="xsd:int"> +
263 <xsd:maxInclusive value="2147483647"/> +
264 <xsd:minInclusive value="-2147483648"/> +
268 <xsd:simpleType name="VARCHAR"> +
269 <xsd:restriction base="xsd:string"> +
273 <xsd:simpleType name="CHAR"> +
274 <xsd:restriction base="xsd:string"> +
278 <xsd:simpleType name="NUMERIC"> +
281 <xsd:simpleType name="SMALLINT"> +
282 <xsd:restriction base="xsd:short"> +
283 <xsd:maxInclusive value="32767"/> +
284 <xsd:minInclusive value="-32768"/> +
288 <xsd:simpleType name="BIGINT"> +
289 <xsd:restriction base="xsd:long"> +
290 <xsd:maxInclusive value="9223372036854775807"/> +
291 <xsd:minInclusive value="-9223372036854775808"/> +
295 <xsd:simpleType name="REAL"> +
296 <xsd:restriction base="xsd:float"></xsd:restriction> +
299 <xsd:simpleType name="TIME"> +
300 <xsd:restriction base="xsd:time"> +
301 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
305 <xsd:simpleType name="TIMESTAMP"> +
306 <xsd:restriction base="xsd:dateTime"> +
307 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
311 <xsd:simpleType name="DATE"> +
312 <xsd:restriction base="xsd:date"> +
313 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/> +
317 <xsd:complexType mixed="true"> +
319 <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/> +
323 <xsd:simpleType name="Domain.regression.public.testxmldomain"> +
324 <xsd:restriction base="VARCHAR"/> +
327 <xsd:simpleType name="BOOLEAN"> +
328 <xsd:restriction base="xsd:boolean"></xsd:restriction> +
331 <xsd:simpleType name="UDT.regression.pg_catalog.bytea"> +
332 <xsd:restriction base="xsd:base64Binary"> +
336 <xsd:complexType name="RowType.regression.testxmlschema.test2"> +
338 <xsd:element name="z" type="INTEGER" minOccurs="0"></xsd:element> +
339 <xsd:element name="y" type="VARCHAR" minOccurs="0"></xsd:element> +
340 <xsd:element name="x" type="CHAR" minOccurs="0"></xsd:element> +
341 <xsd:element name="w" type="NUMERIC" minOccurs="0"></xsd:element> +
342 <xsd:element name="v" type="SMALLINT" minOccurs="0"></xsd:element> +
343 <xsd:element name="u" type="BIGINT" minOccurs="0"></xsd:element> +
344 <xsd:element name="t" type="REAL" minOccurs="0"></xsd:element> +
345 <xsd:element name="s" type="TIME" minOccurs="0"></xsd:element> +
346 <xsd:element name="r" type="TIMESTAMP" minOccurs="0"></xsd:element> +
347 <xsd:element name="q" type="DATE" minOccurs="0"></xsd:element> +
348 <xsd:element name="p" type="XML" minOccurs="0"></xsd:element> +
349 <xsd:element name="o" type="Domain.regression.public.testxmldomain" minOccurs="0"></xsd:element> +
350 <xsd:element name="n" type="BOOLEAN" minOccurs="0"></xsd:element> +
351 <xsd:element name="m" type="UDT.regression.pg_catalog.bytea" minOccurs="0"></xsd:element> +
355 <xsd:complexType name="TableType.regression.testxmlschema.test2"> +
357 <xsd:element name="row" type="RowType.regression.testxmlschema.test2" minOccurs="0" maxOccurs="unbounded"/>+
361 <xsd:element name="test2" type="TableType.regression.testxmlschema.test2"/> +
366 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, false, '');
367 table_to_xml_and_xmlschema
368 -----------------------------------------------------------------------------------------------------------------
369 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#"> +
372 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
374 <xsd:simpleType name="INTEGER"> +
375 <xsd:restriction base="xsd:int"> +
376 <xsd:maxInclusive value="2147483647"/> +
377 <xsd:minInclusive value="-2147483648"/> +
381 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
382 <xsd:restriction base="xsd:string"> +
386 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
388 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
389 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element> +
393 <xsd:complexType name="TableType.regression.testxmlschema.test1"> +
395 <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
399 <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/> +
421 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, false, '');
422 table_to_xml_and_xmlschema
423 -----------------------------------------------------------------------------------------------------------------
424 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#"> +
427 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
429 <xsd:simpleType name="INTEGER"> +
430 <xsd:restriction base="xsd:int"> +
431 <xsd:maxInclusive value="2147483647"/> +
432 <xsd:minInclusive value="-2147483648"/> +
436 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
437 <xsd:restriction base="xsd:string"> +
441 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
443 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
444 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element> +
448 <xsd:complexType name="TableType.regression.testxmlschema.test1"> +
450 <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
454 <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/> +
470 <b xsi:nil="true"/> +
477 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, '');
478 table_to_xml_and_xmlschema
479 ----------------------------------------------------------------------------------------------
481 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
483 <xsd:simpleType name="INTEGER"> +
484 <xsd:restriction base="xsd:int"> +
485 <xsd:maxInclusive value="2147483647"/> +
486 <xsd:minInclusive value="-2147483648"/> +
490 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
491 <xsd:restriction base="xsd:string"> +
495 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
497 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
498 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
502 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/> +
506 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
511 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
516 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
523 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo');
524 table_to_xml_and_xmlschema
525 ------------------------------------------------------------------------------------------------
527 xmlns:xsd="http://www.w3.org/2001/XMLSchema" +
528 targetNamespace="foo" +
529 elementFormDefault="qualified"> +
531 <xsd:simpleType name="INTEGER"> +
532 <xsd:restriction base="xsd:int"> +
533 <xsd:maxInclusive value="2147483647"/> +
534 <xsd:minInclusive value="-2147483648"/> +
538 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
539 <xsd:restriction base="xsd:string"> +
543 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
545 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
546 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
550 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/> +
554 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
559 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
564 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
566 <b xsi:nil="true"/> +
572 SELECT query_to_xml('SELECT * FROM testxmlschema.test1', false, false, '');
574 ---------------------------------------------------------------
575 <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
595 SELECT query_to_xmlschema('SELECT * FROM testxmlschema.test1', false, false, '');
597 ----------------------------------------------------------------------------------------------
599 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
601 <xsd:simpleType name="INTEGER"> +
602 <xsd:restriction base="xsd:int"> +
603 <xsd:maxInclusive value="2147483647"/> +
604 <xsd:minInclusive value="-2147483648"/> +
608 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
609 <xsd:restriction base="xsd:string"> +
613 <xsd:complexType name="RowType"> +
615 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
616 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
620 <xsd:complexType name="TableType"> +
622 <xsd:element name="row" type="RowType" minOccurs="0" maxOccurs="unbounded"/> +
626 <xsd:element name="table" type="TableType"/> +
631 SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, true, '');
632 query_to_xml_and_xmlschema
633 ------------------------------------------------------------------------------------------------
635 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
637 <xsd:simpleType name="INTEGER"> +
638 <xsd:restriction base="xsd:int"> +
639 <xsd:maxInclusive value="2147483647"/> +
640 <xsd:minInclusive value="-2147483648"/> +
644 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
645 <xsd:restriction base="xsd:string"> +
649 <xsd:complexType name="RowType"> +
651 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
652 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
656 <xsd:element name="row" type="RowType"/> +
660 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
665 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
670 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
672 <b xsi:nil="true"/> +
678 DECLARE xc CURSOR WITH HOLD FOR SELECT * FROM testxmlschema.test1 ORDER BY 1, 2;
679 SELECT cursor_to_xml('xc'::refcursor, 5, false, true, '');
681 -------------------------------------------------------------
682 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
686 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
691 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
699 SELECT cursor_to_xmlschema('xc'::refcursor, false, true, '');
701 ----------------------------------------------------------------------------------------------
703 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
705 <xsd:simpleType name="INTEGER"> +
706 <xsd:restriction base="xsd:int"> +
707 <xsd:maxInclusive value="2147483647"/> +
708 <xsd:minInclusive value="-2147483648"/> +
712 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
713 <xsd:restriction base="xsd:string"> +
717 <xsd:complexType name="RowType"> +
719 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
720 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
724 <xsd:element name="row" type="RowType"/> +
729 MOVE BACKWARD ALL IN xc;
730 SELECT cursor_to_xml('xc'::refcursor, 5, true, false, '');
732 ---------------------------------------------------------------
733 <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
737 <b xsi:nil="true"/> +
754 SELECT cursor_to_xmlschema('xc'::refcursor, true, false, '');
756 ------------------------------------------------------------------------------------------------
758 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
760 <xsd:simpleType name="INTEGER"> +
761 <xsd:restriction base="xsd:int"> +
762 <xsd:maxInclusive value="2147483647"/> +
763 <xsd:minInclusive value="-2147483648"/> +
767 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
768 <xsd:restriction base="xsd:string"> +
772 <xsd:complexType name="RowType"> +
774 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
775 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
779 <xsd:complexType name="TableType"> +
781 <xsd:element name="row" type="RowType" minOccurs="0" maxOccurs="unbounded"/> +
785 <xsd:element name="table" type="TableType"/> +
790 SELECT schema_to_xml('testxmlschema', false, true, '');
792 -----------------------------------------------------------------------
793 <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
819 <r>2009-06-08T21:07:30</r> +
831 SELECT schema_to_xml('testxmlschema', true, false, '');
833 -----------------------------------------------------------------------
834 <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
850 <b xsi:nil="true"/> +
866 <r>2009-06-08T21:07:30</r> +
868 <p xsi:nil="true"/> +
880 SELECT schema_to_xmlschema('testxmlschema', false, true, '');
882 -------------------------------------------------------------------------------------------------------------------
884 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
886 <xsd:simpleType name="INTEGER"> +
887 <xsd:restriction base="xsd:int"> +
888 <xsd:maxInclusive value="2147483647"/> +
889 <xsd:minInclusive value="-2147483648"/> +
893 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
894 <xsd:restriction base="xsd:string"> +
898 <xsd:simpleType name="VARCHAR"> +
899 <xsd:restriction base="xsd:string"> +
903 <xsd:simpleType name="CHAR"> +
904 <xsd:restriction base="xsd:string"> +
908 <xsd:simpleType name="NUMERIC"> +
911 <xsd:simpleType name="SMALLINT"> +
912 <xsd:restriction base="xsd:short"> +
913 <xsd:maxInclusive value="32767"/> +
914 <xsd:minInclusive value="-32768"/> +
918 <xsd:simpleType name="BIGINT"> +
919 <xsd:restriction base="xsd:long"> +
920 <xsd:maxInclusive value="9223372036854775807"/> +
921 <xsd:minInclusive value="-9223372036854775808"/> +
925 <xsd:simpleType name="REAL"> +
926 <xsd:restriction base="xsd:float"></xsd:restriction> +
929 <xsd:simpleType name="TIME"> +
930 <xsd:restriction base="xsd:time"> +
931 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
935 <xsd:simpleType name="TIMESTAMP"> +
936 <xsd:restriction base="xsd:dateTime"> +
937 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
941 <xsd:simpleType name="DATE"> +
942 <xsd:restriction base="xsd:date"> +
943 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/> +
947 <xsd:complexType mixed="true"> +
949 <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/> +
953 <xsd:simpleType name="Domain.regression.public.testxmldomain"> +
954 <xsd:restriction base="VARCHAR"/> +
957 <xsd:simpleType name="BOOLEAN"> +
958 <xsd:restriction base="xsd:boolean"></xsd:restriction> +
961 <xsd:simpleType name="UDT.regression.pg_catalog.bytea"> +
962 <xsd:restriction base="xsd:base64Binary"> +
966 <xsd:complexType name="SchemaType.regression.testxmlschema"> +
968 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
969 <xsd:element name="test2" type="RowType.regression.testxmlschema.test2" minOccurs="0" maxOccurs="unbounded"/>+
973 <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/> +
978 SELECT schema_to_xmlschema('testxmlschema', true, false, '');
980 ---------------------------------------------------------------------------------------------------
982 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
984 <xsd:simpleType name="INTEGER"> +
985 <xsd:restriction base="xsd:int"> +
986 <xsd:maxInclusive value="2147483647"/> +
987 <xsd:minInclusive value="-2147483648"/> +
991 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
992 <xsd:restriction base="xsd:string"> +
996 <xsd:simpleType name="VARCHAR"> +
997 <xsd:restriction base="xsd:string"> +
1001 <xsd:simpleType name="CHAR"> +
1002 <xsd:restriction base="xsd:string"> +
1003 </xsd:restriction> +
1006 <xsd:simpleType name="NUMERIC"> +
1009 <xsd:simpleType name="SMALLINT"> +
1010 <xsd:restriction base="xsd:short"> +
1011 <xsd:maxInclusive value="32767"/> +
1012 <xsd:minInclusive value="-32768"/> +
1013 </xsd:restriction> +
1016 <xsd:simpleType name="BIGINT"> +
1017 <xsd:restriction base="xsd:long"> +
1018 <xsd:maxInclusive value="9223372036854775807"/> +
1019 <xsd:minInclusive value="-9223372036854775808"/> +
1020 </xsd:restriction> +
1023 <xsd:simpleType name="REAL"> +
1024 <xsd:restriction base="xsd:float"></xsd:restriction> +
1027 <xsd:simpleType name="TIME"> +
1028 <xsd:restriction base="xsd:time"> +
1029 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
1030 </xsd:restriction> +
1033 <xsd:simpleType name="TIMESTAMP"> +
1034 <xsd:restriction base="xsd:dateTime"> +
1035 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/>+
1036 </xsd:restriction> +
1039 <xsd:simpleType name="DATE"> +
1040 <xsd:restriction base="xsd:date"> +
1041 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/> +
1042 </xsd:restriction> +
1045 <xsd:complexType mixed="true"> +
1047 <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/> +
1049 </xsd:complexType> +
1051 <xsd:simpleType name="Domain.regression.public.testxmldomain"> +
1052 <xsd:restriction base="VARCHAR"/> +
1055 <xsd:simpleType name="BOOLEAN"> +
1056 <xsd:restriction base="xsd:boolean"></xsd:restriction> +
1059 <xsd:simpleType name="UDT.regression.pg_catalog.bytea"> +
1060 <xsd:restriction base="xsd:base64Binary"> +
1061 </xsd:restriction> +
1064 <xsd:complexType name="SchemaType.regression.testxmlschema"> +
1066 <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/> +
1067 <xsd:element name="test2" type="TableType.regression.testxmlschema.test2"/> +
1069 </xsd:complexType> +
1071 <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/> +
1076 SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo');
1077 schema_to_xml_and_xmlschema
1078 -------------------------------------------------------------------------------------------------------------------
1079 <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo" xsi:schemaLocation="foo #"> +
1082 xmlns:xsd="http://www.w3.org/2001/XMLSchema" +
1083 targetNamespace="foo" +
1084 elementFormDefault="qualified"> +
1086 <xsd:simpleType name="INTEGER"> +
1087 <xsd:restriction base="xsd:int"> +
1088 <xsd:maxInclusive value="2147483647"/> +
1089 <xsd:minInclusive value="-2147483648"/> +
1090 </xsd:restriction> +
1093 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
1094 <xsd:restriction base="xsd:string"> +
1095 </xsd:restriction> +
1098 <xsd:simpleType name="VARCHAR"> +
1099 <xsd:restriction base="xsd:string"> +
1100 </xsd:restriction> +
1103 <xsd:simpleType name="CHAR"> +
1104 <xsd:restriction base="xsd:string"> +
1105 </xsd:restriction> +
1108 <xsd:simpleType name="NUMERIC"> +
1111 <xsd:simpleType name="SMALLINT"> +
1112 <xsd:restriction base="xsd:short"> +
1113 <xsd:maxInclusive value="32767"/> +
1114 <xsd:minInclusive value="-32768"/> +
1115 </xsd:restriction> +
1118 <xsd:simpleType name="BIGINT"> +
1119 <xsd:restriction base="xsd:long"> +
1120 <xsd:maxInclusive value="9223372036854775807"/> +
1121 <xsd:minInclusive value="-9223372036854775808"/> +
1122 </xsd:restriction> +
1125 <xsd:simpleType name="REAL"> +
1126 <xsd:restriction base="xsd:float"></xsd:restriction> +
1129 <xsd:simpleType name="TIME"> +
1130 <xsd:restriction base="xsd:time"> +
1131 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
1132 </xsd:restriction> +
1135 <xsd:simpleType name="TIMESTAMP"> +
1136 <xsd:restriction base="xsd:dateTime"> +
1137 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
1138 </xsd:restriction> +
1141 <xsd:simpleType name="DATE"> +
1142 <xsd:restriction base="xsd:date"> +
1143 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/> +
1144 </xsd:restriction> +
1147 <xsd:complexType mixed="true"> +
1149 <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/> +
1151 </xsd:complexType> +
1153 <xsd:simpleType name="Domain.regression.public.testxmldomain"> +
1154 <xsd:restriction base="VARCHAR"/> +
1157 <xsd:simpleType name="BOOLEAN"> +
1158 <xsd:restriction base="xsd:boolean"></xsd:restriction> +
1161 <xsd:simpleType name="UDT.regression.pg_catalog.bytea"> +
1162 <xsd:restriction base="xsd:base64Binary"> +
1163 </xsd:restriction> +
1166 <xsd:complexType name="SchemaType.regression.testxmlschema"> +
1168 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
1169 <xsd:element name="test2" type="RowType.regression.testxmlschema.test2" minOccurs="0" maxOccurs="unbounded"/>+
1171 </xsd:complexType> +
1173 <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/> +
1189 <b xsi:nil="true"/> +
1202 <r>2009-06-08T21:07:30</r> +
1204 <p xsi:nil="true"/> +
1215 -- test that domains are transformed like their base types
1216 CREATE DOMAIN testboolxmldomain AS bool;
1217 CREATE DOMAIN testdatexmldomain AS date;
1218 CREATE TABLE testxmlschema.test3
1220 true::testboolxmldomain c2,
1221 '2013-02-21'::date c3,
1222 '2013-02-21'::testdatexmldomain c4;
1223 SELECT xmlforest(c1, c2, c3, c4) FROM testxmlschema.test3;
1225 ------------------------------------------------------------------
1226 <c1>true</c1><c2>true</c2><c3>2013-02-21</c3><c4>2013-02-21</c4>
1229 SELECT table_to_xml('testxmlschema.test3', true, true, '');
1231 ---------------------------------------------------------------
1232 <test3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
1235 <c3>2013-02-21</c3> +
1236 <c4>2013-02-21</c4> +