<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" 
	xmlns:xs="http://www.w3.org/2001/XMLSchema"
	xmlns="http://www.posti.com/wms/postiwmsxml/InPurchaseOrder/2016/1"
    targetNamespace="http://www.posti.com/wms/postiwmsxml/InPurchaseOrder/2016/1">


	<xs:element name="Order">
		<xs:complexType>
			<xs:all>
				<xs:element name="MetaData" type="ctMetaDataType" minOccurs="1" maxOccurs="1"/>
				<xs:element name="OrderLines" type="ctOrderLinesType" minOccurs="1" maxOccurs="1"/>
				<xs:element name="Instructions" type="ctInstructionsType" minOccurs="0" maxOccurs="1"/>
				<xs:element name="PersonInfoBillTo" type="ctPersonInfoBillToType" minOccurs="1" maxOccurs="1"/>
				<xs:element name="AdditionalAddresses" type="ctAdditionalAddressesType" minOccurs="0" maxOccurs="1"/>
				<xs:element name="References" type="ctReferencesType" minOccurs="0" maxOccurs="1"/>
			</xs:all>
			<xs:attribute name="ReqDeliveryDate" type="xs:dateTime" use="optional">
				<xs:annotation>
					<xs:documentation>Requested delivery date. This date is also used on order line level during order creation if requested delivery date is not given on that level.</xs:documentation>
				</xs:annotation>
			</xs:attribute>
			<xs:attribute name="ReceivingNode" type="stStringMaxLength24Type" use="required">
				<xs:annotation>
					<xs:documentation>Code for the Posti node or warehouse which will receive the purchase order.</xs:documentation>
				</xs:annotation>
			</xs:attribute>
			<xs:attribute name="OrderType" type="stStringMaxLength20Type" use="optional">
				<xs:annotation>
					<xs:documentation>Order classification attribute. This field can be used for reporting purposes or to build conditions for modeling your business process.</xs:documentation>
				</xs:annotation>
			</xs:attribute>
			<xs:attribute name="FreightTerms" type="stStringMaxLength40Type" use="optional">
				<xs:annotation>
					<xs:documentation>Freight terms of the order.</xs:documentation>
				</xs:annotation>
			</xs:attribute>
			<xs:attribute name="CustomerPONo" type="stStringMaxLength100Type" use="optional">
				<xs:annotation>
					<xs:documentation>Principal's purchase order number.</xs:documentation>
				</xs:annotation>
			</xs:attribute>
			<xs:attribute name="CancelMissingLines" type="stStringMaxLength1YNType" use="optional">
				<xs:annotation>
					<xs:documentation>Flag to indicate whether missing lines should be cancelled. Default value: Y.</xs:documentation>
				</xs:annotation>
			</xs:attribute>
		</xs:complexType>
	</xs:element>

	<xs:complexType name="ctMetaDataType">
		<xs:annotation>
			<xs:documentation>Contains information about message.</xs:documentation>
		</xs:annotation>
		<xs:attribute name="SourceOrganizationId" type="stStringMaxLength40Type" use="required">
			<xs:annotation>
				<xs:documentation>Code for the organization that sends the purchase order message, provided by Posti (principal identifier).</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="Language" type="stStringMaxLength2Type" use="optional">
			<xs:annotation>
				<xs:documentation>Language code of the purchase order in two-letter ISO 639-1 format, e.g. FI.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="ExternalUserId" type="stStringMaxLength40Type" use="optional">
			<xs:annotation>
				<xs:documentation>Identifier of the principal in external system (OVT code, EDI sender ID).</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="DocumentType" type="stStringMaxLength40Type" use="required">
			<xs:annotation>
				<xs:documentation>Name of the document. This should be InPurchaseOrder.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="CreationDateTime" type="xs:dateTime" use="optional">
			<xs:annotation>
				<xs:documentation>Date and time of purchase order creation.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="MessageIdentifier" type="stStringMaxLength40Type" use="optional">
			<xs:annotation>
				<xs:documentation>Identifier of the message which is unique at least in the scope of message sender.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="ctOrderLinesType">
		<xs:annotation>
			<xs:documentation>List of order lines.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="OrderLine" type="ctOrderLineType" minOccurs="1" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ctOrderLineType">
		<xs:annotation>
			<xs:documentation>Contains information about the order line.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="Item" type="ctItemType" minOccurs="1" maxOccurs="unbounded"/>
			<xs:element name="Extn" type="ctExtnType" minOccurs="0" maxOccurs="1"/>
			<xs:element name="Instructions" type="ctInstructionsType" minOccurs="0" maxOccurs="1"/>
			<xs:element name="References" type="ctReferencesType" minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="Action" type="stStringMaxLength40Type" use="optional">
			<xs:annotation>
				<xs:documentation>Action to perform on this OrderLine. Default value: CREATE/MODIFY.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="OrderedQty" type="stNonNegDecimal14Dig4FractType" use="required">
			<xs:annotation>
				<xs:documentation>The quantity of the line item that is being ordered. This quantity is in inventory unit of measure.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="ReqDeliveryDate" type="xs:dateTime" use="optional">
			<xs:annotation>
				<xs:documentation>Requested delivery date. If no value is given on this level, the requested delivery date from order level is used on order line level during order creation.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="CustomerLinePONo" type="stStringMaxLength10Type" use="optional">
			<xs:annotation>
				<xs:documentation>Principal’s purchase order line number.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="Segment" type="stStringMaxLength100Type" use="optional">
			<xs:annotation>
				<xs:documentation>Indicates Segment for the order line.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="SegmentType" type="stStringMaxLength10Type" use="optional">
			<xs:annotation>
				<xs:documentation>Indicates SegmentType for the order line.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="ctItemType">
		<xs:annotation>
			<xs:documentation>Contains information about item.</xs:documentation>
		</xs:annotation>
		<xs:attribute name="UnitOfMeasure" type="stStringMaxLength40Type" use="optional">
			<xs:annotation>
				<xs:documentation>Unit of measure.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="SupplierItem" type="stStringMaxLength40Type" use="optional">
			<xs:annotation>
				<xs:documentation>Supplier's item ID. No functionality in WMS.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="SupplierItemDesc" type="stStringMaxLength200Type" use="optional">
			<xs:annotation>
				<xs:documentation>Supplier's item description.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="ProductClass" type="stStringMaxLength10Type" use="optional">
			<xs:annotation>
				<xs:documentation>Product class. This field is used as an inventory identifier.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="ItemID" type="stStringMaxLength40Type" use="required">
			<xs:annotation>
				<xs:documentation>Identifier for the item. The item ID, UOM, and product class form the unique inventory identifier for an order line.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="ItemDesc" type="stStringMaxLength500Type" use="optional">
			<xs:annotation>
				<xs:documentation>Description of the item.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="CountryOfOrigin" type="stStringMaxLength40Type" use="optional">
			<xs:annotation>
				<xs:documentation>Item's country of origin/manufacture. Use ISO 3166-1 alpha-2 format codes.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="ctExtnType">
		<xs:annotation>
			<xs:documentation>More information about order line.</xs:documentation>
		</xs:annotation>
		<xs:attribute name="ExtnCustomerSalesUOM" type="stStringMaxLength40Type" use="optional">
			<xs:annotation>
				<xs:documentation>Customer sales unit of measure.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="ExtnCustomerSalesUOMConversion" type="stNonNegDecimal14Dig4FractType" use="optional">
			<xs:annotation>
				<xs:documentation>Multiplier that can be used together with base unit quantity to gain quantity in sales unit.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="ctInstructionsType">
		<xs:annotation>
			<xs:documentation>List of instructions.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="Instruction" type="ctInstructionType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ctInstructionType">
		<xs:annotation>
			<xs:documentation>Instruction text and type.</xs:documentation>
		</xs:annotation>
		<xs:attribute name="InstructionType" type="stStringMaxLength10Type" use="optional">
			<xs:annotation>
				<xs:documentation>Name of the pre-defined instruction type.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="InstructionText" type="stStringMaxLength4000Type" use="required">
			<xs:annotation>
				<xs:documentation>Free-form instruction text for the given instruction type.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="ctReferencesType">
		<xs:annotation>
			<xs:documentation>List of references.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="Reference" type="ctReferenceType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ctReferenceType">
		<xs:annotation>
			<xs:documentation>Reference.</xs:documentation>
		</xs:annotation>
		<xs:attribute name="Name" type="stStringMaxLength40Type" use="required">
			<xs:annotation>
				<xs:documentation>The name of the reference.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="Value" type="stStringMaxLength254Type" use="optional">
			<xs:annotation>
				<xs:documentation>Free-form text associated with the reference name.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="ctPersonInfoBillToType">
		<xs:annotation>
			<xs:documentation>BillTo address details.</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="ctPersonInfoType">
				<xs:attribute name="Country" type="stStringMaxLength40Type" use="required">
					<xs:annotation>
						<xs:documentation>The unique identifier for a person.</xs:documentation>
					</xs:annotation>
				</xs:attribute>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>

	<xs:complexType name="ctPersonInfoType">
		<xs:annotation>
			<xs:documentation>Party details.</xs:documentation>
		</xs:annotation>
		<xs:attribute name="FirstName" type="stStringMaxLength64Type" use="optional">
			<xs:annotation>
				<xs:documentation>The first name of the person. If last name and first name are not used in separate fields, then both names are written in the FirstName field.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="LastName" type="stStringMaxLength64Type" use="optional">
			<xs:annotation>
				<xs:documentation>The last name of the person. This is used only if person’s first name and last name are used separately.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="Company" type="stStringMaxLength40Type" use="optional">
			<xs:annotation>
				<xs:documentation>The company this person is associated with. In case of company name is known it is written here.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="ZipCode" type="stStringMaxLength35Type" use="optional">
			<xs:annotation>
				<xs:documentation>The zip code in the address.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="City" type="stStringMaxLength35Type" use="optional">
			<xs:annotation>
				<xs:documentation>The city in the address.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="AddressLine1" type="stStringMaxLength70Type" use="optional">
			<xs:annotation>
				<xs:documentation>The address line 1 field.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="AddressLine2" type="stStringMaxLength70Type" use="optional">
			<xs:annotation>
				<xs:documentation>The address line 2 field.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="AddressLine3" type="stStringMaxLength70Type" use="optional">
			<xs:annotation>
				<xs:documentation>The address line 3 field.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="DayPhone" type="stStringMaxLength40Type" use="optional">
			<xs:annotation>
				<xs:documentation>The day time phone at which the person or organization referred to in the address can be called.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="OtherPhone" type="stStringMaxLength40Type" use="optional">
			<xs:annotation>
				<xs:documentation>The alternate phone number at which the person or a predesignated employee of the organization referred to in the address can be called.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="EmailId" type="stStringMaxLength150Type" use="optional">
			<xs:annotation>
				<xs:documentation>The email address at which the person or a predesignated employee of the organization referred to in the address can be contacted.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="ctAdditionalAddressesType">
		<xs:annotation>
			<xs:documentation>List of additional addresses.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="AdditionalAddress" type="ctAdditionalAddressType" minOccurs="0" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="ctAdditionalAddressType">
		<xs:annotation>
			<xs:documentation>Additional address.</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="PersonInfo" type="ctAdditAdd_PersonInfoType" minOccurs="1" maxOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="AddressType" type="stStringMaxLength40Type" use="required">
			<xs:annotation>
				<xs:documentation>Identifies the type of address. Part of unique key.</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>

	<xs:complexType name="ctAdditAdd_PersonInfoType">
		<xs:annotation>
			<xs:documentation>Address information for additional address.</xs:documentation>
		</xs:annotation>
		<xs:complexContent>
			<xs:extension base="ctPersonInfoType">
				<xs:attribute name="PersonId" type="stStringMaxLength35Type" use="optional">
					<xs:annotation>
						<xs:documentation>The unique identifier for a person.</xs:documentation>
					</xs:annotation>
				</xs:attribute>
				<xs:attribute name="Country" type="stStringMaxLength40Type" use="optional">
					<xs:annotation>
						<xs:documentation>The unique identifier for a person.</xs:documentation>
					</xs:annotation>
				</xs:attribute>
			</xs:extension>
		</xs:complexContent>
	</xs:complexType>

	<xs:simpleType name="stStringMaxLength2Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 2 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="2"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength10Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 10 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="10"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength20Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 20 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="20"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength24Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 24 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="24"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength35Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 35 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="35"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength40Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 40 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="40"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength64Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 64 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="64"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength70Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 70 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="70"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength100Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 100 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="100"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength150Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 150 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="150"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength200Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 200 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="200"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength254Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 254 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="254"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength500Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 500 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="500"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength4000Type">
		<xs:annotation>
			<xs:documentation>String with maximum length of 4000 characters.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="4000"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stStringMaxLength1YNType">
		<xs:annotation>
			<xs:documentation>String with maximun length of 1 character and possible values Y or N.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:maxLength value="1"/>
			<xs:pattern value="[YN]"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="stNonNegDecimal14Dig4FractType">
		<xs:annotation>
			<xs:documentation>Non-negative decimal with maximum of 14 total digits and 4 fraction digits.</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:decimal">
			<xs:minInclusive value="0"/>
			<xs:totalDigits value="14"/>
			<xs:fractionDigits value="4"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>
