XML schema documents (XSD files) can be used as templates
to create new XML files and to validate XML data that is inserted
into or updated in a relational database. You can use the workbench
to create and modify XSD files. XML schemas must contain one or more
XML schema documents.
To create an XML schema document:
- Expand the XML folder in your project.
- Right-click the XML Schema folder
in your project, and select . The
New XML Schema wizard opens.
- On the first page of the wizard, select the XMLSchema project,
type customer.xsd in the File name field,
and click Finish. The XSD
editor opens.
- Click the Source tab at the bottom
of the XSD editor.
- In the XSD editor, replace the opening and closing schema tags
with the following XML:
<xs:schema targetNamespace="http://posample.org" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="customerinfo">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="1"></xs:element>
<xs:element name="addr" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="street" type="xs:string" minOccurs="1"></xs:element>
<xs:element name="city" type="xs:string" minOccurs="1"></xs:element>
<xs:element name="prov-state" type="xs:string" minOccurs="1"></xs:element>
<xs:element name="pcode-zip" type="xs:string" minOccurs="1"></xs:element>
</xs:sequence>
<xs:attribute name="country" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="phone" nillable="true" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="type" form="unqualified" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="assistant" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0"></xs:element>
<xs:element name="phone" nillable="true" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="type" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Cid" type="xs:integer"/>
</xs:complexType>
</xs:element>
</xs:schema>
- In the File menu, select Save, and
close the XSD editor.
The new XSD file is displayed in the Data Project Explorer.