<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:attributeGroup name="metadata">
    <xs:attribute name="Source" type="xs:string" use="optional" />
    <xs:attribute name="Author" type="xs:string" use="optional" />
    <xs:attribute name="Publisher" type="xs:string" use="optional" />
    <xs:attribute name="Ref" type="xs:anyURI" use="optional" />
    <xs:attribute name="Milieu" type="xs:string" use="optional" />
    <xs:attribute name="Note" type="xs:string" use="optional" />
  </xs:attributeGroup>

  <xs:element name="Sectors">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="Sector" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="Sector">
    <xs:complexType>
      <xs:sequence>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="X" type="xs:integer" />
          <xs:element name="Y" type="xs:integer" />
          <xs:element maxOccurs="unbounded" name="Name">
            <xs:complexType>
              <xs:simpleContent>
                <xs:extension base="xs:string">
                  <xs:attributeGroup ref="metadata"/>
                  <xs:attribute name="Lang" type="xs:string" use="optional" />
                </xs:extension>
              </xs:simpleContent>
            </xs:complexType>
          </xs:element>
          <xs:element minOccurs="0" maxOccurs="unbounded" name="Product">
            <xs:complexType>
              <xs:attribute name="Publisher" type="xs:string" use="required" />
              <xs:attribute name="Title" type="xs:string" use="required" />
              <xs:attribute name="Author" type="xs:string" use="optional" />
              <xs:attribute name="Ref" type="xs:anyURI" use="optional" />
            </xs:complexType>
          </xs:element>
          <xs:element name="Credits" type="xs:string"/>
          <xs:element name="DataFile">
            <xs:complexType>
              <xs:simpleContent>
                <xs:extension base="xs:string">
                  <xs:attribute name="Type" use="optional">
                    <xs:simpleType>
                      <xs:restriction base="xs:string">
                        <xs:enumeration value="SEC"/>
                        <xs:enumeration value="TabDelimited"/>
                        <xs:enumeration value="SecondSurvey"/>
                      </xs:restriction>
                    </xs:simpleType>
                  </xs:attribute>
                  <xs:attributeGroup ref="metadata"/>
                </xs:extension>
              </xs:simpleContent>
            </xs:complexType>
          </xs:element>
          <xs:element name="MetadataFile">
            <xs:complexType>
              <xs:simpleContent>
                <xs:extension base="xs:string">
                  <xs:attributeGroup ref="metadata"/>
                </xs:extension>
              </xs:simpleContent>
            </xs:complexType>
          </xs:element>
          <xs:element name="Subsectors">
            <xs:complexType>
              <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="16" name="Subsector">
                  <xs:complexType>
                    <xs:simpleContent>
                      <xs:extension base="xs:string">
                        <xs:attribute name="Lang" type="xs:string" use="optional" />
                        <xs:attribute name="Index" use="required">
                          <xs:simpleType>
                            <xs:restriction base="xs:string">
                              <xs:pattern value="[A-P]" />
                            </xs:restriction>
                          </xs:simpleType>
                        </xs:attribute>
                        <xs:attributeGroup ref="metadata"/>
                      </xs:extension>
                    </xs:simpleContent>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
              <xs:attributeGroup ref="metadata"/>
            </xs:complexType>
          </xs:element>
          <xs:element name="Stylesheet" type="xs:string"/>
          <xs:element name="Labels">
            <xs:complexType>
              <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" name="Label">
                  <xs:complexType>
                    <xs:simpleContent>
                      <xs:extension base="xs:string">
                        <xs:attribute name="Allegiance" type="xs:string" use="optional" />
                        <xs:attribute name="Hex" type="xs:unsignedShort" use="required" />
                        <xs:attribute name="Color" type="xs:string" use="required" />
                        <xs:attribute name="Size" type="xs:string" use="optional" />
                        <xs:attribute name="Wrap" type="xs:boolean" use="optional" />
                        <xs:attribute name="OffsetX" type="xs:float" use="optional" />
                        <xs:attribute name="OffsetY" type="xs:float" use="optional" />
                        <xs:attributeGroup ref="metadata"/>
                      </xs:extension>
                    </xs:simpleContent>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
              <xs:attributeGroup ref="metadata"/>
            </xs:complexType>
          </xs:element>
          <xs:element name="Routes">
            <xs:complexType>
              <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" name="Route">
                  <xs:complexType>
                    <xs:attribute name="Start" type="xs:unsignedShort" use="required" />
                    <xs:attribute name="StartOffsetX" type="xs:byte" use="optional" />
                    <xs:attribute name="StartOffsetY" type="xs:byte" use="optional" />
                    <xs:attribute name="End" type="xs:unsignedShort" use="required" />
                    <xs:attribute name="EndOffsetX" type="xs:byte" use="optional" />
                    <xs:attribute name="EndOffsetY" type="xs:byte" use="optional" />
                    <xs:attribute name="Allegiance" type="xs:string" use="optional" />
                    <xs:attribute name="Type" type="xs:string" use="optional" />
                    <xs:attribute name="Color" type="xs:string" use="optional" />
                    <xs:attribute name="Width" type="xs:float" use="optional" />
                    <xs:attribute name="Style" type="xs:string" use="optional" />
                    <xs:attributeGroup ref="metadata"/>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
              <xs:attributeGroup ref="metadata"/>
            </xs:complexType>
          </xs:element>
          <xs:element name="Borders">
            <xs:complexType>
              <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" name="Border">
                  <xs:complexType>
                    <xs:simpleContent>
                      <xs:extension base="xs:string">
                        <xs:attribute name="Allegiance" type="xs:string" use="optional" />
                        <xs:attribute name="Color" type="xs:string" use="optional" />
                        <xs:attribute name="Style" type="xs:string" use="optional" />
                        <xs:attribute name="Label" type="xs:string" use="optional" />
                        <xs:attribute name="ShowLabel" type="xs:boolean" use="optional" />
                        <xs:attribute name="WrapLabel" type="xs:boolean" use="optional" />
                        <xs:attribute name="LabelPosition" type="xs:unsignedShort" use="optional" />
                        <xs:attribute name="LabelOffsetX" type="xs:float" use="optional" />
                        <xs:attribute name="LabelOffsetY" type="xs:float" use="optional" />
                        <xs:attributeGroup ref="metadata"/>
                      </xs:extension>
                    </xs:simpleContent>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
              <xs:attributeGroup ref="metadata"/>
            </xs:complexType>
          </xs:element>
          <xs:element name="Regions">
            <xs:complexType>
              <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" name="Region">
                  <xs:complexType>
                    <xs:simpleContent>
                      <xs:extension base="xs:string">
                        <xs:attribute name="Allegiance" type="xs:string" use="optional" />
                        <xs:attribute name="Color" type="xs:string" use="optional" />
                        <xs:attribute name="Label" type="xs:string" use="optional" />
                        <xs:attribute name="ShowLabel" type="xs:boolean" use="optional" />
                        <xs:attribute name="WrapLabel" type="xs:boolean" use="optional" />
                        <xs:attribute name="LabelPosition" type="xs:unsignedShort" use="optional" />
                        <xs:attribute name="LabelOffsetX" type="xs:float" use="optional" />
                        <xs:attribute name="LabelOffsetY" type="xs:float" use="optional" />
                        <xs:attributeGroup ref="metadata"/>
                      </xs:extension>
                    </xs:simpleContent>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
              <xs:attributeGroup ref="metadata"/>
            </xs:complexType>
          </xs:element>
          <xs:element name="Allegiances">
            <xs:complexType>
              <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" name="Allegiance">
                  <xs:complexType>
                    <xs:simpleContent>
                      <xs:extension base="xs:string">
                        <xs:attribute name="Code" type="xs:string" use="required" />
                        <xs:attribute name="Base" type="xs:string" use="optional" />
                        <xs:attributeGroup ref="metadata"/>
                      </xs:extension>
                    </xs:simpleContent>
                  </xs:complexType>
                </xs:element>
              </xs:sequence>
              <xs:attributeGroup ref="metadata"/>
            </xs:complexType>
          </xs:element>
        </xs:choice>
      </xs:sequence>
      <xs:attribute name="Selected" type="xs:boolean" use="optional" />
      <xs:attribute name="Abbreviation" type="xs:string" use="optional" />
      <xs:attribute name="Label" type="xs:string" use="optional" />
      <xs:attribute name="Tags" type="xs:NMTOKENS" use="optional" />
    </xs:complexType>
  </xs:element>

</xs:schema>
