<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
            xmlns:po="http://www.example.org/po"
            targetNamespace="http://www.example.org/po">
 
  <xsd:element name="purchaseOrder" type="po:PurchaseOrder" />

  <xsd:complexType name="PurchaseOrder">
    <xsd:sequence>
      <xsd:element name="shipTo" type="po:Address" 
                   minOccurs = "1" maxOccurs="1" />
      <xsd:element name="billTo" type="po:Address" 
                   minOccurs = "1" maxOccurs="1" />
      <xsd:element name="items" type="po:Item" 
                   minOccurs="1" maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="orderDate" type="xsd:date" />
  </xsd:complexType>

  <xsd:complexType name="Address">
    <xsd:sequence>
      <xsd:element name="name" type="xsd:string" />
      <xsd:element name="street" type="xsd:string" />
      <xsd:element name="city" type="xsd:string" />
      <xsd:element name="postalCode" type="po:PostalCode" />
      <xsd:element name="country" type="xsd:string" />
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name="Item">
    <xsd:sequence>
      <xsd:element name="productName" type="xsd:string" />
      <xsd:element name="quantity" type="xsd:positiveInteger" />
      <xsd:element name="price" type="xsd:float" />
      <xsd:element name="shipDate" type="xsd:date" />
    </xsd:sequence>
    <xsd:attribute name="partNum" type="xsd:string" />
  </xsd:complexType>

  <xsd:simpleType name="PostalCode">
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="[A-Z]{2}\d{5}" />
    </xsd:restriction>
  </xsd:simpleType>
  
</xsd:schema>
