XSD  •  Define Data Structure

Listing 3. This XML schema defines what the structure of the XML data should be when the XmlAdapter fills the XPathDocument2 object. The main mapping schema references this XML schema and ties it with the database schema (see Listing 4).

<?xml version="1.0" encoding="utf-8" ?> 
<xsd:schema id="CustomerOrders" 
   elementFormDefault="qualified" 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <xsd:element name="Customer">
      <xsd:complexType>
         <xsd:sequence>
            <xsd:element name="Order" >
               <xsd:complexType>
               <xsd:attribute name="id" 
                  type="xsd:string"/>
               <xsd:attribute name="orderID" 
                  type="xsd:string"/>
               <xsd:attribute name="date" 
                  type="xsd:date"/> 
         </xsd:complexType>
            </xsd:element>
         </xsd:sequence>
         <xsd:attribute name="id" 
            type="xsd:string"/>
         <xsd:attribute name="name" 
            type="xsd:string" />
      </xsd:complexType>
   </xsd:element>
</xsd:schema>