WebReference.com - Part 4 of Chapter 1: Professional XML Schemas, from Wrox Press Ltd (2/4) | WebReference

WebReference.com - Part 4 of Chapter 1: Professional XML Schemas, from Wrox Press Ltd (2/4)

To page 1current pageTo page 3To page 4
[previous] [next]

Professional XML Schemas

Now let's see the schema that we use for our Delivery Receipt documents. The schema is called DeliveryReceipt.xsd:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs = "http://www.w3.org/2001/XMLSchema">
   <xs:element name = "DeliveryReceipt">
      <xs:complexType>
         <xs:sequence>
            <xs:element name = "Customer">
               <xs:complexType>
                  <xs:sequence>
                     <xs:element ref = "Name" />
                     <xs:element ref = "Address" />
                  </xs:sequence>
               </xs:complexType>
            </xs:element>
            <xs:element name = "Items">
               <xs:complexType>
                  <xs:sequence>
                     <xs:element ref = "DeliveryItem" 
                                 minOccurs = "1" maxOccurs = "unbounded"/>
                  </xs:sequence>
               </xs:complexType>
            </xs:element>
         </xs:sequence>
         <xs:attribute name = "deliveryID" type = "xs:integer" />
         <xs:attribute name = "dateReceived" type = "xs:date" />
      </xs:complexType>
   </xs:element>
   <xs:element name = "Name">
      <xs:complexType>
         <xs:sequence>
            <xs:element name = "FirstName" type = "xs:string" />
            <xs:element name = "MiddleInitial" type = "xs:string" 
                                 minOccurs = "0" maxOccurs = "1" />
            <xs:element name = "LastName" type = "xs:string" />
         </xs:sequence>
      </xs:complexType>
   </xs:element>
   <xs:element name = "Address">
      <xs:complexType>
         <xs:sequence>
            <xs:element name = "AddressLine1"  type = "xs:string" />
            <xs:element name = "AddressLine2" type = "xs:string" 
                        minOccurs = "0" maxOccurs = "1" />
            <xs:element name = "Town" type = "xs:string" />
            <xs:element name = "City" type = "xs:string" 
                        minOccurs = "0" maxOccurs = "1" />
            <xs:element name = "StateProvinceCounty" type = "xs:string" />
            <xs:element name = "ZipPostCode"  type = "xs:string" />
         </xs:sequence>
      </xs:complexType>
   </xs:element>
   <xs:element name = "DeliveryItem">
      <xs:complexType>
         <xs:sequence>
            <xs:element name = "Description"  type = "xs:string" />
         </xs:sequence>
         <xs:attribute name = "quantity" type = "xs:integer" />
      </xs:complexType>
   </xs:element>
</xs:schema>

There are a few things we should note about this schema:


To page 1current pageTo page 3To page 4
[previous] [next]

Created: October 30, 2001
Revised: October 30, 2001


URL: http://webreference.com/authoring/languages/xml/schemas/chap1/4/2.html