<?xml version="1.0" encoding="UTF-8"?>
<!-- 
(C) KDPW S.A.
Company: KDPW
Unit: KDPW_TR
System: kdpw_stream
Message name: auth.rlt.002.02
Description: EMIR - Message used to define relations between RSE and ERRs
Creation date: 2023-04-05
Last changed: 2023-11-30
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn:kdpw:xsd:auth.rlt.002.02" targetNamespace="urn:kdpw:xsd:auth.rlt.002.02" elementFormDefault="qualified" attributeFormDefault="unqualified">
  <xs:annotation>
    <xs:documentation source="Name" xml:lang="EN">EMIR - Entity relations message</xs:documentation>
    <xs:documentation source="Definition" xml:lang="EN">EMIR - Message used to define relations between RSE and ERRs</xs:documentation>
  </xs:annotation>
  <xs:element name="KDPWDocument" type="KDPWDocument">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">KDPW_TR system message</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">KDPW_TR system message</xs:documentation>
    </xs:annotation>
  </xs:element>
  <xs:complexType name="RelationReferenceData">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">Relation data</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">Relation reference data</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="NttyRspnsblForRpt" type="EntityResponsibleForReport">
        <xs:annotation>
          <xs:documentation source="Name" xml:lang="EN">Entity responsible for report</xs:documentation>
          <xs:documentation source="Definition" xml:lang="EN">According to jurisdictional requirements, identification of the entity with the legal obligation or responsibility to report.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="EmailAddress">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">EmailAddress</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">Email address</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:maxLength value="256"/>
      <xs:pattern value="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="EntityRelationsData">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">Relation data</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">Realation data</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:choice>
        <xs:element name="New" type="RelationReferenceData">
          <xs:annotation>
            <xs:documentation source="Name" xml:lang="EN">New relation data or modification of existing relation data</xs:documentation>
            <xs:documentation source="Definition" xml:lang="EN">New relation data or modification of existing relation data</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="Cxl" type="RelationCancellationData">
          <xs:annotation>
            <xs:documentation source="Name" xml:lang="EN">Relation cancellation</xs:documentation>
            <xs:documentation source="Definition" xml:lang="EN">Relation cancellation</xs:documentation>
          </xs:annotation>
        </xs:element>
      </xs:choice>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="GeneralInformation">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">General information</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">General information</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="SubmitgAgt" type="LEIIdentifier">
        <xs:annotation>
          <xs:documentation source="Name" xml:lang="EN">Report submitting entity Id</xs:documentation>
          <xs:documentation source="Definition" xml:lang="EN">Report submitting entity Id</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="SndrMsgRef" type="Max16Text">
        <xs:annotation>
          <xs:documentation source="Name" xml:lang="EN">Sender message reference</xs:documentation>
          <xs:documentation source="Definition" xml:lang="EN">Sender message reference</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="KDPWDocument">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">KDPW_TR system message</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">KDPW_TR system message </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="auth.rlt.002.02" type="auth.rlt.002.02" minOccurs="1" maxOccurs="10000">
        <xs:annotation>
          <xs:documentation source="Name" xml:lang="EN">Entity relations message</xs:documentation>
          <xs:documentation source="Definition" xml:lang="EN">Entity relations message</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="Sndr" type="KDPWMemberIdentifier" use="required">
      <xs:annotation>
        <xs:documentation source="Name" xml:lang="EN">Senders KDPW institution code</xs:documentation>
        <xs:documentation source="Definition" xml:lang="EN">Senders KDPW institution code</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="Rcvr" type="KDPWMemberIdentifier" use="required">
      <xs:annotation>
        <xs:documentation source="Name" xml:lang="EN">Receivers KDPW institution code</xs:documentation>
        <xs:documentation source="Definition" xml:lang="EN">Receivers KDPW institution code</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
  <xs:simpleType name="KDPWMemberIdentifier">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">KDPW institution code</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">KDPW institution code</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:whiteSpace value="collapse"/>
      <xs:minLength value="4"/>
      <xs:maxLength value="4"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="LEIIdentifier">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">LEIIdentifier</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">Legal Entity Identifier is a code allocated to a party as described in ISO 17442 "Financial Services - Legal Entity Identifier (LEI)".</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:pattern value="[A-Z0-9]{18,18}[0-9]{2,2}"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="RelationCancellationData">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">Relation cancellation</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">Relation cancellation</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="NttyRspnsblForRpt" type="LEIIdentifier">
        <xs:annotation>
          <xs:documentation source="Name" xml:lang="EN">Entity responsible for report</xs:documentation>
          <xs:documentation source="Definition" xml:lang="EN">According to jurisdictional requirements, identification of the entity with the legal obligation or responsibility to report.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="Max16Text">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">Max16Text</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">Specifies a character string with a maximum length of 16 characters.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="1"/>
      <xs:maxLength value="16"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="Max256Text">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">Max256Text</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">Specifies a character string with a maximum length of 256 characters.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="1"/>
      <xs:maxLength value="256"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:complexType name="EntityResponsibleForReport">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">Entity responsible for report</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">Entity responsible for report</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="LEI" type="LEIIdentifier">
        <xs:annotation>
          <xs:documentation source="Name" xml:lang="EN">Id of entity responsible for report</xs:documentation>
          <xs:documentation source="Definition" xml:lang="EN">Unique code identifying entity responsible for report</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="EmailAdr" type="EmailAddress" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation source="Name" xml:lang="EN">Email address</xs:documentation>
          <xs:documentation source="Definition" xml:lang="EN">Email address.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="auth.rlt.002.02">
    <xs:annotation>
      <xs:documentation source="Name" xml:lang="EN">Entity relations message</xs:documentation>
      <xs:documentation source="Definition" xml:lang="EN">Entity relations message</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="GnlInf" type="GeneralInformation">
        <xs:annotation>
          <xs:documentation source="Name" xml:lang="EN">General information</xs:documentation>
          <xs:documentation source="Definition" xml:lang="EN">General information</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="RltnData" type="EntityRelationsData" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation source="Name" xml:lang="EN">Relations</xs:documentation>
          <xs:documentation source="Definition" xml:lang="EN">Relations</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>