<?xml version="1.0" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

	<xs:annotation>
		<xs:documentation>
			<p>Written by Michael Dale for DCA Assignment 1 Part 2 - 10309108 - Copyright 2005</p>
			<p>This schema contains two main sections. The first part is the simpleType setup where I define <br />
			  values that require checking (and aren't just strings).</p>
			<p>orderNumberType: Any 6 digit number.<br />
			  yearType: Any integer between (and including) 2000 - 3000.<br />
			  monthType: Any integer between (and including) 1 - 12.<br />
			  dayType: Any integer between (and including) 1 - 31.<br />
			  currencyType: A string of one of the following values: AUD, USD, EUR, JPY.<br />
			  quantityType: Any integer between (and including) 1 - 1000.<br />
			  unitcostType: A double that is between (and including) 0.00 - 99999.00 and also in that format.</p>
			<p>The next section is where the elements and structure of the XML document is defind.</p>
		</xs:documentation>
	</xs:annotation>
	
	
	<xs:simpleType name="orderNumberType">
		<xs:restriction base="xs:integer">
			<xs:pattern value="[0-9]{6}"/>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="yearType">
		<xs:restriction base="xs:integer">
			<xs:minInclusive value="2000"/>
			<xs:maxInclusive value="3000"/>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="monthType">
		<xs:restriction base="xs:integer">
				<xs:minInclusive value="1"/>
				<xs:maxInclusive value="12"/>
		</xs:restriction>
	</xs:simpleType>
	
	
	<xs:simpleType name="dayType">
		<xs:restriction base="xs:integer">
				<xs:minInclusive value="1"/>
				<xs:maxInclusive value="31"/>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="currencyType">
		<xs:restriction base="xs:string">
					<xs:pattern value="AUD|USD|EUR|JPY"/>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="quantityType">
		<xs:restriction base="xs:integer">
				<xs:minInclusive value="1"/>
				<xs:maxInclusive value="1000"/>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:simpleType name="unitcostType">
		<xs:restriction base="xs:double">
						<xs:minInclusive value="0.00"/>
						<xs:maxInclusive value="99999.00"/>
						<xs:pattern value="\d{1,5}.\d{2}"/>
		</xs:restriction>
	</xs:simpleType>
	
	<xs:element name="purchaseOrder">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="orderNumber" type="orderNumberType" />
				<xs:element name="orderDate">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="year" type="yearType" />
							<xs:element name="month" type="monthType" />
							<xs:element name="day" type="dayType" />
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="orderedBy">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="name" type="xs:string" />
							<xs:element name="company" minOccurs="0" maxOccurs="1" type="xs:string" />
							<xs:element name="address">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="street" minOccurs="1" maxOccurs="2" type="xs:string" />
										<xs:element name="suburb" type="xs:string" />
										<xs:element name="state" type="xs:string" />
										<xs:element name="postcode" type="xs:string" />
										<xs:element name="country" type="xs:string" />
									</xs:sequence>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="shipTo">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="name" type="xs:string" />
							<xs:element name="company" minOccurs="0" maxOccurs="1" type="xs:string" />
							<xs:element name="address">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="street" minOccurs="1" maxOccurs="2" type="xs:string" />
										<xs:element name="suburb" type="xs:string" />
										<xs:element name="state" type="xs:string" />
										<xs:element name="postcode" type="xs:string" />
										<xs:element name="country" type="xs:string" />
									</xs:sequence>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="currency" type="currencyType" />
				<xs:element name="items">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="item" minOccurs="1" maxOccurs="unbounded">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="quantity" type="quantityType" />
										<xs:element name="productCode" type="xs:string" />
										<xs:element name="description" type="xs:string" />
										<xs:element name="unitcost" type="unitcostType" />
									</xs:sequence>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:sequence>	
		</xs:complexType>
	</xs:element>

</xs:schema>