<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:include schemaLocation="Base.xsd"/>
  <xs:include schemaLocation="TableFieldAttrs.xsd"/>
  <xs:include schemaLocation="TableFieldEvents.xsd"/>
  
  <xs:complexType name="DataTable_SourceAndDataField_RulesType">
    <xs:sequence>
      <xs:element name="rules" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation xml:lang="ru-ru">
            События поля источника или обычного поля.
          </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="rule" minOccurs="0" maxOccurs="unbounded">
              <xs:annotation>
                <xs:documentation xml:lang="ru-ru">
                  Событие поля источника или обычного поля.
                </xs:documentation>
              </xs:annotation>
              <xs:complexType>
                <xs:complexContent>
                  <xs:restriction base="EventItemType">
                    <xs:attribute name="event" use="required">
                      <xs:simpleType>
                        <xs:union memberTypes="SourceAndDataField_Events"/>
                      </xs:simpleType>
                    </xs:attribute>
                  </xs:restriction>
                </xs:complexContent>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
        <xs:unique name="DataTable_SourceAndDataField_RulesType_UniqueRules">
          <xs:selector xpath="rule"/>
          <xs:field xpath="@event"/>
        </xs:unique>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="DataTable_SourceFieldType" >
    <xs:annotation>
      <xs:documentation xml:lang="ru-ru">
        Поле-источник.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="DataTable_SourceAndDataField_RulesType">
        <xs:attributeGroup ref="Field_Attrs"/>
        <xs:attributeGroup ref="SourceField_Attrs"/>
        <xs:attributeGroup ref="DataAndSourceAndLookupField_Attrs"/>
        <xs:attributeGroup ref="DataAndSourceField_Attrs"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="DataTable_CalcField_RulesType">    
    <xs:sequence>
      <xs:element name="rules" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation xml:lang="ru-ru">
            События вычислимого поля.
          </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="rule" minOccurs="0" maxOccurs="unbounded">
              <xs:annotation>
                <xs:documentation xml:lang="ru-ru">
                  Событие вычислимого поля.
                </xs:documentation>
              </xs:annotation>
              <xs:complexType>
                <xs:complexContent>
                  <xs:restriction base="EventItemType">
                    <xs:attribute name="event" use="required">
                      <xs:simpleType>
                        <xs:union memberTypes="CalcField_Events"/>
                      </xs:simpleType>
                    </xs:attribute>
                  </xs:restriction>
                </xs:complexContent>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
        <xs:unique name="DataTable_Field_RulesType_UniqueRules">
          <xs:selector xpath="rule"/>
          <xs:field xpath="@event"/>
        </xs:unique>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="DataTable_CalcFieldType" >
    <xs:annotation>
      <xs:documentation xml:lang="ru-ru">
        Вычислимое поле.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="DataTable_CalcField_RulesType">
        <xs:attributeGroup ref="Field_Attrs"/>
        <xs:attributeGroup ref="CalcAndDataField_Attrs"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="DataTable_LookupFieldType" >
    <xs:annotation>
      <xs:documentation xml:lang="ru-ru">
        Поле дающее ссылку на поле из другой таблицы.
      </xs:documentation>
    </xs:annotation>
    <xs:attributeGroup ref="Field_Attrs"/>
    <xs:attributeGroup ref="LookupField_Attrs"/>
    <xs:attributeGroup ref="DataAndSourceAndLookupField_Attrs"/>
  </xs:complexType>

  <xs:complexType name="DataTable_DataFieldType" >
    <xs:annotation>
      <xs:documentation xml:lang="ru-ru">
        Обычное поле с данными.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="DataTable_SourceAndDataField_RulesType">
        <xs:attributeGroup ref="Field_Attrs"/>
        <xs:attributeGroup ref="CalcAndDataField_Attrs"/>
        <xs:attributeGroup ref="DataAndSourceAndLookupField_Attrs"/>
        <xs:attributeGroup ref="DataAndSourceField_Attrs"/>        
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  

</xs:schema>