<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified" 
    targetNamespace="http://www.example.com/IPO" 
    xmlns:ipo="http://www.example.com/IPO" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

   <xs:include schemaLocation="Address.xsd"/>

<!-- _________________________________________________ -->
<!--                                                   -->
<!-- PACKAGE: <<XSDschema>> PO  -->
<!-- _________________________________________________ -->

   <xs:annotation>
      <xs:documentation>International Purchase order schema for Example.com. Copyright 2000 Example.com. All rights reserved.</xs:documentation>
   </xs:annotation>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- CLASS: <<XSDcomplexType>> Item  -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

   <xs:element name="item" type="ipo:Item"/>
   <xs:complexType name="Item">
      <xs:sequence>
         <xs:element name="productName" type="xs:string"/>
         <xs:element name="quantity" type="ipo:QuantityType"/>
         <xs:element name="USPrice" type="xs:decimal"/>
         <xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="1"/>
         <xs:element name="shipDate" type="xs:date" minOccurs="0" maxOccurs="1"/>
      </xs:sequence>
      <xs:attribute name="partNum" type="ipo:SKU" use="required"/>
   </xs:complexType>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- DATATYPE: <<XSDsimpleType>> QuantityType  -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

   <xs:simpleType name="QuantityType">
      <xs:restriction base="xs:positiveInteger">
         <xs:maxExclusive value="100"/>
      </xs:restriction>
   </xs:simpleType>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- CLASS: PurchaseOrder  -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

   <xs:element name="purchaseOrder" type="ipo:PurchaseOrder"/>
   <xs:complexType name="PurchaseOrder">
      <xs:sequence>
         <xs:element name="shipTo" type="ipo:Address"/>
         <xs:element name="billTo" type="ipo:Address"/>
         <xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="1"/>
         <xs:element name="items" minOccurs="0" maxOccurs="1">
            <xs:complexType>
               <xs:sequence>
                  <xs:element ref="ipo:item" minOccurs="0" maxOccurs="unbounded"/>
               </xs:sequence>
            </xs:complexType>
         </xs:element>
      </xs:sequence>
      <xs:attribute name="orderDate" type="xs:date"/>
   </xs:complexType>

<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- DATATYPE: <<XSDsimpleType>> SKU  -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->

   <xs:simpleType name="SKU">
      <xs:annotation>
         <xs:documentation>Stock Keeping Unit, a code for identifying products</xs:documentation>
      </xs:annotation>
      <xs:restriction base="xs:string">
         <xs:pattern value="\d{3}-[A-Z]{2}"/>
      </xs:restriction>
   </xs:simpleType>
</xs:schema>