Consistently use "superuser" instead of "super user"
[pgsql.git] / src / test / regress / expected / xmlmap.out
blobc08f8a0d9c17a466c63a83150ce2baa49445f971
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, '');
9                          table_to_xml                          
10 ---------------------------------------------------------------
11  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
12                                                               +
13  <row>                                                        +
14    <a>1</a>                                                   +
15    <b>one</b>                                                 +
16  </row>                                                       +
17                                                               +
18  <row>                                                        +
19    <a>2</a>                                                   +
20    <b>two</b>                                                 +
21  </row>                                                       +
22                                                               +
23  <row>                                                        +
24    <a>-1</a>                                                  +
25  </row>                                                       +
26                                                               +
27  </test1>                                                     +
29 (1 row)
31 SELECT table_to_xml('testxmlschema.test1', true, false, 'foo');
32                                table_to_xml                                
33 ---------------------------------------------------------------------------
34  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo">+
35                                                                           +
36  <row>                                                                    +
37    <a>1</a>                                                               +
38    <b>one</b>                                                             +
39  </row>                                                                   +
40                                                                           +
41  <row>                                                                    +
42    <a>2</a>                                                               +
43    <b>two</b>                                                             +
44  </row>                                                                   +
45                                                                           +
46  <row>                                                                    +
47    <a>-1</a>                                                              +
48    <b xsi:nil="true"/>                                                    +
49  </row>                                                                   +
50                                                                           +
51  </test1>                                                                 +
53 (1 row)
55 SELECT table_to_xml('testxmlschema.test1', false, true, '');
56                          table_to_xml                          
57 ---------------------------------------------------------------
58  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
59    <a>1</a>                                                   +
60    <b>one</b>                                                 +
61  </test1>                                                     +
62                                                               +
63  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
64    <a>2</a>                                                   +
65    <b>two</b>                                                 +
66  </test1>                                                     +
67                                                               +
68  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
69    <a>-1</a>                                                  +
70  </test1>                                                     +
71                                                               +
73 (1 row)
75 SELECT table_to_xml('testxmlschema.test1', true, true, '');
76                          table_to_xml                          
77 ---------------------------------------------------------------
78  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
79    <a>1</a>                                                   +
80    <b>one</b>                                                 +
81  </test1>                                                     +
82                                                               +
83  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
84    <a>2</a>                                                   +
85    <b>two</b>                                                 +
86  </test1>                                                     +
87                                                               +
88  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
89    <a>-1</a>                                                  +
90    <b xsi:nil="true"/>                                        +
91  </test1>                                                     +
92                                                               +
94 (1 row)
96 SELECT table_to_xml('testxmlschema.test2', false, false, '');
97                          table_to_xml                          
98 ---------------------------------------------------------------
99  <test2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
100                                                               +
101  <row>                                                        +
102    <z>55</z>                                                  +
103    <y>abc</y>                                                 +
104    <x>def   </x>                                              +
105    <w>98.60</w>                                               +
106    <v>2</v>                                                   +
107    <u>999</u>                                                 +
108    <t>0</t>                                                   +
109    <s>21:07:00</s>                                            +
110    <r>2009-06-08T21:07:30</r>                                 +
111    <q>2009-06-08</q>                                          +
112    <o>ABC</o>                                                 +
113    <n>true</n>                                                +
114    <m>WFla</m>                                                +
115  </row>                                                       +
116                                                               +
117  </test2>                                                     +
119 (1 row)
121 SELECT table_to_xmlschema('testxmlschema.test1', false, false, '');
122                                                table_to_xmlschema                                                
123 -----------------------------------------------------------------------------------------------------------------
124  <xsd:schema                                                                                                    +
125      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                              +
126                                                                                                                 +
127  <xsd:simpleType name="INTEGER">                                                                                +
128    <xsd:restriction base="xsd:int">                                                                             +
129      <xsd:maxInclusive value="2147483647"/>                                                                     +
130      <xsd:minInclusive value="-2147483648"/>                                                                    +
131    </xsd:restriction>                                                                                           +
132  </xsd:simpleType>                                                                                              +
133                                                                                                                 +
134  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                         +
135    <xsd:restriction base="xsd:string">                                                                          +
136    </xsd:restriction>                                                                                           +
137  </xsd:simpleType>                                                                                              +
138                                                                                                                 +
139  <xsd:complexType name="RowType.regression.testxmlschema.test1">                                                +
140    <xsd:sequence>                                                                                               +
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>                   +
143    </xsd:sequence>                                                                                              +
144  </xsd:complexType>                                                                                             +
145                                                                                                                 +
146  <xsd:complexType name="TableType.regression.testxmlschema.test1">                                              +
147    <xsd:sequence>                                                                                               +
148      <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
149    </xsd:sequence>                                                                                              +
150  </xsd:complexType>                                                                                             +
151                                                                                                                 +
152  <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/>                                    +
153                                                                                                                 +
154  </xsd:schema>
155 (1 row)
157 SELECT table_to_xmlschema('testxmlschema.test1', true, false, '');
158                                                table_to_xmlschema                                                
159 -----------------------------------------------------------------------------------------------------------------
160  <xsd:schema                                                                                                    +
161      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                              +
162                                                                                                                 +
163  <xsd:simpleType name="INTEGER">                                                                                +
164    <xsd:restriction base="xsd:int">                                                                             +
165      <xsd:maxInclusive value="2147483647"/>                                                                     +
166      <xsd:minInclusive value="-2147483648"/>                                                                    +
167    </xsd:restriction>                                                                                           +
168  </xsd:simpleType>                                                                                              +
169                                                                                                                 +
170  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                         +
171    <xsd:restriction base="xsd:string">                                                                          +
172    </xsd:restriction>                                                                                           +
173  </xsd:simpleType>                                                                                              +
174                                                                                                                 +
175  <xsd:complexType name="RowType.regression.testxmlschema.test1">                                                +
176    <xsd:sequence>                                                                                               +
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>                 +
179    </xsd:sequence>                                                                                              +
180  </xsd:complexType>                                                                                             +
181                                                                                                                 +
182  <xsd:complexType name="TableType.regression.testxmlschema.test1">                                              +
183    <xsd:sequence>                                                                                               +
184      <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
185    </xsd:sequence>                                                                                              +
186  </xsd:complexType>                                                                                             +
187                                                                                                                 +
188  <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/>                                    +
189                                                                                                                 +
190  </xsd:schema>
191 (1 row)
193 SELECT table_to_xmlschema('testxmlschema.test1', false, true, 'foo');
194                                       table_to_xmlschema                                      
195 ----------------------------------------------------------------------------------------------
196  <xsd:schema                                                                                 +
197      xmlns:xsd="http://www.w3.org/2001/XMLSchema"                                            +
198      targetNamespace="foo"                                                                   +
199      elementFormDefault="qualified">                                                         +
200                                                                                              +
201  <xsd:simpleType name="INTEGER">                                                             +
202    <xsd:restriction base="xsd:int">                                                          +
203      <xsd:maxInclusive value="2147483647"/>                                                  +
204      <xsd:minInclusive value="-2147483648"/>                                                 +
205    </xsd:restriction>                                                                        +
206  </xsd:simpleType>                                                                           +
207                                                                                              +
208  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                      +
209    <xsd:restriction base="xsd:string">                                                       +
210    </xsd:restriction>                                                                        +
211  </xsd:simpleType>                                                                           +
212                                                                                              +
213  <xsd:complexType name="RowType.regression.testxmlschema.test1">                             +
214    <xsd:sequence>                                                                            +
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>+
217    </xsd:sequence>                                                                           +
218  </xsd:complexType>                                                                          +
219                                                                                              +
220  <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/>                   +
221                                                                                              +
222  </xsd:schema>
223 (1 row)
225 SELECT table_to_xmlschema('testxmlschema.test1', true, true, '');
226                                        table_to_xmlschema                                       
227 ------------------------------------------------------------------------------------------------
228  <xsd:schema                                                                                   +
229      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                             +
230                                                                                                +
231  <xsd:simpleType name="INTEGER">                                                               +
232    <xsd:restriction base="xsd:int">                                                            +
233      <xsd:maxInclusive value="2147483647"/>                                                    +
234      <xsd:minInclusive value="-2147483648"/>                                                   +
235    </xsd:restriction>                                                                          +
236  </xsd:simpleType>                                                                             +
237                                                                                                +
238  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                        +
239    <xsd:restriction base="xsd:string">                                                         +
240    </xsd:restriction>                                                                          +
241  </xsd:simpleType>                                                                             +
242                                                                                                +
243  <xsd:complexType name="RowType.regression.testxmlschema.test1">                               +
244    <xsd:sequence>                                                                              +
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>+
247    </xsd:sequence>                                                                             +
248  </xsd:complexType>                                                                            +
249                                                                                                +
250  <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/>                     +
251                                                                                                +
252  </xsd:schema>
253 (1 row)
255 SELECT table_to_xmlschema('testxmlschema.test2', false, false, '');
256                                                table_to_xmlschema                                                
257 -----------------------------------------------------------------------------------------------------------------
258  <xsd:schema                                                                                                    +
259      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                              +
260                                                                                                                 +
261  <xsd:simpleType name="INTEGER">                                                                                +
262    <xsd:restriction base="xsd:int">                                                                             +
263      <xsd:maxInclusive value="2147483647"/>                                                                     +
264      <xsd:minInclusive value="-2147483648"/>                                                                    +
265    </xsd:restriction>                                                                                           +
266  </xsd:simpleType>                                                                                              +
267                                                                                                                 +
268  <xsd:simpleType name="VARCHAR">                                                                                +
269    <xsd:restriction base="xsd:string">                                                                          +
270    </xsd:restriction>                                                                                           +
271  </xsd:simpleType>                                                                                              +
272                                                                                                                 +
273  <xsd:simpleType name="CHAR">                                                                                   +
274    <xsd:restriction base="xsd:string">                                                                          +
275    </xsd:restriction>                                                                                           +
276  </xsd:simpleType>                                                                                              +
277                                                                                                                 +
278  <xsd:simpleType name="NUMERIC">                                                                                +
279  </xsd:simpleType>                                                                                              +
280                                                                                                                 +
281  <xsd:simpleType name="SMALLINT">                                                                               +
282    <xsd:restriction base="xsd:short">                                                                           +
283      <xsd:maxInclusive value="32767"/>                                                                          +
284      <xsd:minInclusive value="-32768"/>                                                                         +
285    </xsd:restriction>                                                                                           +
286  </xsd:simpleType>                                                                                              +
287                                                                                                                 +
288  <xsd:simpleType name="BIGINT">                                                                                 +
289    <xsd:restriction base="xsd:long">                                                                            +
290      <xsd:maxInclusive value="9223372036854775807"/>                                                            +
291      <xsd:minInclusive value="-9223372036854775808"/>                                                           +
292    </xsd:restriction>                                                                                           +
293  </xsd:simpleType>                                                                                              +
294                                                                                                                 +
295  <xsd:simpleType name="REAL">                                                                                   +
296    <xsd:restriction base="xsd:float"></xsd:restriction>                                                         +
297  </xsd:simpleType>                                                                                              +
298                                                                                                                 +
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}+)?"/>                                            +
302    </xsd:restriction>                                                                                           +
303  </xsd:simpleType>                                                                                              +
304                                                                                                                 +
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}+)?"/>              +
308    </xsd:restriction>                                                                                           +
309  </xsd:simpleType>                                                                                              +
310                                                                                                                 +
311  <xsd:simpleType name="DATE">                                                                                   +
312    <xsd:restriction base="xsd:date">                                                                            +
313      <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/>                                                       +
314    </xsd:restriction>                                                                                           +
315  </xsd:simpleType>                                                                                              +
316                                                                                                                 +
317  <xsd:complexType mixed="true">                                                                                 +
318    <xsd:sequence>                                                                                               +
319      <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/>                       +
320    </xsd:sequence>                                                                                              +
321  </xsd:complexType>                                                                                             +
322                                                                                                                 +
323  <xsd:simpleType name="Domain.regression.public.testxmldomain">                                                 +
324    <xsd:restriction base="VARCHAR"/>                                                                            +
325  </xsd:simpleType>                                                                                              +
326                                                                                                                 +
327  <xsd:simpleType name="BOOLEAN">                                                                                +
328    <xsd:restriction base="xsd:boolean"></xsd:restriction>                                                       +
329  </xsd:simpleType>                                                                                              +
330                                                                                                                 +
331  <xsd:simpleType name="UDT.regression.pg_catalog.bytea">                                                        +
332    <xsd:restriction base="xsd:base64Binary">                                                                    +
333    </xsd:restriction>                                                                                           +
334  </xsd:simpleType>                                                                                              +
335                                                                                                                 +
336  <xsd:complexType name="RowType.regression.testxmlschema.test2">                                                +
337    <xsd:sequence>                                                                                               +
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>                  +
352    </xsd:sequence>                                                                                              +
353  </xsd:complexType>                                                                                             +
354                                                                                                                 +
355  <xsd:complexType name="TableType.regression.testxmlschema.test2">                                              +
356    <xsd:sequence>                                                                                               +
357      <xsd:element name="row" type="RowType.regression.testxmlschema.test2" minOccurs="0" maxOccurs="unbounded"/>+
358    </xsd:sequence>                                                                                              +
359  </xsd:complexType>                                                                                             +
360                                                                                                                 +
361  <xsd:element name="test2" type="TableType.regression.testxmlschema.test2"/>                                    +
362                                                                                                                 +
363  </xsd:schema>
364 (1 row)
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="#">                +
370                                                                                                                 +
371  <xsd:schema                                                                                                    +
372      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                              +
373                                                                                                                 +
374  <xsd:simpleType name="INTEGER">                                                                                +
375    <xsd:restriction base="xsd:int">                                                                             +
376      <xsd:maxInclusive value="2147483647"/>                                                                     +
377      <xsd:minInclusive value="-2147483648"/>                                                                    +
378    </xsd:restriction>                                                                                           +
379  </xsd:simpleType>                                                                                              +
380                                                                                                                 +
381  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                         +
382    <xsd:restriction base="xsd:string">                                                                          +
383    </xsd:restriction>                                                                                           +
384  </xsd:simpleType>                                                                                              +
385                                                                                                                 +
386  <xsd:complexType name="RowType.regression.testxmlschema.test1">                                                +
387    <xsd:sequence>                                                                                               +
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>                   +
390    </xsd:sequence>                                                                                              +
391  </xsd:complexType>                                                                                             +
392                                                                                                                 +
393  <xsd:complexType name="TableType.regression.testxmlschema.test1">                                              +
394    <xsd:sequence>                                                                                               +
395      <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
396    </xsd:sequence>                                                                                              +
397  </xsd:complexType>                                                                                             +
398                                                                                                                 +
399  <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/>                                    +
400                                                                                                                 +
401  </xsd:schema>                                                                                                  +
402                                                                                                                 +
403  <row>                                                                                                          +
404    <a>1</a>                                                                                                     +
405    <b>one</b>                                                                                                   +
406  </row>                                                                                                         +
407                                                                                                                 +
408  <row>                                                                                                          +
409    <a>2</a>                                                                                                     +
410    <b>two</b>                                                                                                   +
411  </row>                                                                                                         +
412                                                                                                                 +
413  <row>                                                                                                          +
414    <a>-1</a>                                                                                                    +
415  </row>                                                                                                         +
416                                                                                                                 +
417  </test1>                                                                                                       +
419 (1 row)
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="#">                +
425                                                                                                                 +
426  <xsd:schema                                                                                                    +
427      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                              +
428                                                                                                                 +
429  <xsd:simpleType name="INTEGER">                                                                                +
430    <xsd:restriction base="xsd:int">                                                                             +
431      <xsd:maxInclusive value="2147483647"/>                                                                     +
432      <xsd:minInclusive value="-2147483648"/>                                                                    +
433    </xsd:restriction>                                                                                           +
434  </xsd:simpleType>                                                                                              +
435                                                                                                                 +
436  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                         +
437    <xsd:restriction base="xsd:string">                                                                          +
438    </xsd:restriction>                                                                                           +
439  </xsd:simpleType>                                                                                              +
440                                                                                                                 +
441  <xsd:complexType name="RowType.regression.testxmlschema.test1">                                                +
442    <xsd:sequence>                                                                                               +
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>                 +
445    </xsd:sequence>                                                                                              +
446  </xsd:complexType>                                                                                             +
447                                                                                                                 +
448  <xsd:complexType name="TableType.regression.testxmlschema.test1">                                              +
449    <xsd:sequence>                                                                                               +
450      <xsd:element name="row" type="RowType.regression.testxmlschema.test1" minOccurs="0" maxOccurs="unbounded"/>+
451    </xsd:sequence>                                                                                              +
452  </xsd:complexType>                                                                                             +
453                                                                                                                 +
454  <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/>                                    +
455                                                                                                                 +
456  </xsd:schema>                                                                                                  +
457                                                                                                                 +
458  <row>                                                                                                          +
459    <a>1</a>                                                                                                     +
460    <b>one</b>                                                                                                   +
461  </row>                                                                                                         +
462                                                                                                                 +
463  <row>                                                                                                          +
464    <a>2</a>                                                                                                     +
465    <b>two</b>                                                                                                   +
466  </row>                                                                                                         +
467                                                                                                                 +
468  <row>                                                                                                          +
469    <a>-1</a>                                                                                                    +
470    <b xsi:nil="true"/>                                                                                          +
471  </row>                                                                                                         +
472                                                                                                                 +
473  </test1>                                                                                                       +
475 (1 row)
477 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', false, true, '');
478                                   table_to_xml_and_xmlschema                                  
479 ----------------------------------------------------------------------------------------------
480  <xsd:schema                                                                                 +
481      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                           +
482                                                                                              +
483  <xsd:simpleType name="INTEGER">                                                             +
484    <xsd:restriction base="xsd:int">                                                          +
485      <xsd:maxInclusive value="2147483647"/>                                                  +
486      <xsd:minInclusive value="-2147483648"/>                                                 +
487    </xsd:restriction>                                                                        +
488  </xsd:simpleType>                                                                           +
489                                                                                              +
490  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                      +
491    <xsd:restriction base="xsd:string">                                                       +
492    </xsd:restriction>                                                                        +
493  </xsd:simpleType>                                                                           +
494                                                                                              +
495  <xsd:complexType name="RowType.regression.testxmlschema.test1">                             +
496    <xsd:sequence>                                                                            +
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>+
499    </xsd:sequence>                                                                           +
500  </xsd:complexType>                                                                          +
501                                                                                              +
502  <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/>                   +
503                                                                                              +
504  </xsd:schema>                                                                               +
505                                                                                              +
506  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                               +
507    <a>1</a>                                                                                  +
508    <b>one</b>                                                                                +
509  </test1>                                                                                    +
510                                                                                              +
511  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                               +
512    <a>2</a>                                                                                  +
513    <b>two</b>                                                                                +
514  </test1>                                                                                    +
515                                                                                              +
516  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                               +
517    <a>-1</a>                                                                                 +
518  </test1>                                                                                    +
519                                                                                              +
521 (1 row)
523 SELECT table_to_xml_and_xmlschema('testxmlschema.test1', true, true, 'foo');
524                                    table_to_xml_and_xmlschema                                   
525 ------------------------------------------------------------------------------------------------
526  <xsd:schema                                                                                   +
527      xmlns:xsd="http://www.w3.org/2001/XMLSchema"                                              +
528      targetNamespace="foo"                                                                     +
529      elementFormDefault="qualified">                                                           +
530                                                                                                +
531  <xsd:simpleType name="INTEGER">                                                               +
532    <xsd:restriction base="xsd:int">                                                            +
533      <xsd:maxInclusive value="2147483647"/>                                                    +
534      <xsd:minInclusive value="-2147483648"/>                                                   +
535    </xsd:restriction>                                                                          +
536  </xsd:simpleType>                                                                             +
537                                                                                                +
538  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                        +
539    <xsd:restriction base="xsd:string">                                                         +
540    </xsd:restriction>                                                                          +
541  </xsd:simpleType>                                                                             +
542                                                                                                +
543  <xsd:complexType name="RowType.regression.testxmlschema.test1">                               +
544    <xsd:sequence>                                                                              +
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>+
547    </xsd:sequence>                                                                             +
548  </xsd:complexType>                                                                            +
549                                                                                                +
550  <xsd:element name="test1" type="RowType.regression.testxmlschema.test1"/>                     +
551                                                                                                +
552  </xsd:schema>                                                                                 +
553                                                                                                +
554  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo">                     +
555    <a>1</a>                                                                                    +
556    <b>one</b>                                                                                  +
557  </test1>                                                                                      +
558                                                                                                +
559  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo">                     +
560    <a>2</a>                                                                                    +
561    <b>two</b>                                                                                  +
562  </test1>                                                                                      +
563                                                                                                +
564  <test1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="foo">                     +
565    <a>-1</a>                                                                                   +
566    <b xsi:nil="true"/>                                                                         +
567  </test1>                                                                                      +
568                                                                                                +
570 (1 row)
572 SELECT query_to_xml('SELECT * FROM testxmlschema.test1', false, false, '');
573                          query_to_xml                          
574 ---------------------------------------------------------------
575  <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
576                                                               +
577  <row>                                                        +
578    <a>1</a>                                                   +
579    <b>one</b>                                                 +
580  </row>                                                       +
581                                                               +
582  <row>                                                        +
583    <a>2</a>                                                   +
584    <b>two</b>                                                 +
585  </row>                                                       +
586                                                               +
587  <row>                                                        +
588    <a>-1</a>                                                  +
589  </row>                                                       +
590                                                               +
591  </table>                                                     +
593 (1 row)
595 SELECT query_to_xmlschema('SELECT * FROM testxmlschema.test1', false, false, '');
596                                       query_to_xmlschema                                      
597 ----------------------------------------------------------------------------------------------
598  <xsd:schema                                                                                 +
599      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                           +
600                                                                                              +
601  <xsd:simpleType name="INTEGER">                                                             +
602    <xsd:restriction base="xsd:int">                                                          +
603      <xsd:maxInclusive value="2147483647"/>                                                  +
604      <xsd:minInclusive value="-2147483648"/>                                                 +
605    </xsd:restriction>                                                                        +
606  </xsd:simpleType>                                                                           +
607                                                                                              +
608  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                      +
609    <xsd:restriction base="xsd:string">                                                       +
610    </xsd:restriction>                                                                        +
611  </xsd:simpleType>                                                                           +
612                                                                                              +
613  <xsd:complexType name="RowType">                                                            +
614    <xsd:sequence>                                                                            +
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>+
617    </xsd:sequence>                                                                           +
618  </xsd:complexType>                                                                          +
619                                                                                              +
620  <xsd:complexType name="TableType">                                                          +
621    <xsd:sequence>                                                                            +
622      <xsd:element name="row" type="RowType" minOccurs="0" maxOccurs="unbounded"/>            +
623    </xsd:sequence>                                                                           +
624  </xsd:complexType>                                                                          +
625                                                                                              +
626  <xsd:element name="table" type="TableType"/>                                                +
627                                                                                              +
628  </xsd:schema>
629 (1 row)
631 SELECT query_to_xml_and_xmlschema('SELECT * FROM testxmlschema.test1', true, true, '');
632                                    query_to_xml_and_xmlschema                                   
633 ------------------------------------------------------------------------------------------------
634  <xsd:schema                                                                                   +
635      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                             +
636                                                                                                +
637  <xsd:simpleType name="INTEGER">                                                               +
638    <xsd:restriction base="xsd:int">                                                            +
639      <xsd:maxInclusive value="2147483647"/>                                                    +
640      <xsd:minInclusive value="-2147483648"/>                                                   +
641    </xsd:restriction>                                                                          +
642  </xsd:simpleType>                                                                             +
643                                                                                                +
644  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                        +
645    <xsd:restriction base="xsd:string">                                                         +
646    </xsd:restriction>                                                                          +
647  </xsd:simpleType>                                                                             +
648                                                                                                +
649  <xsd:complexType name="RowType">                                                              +
650    <xsd:sequence>                                                                              +
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>+
653    </xsd:sequence>                                                                             +
654  </xsd:complexType>                                                                            +
655                                                                                                +
656  <xsd:element name="row" type="RowType"/>                                                      +
657                                                                                                +
658  </xsd:schema>                                                                                 +
659                                                                                                +
660  <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                                   +
661    <a>1</a>                                                                                    +
662    <b>one</b>                                                                                  +
663  </row>                                                                                        +
664                                                                                                +
665  <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                                   +
666    <a>2</a>                                                                                    +
667    <b>two</b>                                                                                  +
668  </row>                                                                                        +
669                                                                                                +
670  <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">                                   +
671    <a>-1</a>                                                                                   +
672    <b xsi:nil="true"/>                                                                         +
673  </row>                                                                                        +
674                                                                                                +
676 (1 row)
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, '');
680                         cursor_to_xml                        
681 -------------------------------------------------------------
682  <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
683    <a>-1</a>                                                +
684  </row>                                                     +
685                                                             +
686  <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
687    <a>1</a>                                                 +
688    <b>one</b>                                               +
689  </row>                                                     +
690                                                             +
691  <row xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
692    <a>2</a>                                                 +
693    <b>two</b>                                               +
694  </row>                                                     +
695                                                             +
697 (1 row)
699 SELECT cursor_to_xmlschema('xc'::refcursor, false, true, '');
700                                      cursor_to_xmlschema                                      
701 ----------------------------------------------------------------------------------------------
702  <xsd:schema                                                                                 +
703      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                           +
704                                                                                              +
705  <xsd:simpleType name="INTEGER">                                                             +
706    <xsd:restriction base="xsd:int">                                                          +
707      <xsd:maxInclusive value="2147483647"/>                                                  +
708      <xsd:minInclusive value="-2147483648"/>                                                 +
709    </xsd:restriction>                                                                        +
710  </xsd:simpleType>                                                                           +
711                                                                                              +
712  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                      +
713    <xsd:restriction base="xsd:string">                                                       +
714    </xsd:restriction>                                                                        +
715  </xsd:simpleType>                                                                           +
716                                                                                              +
717  <xsd:complexType name="RowType">                                                            +
718    <xsd:sequence>                                                                            +
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>+
721    </xsd:sequence>                                                                           +
722  </xsd:complexType>                                                                          +
723                                                                                              +
724  <xsd:element name="row" type="RowType"/>                                                    +
725                                                                                              +
726  </xsd:schema>
727 (1 row)
729 MOVE BACKWARD ALL IN xc;
730 SELECT cursor_to_xml('xc'::refcursor, 5, true, false, '');
731                          cursor_to_xml                         
732 ---------------------------------------------------------------
733  <table xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
734                                                               +
735  <row>                                                        +
736    <a>-1</a>                                                  +
737    <b xsi:nil="true"/>                                        +
738  </row>                                                       +
739                                                               +
740  <row>                                                        +
741    <a>1</a>                                                   +
742    <b>one</b>                                                 +
743  </row>                                                       +
744                                                               +
745  <row>                                                        +
746    <a>2</a>                                                   +
747    <b>two</b>                                                 +
748  </row>                                                       +
749                                                               +
750  </table>                                                     +
752 (1 row)
754 SELECT cursor_to_xmlschema('xc'::refcursor, true, false, '');
755                                       cursor_to_xmlschema                                       
756 ------------------------------------------------------------------------------------------------
757  <xsd:schema                                                                                   +
758      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                             +
759                                                                                                +
760  <xsd:simpleType name="INTEGER">                                                               +
761    <xsd:restriction base="xsd:int">                                                            +
762      <xsd:maxInclusive value="2147483647"/>                                                    +
763      <xsd:minInclusive value="-2147483648"/>                                                   +
764    </xsd:restriction>                                                                          +
765  </xsd:simpleType>                                                                             +
766                                                                                                +
767  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                        +
768    <xsd:restriction base="xsd:string">                                                         +
769    </xsd:restriction>                                                                          +
770  </xsd:simpleType>                                                                             +
771                                                                                                +
772  <xsd:complexType name="RowType">                                                              +
773    <xsd:sequence>                                                                              +
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>+
776    </xsd:sequence>                                                                             +
777  </xsd:complexType>                                                                            +
778                                                                                                +
779  <xsd:complexType name="TableType">                                                            +
780    <xsd:sequence>                                                                              +
781      <xsd:element name="row" type="RowType" minOccurs="0" maxOccurs="unbounded"/>              +
782    </xsd:sequence>                                                                             +
783  </xsd:complexType>                                                                            +
784                                                                                                +
785  <xsd:element name="table" type="TableType"/>                                                  +
786                                                                                                +
787  </xsd:schema>
788 (1 row)
790 SELECT schema_to_xml('testxmlschema', false, true, '');
791                              schema_to_xml                             
792 -----------------------------------------------------------------------
793  <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
794                                                                       +
795  <test1>                                                              +
796    <a>1</a>                                                           +
797    <b>one</b>                                                         +
798  </test1>                                                             +
799                                                                       +
800  <test1>                                                              +
801    <a>2</a>                                                           +
802    <b>two</b>                                                         +
803  </test1>                                                             +
804                                                                       +
805  <test1>                                                              +
806    <a>-1</a>                                                          +
807  </test1>                                                             +
808                                                                       +
809                                                                       +
810  <test2>                                                              +
811    <z>55</z>                                                          +
812    <y>abc</y>                                                         +
813    <x>def   </x>                                                      +
814    <w>98.60</w>                                                       +
815    <v>2</v>                                                           +
816    <u>999</u>                                                         +
817    <t>0</t>                                                           +
818    <s>21:07:00</s>                                                    +
819    <r>2009-06-08T21:07:30</r>                                         +
820    <q>2009-06-08</q>                                                  +
821    <o>ABC</o>                                                         +
822    <n>true</n>                                                        +
823    <m>WFla</m>                                                        +
824  </test2>                                                             +
825                                                                       +
826                                                                       +
827  </testxmlschema>                                                     +
829 (1 row)
831 SELECT schema_to_xml('testxmlschema', true, false, '');
832                              schema_to_xml                             
833 -----------------------------------------------------------------------
834  <testxmlschema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
835                                                                       +
836  <test1>                                                              +
837                                                                       +
838  <row>                                                                +
839    <a>1</a>                                                           +
840    <b>one</b>                                                         +
841  </row>                                                               +
842                                                                       +
843  <row>                                                                +
844    <a>2</a>                                                           +
845    <b>two</b>                                                         +
846  </row>                                                               +
847                                                                       +
848  <row>                                                                +
849    <a>-1</a>                                                          +
850    <b xsi:nil="true"/>                                                +
851  </row>                                                               +
852                                                                       +
853  </test1>                                                             +
854                                                                       +
855  <test2>                                                              +
856                                                                       +
857  <row>                                                                +
858    <z>55</z>                                                          +
859    <y>abc</y>                                                         +
860    <x>def   </x>                                                      +
861    <w>98.60</w>                                                       +
862    <v>2</v>                                                           +
863    <u>999</u>                                                         +
864    <t>0</t>                                                           +
865    <s>21:07:00</s>                                                    +
866    <r>2009-06-08T21:07:30</r>                                         +
867    <q>2009-06-08</q>                                                  +
868    <p xsi:nil="true"/>                                                +
869    <o>ABC</o>                                                         +
870    <n>true</n>                                                        +
871    <m>WFla</m>                                                        +
872  </row>                                                               +
873                                                                       +
874  </test2>                                                             +
875                                                                       +
876  </testxmlschema>                                                     +
878 (1 row)
880 SELECT schema_to_xmlschema('testxmlschema', false, true, '');
881                                                 schema_to_xmlschema                                                
882 -------------------------------------------------------------------------------------------------------------------
883  <xsd:schema                                                                                                      +
884      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                                +
885                                                                                                                   +
886  <xsd:simpleType name="INTEGER">                                                                                  +
887    <xsd:restriction base="xsd:int">                                                                               +
888      <xsd:maxInclusive value="2147483647"/>                                                                       +
889      <xsd:minInclusive value="-2147483648"/>                                                                      +
890    </xsd:restriction>                                                                                             +
891  </xsd:simpleType>                                                                                                +
892                                                                                                                   +
893  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                           +
894    <xsd:restriction base="xsd:string">                                                                            +
895    </xsd:restriction>                                                                                             +
896  </xsd:simpleType>                                                                                                +
897                                                                                                                   +
898  <xsd:simpleType name="VARCHAR">                                                                                  +
899    <xsd:restriction base="xsd:string">                                                                            +
900    </xsd:restriction>                                                                                             +
901  </xsd:simpleType>                                                                                                +
902                                                                                                                   +
903  <xsd:simpleType name="CHAR">                                                                                     +
904    <xsd:restriction base="xsd:string">                                                                            +
905    </xsd:restriction>                                                                                             +
906  </xsd:simpleType>                                                                                                +
907                                                                                                                   +
908  <xsd:simpleType name="NUMERIC">                                                                                  +
909  </xsd:simpleType>                                                                                                +
910                                                                                                                   +
911  <xsd:simpleType name="SMALLINT">                                                                                 +
912    <xsd:restriction base="xsd:short">                                                                             +
913      <xsd:maxInclusive value="32767"/>                                                                            +
914      <xsd:minInclusive value="-32768"/>                                                                           +
915    </xsd:restriction>                                                                                             +
916  </xsd:simpleType>                                                                                                +
917                                                                                                                   +
918  <xsd:simpleType name="BIGINT">                                                                                   +
919    <xsd:restriction base="xsd:long">                                                                              +
920      <xsd:maxInclusive value="9223372036854775807"/>                                                              +
921      <xsd:minInclusive value="-9223372036854775808"/>                                                             +
922    </xsd:restriction>                                                                                             +
923  </xsd:simpleType>                                                                                                +
924                                                                                                                   +
925  <xsd:simpleType name="REAL">                                                                                     +
926    <xsd:restriction base="xsd:float"></xsd:restriction>                                                           +
927  </xsd:simpleType>                                                                                                +
928                                                                                                                   +
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}+)?"/>                                              +
932    </xsd:restriction>                                                                                             +
933  </xsd:simpleType>                                                                                                +
934                                                                                                                   +
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}+)?"/>                +
938    </xsd:restriction>                                                                                             +
939  </xsd:simpleType>                                                                                                +
940                                                                                                                   +
941  <xsd:simpleType name="DATE">                                                                                     +
942    <xsd:restriction base="xsd:date">                                                                              +
943      <xsd:pattern value="\p{Nd}{4}-\p{Nd}{2}-\p{Nd}{2}"/>                                                         +
944    </xsd:restriction>                                                                                             +
945  </xsd:simpleType>                                                                                                +
946                                                                                                                   +
947  <xsd:complexType mixed="true">                                                                                   +
948    <xsd:sequence>                                                                                                 +
949      <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/>                         +
950    </xsd:sequence>                                                                                                +
951  </xsd:complexType>                                                                                               +
952                                                                                                                   +
953  <xsd:simpleType name="Domain.regression.public.testxmldomain">                                                   +
954    <xsd:restriction base="VARCHAR"/>                                                                              +
955  </xsd:simpleType>                                                                                                +
956                                                                                                                   +
957  <xsd:simpleType name="BOOLEAN">                                                                                  +
958    <xsd:restriction base="xsd:boolean"></xsd:restriction>                                                         +
959  </xsd:simpleType>                                                                                                +
960                                                                                                                   +
961  <xsd:simpleType name="UDT.regression.pg_catalog.bytea">                                                          +
962    <xsd:restriction base="xsd:base64Binary">                                                                      +
963    </xsd:restriction>                                                                                             +
964  </xsd:simpleType>                                                                                                +
965                                                                                                                   +
966  <xsd:complexType name="SchemaType.regression.testxmlschema">                                                     +
967    <xsd:sequence>                                                                                                 +
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"/>+
970    </xsd:sequence>                                                                                                +
971  </xsd:complexType>                                                                                               +
972                                                                                                                   +
973  <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/>                                   +
974                                                                                                                   +
975  </xsd:schema>
976 (1 row)
978 SELECT schema_to_xmlschema('testxmlschema', true, false, '');
979                                         schema_to_xmlschema                                        
980 ---------------------------------------------------------------------------------------------------
981  <xsd:schema                                                                                      +
982      xmlns:xsd="http://www.w3.org/2001/XMLSchema">                                                +
983                                                                                                   +
984  <xsd:simpleType name="INTEGER">                                                                  +
985    <xsd:restriction base="xsd:int">                                                               +
986      <xsd:maxInclusive value="2147483647"/>                                                       +
987      <xsd:minInclusive value="-2147483648"/>                                                      +
988    </xsd:restriction>                                                                             +
989  </xsd:simpleType>                                                                                +
990                                                                                                   +
991  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                           +
992    <xsd:restriction base="xsd:string">                                                            +
993    </xsd:restriction>                                                                             +
994  </xsd:simpleType>                                                                                +
995                                                                                                   +
996  <xsd:simpleType name="VARCHAR">                                                                  +
997    <xsd:restriction base="xsd:string">                                                            +
998    </xsd:restriction>                                                                             +
999  </xsd:simpleType>                                                                                +
1000                                                                                                   +
1001  <xsd:simpleType name="CHAR">                                                                     +
1002    <xsd:restriction base="xsd:string">                                                            +
1003    </xsd:restriction>                                                                             +
1004  </xsd:simpleType>                                                                                +
1005                                                                                                   +
1006  <xsd:simpleType name="NUMERIC">                                                                  +
1007  </xsd:simpleType>                                                                                +
1008                                                                                                   +
1009  <xsd:simpleType name="SMALLINT">                                                                 +
1010    <xsd:restriction base="xsd:short">                                                             +
1011      <xsd:maxInclusive value="32767"/>                                                            +
1012      <xsd:minInclusive value="-32768"/>                                                           +
1013    </xsd:restriction>                                                                             +
1014  </xsd:simpleType>                                                                                +
1015                                                                                                   +
1016  <xsd:simpleType name="BIGINT">                                                                   +
1017    <xsd:restriction base="xsd:long">                                                              +
1018      <xsd:maxInclusive value="9223372036854775807"/>                                              +
1019      <xsd:minInclusive value="-9223372036854775808"/>                                             +
1020    </xsd:restriction>                                                                             +
1021  </xsd:simpleType>                                                                                +
1022                                                                                                   +
1023  <xsd:simpleType name="REAL">                                                                     +
1024    <xsd:restriction base="xsd:float"></xsd:restriction>                                           +
1025  </xsd:simpleType>                                                                                +
1026                                                                                                   +
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>                                                                             +
1031  </xsd:simpleType>                                                                                +
1032                                                                                                   +
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>                                                                             +
1037  </xsd:simpleType>                                                                                +
1038                                                                                                   +
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>                                                                             +
1043  </xsd:simpleType>                                                                                +
1044                                                                                                   +
1045  <xsd:complexType mixed="true">                                                                   +
1046    <xsd:sequence>                                                                                 +
1047      <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/>         +
1048    </xsd:sequence>                                                                                +
1049  </xsd:complexType>                                                                               +
1050                                                                                                   +
1051  <xsd:simpleType name="Domain.regression.public.testxmldomain">                                   +
1052    <xsd:restriction base="VARCHAR"/>                                                              +
1053  </xsd:simpleType>                                                                                +
1054                                                                                                   +
1055  <xsd:simpleType name="BOOLEAN">                                                                  +
1056    <xsd:restriction base="xsd:boolean"></xsd:restriction>                                         +
1057  </xsd:simpleType>                                                                                +
1058                                                                                                   +
1059  <xsd:simpleType name="UDT.regression.pg_catalog.bytea">                                          +
1060    <xsd:restriction base="xsd:base64Binary">                                                      +
1061    </xsd:restriction>                                                                             +
1062  </xsd:simpleType>                                                                                +
1063                                                                                                   +
1064  <xsd:complexType name="SchemaType.regression.testxmlschema">                                     +
1065    <xsd:all>                                                                                      +
1066      <xsd:element name="test1" type="TableType.regression.testxmlschema.test1"/>                  +
1067      <xsd:element name="test2" type="TableType.regression.testxmlschema.test2"/>                  +
1068    </xsd:all>                                                                                     +
1069  </xsd:complexType>                                                                               +
1070                                                                                                   +
1071  <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/>                   +
1072                                                                                                   +
1073  </xsd:schema>
1074 (1 row)
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 #">     +
1080                                                                                                                   +
1081  <xsd:schema                                                                                                      +
1082      xmlns:xsd="http://www.w3.org/2001/XMLSchema"                                                                 +
1083      targetNamespace="foo"                                                                                        +
1084      elementFormDefault="qualified">                                                                              +
1085                                                                                                                   +
1086  <xsd:simpleType name="INTEGER">                                                                                  +
1087    <xsd:restriction base="xsd:int">                                                                               +
1088      <xsd:maxInclusive value="2147483647"/>                                                                       +
1089      <xsd:minInclusive value="-2147483648"/>                                                                      +
1090    </xsd:restriction>                                                                                             +
1091  </xsd:simpleType>                                                                                                +
1092                                                                                                                   +
1093  <xsd:simpleType name="UDT.regression.pg_catalog.text">                                                           +
1094    <xsd:restriction base="xsd:string">                                                                            +
1095    </xsd:restriction>                                                                                             +
1096  </xsd:simpleType>                                                                                                +
1097                                                                                                                   +
1098  <xsd:simpleType name="VARCHAR">                                                                                  +
1099    <xsd:restriction base="xsd:string">                                                                            +
1100    </xsd:restriction>                                                                                             +
1101  </xsd:simpleType>                                                                                                +
1102                                                                                                                   +
1103  <xsd:simpleType name="CHAR">                                                                                     +
1104    <xsd:restriction base="xsd:string">                                                                            +
1105    </xsd:restriction>                                                                                             +
1106  </xsd:simpleType>                                                                                                +
1107                                                                                                                   +
1108  <xsd:simpleType name="NUMERIC">                                                                                  +
1109  </xsd:simpleType>                                                                                                +
1110                                                                                                                   +
1111  <xsd:simpleType name="SMALLINT">                                                                                 +
1112    <xsd:restriction base="xsd:short">                                                                             +
1113      <xsd:maxInclusive value="32767"/>                                                                            +
1114      <xsd:minInclusive value="-32768"/>                                                                           +
1115    </xsd:restriction>                                                                                             +
1116  </xsd:simpleType>                                                                                                +
1117                                                                                                                   +
1118  <xsd:simpleType name="BIGINT">                                                                                   +
1119    <xsd:restriction base="xsd:long">                                                                              +
1120      <xsd:maxInclusive value="9223372036854775807"/>                                                              +
1121      <xsd:minInclusive value="-9223372036854775808"/>                                                             +
1122    </xsd:restriction>                                                                                             +
1123  </xsd:simpleType>                                                                                                +
1124                                                                                                                   +
1125  <xsd:simpleType name="REAL">                                                                                     +
1126    <xsd:restriction base="xsd:float"></xsd:restriction>                                                           +
1127  </xsd:simpleType>                                                                                                +
1128                                                                                                                   +
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>                                                                                             +
1133  </xsd:simpleType>                                                                                                +
1134                                                                                                                   +
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>                                                                                             +
1139  </xsd:simpleType>                                                                                                +
1140                                                                                                                   +
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>                                                                                             +
1145  </xsd:simpleType>                                                                                                +
1146                                                                                                                   +
1147  <xsd:complexType mixed="true">                                                                                   +
1148    <xsd:sequence>                                                                                                 +
1149      <xsd:any name="element" minOccurs="0" maxOccurs="unbounded" processContents="skip"/>                         +
1150    </xsd:sequence>                                                                                                +
1151  </xsd:complexType>                                                                                               +
1152                                                                                                                   +
1153  <xsd:simpleType name="Domain.regression.public.testxmldomain">                                                   +
1154    <xsd:restriction base="VARCHAR"/>                                                                              +
1155  </xsd:simpleType>                                                                                                +
1156                                                                                                                   +
1157  <xsd:simpleType name="BOOLEAN">                                                                                  +
1158    <xsd:restriction base="xsd:boolean"></xsd:restriction>                                                         +
1159  </xsd:simpleType>                                                                                                +
1160                                                                                                                   +
1161  <xsd:simpleType name="UDT.regression.pg_catalog.bytea">                                                          +
1162    <xsd:restriction base="xsd:base64Binary">                                                                      +
1163    </xsd:restriction>                                                                                             +
1164  </xsd:simpleType>                                                                                                +
1165                                                                                                                   +
1166  <xsd:complexType name="SchemaType.regression.testxmlschema">                                                     +
1167    <xsd:sequence>                                                                                                 +
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"/>+
1170    </xsd:sequence>                                                                                                +
1171  </xsd:complexType>                                                                                               +
1172                                                                                                                   +
1173  <xsd:element name="testxmlschema" type="SchemaType.regression.testxmlschema"/>                                   +
1174                                                                                                                   +
1175  </xsd:schema>                                                                                                    +
1176                                                                                                                   +
1177  <test1>                                                                                                          +
1178    <a>1</a>                                                                                                       +
1179    <b>one</b>                                                                                                     +
1180  </test1>                                                                                                         +
1181                                                                                                                   +
1182  <test1>                                                                                                          +
1183    <a>2</a>                                                                                                       +
1184    <b>two</b>                                                                                                     +
1185  </test1>                                                                                                         +
1186                                                                                                                   +
1187  <test1>                                                                                                          +
1188    <a>-1</a>                                                                                                      +
1189    <b xsi:nil="true"/>                                                                                            +
1190  </test1>                                                                                                         +
1191                                                                                                                   +
1192                                                                                                                   +
1193  <test2>                                                                                                          +
1194    <z>55</z>                                                                                                      +
1195    <y>abc</y>                                                                                                     +
1196    <x>def   </x>                                                                                                  +
1197    <w>98.60</w>                                                                                                   +
1198    <v>2</v>                                                                                                       +
1199    <u>999</u>                                                                                                     +
1200    <t>0</t>                                                                                                       +
1201    <s>21:07:00</s>                                                                                                +
1202    <r>2009-06-08T21:07:30</r>                                                                                     +
1203    <q>2009-06-08</q>                                                                                              +
1204    <p xsi:nil="true"/>                                                                                            +
1205    <o>ABC</o>                                                                                                     +
1206    <n>true</n>                                                                                                    +
1207    <m>WFla</m>                                                                                                    +
1208  </test2>                                                                                                         +
1209                                                                                                                   +
1210                                                                                                                   +
1211  </testxmlschema>                                                                                                 +
1213 (1 row)
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
1219     AS SELECT true c1,
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;
1224                             xmlforest                             
1225 ------------------------------------------------------------------
1226  <c1>true</c1><c2>true</c2><c3>2013-02-21</c3><c4>2013-02-21</c4>
1227 (1 row)
1229 SELECT table_to_xml('testxmlschema.test3', true, true, '');
1230                          table_to_xml                          
1231 ---------------------------------------------------------------
1232  <test3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">+
1233    <c1>true</c1>                                              +
1234    <c2>true</c2>                                              +
1235    <c3>2013-02-21</c3>                                        +
1236    <c4>2013-02-21</c4>                                        +
1237  </test3>                                                     +
1238                                                               +
1240 (1 row)