<?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:dd717="http://www.mf.gov.pl/schematy/EDD/DD717/2020/05/"
           targetNamespace="http://www.mf.gov.pl/schematy/EDD/DD717/2020/05/">
  <!--=============================================-->
  <!--=====              DD717                =====-->
  <!--=====         Raport z kontroli         =====-->
  <!--=============================================-->

  <!--===== 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="DD717" type="dd717:DD717Type" />

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

  <!--===== IE Specific Data Groups Declarations =====-->
  <xs:complexType name="BodyType">
    <xs:sequence>
      <xs:element name="ControlReportEnvelope" type="dd717:ControlReportEnvelopeType" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====            Control Report Envelope             =====-->
  <!--==========================================================-->
  <xs:complexType name="ControlReportEnvelopeType">
    <xs:sequence>
      <xs:element name="Attributes" type="dd717:AttributesType" />
      <xs:element name="HeaderControlReport" type="dd717:HeaderControlReportType" />
      <xs:element name="ControlReport" type="dd717:ControlReportType" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====                   Attributes                   =====-->
  <!--==========================================================-->
  <xs:complexType name="AttributesType">
    <xs:sequence>
      <xs:element name="ControlReportMessageType" type="tcl:ControlReportMessageType" />
      <xs:element name="DateAndTimeOfValidationOfControlReport" type="emcs:DateTimeType" minOccurs="0" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====             Header Control Report              =====-->
  <!--==========================================================-->
  <xs:complexType name="HeaderControlReportType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="(HEADER) CONTROL REPORT" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="ControlReportReference" type="emcs:ControlReportReferenceType" />
      <xs:element name="DeliveryDocumentAdministrativeReferenceCode" type="ddtypes:DeliveryDocumentAdministrativeReferenceCodeType" />
      <xs:element name="SequenceNumber" type="emcs:SequenceNumberType" />
      <xs:element name="ControlOffice" type="dd717:ControlOfficeType" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====                 Control Office                 =====-->
  <!--==========================================================-->
  <xs:complexType name="ControlOfficeType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="CONTROL OFFICE" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="ReferenceNumberOfControlOffice" type="emcs:ExciseOfficeCodeType" minOccurs="0" />
      <xs:element name="MemberStateCode" type="emcs:MemberStateCodeType" minOccurs="0" />
      <xs:element name="ControlOfficeName" type="emcs:ControlOfficeNameType" minOccurs="0" />
      <xs:element name="StreetName" type="emcs:StreetNameType" minOccurs="0" />
      <xs:element name="StreetNumber" type="emcs:StreetNumberType" minOccurs="0" />
      <xs:element name="Postcode" type="emcs:PostcodeType" minOccurs="0" />
      <xs:element name="City" type="emcs:CityType" minOccurs="0" />
      <xs:element name="PhoneNumber" type="emcs:PhoneNumberType" minOccurs="0" />
      <xs:element name="FaxNumber" type="emcs:FaxNumberType" minOccurs="0" />
      <xs:element name="EmailAddress" type="emcs:EmailAddressType" minOccurs="0" />
    </xs:sequence>
    <xs:attribute name="language" type="emcs:LanguageCodeType" use="optional" />
  </xs:complexType>

  <!--==========================================================-->
  <!--=====                 Control Report                 =====-->
  <!--==========================================================-->
  <xs:complexType name="ControlReportType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="CONTROL REPORT" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="DateOfControl" type="emcs:DateType" />
      <xs:element name="PlaceOfControl" type="dd717:LSDPlaceOfControlType" />
      <xs:element name="ControlType" type="tcl:ControlType" />
      <xs:element name="ReasonForControl" type="tcl:ReasonForControl" />
      <xs:element name="ComplementaryOriginReference" type="dd717:LSDComplementaryOriginReferenceType" minOccurs="0" />
      <xs:element name="ControlOfficerIdentity" type="dd717:LSDControlOfficerIdentityType" />
      <xs:element name="GlobalControlConclusion" type="tcl:GlobalControlConclusion" />
      <xs:element name="ControlAtArrivalRequired" type="tcl:Flag" />
      <xs:element name="Flag" type="tcl:Flag" />
      <xs:element name="Comments" type="dd717:LSDCommentsType" minOccurs="0" />
      <xs:element name="PerformedControlAction" type="dd717:PerformedControlActionType" maxOccurs="99" />
      <xs:element name="EvidenceOfEvent" type="dd717:EvidenceOfEventType" minOccurs="0" maxOccurs="9" />
      <xs:element name="UnsatisfactoryReason" type="dd717:UnsatisfactoryReasonType" minOccurs="0" maxOccurs="9" />
      <xs:element name="DDTransportDetails" type="ddtypes:DDTransportDetailsType" minOccurs="0" maxOccurs="99" />
      <xs:element name="BodyControlReport" type="dd717:BodyControlReportType" minOccurs="0" maxOccurs="99" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====            Performed Control Action            =====-->
  <!--==========================================================-->
  <xs:complexType name="PerformedControlActionType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="PERFORMED CONTROL ACTION" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="PerformedControlAction" type="tcl:PerformedControlAction" />
      <xs:element name="OtherControlAction" type="dd717:LSDOtherControlActionType" minOccurs="0" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====               Evidence Of Event                =====-->
  <!--==========================================================-->
  <xs:complexType name="EvidenceOfEventType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="EVIDENCE OF EVENT" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="IssuingAuthority" type="dd717:LSDIssuingAuthorityType" minOccurs="0" />
      <xs:element name="EvidenceTypeCode" type="emcs:EvidenceTypeCodeType" />
      <xs:element name="EvidenceTypeComplement" type="dd717:LSDEvidenceTypeComplementType" minOccurs="0" />
      <xs:element name="ReferenceOfEvidence" type="dd717:LSDReferenceOfEvidenceType" minOccurs="0" />
      <xs:element name="ImageOfEvidence" type="xs:base64Binary" minOccurs="0" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====             Unsatisfactory Reason              =====-->
  <!--==========================================================-->
  <xs:complexType name="UnsatisfactoryReasonType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="UNSATISFACTORY REASON" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="UnsatisfactoryReasonCode" type="emcs:UnsatisfactoryReasonCodeType" />
      <xs:element name="ComplementaryInformation" type="dd717:LSDComplementaryInformationType" minOccurs="0" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====               Body Control Report              =====-->
  <!--==========================================================-->
  <xs:complexType name="BodyControlReportType">
    <xs:annotation>
      <xs:documentation>
        <doc:description value="(BODY) CONTROL REPORT" />
      </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="BodyRecordUniqueReference" type="emcs:BodyRecordUniqueReferenceType" />
      <xs:element name="IndicatorOfShortageOrExcess" type="tcl:IndicatorOfShortageOrExcess" minOccurs="0" />
      <xs:element name="ObservedShortageOrExcess" type="emcs:ObservedShortageOrExcessType" minOccurs="0" />
      <xs:element name="Comments" type="dd717:LSDCommentsType" minOccurs="0" />
      <xs:element name="UnsatisfactoryReason" type="dd717:UnsatisfactoryReasonType" minOccurs="0" maxOccurs="9" />
    </xs:sequence>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====                  LSD Comments                  =====-->
  <!--==========================================================-->
  <xs:complexType name="LSDCommentsType">
    <xs:simpleContent>
      <xs:extension base="emcs:CommentsType">
        <xs:attribute name="language" type="emcs:LanguageCodeType" use="required" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====          LSD Complementary Information         =====-->
  <!--==========================================================-->
  <xs:complexType name="LSDComplementaryInformationType">
    <xs:simpleContent>
      <xs:extension base="emcs:ComplementaryInformationType">
        <xs:attribute name="language" type="emcs:LanguageCodeType" use="required" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====       LSD Complementary Origin Reference       =====-->
  <!--==========================================================-->
  <xs:complexType name="LSDComplementaryOriginReferenceType">
    <xs:simpleContent>
      <xs:extension base="emcs:ComplementaryOriginReferenceType">
        <xs:attribute name="language" type="emcs:LanguageCodeType" use="required" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====          LSD Control Officer Identity          =====-->
  <!--==========================================================-->
  <xs:complexType name="LSDControlOfficerIdentityType">
    <xs:simpleContent>
      <xs:extension base="emcs:ControlOfficerIdentityType">
        <xs:attribute name="language" type="emcs:LanguageCodeType" use="required" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====          LSD Evidence Type Complement          =====-->
  <!--==========================================================-->
  <xs:complexType name="LSDEvidenceTypeComplementType">
    <xs:simpleContent>
      <xs:extension base="emcs:EvidenceTypeComplementType">
        <xs:attribute name="language" type="emcs:LanguageCodeType" use="required" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====              LSD Issuing Authority             =====-->
  <!--==========================================================-->
  <xs:complexType name="LSDIssuingAuthorityType">
    <xs:simpleContent>
      <xs:extension base="emcs:IssuingAuthorityType">
        <xs:attribute name="language" type="emcs:LanguageCodeType" use="required" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====            LSD Other Control Action            =====-->
  <!--==========================================================-->
  <xs:complexType name="LSDOtherControlActionType">
    <xs:simpleContent>
      <xs:extension base="emcs:OtherControlActionType">
        <xs:attribute name="language" type="emcs:LanguageCodeType" use="required" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====              LSD Place Of Control              =====-->
  <!--==========================================================-->
  <xs:complexType name="LSDPlaceOfControlType">
    <xs:simpleContent>
      <xs:extension base="emcs:PlaceOfControlType">
        <xs:attribute name="language" type="emcs:LanguageCodeType" use="required" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====            LSD Reference Of Evidence           =====-->
  <!--==========================================================-->
  <xs:complexType name="LSDReferenceOfEvidenceType">
    <xs:simpleContent>
      <xs:extension base="emcs:ReferenceOfEvidenceType">
        <xs:attribute name="language" type="emcs:LanguageCodeType" use="required" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!--==========================================================-->
  <!--=====              LSD Seal Information              =====-->
  <!--==========================================================-->
  <xs:complexType name="LSDSealInformationType">
    <xs:simpleContent>
      <xs:extension base="emcs:SealInformationType">
        <xs:attribute name="language" type="emcs:LanguageCodeType" use="required" />
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:schema>