The genxmlschema() and genxmlschemaclob() XML functions
These functions generate an XML schema and result in XML format.
Purpose
These functions are identical to genxml() and genxmlclob(), but they also generate an XML schema.
The genxmlschema() syntax
genxmlschma(row,
element)
The genxmlschemaclob() syntax
genxmlschemaclob(row
,element)
Parameters
- row
- The rows and columns to return.
- element
- The name of the element that contains the result set.
Example 1
SELECT genxmlschema(customer, “customer) FROM customers;
<?xml version="1.0" encoding="en_US.819" ?>
xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"\
targetNamespace="http://www.ibm.com"\
xmlns="http://www.ibm.com"\
ElementFormDefault="qualified">
<xs:element name="customer">
<xs:complexType>
<xs:sequence>
<xs:element name="customer_num" type="xs:serial"/>
<xs:element name="fname" type="xs:char(15)"/>
<xs:element name="lname" type="xs:char(15)"/>
<xs:element name="company" type="xs:char(20)"/>
<xs:element name="address1" type="xs:char(20)"/>
<xs:element name="city" type="xs:char(15)"/>
<xs:element name="state" type="xs:char(2)"/>
<xs:element name="zipcode" type="xs:char(5)"/>
<xs:element name="phone" type="xs:char(18)"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<customer>
<row>
<customer_num>101</customer_num>
<fname>Ludwig </fname>
<lname>Pauli </lname>
<company>All Sports Supplies </company>
<address1>213 Erstwild Court </address1>
<city>Sunnyvale </city>
<state>CA</state>
<zipcode>94086</zipcode>
<phone>408-789-8075 </phone>
</row>