<?xml version="1.0" encoding="utf-8"?>
<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns="reflection"
  xmlns:key="reflection"
  targetNamespace="reflection"
  elementFormDefault="qualified">
  
  <xs:element name="mtz">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="target" type="Target" maxOccurs="unbounded"/>
        <xs:element name="compound" type="Compound" maxOccurs="unbounded"/>
        <xs:element name="crystal" type="Crystal" maxOccurs="unbounded"/>
        <xs:element name="experiment" type="Experiment" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute name="version" type="xs:string" use="required"/>
      <xs:attribute name="title" type="xs:string" use="required"/>
    </xs:complexType>
    <xs:key name="targetKey">
      <xs:selector xpath="key:target"/>
      <xs:field xpath="key:attribute::id"/>
    </xs:key>
    <xs:key name="compoundKey">
      <xs:selector xpath="key:compound"/>
      <xs:field xpath="key:attribute::id"/>
    </xs:key>
    <xs:key name="crystalKey">
      <xs:selector xpath="key:crystal"/>
      <xs:field xpath="key:attribute::id"/>
    </xs:key>
    <xs:key name="experimentKey">
      <xs:selector xpath="key:experiment"/>
      <xs:field xpath="key:attribute::id"/>
    </xs:key>
    <xs:keyref name="targetKeyref" refer="targetKey">
      <xs:selector xpath="key:compound"/>
      <xs:field xpath="key:target/attribute::ref"/>
    </xs:keyref>
    <xs:keyref name="compoundKeyref" refer="compoundKey">
      <xs:selector xpath="key:crystal"/>
      <xs:field xpath="key:compound/attribute::ref"/>
    </xs:keyref>
    <xs:keyref name="crystalKeyref" refer="crystalKey">
      <xs:selector xpath="key:experiment"/>
      <xs:field xpath="key:crystal/attribute::ref"/>
    </xs:keyref>
  </xs:element>

  <xs:complexType name="Target">
    <xs:annotation>
      <xs:documentation>The target class represents a gene
      target. Physically, it is closest to a nucleic acid sequence that
      encloses a simple gene.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="orf" type="xs:string">
        <xs:annotation>
          <xs:documentation>Open Reading Frame name</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="localName" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'YPR062w'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="geneName" type="xs:string">
        <xs:annotation>
          <xs:documentation>The name of the gene corresponding to the target.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="proteinName" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'cytosine deaminase'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="systematicName" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'YPR062w'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="commonName" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'FCY1'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="sourceOrganism" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'Yeast'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="details" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'Cytosine deaminase highly homologous
          to Candida albicans cytosine deaminase'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="similarityDetails" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'Belongs to the cytidine and
          deoxycytidylate deaminases family.'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="whyChosen" type="xs:string">
        <xs:annotation>
          <xs:documentation>N/A</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="biologicalProcess" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'Unknown'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="biochemicalFunction" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'Cytosine deaminase'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="preciseFunction" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'Converts cytosine to uracil or
          5-methylcytosine to thymine by deaminating carbon number
          4'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="catalyticActivity" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'CYTOSINE + H(2)O = URACIL +
          NH(3).'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="pathway" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'Pyrimidine salvage pathway'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="cellLocation" type="xs:string">
        <xs:annotation>
          <xs:documentation>N/A</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="refDbName" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'SwissProt'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="refDbCode" type="xs:string">
        <xs:annotation>
          <xs:documentation>ex. 'Q12178'</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="geneOntologyCode" type="xs:string">
        <xs:annotation>
          <xs:documentation>N/A</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="interproCode" type="xs:string">
        <xs:annotation>
          <xs:documentation>N/A</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ecNumbers" type="xs:string">
        <xs:annotation>
          <xs:documentation>Enzyme Commission numbers(more than 1 number a.b.c.d;a.b.c.e;a.b.c.g)</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="id" type="xs:int" use="required">
      <xs:annotation>
        <xs:documentation>N/A</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="Compound">
    <xs:sequence>
      <xs:element name="target">
        <xs:complexType>
          <xs:attribute name="ref" type="xs:int" use="required"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="id" type="xs:int" use="required"/>
  </xs:complexType>

  <xs:complexType name="Crystal">
    <xs:sequence>
      <xs:element name="compound">
        <xs:complexType>
          <xs:attribute name="ref" type="xs:int" use="required"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="id" type="xs:int" use="required"/>
  </xs:complexType>

  <xs:complexType name="Experiment">
    <xs:sequence>
      <xs:element name="crystal">
        <xs:complexType>
          <xs:attribute name="ref" type="xs:int" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="ncol">
        <xs:complexType>
          <xs:attribute name="nbColumns" type="xs:int" use="required"/>
          <xs:attribute name="nbReflections" type="xs:int" use="required"/>
          <xs:attribute name="nbBatches" type="xs:int" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="cell">
        <xs:complexType>
          <xs:attribute name="p1" type="xs:float" use="required"/>
          <xs:attribute name="p2" type="xs:float" use="required"/>
          <xs:attribute name="p3" type="xs:float" use="required"/>
          <xs:attribute name="p4" type="xs:float" use="required"/>
          <xs:attribute name="p5" type="xs:float" use="required"/>
          <xs:attribute name="p6" type="xs:float" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="sort">
        <xs:complexType>
          <xs:attribute name="column1" type="xs:int" use="required"/>
          <xs:attribute name="column2" type="xs:int" use="required"/>
          <xs:attribute name="column3" type="xs:int" use="required"/>
          <xs:attribute name="column4" type="xs:int" use="required"/>
          <xs:attribute name="column5" type="xs:int" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="syminf">
        <xs:complexType>
          <xs:attribute name="nbSymmetryOperations" type="xs:int" use="required"/>
          <xs:attribute name="nbPrimitiveOperations" type="xs:int" use="required"/>
          <xs:attribute name="latticeType" type="xs:string" use="required"/>
          <xs:attribute name="spaceGroupNumber" type="xs:int" use="required"/>
          <xs:attribute name="spaceGroupName" type="xs:string" use="required"/>
          <xs:attribute name="pointGroupName" type="xs:string" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="symm" maxOccurs="unbounded">
        <xs:complexType>
          <xs:attribute name="x" type="xs:string" use="required"/>
          <xs:attribute name="y" type="xs:string" use="required"/>
          <xs:attribute name="z" type="xs:string" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="reso">
        <xs:complexType>
          <xs:attribute name="min" type="xs:float" use="required"/>
          <xs:attribute name="max" type="xs:float" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="valm">
        <xs:complexType>
          <xs:attribute name="missingNumberFlag" type="xs:string" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="datasetList">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="dataset" minOccurs="0" maxOccurs="unbounded">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="project">
                    <xs:complexType>
                      <xs:attribute name="name" type="xs:string"/>
                    </xs:complexType>
                  </xs:element>
                  <xs:element name="crystal">
                    <xs:complexType>
                      <xs:attribute name="name" type="xs:string"/>
                    </xs:complexType>
                  </xs:element>
                  <xs:element name="dcell">
                    <xs:complexType>
                      <xs:attribute name="dim1" type="xs:float"/>
                      <xs:attribute name="dim2" type="xs:float"/>
                      <xs:attribute name="dim3" type="xs:float"/>
                      <xs:attribute name="dim4" type="xs:float"/>
                      <xs:attribute name="dim5" type="xs:float"/>
                      <xs:attribute name="dim6" type="xs:float"/>
                    </xs:complexType>
                  </xs:element>
                  <xs:element name="dwavel" type="xs:float"/>
                  <xs:element name="h" type="xs:float"/>
                  <xs:element name="k" type="xs:float"/>
                  <xs:element name="l" type="xs:float"/>
                  <xs:element name="Fplus" type="xs:float"/>
                  <xs:element name="sigFplus" type="xs:float"/>
                  <xs:element name="Fminus" type="xs:float"/>
                  <xs:element name="sigFminus" type="xs:float"/>
                  <xs:element name="A" type="xs:float" minOccurs="0"/>
                  <xs:element name="B" type="xs:float" minOccurs="0"/>
                  <xs:element name="C" type="xs:float" minOccurs="0"/>
                  <xs:element name="D" type="xs:float" minOccurs="0"/>
                  <xs:element name="intermediateData" minOccurs="0" maxOccurs="unbounded">
                    <xs:complexType>
                      <xs:simpleContent>
                        <xs:extension base="xs:float">
                          <xs:attribute name="name" type="xs:string" use="required"/>
                        </xs:extension>
                      </xs:simpleContent>
                    </xs:complexType>
                  </xs:element>
                </xs:sequence>
                <xs:attribute name="name" type="xs:string"/>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
          <xs:attribute name="nbDatasets" type="xs:int" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="batch" type="xs:int" minOccurs="0"/>
      <xs:element name="mtzhist" type="xs:string"/>
    </xs:sequence>
    <xs:attribute name="id" type="xs:int" use="required"/>
  </xs:complexType>

</xs:schema>

