< Previous | Next >

Creating an XML schema document

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:

  1. Expand the XML folder in your project.
  2. Right-click the XML Schema folder in your project, and select New > XML Schema. The New XML Schema wizard opens.
  3. 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.
  4. Click the Source tab at the bottom of the XSD editor.
  5. 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>
  6. In the File menu, select Save, and close the XSD editor.
The new XSD file is displayed in the Data Project Explorer.
Screen capture showing the customer file displayed in the Data Project Explorer, as described.
< Previous | Next >

Feedback