<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:include schemaLocation="GridSheetAttrs.xsd"/>
  <xs:include schemaLocation="GridSheetEvents.xsd"/>
  <xs:include schemaLocation="Base.xsd"/>
  <xs:include schemaLocation="Buttons.xsd"/>
  <xs:include schemaLocation="MenuItems.xsd"/>

  <xs:group name="GridSheetContentSequence">
    <xs:choice>
      <xs:element name="view" type="GridSheet_ViewType">
        <xs:annotation>
          <xs:documentation xml:lang="ru-ru">
            Представление табличного листа.
          </xs:documentation>
        </xs:annotation>
      </xs:element>      
      <xs:element name="template" type="GridSheet_TemplateViewType">
        <xs:annotation>
          <xs:documentation xml:lang="ru-ru">
            Шаблон представления табличного листа.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="col" type="GridSheet_ColumnType">
        <xs:annotation>
          <xs:documentation xml:lang="ru-ru">
            Графа табличного листа.
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:choice>
  </xs:group>
  
  <xs:complexType name="GridSheet_ViewType">
          <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:group ref="GridSheetContentSequence" minOccurs="1" maxOccurs="unbounded"/>
          <xs:element ref="editors" minOccurs="0" maxOccurs="1" />
          <xs:element name="menuitems" type="MainMenuItemsType" minOccurs="0" maxOccurs="1" />
          <xs:element name="rules" minOccurs="0" maxOccurs="1">
            <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="GridSheet_View_Events"/>
                          </xs:simpleType>
                        </xs:attribute>
                      </xs:restriction>
                    </xs:complexContent>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
            <xs:unique name="GridSheet_View_UniqueRules">
              <xs:selector xpath="rule"/>
              <xs:field xpath="@event"/>
            </xs:unique>
          </xs:element>
          </xs:choice>
        <xs:attributeGroup ref="GridSheet_Content_Attrs"/>
        <xs:attributeGroup ref="GridSheet_TemplateAndView_Attrs"/>
        <xs:attributeGroup ref="GridSheet_View_Attrs"/>
  </xs:complexType>

  <xs:complexType name="GridSheet_TemplateViewType">
        <xs:sequence>
          <xs:group ref="GridSheetContentSequence" minOccurs="0" maxOccurs="unbounded"/>
          <xs:element name="rules" minOccurs="0" maxOccurs="1">
            <xs:annotation>
              <xs:documentation xml:lang="ru-ru">
                События шаблона представления табличного листа.
              </xs:documentation>
            </xs:annotation>
            <xs:complexType>
              <xs:sequence>
                <xs:element name="rule" minOccurs="1" 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="GridSheet_TemplateView_Events"/>
                          </xs:simpleType>
                        </xs:attribute>
                      </xs:restriction>
                    </xs:complexContent>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
            </xs:complexType>
            <xs:unique name="GridSheet_TemplateView_UniqueRules">
              <xs:selector xpath="rule"/>
              <xs:field xpath="@event"/>
            </xs:unique>
          </xs:element>
        </xs:sequence>
        <xs:attributeGroup ref="GridSheet_Content_Attrs"/>
        <xs:attributeGroup ref="GridSheet_TemplateAndView_Attrs"/>
        <xs:attributeGroup ref="GridSheet_Template_Attrs"/>
  </xs:complexType>

  <xs:complexType name="GridSheet_ColumnType">
      <xs:sequence>
        <xs:element ref="buttons" minOccurs="0" maxOccurs="1" />
        <xs:element ref="editors" minOccurs="0" maxOccurs="1" />
      </xs:sequence>
      <xs:attributeGroup ref="GridSheet_Content_Attrs"/>
      <xs:attributeGroup ref="GridSheet_Column_Attrs"/>  
  </xs:complexType>

  <xs:element name="editors">
    <xs:annotation>
      <xs:documentation xml:lang="ru-ru">
        Редакторы элемента табличного листа.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="editor" minOccurs="1" maxOccurs="unbounded">
          <xs:annotation>
            <xs:documentation xml:lang="ru-ru">
              Редактор элемента табличного листа.
            </xs:documentation>
          </xs:annotation>
          <xs:complexType>
            <xs:attributeGroup ref="GridSheet_Content_Editor_Attrs"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
    <xs:unique name="GridSheet_ContentType_UniqueEditors">
      <xs:selector xpath="editor"/>
      <xs:field xpath="@id"/>
    </xs:unique>
  </xs:element>
  

</xs:schema>
