<?xml version="1.0" encoding="UTF-8"?>
<!--Версия схемы 1.1-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:simpleType name="DOCTYPEID_Type">
    <xs:annotation>
      <xs:documentation>Тип: "Идентификатор типа документа в системе электронного
        документооборота"</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="1"/>
      <xs:maxLength value="35"/>
      <xs:pattern value="[A-Z0-9_]{1,35}"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="DOCNO_Type">
    <xs:annotation>
      <xs:documentation>Тип: "Уникальный учетный номер документа в системе ЭДО"</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="0"/>
      <xs:maxLength value="30"/>
      <xs:pattern value="[A-Z0-9_/-]{1,30}"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SENDERID_Type">
    <xs:annotation>
      <xs:documentation>Тип: "Идентификатор ЭДО фирмы отправителя/получателя "</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:maxLength value="7"/>
      <xs:minLength value="3"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="SENDERNAME_Type">
    <xs:annotation>
      <xs:documentation>Тип: "Краткое наименование отправителя"</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="0"/>
      <xs:maxLength value="200"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="REMARKS_Type">
    <xs:annotation>
      <xs:documentation>Тип: "Примечание к документу"</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:minLength value="0"/>
      <xs:maxLength value="200"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="DOC_SUBTYPE_Type">
    <xs:restriction base="xs:string">
      <xs:maxLength value="32"/>      
      <xs:enumeration value="GENERIC_ERROR"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:element name="RTS_DOC">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="DOC_REQUISITES"/>
        <xs:element ref="GENERIC_ERROR"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="DOC_REQUISITES">
    <xs:complexType>
      <xs:attribute name="DOC_DATE" use="required" type="xs:date"/>
      <!--Дата формирования документа-->
      <xs:attribute name="DOC_TIME" use="required" type="xs:time"/>
      <!--Время формирования документа-->
      <xs:attribute name="DOC_NO" use="required" type="DOCNO_Type"/>
      <!--Уникальный учетный номер документа-->
      <xs:attribute name="DOC_TYPE_ID" use="required" type="DOCTYPEID_Type"/>
      <!--Идентификатор типа документа-->
      <xs:attribute name="RECEIVER_ID" use="required" type="SENDERID_Type"/>
      <!--Код ЭДО РТС получателя -->
      <xs:attribute name="SENDER_ID" use="required" type="SENDERID_Type"/>
      <!--Краткое наименование отправителя-->
      <xs:attribute name="SENDER_NAME" use="optional" type="SENDERNAME_Type"/>
      <!--Краткое наименование отправителя-->
      <xs:attribute name="REMARKS" use="optional" type="REMARKS_Type"/>
      <!--Текст примечания к документу-->
    </xs:complexType>
  </xs:element>
  <xs:element name="GENERIC_ERROR">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="1" ref="FILE_RECV"/>
        <xs:element minOccurs="1" maxOccurs="1" ref="ERROR"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="FILE_RECV">
    <xs:complexType>
      <xs:attribute name="filename" use="required" type="xs:string"/>
      <xs:attribute name="extension" use="required" type="xs:string"/>
      <xs:attribute name="date_recv" use="required" type="xs:date"/>
      <xs:attribute name="time_recv" use="required" type="xs:time"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="ERROR">
    <xs:complexType>
      <xs:attribute name="ErrorCode" use="required" type="xs:integer"/>
      <xs:attribute name="Description" use="optional" type="xs:string"/>
    </xs:complexType>
  </xs:element>
</xs:schema>
