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),
6 w numeric(9,2), v smallint, u bigint, t real,
7 s time, stz timetz, r timestamp, rtz timestamptz, q date,
8 p xml, o testxmldomain, n bool, m bytea, aaa text);
9 ALTER TABLE testxmlschema.test2 DROP COLUMN aaa;
10 INSERT INTO testxmlschema.test2 VALUES (55, 'abc', 'def',
12 '21:07', '21:11 +05', '2009-06-08 21:07:30', '2009-06-08 21:07:30 -07', '2009-06-08',
13 NULL, 'ABC', true, 'XYZ');
14 SELECT table_to_xml('testxmlschema.test1', false, false, '');
16 ---------------------------------------------------------------
17 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
37 SELECT table_to_xml('testxmlschema.test1', true, false, 'foo');
39 ---------------------------------------------------------------------------
40 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo">+
61 SELECT table_to_xml('testxmlschema.test1', false, true, '');
63 ---------------------------------------------------------------
64 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
69 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
74 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
81 SELECT table_to_xml('testxmlschema.test1', true, true, '');
83 ---------------------------------------------------------------
84 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
89 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
94 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
102 SELECT table_to_xml('testxmlschema.test2', false, false, '');
104 ---------------------------------------------------------------
105 <test2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
116 <stz>21:11:00+05</stz> +
117 <r>2009-06-08T21:07:30</r> +
118 <rtz>2009-06-08T21:07:30-07:00</rtz> +
129 SELECT table_to_xmlschema('testxmlschema.test1', false, false, '');
131 -----------------------------------------------------------------------------------------------------------------
133 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
135 <xsd:simpleType name="INTEGER"> +
136 <xsd:restriction base="xsd:int"> +
137 <xsd:maxInclusive value="2147483647"/> +
138 <xsd:minInclusive value="-2147483648"/> +
142 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
143 <xsd:restriction base="xsd:string"> +
147 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
149 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
150 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element> +
154 <xsd:complexType name="TableType.regression.testxmlschema.test1"> +
156 <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
160 <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/> +
165 SELECT table_to_xmlschema('testxmlschema.test1', true, false, '');
167 -----------------------------------------------------------------------------------------------------------------
169 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
171 <xsd:simpleType name="INTEGER"> +
172 <xsd:restriction base="xsd:int"> +
173 <xsd:maxInclusive value="2147483647"/> +
174 <xsd:minInclusive value="-2147483648"/> +
178 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
179 <xsd:restriction base="xsd:string"> +
183 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
185 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
186 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element> +
190 <xsd:complexType name="TableType.regression.testxmlschema.test1"> +
192 <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
196 <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/> +
201 SELECT table_to_xmlschema('testxmlschema.test1', false, true, 'foo');
203 ----------------------------------------------------------------------------------------------
205 xmlns:xsd="http://www.w3.org/2001/XMLSchema" +
206 targetNamespace="foo" +
207 elementFormDefault="qualified"> +
209 <xsd:simpleType name="INTEGER"> +
210 <xsd:restriction base="xsd:int"> +
211 <xsd:maxInclusive value="2147483647"/> +
212 <xsd:minInclusive value="-2147483648"/> +
216 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
217 <xsd:restriction base="xsd:string"> +
221 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
223 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
224 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
228 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/> +
233 SELECT table_to_xmlschema('testxmlschema.test1', true, true, '');
235 ------------------------------------------------------------------------------------------------
237 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
239 <xsd:simpleType name="INTEGER"> +
240 <xsd:restriction base="xsd:int"> +
241 <xsd:maxInclusive value="2147483647"/> +
242 <xsd:minInclusive value="-2147483648"/> +
246 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
247 <xsd:restriction base="xsd:string"> +
251 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
253 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
254 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
258 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/> +
263 SELECT table_to_xmlschema('testxmlschema.test2', false, false, '');
265 ----------------------------------------------------------------------------------------------------------------------------
267 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
269 <xsd:simpleType name="INTEGER"> +
270 <xsd:restriction base="xsd:int"> +
271 <xsd:maxInclusive value="2147483647"/> +
272 <xsd:minInclusive value="-2147483648"/> +
276 <xsd:simpleType name="VARCHAR"> +
277 <xsd:restriction base="xsd:string"> +
281 <xsd:simpleType name="CHAR"> +
282 <xsd:restriction base="xsd:string"> +
286 <xsd:simpleType name="NUMERIC"> +
289 <xsd:simpleType name="SMALLINT"> +
290 <xsd:restriction base="xsd:short"> +
291 <xsd:maxInclusive value="32767"/> +
292 <xsd:minInclusive value="-32768"/> +
296 <xsd:simpleType name="BIGINT"> +
297 <xsd:restriction base="xsd:long"> +
298 <xsd:maxInclusive value="9223372036854775807"/> +
299 <xsd:minInclusive value="-9223372036854775808"/> +
303 <xsd:simpleType name="REAL"> +
304 <xsd:restriction base="xsd:float"></xsd:restriction> +
307 <xsd:simpleType name="TIME"> +
308 <xsd:restriction base="xsd:time"> +
309 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
313 <xsd:simpleType name="TIME_WTZ"> +
314 <xsd:restriction base="xsd:time"> +
315 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?(\+|-)\p{Nd}{2}:\p{Nd}{2}"/> +
319 <xsd:simpleType name="TIMESTAMP"> +
320 <xsd:restriction base="xsd:dateTime"> +
321 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
325 <xsd:simpleType name="TIMESTAMP_WTZ"> +
326 <xsd:restriction base="xsd:dateTime"> +
327 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?(\+|-)\p{Nd}{2}:\p{Nd}{2}"/>+
331 <xsd:simpleType name="DATE"> +
332 <xsd:restriction base="xsd:date"> +
333 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/> +
337 <xsd:complexType mixed="true"> +
339 <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/> +
343 <xsd:simpleType name="Domain.regression.public.testxmldomain"> +
344 <xsd:restriction base="VARCHAR"/> +
347 <xsd:simpleType name="BOOLEAN"> +
348 <xsd:restriction base="xsd:boolean"></xsd:restriction> +
351 <xsd:simpleType name="UDT.regression.pg_catalog.bytea"> +
352 <xsd:restriction base="xsd:base64Binary"> +
356 <xsd:complexType name="RowType.regression.testxmlschema.test2"> +
358 <xsd:element name="z" type="INTEGER" minOccurs="0"></xsd:element> +
359 <xsd:element name="y" type="VARCHAR" minOccurs="0"></xsd:element> +
360 <xsd:element name="x" type="CHAR" minOccurs="0"></xsd:element> +
361 <xsd:element name="w" type="NUMERIC" minOccurs="0"></xsd:element> +
362 <xsd:element name="v" type="SMALLINT" minOccurs="0"></xsd:element> +
363 <xsd:element name="u" type="BIGINT" minOccurs="0"></xsd:element> +
364 <xsd:element name="t" type="REAL" minOccurs="0"></xsd:element> +
365 <xsd:element name="s" type="TIME" minOccurs="0"></xsd:element> +
366 <xsd:element name="stz" type="TIME_WTZ" minOccurs="0"></xsd:element> +
367 <xsd:element name="r" type="TIMESTAMP" minOccurs="0"></xsd:element> +
368 <xsd:element name="rtz" type="TIMESTAMP_WTZ" minOccurs="0"></xsd:element> +
369 <xsd:element name="q" type="DATE" minOccurs="0"></xsd:element> +
370 <xsd:element name="p" type="XML" minOccurs="0"></xsd:element> +
371 <xsd:element name="o" type="Domain.regression.public.testxmldomain" minOccurs="0"></xsd:element> +
372 <xsd:element name="n" type="BOOLEAN" minOccurs="0"></xsd:element> +
373 <xsd:element name="m" type="UDT.regression.pg_catalog.bytea" minOccurs="0"></xsd:element> +
377 <xsd:complexType name="TableType.regression.testxmlschema.test2"> +
379 <xsd:element name="row" type="RowType.regression.testxmlschema.test2" minOccurs="0" maxOccurs="unbounded"/> +
383 <xsd:element name="test2" type="TableType.regression.testxmlschema.test2"/> +
388 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, false, '');
389 table_to_xml_and_xmlschema
390 -----------------------------------------------------------------------------------------------------------------
391 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#"> +
394 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
396 <xsd:simpleType name="INTEGER"> +
397 <xsd:restriction base="xsd:int"> +
398 <xsd:maxInclusive value="2147483647"/> +
399 <xsd:minInclusive value="-2147483648"/> +
403 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
404 <xsd:restriction base="xsd:string"> +
408 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
410 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
411 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element> +
415 <xsd:complexType name="TableType.regression.testxmlschema.test1"> +
417 <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
421 <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/> +
443 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, false, '');
444 table_to_xml_and_xmlschema
445 -----------------------------------------------------------------------------------------------------------------
446 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="#"> +
449 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
451 <xsd:simpleType name="INTEGER"> +
452 <xsd:restriction base="xsd:int"> +
453 <xsd:maxInclusive value="2147483647"/> +
454 <xsd:minInclusive value="-2147483648"/> +
458 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
459 <xsd:restriction base="xsd:string"> +
463 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
465 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
466 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element> +
470 <xsd:complexType name="TableType.regression.testxmlschema.test1"> +
472 <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
476 <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/> +
492 <b xsi:nil="true"/> +
499 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, '');
500 table_to_xml_and_xmlschema
501 ----------------------------------------------------------------------------------------------
503 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
505 <xsd:simpleType name="INTEGER"> +
506 <xsd:restriction base="xsd:int"> +
507 <xsd:maxInclusive value="2147483647"/> +
508 <xsd:minInclusive value="-2147483648"/> +
512 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
513 <xsd:restriction base="xsd:string"> +
517 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
519 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
520 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
524 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/> +
528 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
533 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
538 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
545 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo');
546 table_to_xml_and_xmlschema
547 ------------------------------------------------------------------------------------------------
549 xmlns:xsd="http://www.w3.org/2001/XMLSchema" +
550 targetNamespace="foo" +
551 elementFormDefault="qualified"> +
553 <xsd:simpleType name="INTEGER"> +
554 <xsd:restriction base="xsd:int"> +
555 <xsd:maxInclusive value="2147483647"/> +
556 <xsd:minInclusive value="-2147483648"/> +
560 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
561 <xsd:restriction base="xsd:string"> +
565 <xsd:complexType name="RowType.regression.testxmlschema.test1"> +
567 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
568 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
572 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/> +
576 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
581 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
586 <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo"> +
588 <b xsi:nil="true"/> +
594 SELECT query_to_xml('SELECT * FROM testxmlschema.test1', false, false, '');
596 ---------------------------------------------------------------
597 <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
617 SELECT query_to_xmlschema('SELECT * FROM testxmlschema.test1', false, false, '');
619 ----------------------------------------------------------------------------------------------
621 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
623 <xsd:simpleType name="INTEGER"> +
624 <xsd:restriction base="xsd:int"> +
625 <xsd:maxInclusive value="2147483647"/> +
626 <xsd:minInclusive value="-2147483648"/> +
630 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
631 <xsd:restriction base="xsd:string"> +
635 <xsd:complexType name="RowType"> +
637 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
638 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
642 <xsd:complexType name="TableType"> +
644 <xsd:element name="row" type="RowType" minOccurs="0" maxOccurs="unbounded"/> +
648 <xsd:element name="table" type="TableType"/> +
653 SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, true, '');
654 query_to_xml_and_xmlschema
655 ------------------------------------------------------------------------------------------------
657 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
659 <xsd:simpleType name="INTEGER"> +
660 <xsd:restriction base="xsd:int"> +
661 <xsd:maxInclusive value="2147483647"/> +
662 <xsd:minInclusive value="-2147483648"/> +
666 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
667 <xsd:restriction base="xsd:string"> +
671 <xsd:complexType name="RowType"> +
673 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
674 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
678 <xsd:element name="row" type="RowType"/> +
682 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
687 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
692 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> +
694 <b xsi:nil="true"/> +
700 DECLARE xc CURSOR WITH HOLD FOR SELECT * FROM testxmlschema.test1 ORDER BY 1, 2;
701 SELECT cursor_to_xml('xc'::refcursor, 5, false, true, '');
703 -------------------------------------------------------------
704 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
708 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
713 <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
721 SELECT cursor_to_xmlschema('xc'::refcursor, false, true, '');
723 ----------------------------------------------------------------------------------------------
725 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
727 <xsd:simpleType name="INTEGER"> +
728 <xsd:restriction base="xsd:int"> +
729 <xsd:maxInclusive value="2147483647"/> +
730 <xsd:minInclusive value="-2147483648"/> +
734 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
735 <xsd:restriction base="xsd:string"> +
739 <xsd:complexType name="RowType"> +
741 <xsd:element name="a" type="INTEGER" minOccurs="0"></xsd:element> +
742 <xsd:element name="b" type="UDT.regression.pg_catalog.text" minOccurs="0"></xsd:element>+
746 <xsd:element name="row" type="RowType"/> +
751 MOVE BACKWARD ALL IN xc;
752 SELECT cursor_to_xml('xc'::refcursor, 5, true, false, '');
754 ---------------------------------------------------------------
755 <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
759 <b xsi:nil="true"/> +
776 SELECT cursor_to_xmlschema('xc'::refcursor, true, false, '');
778 ------------------------------------------------------------------------------------------------
780 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
782 <xsd:simpleType name="INTEGER"> +
783 <xsd:restriction base="xsd:int"> +
784 <xsd:maxInclusive value="2147483647"/> +
785 <xsd:minInclusive value="-2147483648"/> +
789 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
790 <xsd:restriction base="xsd:string"> +
794 <xsd:complexType name="RowType"> +
796 <xsd:element name="a" type="INTEGER" nillable="true"></xsd:element> +
797 <xsd:element name="b" type="UDT.regression.pg_catalog.text" nillable="true"></xsd:element>+
801 <xsd:complexType name="TableType"> +
803 <xsd:element name="row" type="RowType" minOccurs="0" maxOccurs="unbounded"/> +
807 <xsd:element name="table" type="TableType"/> +
812 SELECT schema_to_xml('testxmlschema', false, true, '');
814 -----------------------------------------------------------------------
815 <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
841 <stz>21:11:00+05</stz> +
842 <r>2009-06-08T21:07:30</r> +
843 <rtz>2009-06-08T21:07:30-07:00</rtz> +
855 SELECT schema_to_xml('testxmlschema', true, false, '');
857 -----------------------------------------------------------------------
858 <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
874 <b xsi:nil="true"/> +
890 <stz>21:11:00+05</stz> +
891 <r>2009-06-08T21:07:30</r> +
892 <rtz>2009-06-08T21:07:30-07:00</rtz> +
894 <p xsi:nil="true"/> +
906 SELECT schema_to_xmlschema('testxmlschema', false, true, '');
908 ----------------------------------------------------------------------------------------------------------------------------
910 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
912 <xsd:simpleType name="INTEGER"> +
913 <xsd:restriction base="xsd:int"> +
914 <xsd:maxInclusive value="2147483647"/> +
915 <xsd:minInclusive value="-2147483648"/> +
919 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
920 <xsd:restriction base="xsd:string"> +
924 <xsd:simpleType name="VARCHAR"> +
925 <xsd:restriction base="xsd:string"> +
929 <xsd:simpleType name="CHAR"> +
930 <xsd:restriction base="xsd:string"> +
934 <xsd:simpleType name="NUMERIC"> +
937 <xsd:simpleType name="SMALLINT"> +
938 <xsd:restriction base="xsd:short"> +
939 <xsd:maxInclusive value="32767"/> +
940 <xsd:minInclusive value="-32768"/> +
944 <xsd:simpleType name="BIGINT"> +
945 <xsd:restriction base="xsd:long"> +
946 <xsd:maxInclusive value="9223372036854775807"/> +
947 <xsd:minInclusive value="-9223372036854775808"/> +
951 <xsd:simpleType name="REAL"> +
952 <xsd:restriction base="xsd:float"></xsd:restriction> +
955 <xsd:simpleType name="TIME"> +
956 <xsd:restriction base="xsd:time"> +
957 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
961 <xsd:simpleType name="TIME_WTZ"> +
962 <xsd:restriction base="xsd:time"> +
963 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?(\+|-)\p{Nd}{2}:\p{Nd}{2}"/> +
967 <xsd:simpleType name="TIMESTAMP"> +
968 <xsd:restriction base="xsd:dateTime"> +
969 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
973 <xsd:simpleType name="TIMESTAMP_WTZ"> +
974 <xsd:restriction base="xsd:dateTime"> +
975 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?(\+|-)\p{Nd}{2}:\p{Nd}{2}"/>+
979 <xsd:simpleType name="DATE"> +
980 <xsd:restriction base="xsd:date"> +
981 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/> +
985 <xsd:complexType mixed="true"> +
987 <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/> +
991 <xsd:simpleType name="Domain.regression.public.testxmldomain"> +
992 <xsd:restriction base="VARCHAR"/> +
995 <xsd:simpleType name="BOOLEAN"> +
996 <xsd:restriction base="xsd:boolean"></xsd:restriction> +
999 <xsd:simpleType name="UDT.regression.pg_catalog.bytea"> +
1000 <xsd:restriction base="xsd:base64Binary"> +
1001 </xsd:restriction> +
1004 <xsd:complexType name="SchemaType.regression.testxmlschema"> +
1006 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/> +
1007 <xsd:element name="test2" type="RowType.regression.testxmlschema.test2" minOccurs="0" maxOccurs="unbounded"/> +
1009 </xsd:complexType> +
1011 <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/> +
1016 SELECT schema_to_xmlschema('testxmlschema', true, false, '');
1018 ----------------------------------------------------------------------------------------------------------------------------
1020 xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +
1022 <xsd:simpleType name="INTEGER"> +
1023 <xsd:restriction base="xsd:int"> +
1024 <xsd:maxInclusive value="2147483647"/> +
1025 <xsd:minInclusive value="-2147483648"/> +
1026 </xsd:restriction> +
1029 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
1030 <xsd:restriction base="xsd:string"> +
1031 </xsd:restriction> +
1034 <xsd:simpleType name="VARCHAR"> +
1035 <xsd:restriction base="xsd:string"> +
1036 </xsd:restriction> +
1039 <xsd:simpleType name="CHAR"> +
1040 <xsd:restriction base="xsd:string"> +
1041 </xsd:restriction> +
1044 <xsd:simpleType name="NUMERIC"> +
1047 <xsd:simpleType name="SMALLINT"> +
1048 <xsd:restriction base="xsd:short"> +
1049 <xsd:maxInclusive value="32767"/> +
1050 <xsd:minInclusive value="-32768"/> +
1051 </xsd:restriction> +
1054 <xsd:simpleType name="BIGINT"> +
1055 <xsd:restriction base="xsd:long"> +
1056 <xsd:maxInclusive value="9223372036854775807"/> +
1057 <xsd:minInclusive value="-9223372036854775808"/> +
1058 </xsd:restriction> +
1061 <xsd:simpleType name="REAL"> +
1062 <xsd:restriction base="xsd:float"></xsd:restriction> +
1065 <xsd:simpleType name="TIME"> +
1066 <xsd:restriction base="xsd:time"> +
1067 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
1068 </xsd:restriction> +
1071 <xsd:simpleType name="TIME_WTZ"> +
1072 <xsd:restriction base="xsd:time"> +
1073 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?(\+|-)\p{Nd}{2}:\p{Nd}{2}"/> +
1074 </xsd:restriction> +
1077 <xsd:simpleType name="TIMESTAMP"> +
1078 <xsd:restriction base="xsd:dateTime"> +
1079 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
1080 </xsd:restriction> +
1083 <xsd:simpleType name="TIMESTAMP_WTZ"> +
1084 <xsd:restriction base="xsd:dateTime"> +
1085 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?(\+|-)\p{Nd}{2}:\p{Nd}{2}"/>+
1086 </xsd:restriction> +
1089 <xsd:simpleType name="DATE"> +
1090 <xsd:restriction base="xsd:date"> +
1091 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/> +
1092 </xsd:restriction> +
1095 <xsd:complexType mixed="true"> +
1097 <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/> +
1099 </xsd:complexType> +
1101 <xsd:simpleType name="Domain.regression.public.testxmldomain"> +
1102 <xsd:restriction base="VARCHAR"/> +
1105 <xsd:simpleType name="BOOLEAN"> +
1106 <xsd:restriction base="xsd:boolean"></xsd:restriction> +
1109 <xsd:simpleType name="UDT.regression.pg_catalog.bytea"> +
1110 <xsd:restriction base="xsd:base64Binary"> +
1111 </xsd:restriction> +
1114 <xsd:complexType name="SchemaType.regression.testxmlschema"> +
1116 <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/> +
1117 <xsd:element name="test2" type="TableType.regression.testxmlschema.test2"/> +
1119 </xsd:complexType> +
1121 <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/> +
1126 SELECT schema_to_xml_and_xmlschema('testxmlschema', true, true, 'foo');
1127 schema_to_xml_and_xmlschema
1128 ----------------------------------------------------------------------------------------------------------------------------
1129 <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo" xsi:schemaLocation="foo #"> +
1132 xmlns:xsd="http://www.w3.org/2001/XMLSchema" +
1133 targetNamespace="foo" +
1134 elementFormDefault="qualified"> +
1136 <xsd:simpleType name="INTEGER"> +
1137 <xsd:restriction base="xsd:int"> +
1138 <xsd:maxInclusive value="2147483647"/> +
1139 <xsd:minInclusive value="-2147483648"/> +
1140 </xsd:restriction> +
1143 <xsd:simpleType name="UDT.regression.pg_catalog.text"> +
1144 <xsd:restriction base="xsd:string"> +
1145 </xsd:restriction> +
1148 <xsd:simpleType name="VARCHAR"> +
1149 <xsd:restriction base="xsd:string"> +
1150 </xsd:restriction> +
1153 <xsd:simpleType name="CHAR"> +
1154 <xsd:restriction base="xsd:string"> +
1155 </xsd:restriction> +
1158 <xsd:simpleType name="NUMERIC"> +
1161 <xsd:simpleType name="SMALLINT"> +
1162 <xsd:restriction base="xsd:short"> +
1163 <xsd:maxInclusive value="32767"/> +
1164 <xsd:minInclusive value="-32768"/> +
1165 </xsd:restriction> +
1168 <xsd:simpleType name="BIGINT"> +
1169 <xsd:restriction base="xsd:long"> +
1170 <xsd:maxInclusive value="9223372036854775807"/> +
1171 <xsd:minInclusive value="-9223372036854775808"/> +
1172 </xsd:restriction> +
1175 <xsd:simpleType name="REAL"> +
1176 <xsd:restriction base="xsd:float"></xsd:restriction> +
1179 <xsd:simpleType name="TIME"> +
1180 <xsd:restriction base="xsd:time"> +
1181 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
1182 </xsd:restriction> +
1185 <xsd:simpleType name="TIME_WTZ"> +
1186 <xsd:restriction base="xsd:time"> +
1187 <xsd:pattern value="\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?(\+|-)\p{Nd}{2}:\p{Nd}{2}"/> +
1188 </xsd:restriction> +
1191 <xsd:simpleType name="TIMESTAMP"> +
1192 <xsd:restriction base="xsd:dateTime"> +
1193 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?"/> +
1194 </xsd:restriction> +
1197 <xsd:simpleType name="TIMESTAMP_WTZ"> +
1198 <xsd:restriction base="xsd:dateTime"> +
1199 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}T\p{Nd}{2}:\p{Nd}{2}:\p{Nd}{2}(.\p{Nd}+)?(\+|-)\p{Nd}{2}:\p{Nd}{2}"/>+
1200 </xsd:restriction> +
1203 <xsd:simpleType name="DATE"> +
1204 <xsd:restriction base="xsd:date"> +
1205 <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/> +
1206 </xsd:restriction> +
1209 <xsd:complexType mixed="true"> +
1211 <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/> +
1213 </xsd:complexType> +
1215 <xsd:simpleType name="Domain.regression.public.testxmldomain"> +
1216 <xsd:restriction base="VARCHAR"/> +
1219 <xsd:simpleType name="BOOLEAN"> +
1220 <xsd:restriction base="xsd:boolean"></xsd:restriction> +
1223 <xsd:simpleType name="UDT.regression.pg_catalog.bytea"> +
1224 <xsd:restriction base="xsd:base64Binary"> +
1225 </xsd:restriction> +
1228 <xsd:complexType name="SchemaType.regression.testxmlschema"> +
1230 <xsd:element name="test1" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/> +
1231 <xsd:element name="test2" type="RowType.regression.testxmlschema.test2" minOccurs="0" maxOccurs="unbounded"/> +
1233 </xsd:complexType> +
1235 <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/> +
1251 <b xsi:nil="true"/> +
1264 <stz>21:11:00+05</stz> +
1265 <r>2009-06-08T21:07:30</r> +
1266 <rtz>2009-06-08T21:07:30-07:00</rtz> +
1268 <p xsi:nil="true"/> +
1279 -- test that domains are transformed like their base types
1280 CREATE DOMAIN testboolxmldomain AS bool;
1281 CREATE DOMAIN testdatexmldomain AS date;
1282 CREATE TABLE testxmlschema.test3
1284 true::testboolxmldomain c2,
1285 '2013-02-21'::date c3,
1286 '2013-02-21'::testdatexmldomain c4;
1287 SELECT xmlforest(c1, c2, c3, c4) FROM testxmlschema.test3;
1289 ------------------------------------------------------------------
1290 <c1>true</c1><c2>true</c2><c3>2013-02-21</c3><c4>2013-02-21</c4>
1293 SELECT table_to_xml('testxmlschema.test3', true, true, '');
1295 ---------------------------------------------------------------
1296 <test3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
1299 <c3>2013-02-21</c3> +
1300 <c4>2013-02-21</c4> +