<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.00"
           xmlns:emcs="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:EMCS:V2.02"
           xmlns:tms="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:TMS:V2.02"
           xmlns:tcl="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:TCL:V2.02"
           xmlns:doc="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:DOC:V2.02"
           xmlns:ddtypes="http://www.mf.gov.pl/schematy/EDD/DDTYPES/2020/05/"
           xmlns:dd813="http://www.mf.gov.pl/schematy/EDD/DD813/2020/05/"
           targetNamespace="http://www.mf.gov.pl/schematy/EDD/DD813/2020/05/">
  <!--=============================================-->
  <!--=====              DD813                =====-->
  <!--=====       CHANGE OF DESTINATION       =====-->
  <!--=============================================-->

  <!--===== Imports =====-->
  <xs:import namespace="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:EMCS:V2.02" schemaLocation="types.xsd" />
  <xs:import namespace="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:TMS:V2.02" schemaLocation="tms.xsd" />
  <xs:import namespace="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:TCL:V2.02" schemaLocation="tcl.xsd" />
  <xs:import namespace="urn:publicid:-:EC:DGTAXUD:EMCS:PHASE3:DOC:V2.02" schemaLocation="doc.xsd" />
  <xs:import namespace="http://www.mf.gov.pl/schematy/EDD/DDTYPES/2020/05/" schemaLocation="ddTypes.xsd" />

  <!--===== Root Element =====-->
  <xs:element name="DD813" type="dd813:DD813Type" />

  <!--===== EMCS Data Groups Declarations =====-->
  <xs:complexType name="DD813Type">
    <xs:sequence>
      <xs:element name="Header" type="tms:HeaderType" />
      <xs:element name="Body" type="dd813:BodyType" />
    </xs:sequence>
  </xs:complexType>

  <!--===== IE Specific Data Groups Declarations =====-->
  <xs:complexType name="BodyType">
    <xs:sequence>
      <xs:element name="ChangeOfDestination" type="dd813:ChangeOfDestinationType" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====             Change Of Destination              =====-->
  <!--==========================================================-->
  <xs:complexType name="ChangeOfDestinationType">
    <xs:sequence>
      <xs:element name="UpdateEDD" type="dd813:UpdateEDDType" minOccurs="1" maxOccurs="1"/>
      <xs:element name="DestinationChanged" type="dd813:DestinationChangedType" />
      <xs:element name="TransportDetails" type="ddtypes:DDTransportDetailsType" minOccurs="0" maxOccurs="99" />
      <xs:element name="DateAndTimeOfValidationOfChangeOfDestination" type="emcs:DateTimeType" minOccurs="0" maxOccurs="1"/>
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====                   Update EDD                   =====-->
  <!--==========================================================-->
  <xs:complexType name="UpdateEDDType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="(UPDATE) E-DD" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="DocumentReference" type="ddtypes:UpdatedAdministrativeReferenceType" minOccurs="1" maxOccurs="1" />
      <xs:element name="JourneyTime" type="emcs:JourneyTimeType" minOccurs="0" />
      <xs:element name="InvoiceDate" type="emcs:DateType" minOccurs="0" />
      <xs:element name="InvoiceNumber" type="emcs:InvoiceNumberType" minOccurs="0" />
      <xs:element name="TransportMode" type="ddtypes:DDTransportModeType" />
      <xs:element name="DeliveryClosingFlag" minOccurs="1" maxOccurs="1" type="ddtypes:DeliveryClosingFlagType"/>
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====              Destination Changed               =====-->
  <!--==========================================================-->
  <xs:complexType name="DestinationChangedType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="(DESTINATION) CHANGED" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="NewConsigneeTrader" type="ddtypes:DDTraderType" minOccurs="1" maxOccurs="1"/>
      <xs:element name="DeliveryPlaceTrader" type="ddtypes:DDTraderType" minOccurs="0" maxOccurs="1"/>
      <xs:element name="DeliveryPlaceCustomsOffice" type="ddtypes:DDCustomsOfficeType" minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
  </xs:complexType>

</xs:schema>