<?xml version="1.0" encoding="UTF-8"?>

<!--
	Current Version: 1.15
	Version History:
	0.1 	04/10/2019:	Schema Created
	1.01	03/04/2020:	There are structural updates due to the move to EUCDM
						version 5.1.
						For more details on the changes, please refer to the AIS
						Message Structure and Schema Change Log spreadsheet.
						
	1.02	17/06/2020: All the Business Rules and Conditions have changed from the previous version.
 						There is a detailed list of changes in the "AIS Schema Change Log" document. 
	1.03	08/09/2020: The Business Rules and Conditions have been updated.
						The amendments and the invalidation messages for D3 ETD04, ETD05, ETD09,
						ETD13 and ETD04 have been removed.
						The Refunds messages RF409, RF415 and RF416 have been revised.
						The Good Shipment Item list now support up to 99.999 Good Items.
 						There is a detailed list of changes in the "AIS Schema Change Log" document. 
	1.04	10/11/2020: The Business Rules and Conditions have been updated.
						The Code lists have been updated.
						The optionality of several fields has changed.
						There is a detailed list of changes in the "AIS Schema Change Log" document.
	1.05	23/12/2020: The type of the XML element "TypeOfPackages" was changed from n16,6 to an1..2,
						wherever the element is used.
						There is a detailed list of changes in the "AIS Schema Change Log" document.
	1.06	19/01/2021: The version introduces no changes in the schemas. It only brings changes in the
						Business Rules, plus one new item in the "Common documents" code list..
						There is a detailed list of changes in the "AIS Schema Change Log" document.
	1.07	30/03/2021: This version includes the new messages for the H7 declarations.
						The new H7 declarations comply with the EUCDM 6.0 r1. This has a completely
						different structure than the H1-H6 declarations that comply with the EUCDM 5.1.
	1.08	17/06/2021: The version introduces no changes in the schemas. It only brings changes in the
						Business Rules, changes in the optionality of XML elements for H7 declarations
						and three new elements in the XML declarations.
						There is a detailed list of changes in the "AIS Schema Change Log" document.
	1.09	20/09/2021: The version introduces no changes in the schemas. It only brings changes in the
						Business Rules, changes in the optionality of XML elements and in the links
						between XML elements anc Code Lists.
						There is a detailed list of changes in the "AIS Schema Change Log" document.
	
	1.10	07/10/2021: The messages H7/RD409, H7/RD415 and H7/RD416 have been removed from the H7
						specifications. The message were never used in the H7 business.
						There are minor changes in XML element definitions. 
						There is a detailed list of changes in the "AIS Schema Change Log" document.
	1.11	23/11/2021: The length of the XML element “RejectionReason” is now 350 is all messages and usages.
						There are minor changes in XML element definitions. 
						There is a detailed list of changes in the "AIS Schema Change Log" document.
	1.12	14/02/2022: The xsds of RF415 and RF409 for AIS and H7 have been modified. The legal basis code (an1)
						and te legal basis subdivision (an2) were merged into one element, the new legal basis
						code (an3).
						There is a detailed list of changes in the "AIS Schema Change Log" document.
	1.13	27/04/2022: The "Parties" and the "Declarant" complex XML elements were optional in the IM414 (AIS)
						and now are mandatory.
						The structure of the Authorisation_8f complex XML element  has been significantly revamped.
						There is a detailed list of changes in the "AIS Schema Change Log" document.
	1.14	14/06/2022: No changes have been made in the structures of the XML messages.

	1.15	18/11/2022: Minor changes in the IM415 and the IM413 for AIS.
						There is a detailed list of changes in the "AIS Schema Change Log" document.
-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:doc="http://www.ros.ie/schemas/customs/doc"
    xmlns:base="http://www.ros.ie/schemas/customs/base"
    xmlns:simple="http://www.ros.ie/schemas/customs/simple"
    xmlns:complex="http://www.ros.ie/schemas/customs/complex"
    xmlns="http://www.ros.ie/schemas/customs/RD416"
    targetNamespace="http://www.ros.ie/schemas/customs/RD416" elementFormDefault="qualified"
    version="1.00">



    <!--===== Includes =====-->
    <xs:import namespace="http://www.ros.ie/schemas/customs/base" schemaLocation="AIS_base.xsd"/>
    <xs:import namespace="http://www.ros.ie/schemas/customs/simple" schemaLocation="AIS_simple.xsd"/>
    <xs:import namespace="http://www.ros.ie/schemas/customs/complex"
        schemaLocation="AIS_complex.xsd"/>

    <!--===== Root Element =====-->
    <xs:element name="RD416" type="RD416">
        <xs:annotation>
            <xs:documentation>
                <doc:description value="Application for deposit refund rejection"/>
            </xs:documentation>
        </xs:annotation>
    </xs:element>
    <xs:complexType name="RD416">
        <xs:sequence>
            <xs:element name="Header" type="HeaderType">
                <xs:annotation>
                    <xs:documentation>
                        <doc:description value="Header"/>
                        </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="FunctionalError" type="complex:FunctionalErrorType" minOccurs="0"
                maxOccurs="unbounded">
                <xs:annotation>
                    <xs:documentation>
                        <doc:description value="Functional Error"/>
                    </xs:documentation>
                </xs:annotation>
            </xs:element>

        </xs:sequence>
    </xs:complexType>


    <!-- HeaderType -->
    <xs:complexType name="HeaderType">
        <xs:sequence>
            <xs:element name="ApplicationReferenceId" type="simple:ApplicationReferenceId_type"
                minOccurs="1" maxOccurs="1">
                <xs:annotation>
                    <xs:documentation>
                        <doc:description value="Application Reference Id"/>
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="RejectionDate" type="simple:Date_type" minOccurs="1" maxOccurs="1">
                <xs:annotation>
                    <xs:documentation><doc:description value="Application Rejection Date"/></xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="RejectionReason" type="simple:FreeText350_type" minOccurs="0"
                maxOccurs="1">
                <xs:annotation>
                    <xs:documentation><doc:description value="Application Rejection Reason"/></xs:documentation>
                </xs:annotation>
            </xs:element>
            <xs:element name="Applicant" type="simple:TraderIdentification_type" minOccurs="1">
                <xs:annotation>
                    <xs:documentation>
                        <doc:description value="Applicant EORI number"/>
                    </xs:documentation>
                </xs:annotation>
            </xs:element>
        </xs:sequence>
    </xs:complexType>



</xs:schema>
