<?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:ddtypes="http://www.mf.gov.pl/schematy/EDD/DDTYPES/2020/05/"
           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:dd839="http://www.mf.gov.pl/schematy/EDD/DD839/2020/05/"
           targetNamespace="http://www.mf.gov.pl/schematy/EDD/DD839/2020/05/">
  <!--=====================================================-->
  <!--=====                   DD839                   =====-->
  <!--=====         CUSTOMS REJECTION OF E-DD         =====-->
  <!--=====================================================-->
  
  <!--===== 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="DD839" type="dd839:DD839Type" />
  
  <!--===== EMCS Data Groups Declarations =====-->
  <xs:complexType name="DD839Type">
    <xs:sequence>
      <xs:element name="Header" type="tms:HeaderType" />
      <xs:element name="Body" type="dd839:BodyType" />
    </xs:sequence>
  </xs:complexType>
  
  <!--===== IE Specific Data Groups Declarations =====-->
  <xs:complexType name="BodyType">
    <xs:sequence>
      <xs:element name="RefusalByCustoms" type="dd839:RefusalByCustomsType" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====               Refusal By Customs               =====-->
  <!--==========================================================-->
  <xs:complexType name="RefusalByCustomsType">
    <xs:sequence>
      <xs:element name="Attributes" type="dd839:AttributesType" />
      <xs:element name="ConsigneeTrader" type="ddtypes:DDTraderType" minOccurs="0" maxOccurs="1" />
      <xs:element name="DeliveryPlaceTrader" type="ddtypes:DDTraderType" minOccurs="0" maxOccurs="1" />
      <xs:element name="ExportPlaceCustomsOffice" type="ddtypes:DDCustomsOfficeType" minOccurs="0" maxOccurs="1" />
      <xs:element name="ExportCrossCheckingDiagnoses" type="dd839:ExportCrossCheckingDiagnosesType" minOccurs="0" />
      <xs:element name="Rejection" type="dd839:RejectionType" />
      <xs:element name="CEddVal" type="ddtypes:AdministrativeReferenceType" minOccurs="0" maxOccurs="99" />
      <xs:element name="NEddSub" type="dd839:NEddSubType" minOccurs="0" maxOccurs="1" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====                   Attributes                   =====-->
  <!--==========================================================-->
  <xs:complexType name="AttributesType">
    <xs:sequence>
      <xs:element name="DateAndTimeOfIssuance" type="emcs:DateTimeType" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====        Export Cross Checking Diagnoses         =====-->
  <!--==========================================================-->
  <xs:complexType name="ExportCrossCheckingDiagnosesType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="EXPORT CROSS CHECKING DIAGNOSES" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="LocalReferenceNumber" type="emcs:LocalReferenceNumberType" minOccurs="0" maxOccurs="1" />
      <xs:element name="DocumentReferenceNumber" type="emcs:DocumentReferenceNumberType" minOccurs="0" maxOccurs="1" />
      <xs:element name="Diagnosis" type="dd839:DiagnosisType" minOccurs="1" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====                   Diagnosis                    =====-->
  <!--==========================================================-->
  <xs:complexType name="DiagnosisType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="DIAGNOSIS" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="DeliveryDocumentAdministrativeReferenceCode" type="ddtypes:DeliveryDocumentAdministrativeReferenceCodeType" />
      <xs:element name="BodyRecordUniqueReference" type="emcs:BodyRecordUniqueReferenceType" />
      <xs:element name="DiagnosisCode" type="tcl:DiagnosisCode" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====                   Rejection                    =====-->
  <!--==========================================================-->
  <xs:complexType name="RejectionType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="REJECTION" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="RejectionDateAndTime" type="emcs:DateTimeType" />
      <xs:element name="RejectionReasonCode" type="tcl:CustomsRejectionReasonCode" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====                   N Edd Sub                    =====-->
  <!--==========================================================-->
  <xs:complexType name="NEddSubType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="N_EDD_SUB" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="LocalReferenceNumber" type="ddtypes:DeliveryDocumentLocalReferenceNumberType" />
    </xs:sequence>
  </xs:complexType>
</xs:schema>