﻿<?xml version="1.0" encoding="utf-8"?>
<!--
Version: 1
Revision date: 2022-06-30

Changelog:
2020-06-11: Added Version, Revision date and Changelog to XSD.
            Added Simple types:
            * guid
            * string_maxlength25, string_maxlength50, string_maxlength100, string_maxlength255, string_maxlength4096, string_maxlength8192 and string_maxlengthinfinite
            * documenttype
2021-02-22: Pattern of simple type 'guid' corrected: removed brackets at the beginning and end
2021-03-18: Order element expanded: deliverytype, backhauling, acknowledgementreceiptrequired
			Customer element expanded: ultimateaddress
2021-07-15: Orderrow element expanded: totalcontent
2021-08-19: Enumeration documenttypes: values PRODUCTS + RELATIONSWITHPRODUCTS were misspelled
2022-06-30: Added Simple type: string_maxlength11
			Order element expanded: deliverytime
			Orderrow element changed: barcode is no longer mandatory
2022-11-07: Data type from element ordernumberexternal changed from string_maxlength50 to string_maxlength255
-->
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:simpleType name="guid">
    <xs:annotation>
      <xs:documentation xml:lang="en">The representation of a GUID, generally the id of an element.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="string_maxlength11">
    <xs:restriction base="xs:string">
      <xs:maxLength value="11" />
    </xs:restriction>
  </xs:simpleType>  
  <xs:simpleType name="string_maxlength25">
    <xs:restriction base="xs:string">
      <xs:maxLength value="25" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="string_maxlength50">
    <xs:restriction base="xs:string">
      <xs:maxLength value="50" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="string_maxlength100">
    <xs:restriction base="xs:string">
      <xs:maxLength value="100" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="string_maxlength255">
    <xs:restriction base="xs:string">
      <xs:maxLength value="255" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="string_maxlength4096">
    <xs:restriction base="xs:string">
      <xs:maxLength value="4096" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="string_maxlength8192">
    <xs:restriction base="xs:string">
      <xs:maxLength value="8192" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="string_maxlengthinfinite">
    <xs:restriction base="xs:string" />
  </xs:simpleType>
  <xs:simpleType name="color" final="restriction">
    <xs:restriction base="xs:string">
      <xs:enumeration value="green" />
      <xs:enumeration value="red" />
      <xs:enumeration value="blue" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="documenttypes" final="restriction">
    <xs:annotation>
      <xs:documentation xml:lang="en">Enumeration with allowed document types. Case-sensitive.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="[Pp][Rr][Oo][Dd][Uu][Cc][Tt][Ss]" />
      <xs:pattern value="[Rr][Ee][Ll][Aa][Tt][Ii][Oo][Nn][Ww][Ii][Tt][Hh][Pp][Rr][Oo][Dd][Uu][Cc][Tt][Ss]" />
      <xs:pattern value="[Rr][Ee][Ll][Aa][Tt][Ii][Oo][Nn][Ss]" />
      <xs:pattern value="[Pp][Rr][Ii][Cc][Ee][Ss]" />
      <xs:pattern value="[Oo][Rr][Dd][Ee][Rr][Ss]" />
      <xs:pattern value="[Oo][Rr][Dd][Ee][Rr][Rr][Ee][Cc][Ee][Ii][Pp][Tt][Ss]" />
      <xs:pattern value="[Oo][Rr][Dd][Ee][Rr][Dd][Ee][Ll][Ii][Vv][Ee][Rr][Ii][Ee][Ss]" />
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="document">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="header">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="datetimecreatedutc" type="xs:dateTime" />
              <xs:element name="referencenumber" type="string_maxlength100" />
              <xs:element name="documenttype" type="documenttypes" />
              <xs:element name="version" type="xs:unsignedByte" />
              <xs:element name="sender" minOccurs="0">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="name" type="string_maxlength255" minOccurs="0" />
                    <xs:element name="vatnumber" type="string_maxlength25" minOccurs="0" />
                    <xs:element name="cocnumber" type="string_maxlength50" minOccurs="0" />
                    <xs:element name="connectid" type="string_maxlength25" minOccurs="0" />
                    <xs:element name="address" minOccurs="0">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="streetname" type="string_maxlength255" minOccurs="0" />
                          <xs:element name="cityname" type="string_maxlength100" minOccurs="0"/>
                          <xs:element name="postalzone" type="string_maxlength25" minOccurs="0"/>
                          <xs:element name="country" minOccurs="0">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="string_maxlength255">
                                  <xs:attribute name="code" type="string_maxlength25" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                          <xs:element name="gs1gln" type="string_maxlength25" minOccurs="0" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="contact" minOccurs="0">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="phone" type="string_maxlength50" minOccurs="0" />
                          <xs:element name="email" type="string_maxlength255" minOccurs="0" />
                          <xs:element name="website" type="string_maxlength255" minOccurs="0" />
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="receiver" minOccurs="0">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="idrelation" type="guid" minOccurs="0" />
                    <xs:element name="code" type="string_maxlength25" minOccurs="0" />
                    <xs:element name="name" type="string_maxlength255" minOccurs="0" />
                    <xs:element name="creditornumber" type="string_maxlength50" minOccurs="0" />
                    <xs:element name="debtornumber" type="string_maxlength50" minOccurs="0" />
                    <xs:element name="vatnumber" type="string_maxlength25" minOccurs="0" />
                    <xs:element name="cocnumber" type="string_maxlength50" minOccurs="0" />
                    <xs:element name="gs1gln" type="string_maxlength25" minOccurs="0" />
                    <xs:element name="connectid" type="string_maxlength25" minOccurs="0" />
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="data" minOccurs="0">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="orders">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="order" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="idorder" type="guid" minOccurs="0" />
                          <xs:element name="ordernumber" type="string_maxlength25" />
                          <xs:element name="ordernumberexternal" type="string_maxlength255" minOccurs="0" />
                          <xs:element name="orderdate" type="xs:date" minOccurs="0" />
                          <xs:element name="orderdesireddeliverydate" type="xs:date" minOccurs="0" />
                          <xs:element name="orderactualdeliverydate" type="xs:date" minOccurs="0" />
                          <xs:element name="deliverytime" minOccurs="0">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="string_maxlength11">
                                  <xs:attribute name="after" type="xs:time" />
								  <xs:attribute name="before" type="xs:time" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
                          <xs:element name="deliverytype" minOccurs="0">
                            <xs:complexType>
                              <xs:simpleContent>
                                <xs:extension base="string_maxlength25">
                                  <xs:attribute name="code" type="xs:unsignedByte" />
                                </xs:extension>
                              </xs:simpleContent>
                            </xs:complexType>
                          </xs:element>
						  <xs:element name="backhauling" type="xs:boolean" minOccurs="0" />
                          <xs:element name="additionaldescription" type="string_maxlength4096" minOccurs="0" />
						  <xs:element name="acknowledgementreceiptrequired" type="xs:boolean" minOccurs="0" />
                          <xs:element name="supplier" minOccurs="0">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="idrelation" type="guid" minOccurs="0" />
                                <xs:element name="code" type="string_maxlength25" minOccurs="0" />
                                <xs:element name="name" type="string_maxlength255" minOccurs="0" />
                                <xs:element name="creditornumber" type="string_maxlength50" minOccurs="0" />
                                <xs:element name="debtornumber" type="string_maxlength50" minOccurs="0" />
                                <xs:element name="vatnumber" type="string_maxlength25" minOccurs="0" />
                                <xs:element name="cocnumber" type="string_maxlength50" minOccurs="0" />
                                <xs:element name="gs1gln" type="string_maxlength25" minOccurs="0" />
                                <xs:element name="connectid" type="string_maxlength25" minOccurs="0" />
                                <xs:element name="address" minOccurs="0">
                                  <xs:complexType>
                                    <xs:sequence>
                                      <xs:element name="idaddress" type="guid" minOccurs="0" />
                                      <xs:element name="code" type="string_maxlength25" minOccurs="0" />
                                      <xs:element name="name" type="string_maxlength255" minOccurs="0" />
                                      <xs:element name="streetname" type="string_maxlength255" minOccurs="0" />
                                      <xs:element name="cityname" type="string_maxlength100" minOccurs="0" />
                                      <xs:element name="postalzone" type="string_maxlength25" minOccurs="0" />
                                      <xs:element name="country" minOccurs="0">
                                        <xs:complexType>
                                          <xs:simpleContent>
                                            <xs:extension base="string_maxlength255">
                                              <xs:attribute name="code" type="string_maxlength25" />
                                            </xs:extension>
                                          </xs:simpleContent>
                                        </xs:complexType>
                                      </xs:element>
                                      <xs:element name="gs1gln" type="string_maxlength25" minOccurs="0" />
                                    </xs:sequence>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                          <xs:element name="customer" minOccurs="0">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="idrelation" type="guid" minOccurs="0" />
                                <xs:element name="code" type="string_maxlength25" minOccurs="0" />
                                <xs:element name="name" type="string_maxlength255" minOccurs="0" />
                                <xs:element name="creditornumber" type="string_maxlength50" minOccurs="0" />
                                <xs:element name="debtornumber" type="string_maxlength50" minOccurs="0" />
                                <xs:element name="vatnumber" type="string_maxlength25" minOccurs="0" />
                                <xs:element name="cocnumber" type="string_maxlength50" minOccurs="0" />
                                <xs:element name="gs1gln" type="string_maxlength25" minOccurs="0" />
                                <xs:element name="connectid" type="string_maxlength25" minOccurs="0" />
                                <xs:element name="address" minOccurs="0">
                                  <xs:complexType>
                                    <xs:sequence>
                                      <xs:element name="idaddress" type="guid" minOccurs="0" />
                                      <xs:element name="code" type="string_maxlength25" minOccurs="0" />
                                      <xs:element name="name" type="string_maxlength255" minOccurs="0" />
                                      <xs:element name="streetname" type="string_maxlength255" minOccurs="0" />
                                      <xs:element name="cityname" type="string_maxlength100" minOccurs="0" />
                                      <xs:element name="postalzone" type="string_maxlength25" minOccurs="0" />
                                      <xs:element name="country" minOccurs="0">
                                        <xs:complexType>
                                          <xs:simpleContent>
                                            <xs:extension base="string_maxlength255">
                                              <xs:attribute name="code" type="string_maxlength25" />
                                            </xs:extension>
                                          </xs:simpleContent>
                                        </xs:complexType>
                                      </xs:element>
                                      <xs:element name="gs1gln" type="string_maxlength25" minOccurs="0" />
                                    </xs:sequence>
                                  </xs:complexType>
                                </xs:element>
                                <xs:element name="ultimateaddress" minOccurs="0">
                                  <xs:complexType>
                                    <xs:sequence>
                                      <xs:element name="idaddress" type="guid" minOccurs="0" />
                                      <xs:element name="code" type="string_maxlength25" minOccurs="0" />
                                      <xs:element name="name" type="string_maxlength255" minOccurs="0" />
                                      <xs:element name="streetname" type="string_maxlength255" minOccurs="0" />
                                      <xs:element name="cityname" type="string_maxlength100" minOccurs="0" />
                                      <xs:element name="postalzone" type="string_maxlength25" minOccurs="0" />
                                      <xs:element name="country" minOccurs="0">
                                        <xs:complexType>
                                          <xs:simpleContent>
                                            <xs:extension base="string_maxlength255">
                                              <xs:attribute name="code" type="string_maxlength25" />
                                            </xs:extension>
                                          </xs:simpleContent>
                                        </xs:complexType>
                                      </xs:element>
                                      <xs:element name="gs1gln" type="string_maxlength25" minOccurs="0" />
                                    </xs:sequence>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                          <xs:element name="orderrows" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="orderrow" minOccurs="0" maxOccurs="unbounded">
                                  <xs:complexType>
                                    <xs:sequence>
                                      <xs:element name="idorderrow" type="guid" minOccurs="0" />
                                      <xs:element name="orderrownumber" type="xs:unsignedByte" minOccurs="0" />
                                      <xs:element name="orderrownumberexternal" type="string_maxlength50" minOccurs="0" />
                                      <xs:element name="product" minOccurs="0">
                                        <xs:complexType>
                                          <xs:sequence>
                                            <xs:element name="idproduct" type="guid" minOccurs="0" />
                                            <xs:element name="type" minOccurs="0">
                                              <xs:complexType>
                                                <xs:simpleContent>
                                                  <xs:extension base="string_maxlength25">
                                                    <xs:attribute name="code" type="xs:unsignedByte" />
                                                  </xs:extension>
                                                </xs:simpleContent>
                                              </xs:complexType>
                                            </xs:element>
                                            <xs:element name="code" type="string_maxlength25" minOccurs="0" />
                                            <xs:element name="codesupplier" type="string_maxlength25" minOccurs="0" />
                                            <xs:element name="codecustomer" type="string_maxlength25" minOccurs="0" />
                                            <xs:element name="name" type="string_maxlength255" minOccurs="0" />
                                            <xs:element name="composition" minOccurs="0">
                                              <xs:complexType>
                                                <xs:sequence>
                                                  <xs:element name="value" type="xs:decimal" minOccurs="0" />
                                                  <xs:element name="valueuom" type="string_maxlength255" minOccurs="0" />
                                                  <xs:element name="content" type="xs:decimal" minOccurs="0" />
                                                  <xs:element name="contentuom" type="string_maxlength255" minOccurs="0" />
                                                  <xs:element name="isbaseuom" type="xs:boolean" minOccurs="0" />
                                                  <xs:element name="isweightuom" type="xs:boolean" minOccurs="0" />
                                                </xs:sequence>
                                                <xs:attribute name="summary" type="string_maxlength255" />
                                              </xs:complexType>
                                            </xs:element>
                                          </xs:sequence>
                                        </xs:complexType>
                                      </xs:element>
                                      <xs:element name="barcode" type="string_maxlength255" minOccurs="0" />
                                      <xs:element name="orderedquantity" type="xs:decimal" />
                                      <xs:element name="deliveredquantity" type="xs:decimal" minOccurs="0" />
									  <xs:element name="totalcontent" type="xs:decimal" minOccurs="0" />
                                      <xs:element name="price" type="xs:decimal" minOccurs="0" />
                                      <xs:element name="pricebase" type="xs:decimal" minOccurs="0" />
                                      <xs:element name="vatpercent" type="xs:decimal" minOccurs="0" />
                                      <xs:element name="additionaldescription" type="string_maxlength255" minOccurs="0" />
                                    </xs:sequence>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>