<?xml version="1.0" encoding="UTF-8"?>
<!-- version:1.2.0 -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <!-- Main BioSample XML -->
  <xs:element name="BioSample" type="typeBioSample"/>
  <!-- Dictionary of attributes (set of definitions).-->
  <xs:element name="AttributeDictionary" type="typeAttributeDictionary"/>
  <!-- BioSample models-->
  <xs:element name="Model" type="typeSampleModel"/>

  <xs:complexType name="typeBioSample">
    <xs:sequence>
      <xs:element name="Ids" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Identifiers of the sample.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Id" type="typeSampleId" minOccurs="1" maxOccurs="unbounded">
              <xs:annotation>
                <xs:documentation/>
              </xs:annotation>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="Description" type="typeDescription" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Description of the sample.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Owner" type="typeOrganization" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Information about the owner of biosample (organization, author,
            etc.).</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Providers" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Sources of biosample (where one can get it) - Coriell for example. Note
            that it is possible more than one provider of the sample. NOTE!!!!!. we should not have
            this node. Biosample should describe series itself. lot/plate/date info bolong to
            particular experiment whi uses this sample. </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Provider" type="typeProvider" minOccurs="1" maxOccurs="unbounded">
              <xs:annotation>
                <xs:documentation>Biosamle provider description</xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="Models" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Specification of model or model set for the sample.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Model" minOccurs="1" maxOccurs="unbounded">
              <xs:complexType>
                <xs:simpleContent>
                  <xs:extension base="xs:string">
                    <xs:annotation>
                      <xs:documentation>Description of the model to use. Free
                        text.</xs:documentation>
                    </xs:annotation>
                    <xs:attribute name="version" type="xs:string">
                      <xs:annotation>
                        <xs:documentation>Version of the model, e.g. 1.0, 1.2, 2.2, etc. By default the latest public version.</xs:documentation>
                      </xs:annotation>
                    </xs:attribute>
                  </xs:extension>
                </xs:simpleContent>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="Attributes" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation> Attributes (main data) of the biosample. Note that attributes comes
            from dictionaries. One sample can has attributes from several dictionaries. The set of
            mandatory attributes are controlled by the sample model (see Models of the sample)
            Attributes are a primary way to differentiate samples, we have a plenty a things which
            are coded as attributes (key=value) but with so wild keys that they looks more like a
            structured comment. </xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Attribute" type="typeAttribute" minOccurs="1" maxOccurs="unbounded">
              <xs:annotation>
                <xs:documentation>Biosample is represented as a set of attributes</xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="Links" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Links from this biosamples to other objects (URL of web page for
            example)</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Link" type="typeLink" minOccurs="1" maxOccurs="unbounded">
              <xs:annotation>
                <xs:documentation>Set of links from this sample</xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="Relations" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Relations to other biosamples</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Relation" type="typeRelation" minOccurs="1" maxOccurs="unbounded">
              <xs:annotation>
                <xs:documentation>Relations - like 'derived from', 'included in',
                  etc.</xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="last_update" type="xs:dateTime" use="optional">
      <xs:annotation>
        <xs:documentation>When biosamle record has been updated last time</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="publication_date" type="xs:dateTime" use="optional">
      <xs:annotation>
        <xs:documentation>When biosamle record data has been made available to the
          public</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="access" type="typeAccess" use="required">
      <xs:annotation>
        <xs:documentation>Public data or restricted access.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <!-- Types for BioSample XML -->

  <xs:complexType name="typeReference">
    <xs:annotation>
      <xs:documentation>external qualified identifier</xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="namespace" use="required" type="xs:string">
          <xs:annotation>
            <xs:documentation>Repository/database name, where this attribute is referenced, e.g. Coriell (family, plate, subject, etc.).</xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <!-- ID of BioSample -->
  <xs:complexType name="typeSampleId">
    <xs:annotation>
      <xs:documentation>Identificator of the sample.</xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="namespace" use="required">
          <xs:annotation>
            <xs:documentation>Repository/database name, where this sample is referenced, e.g. Coriell, ATCC, etc.</xs:documentation>
          </xs:annotation>
          <xs:simpleType>
            <xs:restriction base="xs:string">
              <xs:enumeration value="Coriell"/>
              <xs:enumeration value="ATCC"/>
              <xs:enumeration value="DSMZ"/>
              <xs:enumeration value="BioSample"/>
              <xs:enumeration value="SRA"/>
              <xs:enumeration value="dbGaP"/>
              <xs:enumeration value="EST"/>
              <xs:enumeration value="GSS"/>
              <xs:enumeration value="GEO"/>
              <xs:enumeration value="other"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="other_namespace" type="xs:string">
          <xs:annotation>
            <xs:documentation>Namespace for Id if namespace="Other".</xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="is_primary" use="optional">
          <xs:annotation>
            <xs:documentation>1 - this is a primary ID. Primary means that this sample is present there (e.g. Coriell). Only one Id can have is_primary="1". If there is no primary Id a BioSample accession will be assigned as a primary Id.</xs:documentation>
          </xs:annotation>
          <xs:simpleType>
            <xs:restriction base="xs:int">
              <xs:enumeration value="0"/>
              <xs:enumeration value="1"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!-- Description of BioSample -->
  <xs:complexType name="typeDescription">
    <xs:sequence>
      <xs:element name="SampleName" maxOccurs="1" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>Name of the sample.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Synonym" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>Information about other names of the sample.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:simpleContent>
            <xs:extension base="xs:string">
              <xs:attribute name="namespace" use="required" type="xs:string">
                <xs:annotation>
                  <xs:documentation>Repository/database from which this name was taken from.</xs:documentation>
                </xs:annotation>
              </xs:attribute>
            </xs:extension>
          </xs:simpleContent>
        </xs:complexType>
      </xs:element>
      <xs:element name="Title" maxOccurs="1" type="xs:string">
        <xs:annotation>
          <xs:documentation>Shorter description of the sample.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <!--xs:element name="Organism" type="typeOrganism" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Information about organism - including taxonomy if the organism has
            taxon id.</xs:documentation>
        </xs:annotation>
      </xs:element-->
      <xs:element name="Organism" minOccurs="1" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>Information about organism - including taxonomy if the organism has taxonomy id.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="OrganismName" type="xs:string"/>
            <xs:element minOccurs="0" name="Label" type="xs:string">
              <xs:annotation>
                <xs:documentation>A label for sample, or name of an individual animal (e.g., Clint).</xs:documentation>
              </xs:annotation>
            </xs:element>
            <xs:element minOccurs="0" name="IsolateName" type="xs:string">
              <xs:annotation>
                <xs:documentation>Identification or description of the specific individual from which this sample was obtained.</xs:documentation>
              </xs:annotation>
            </xs:element>
            <xs:element minOccurs="0" name="Breed" type="xs:string">
              <xs:annotation>
                <xs:documentation>Breed name - chiefly used in domesticated animals or plants.</xs:documentation>
              </xs:annotation>
            </xs:element>
            <xs:element minOccurs="0" name="Strain" type="xs:string">
              <xs:annotation>
                <xs:documentation>Microbial/eukaryotic strain name.</xs:documentation>
              </xs:annotation>
            </xs:element>
            <xs:element minOccurs="0" name="Cultivar" type="xs:string">
              <xs:annotation>
                <xs:documentation>Cultivar name - cultivated variety of plant.</xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:sequence>
          <xs:attribute name="taxonomy_id" type="xs:positiveInteger"/>
          <xs:attribute name="role" type="xs:string"/>
        </xs:complexType>
      </xs:element>

      <xs:element name="Comment" minOccurs="0" maxOccurs="1" type="typeFormattedText">
        <xs:annotation>
          <xs:documentation>Formatted description of the sample.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <!-- Data about sample curation. -->
  <xs:complexType name="typeCuration">
    <xs:annotation>
      <xs:documentation>Curation status to implement 3 tier model.</xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:annotation>
          <xs:documentation>Notes by curator.</xs:documentation>
        </xs:annotation>
        <xs:attribute name="curation_status" use="required">
          <xs:annotation>
            <xs:documentation>Curation status. TODO - provide comments with examples of
              usage.</xs:documentation>
          </xs:annotation>
          <xs:simpleType>
            <xs:restriction base="xs:string">
              <xs:enumeration value="by_archive_after_curation"/>
              <xs:enumeration value="by_archive_on_load"/>
              <xs:enumeration value="by_submitter"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="curation_date" type="xs:date">
          <xs:annotation>
            <xs:documentation>When it was curated.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!-- BioSample provider-->
  <xs:complexType name="typeProvider">
    <xs:annotation>
      <xs:documentation>Provider of the biosample</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="Id" type="xs:string" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Id of the biosample in the source (NA11882 in
            Coriell).</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Url" type="xs:string" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>URL of the link, decribing the sample record on web site of the
            owner.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="LotId" type="xs:string" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Desription of the preparation lot or aliquot.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Location" type="xs:string" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Location of the instance of the sample.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="provider_name" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>Name of the provider (Coriell for example).</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="preparation_date" type="xs:date" use="optional">
      <xs:annotation>
        <xs:documentation>Preparation date of the sample (if known).</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <!-- BioSample organism -->
  <xs:complexType name="typeOrganism">
    <xs:annotation>
      <xs:documentation>Information about organism - Either NCBI taxonomy information or user
        description of a new organism.</xs:documentation>
    </xs:annotation>

    <xs:sequence>
      <xs:element name="Id" type="xs:positiveInteger" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Taxonomy id.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Item" type="typeOrganismDescriptor" minOccurs="1" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>Taxonomy descriptor.</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="taxonomy_id" type="xs:positiveInteger" use="optional"/>
    <!--xs:simpleContent>
      <xs:extension base="xs:anySimpleType">
        <xs:annotation>
          <xs:documentation>The taxon node data goes here.</xs:documentation>
        </xs:annotation>
        <xs:attribute name="taxonomy_id" type="xs:positiveInteger" use="required"> </xs:attribute>
      </xs:extension>
    </xs:simpleContent-->
  </xs:complexType>

  <xs:complexType name="typeOrganismDescriptor">
    <xs:simpleContent>
      <xs:extension base="xs:anySimpleType">
        <xs:annotation>
          <xs:documentation>Taxonomy descriptor.</xs:documentation>
        </xs:annotation>
        <xs:attribute name="Name" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>Name of the descriptor.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="Type" type="xs:string" use="required">
          <xs:annotation>
            <xs:documentation>Name of the descriptor.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!-- BioSample attribute-->
  <xs:complexType name="typeAttribute" mixed="true">
    <xs:annotation>
      <xs:documentation>Value of the attribute. Actually, type is restricted by the attribute
        definition. See typeAttributeDefinition.</xs:documentation>
    </xs:annotation>
    <xs:choice minOccurs="0" maxOccurs="1">
      <xs:element name="Id" type="typeReference"/>
    </xs:choice>
    <xs:attribute name="dictionary_name" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>Dictionary name where this attribute is defined.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="attribute_name" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>Name of the attribute in the dictionary. Attribute name is unique
          within the dictionary scope.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="unit" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>Measurement units for quantitative value of the attribute (when applicable). Should be listed in the attribute definition.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <!-- BioSample link-->
  <xs:complexType name="typeLink">
    <xs:annotation>
      <xs:documentation>Link from this biosample to other objects.</xs:documentation>
    </xs:annotation>
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="type" use="required">
          <xs:annotation>
            <xs:documentation>The links type : URL of web page or dbXRef.</xs:documentation>
          </xs:annotation>
          <xs:simpleType>
            <xs:restriction base="xs:string">
              <xs:enumeration value="url"/>
              <xs:enumeration value="db_xref"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:attribute>
        <xs:attribute name="target" type="xs:string" use="optional">
          <xs:annotation>
            <xs:documentation>Target db if type is dbXRef.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="label" type="xs:string" use="optional">
          <xs:annotation>
            <xs:documentation>Label for url if type is url.</xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!-- BioSample relation to other biosample-->
  <xs:complexType name="typeRelation">
    <xs:annotation>
      <xs:documentation>Relation between 2 biosamples: current and existing one.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="To">
        <xs:annotation>
          <xs:documentation>Pointer to the biosample this one is related to</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:simpleContent>
            <xs:extension base="xs:string">
              <xs:annotation>
                <xs:documentation>Accession of related biosample (either id or accession must be
                  specified)</xs:documentation>
              </xs:annotation>
              <xs:attribute name="id" type="xs:positiveInteger" use="optional">
                <xs:annotation>
                  <xs:documentation>id of related biosample (either id or accession must be
                    specified)</xs:documentation>
                </xs:annotation>
              </xs:attribute>
            </xs:extension>
          </xs:simpleContent>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="type" use="required">
      <xs:annotation>
        <xs:documentation>Type of relation - 'derived from', 'included in', etc -
          TDB</xs:documentation>
      </xs:annotation>
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="derived_from"/>
          <xs:enumeration value="part_of"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:complexType>

  <!-- Access type for biosample and its attributes -->
  <xs:simpleType name="typeAccess">
    <xs:annotation>
      <xs:documentation>Access control type</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:enumeration value="public">
        <xs:annotation>
          <xs:documentation>Can be available to the public.</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="controlled-access">
        <xs:annotation>
          <xs:documentation>Requres special permissions for access to data</xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>

  <!-- BioSample enumerated attribute values-->
  <xs:complexType name="typeValueConstraints">
    <xs:sequence>
      <xs:element name="Min" type="xs:anySimpleType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Minimum value of the attribute if applicable.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Max" type="xs:anySimpleType" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Maximum value of the attribute if applicable.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Value" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>Value for an attribute with enumeration semantics.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:simpleContent>
            <xs:extension base="xs:anySimpleType">
              <xs:annotation>
                <xs:documentation>Attribute enumeration can be any simple type.</xs:documentation>
              </xs:annotation>
              <xs:attribute name="code" type="xs:anySimpleType" use="optional">
                <xs:annotation>
                  <xs:documentation>Enumeration code. Can be any primitive built-in type: string,
                    int, etc.</xs:documentation>
                </xs:annotation>
              </xs:attribute>
            </xs:extension>
          </xs:simpleContent>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <!-- BioSample attribute definition-->
  <xs:complexType name="typeAttributeDefinition">
    <xs:sequence>
      <xs:element name="Name" type="xs:string">
        <xs:annotation>
          <xs:documentation>Name of the attribute</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Synonym" type="xs:string" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>Alternative name of the attribute.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Type">
        <xs:annotation>
          <xs:documentation>Enumeration of possible attribute types</xs:documentation>
        </xs:annotation>
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="Char">
              <xs:annotation>
                <xs:documentation>Strings</xs:documentation>
              </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="Num">
              <xs:annotation>
                <xs:documentation>Numbers</xs:documentation>
              </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="Time">
              <xs:annotation>
                <xs:documentation>Time</xs:documentation>
              </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="TimeSpan">
              <xs:annotation>
                <xs:documentation>Time lapsed</xs:documentation>
              </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="Date">
              <xs:annotation>
                <xs:documentation>Date</xs:documentation>
              </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="DateTime">
              <xs:annotation>
                <xs:documentation>Date and time</xs:documentation>
              </xs:annotation>
            </xs:enumeration>
            <xs:enumeration value="Location">
              <xs:annotation>
                <xs:documentation>Long/Lat</xs:documentation>
              </xs:annotation>
            </xs:enumeration>
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
      <xs:element name="Description" type="xs:string" minOccurs="0">
        <xs:annotation>
          <xs:documentation>Description of the attribute</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Unit" type="xs:string" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>Some attributes with measure semantics need units.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="ValueConstraints" type="typeValueConstraints" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Value set for attributes with enumeration semantics.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element minOccurs="0" name="Extra" type="xs:anyType"/>
    </xs:sequence>
    <xs:attribute name="definition_id" type="xs:positiveInteger" use="optional">
      <xs:annotation>
        <xs:documentation>Unique ID of the attribute definition. assigned by BioSample db
          .</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="semantic_type" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>UMLS Semantic Type of the attribute - broad type (what is
          it).</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="concept_id" type="xs:string" use="optional">
      <xs:annotation>
        <xs:documentation>BioConcept/UMLS_Concept ID - more specific type of the attribute. This
          will allow us to map attributes with other data.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="access" type="typeAccess" use="optional">
      <xs:annotation>
        <xs:documentation>Access to the attribute - public or protected. By default it should be
          public.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="created" type="xs:date">
      <xs:annotation>
        <xs:documentation>When the definition was created.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="last_update" type="xs:date">
      <xs:annotation>
        <xs:documentation>When the definition data was updated last time.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="status" use="required">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="stable">
            <xs:annotation>
              <xs:documentation>The upper level attributes (well-known and
                accepted).</xs:documentation>
            </xs:annotation>
          </xs:enumeration>
          <xs:enumeration value="curated">
            <xs:annotation>
              <xs:documentation>User-defined attributes, which passed the curation process and may
                be considered as candidates to be stable ones.</xs:documentation>
            </xs:annotation>
          </xs:enumeration>
          <xs:enumeration value="user-defined">
            <xs:annotation>
              <xs:documentation>User input attributes for data, which is not present in stable or
                curated sets.</xs:documentation>
            </xs:annotation>
          </xs:enumeration>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:complexType>

  <!-- BioSample attribute dictionary-->
  <xs:complexType name="typeAttributeDictionary">
    <xs:sequence>
      <xs:element name="Definition" type="typeAttributeDefinition" minOccurs="1"
        maxOccurs="unbounded"> </xs:element>
      <xs:element name="Owner" type="typeOrganization" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Information about the owner of the dictionary(organization, author,
            etc.).</xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="dictionary_name" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>Unique name of the dictionary</xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="created" type="xs:date">
      <xs:annotation>
        <xs:documentation>When the dictionary was created.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <!-- BioSample Model  -->
  <xs:complexType name="typeSampleModel">
    <xs:annotation>
      <xs:documentation>Sample model is specification of mandatory and optional
        attributes.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Name of the model, must be unique to the model.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element maxOccurs="unbounded" minOccurs="0" name="Synonym" type="xs:string">
        <xs:annotation>
          <xs:documentation>Alternative name of the model, must be unique to the model.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Description" type="xs:string" minOccurs="1" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Description of the model - free text.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Attribute" minOccurs="1" maxOccurs="unbounded">
        <xs:complexType>
          <xs:attribute name="dictionary_name" type="xs:string" use="required">
            <xs:annotation>
              <xs:documentation>Unique name of the attribute dictionary.</xs:documentation>
            </xs:annotation>
          </xs:attribute>
          <xs:attribute name="definition_id" type="xs:positiveInteger" use="optional">
            <xs:annotation>
              <xs:documentation>Unique ID of the attribute definition</xs:documentation>
            </xs:annotation>
          </xs:attribute>
          <xs:attribute name="attribute_name" type="xs:string" use="required">
            <xs:annotation>
              <xs:documentation>Unique ID of the attribute definition</xs:documentation>
            </xs:annotation>
          </xs:attribute>
          <xs:attribute name="use" use="required">
            <xs:annotation>
              <xs:documentation>Usage of the attribute: mandatory or optional.</xs:documentation>
            </xs:annotation>
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="mandatory">
                  <xs:annotation>
                    <xs:documentation>This attribute is mandatory.</xs:documentation>
                  </xs:annotation>
                </xs:enumeration>
                <xs:enumeration value="optional">
                  <xs:annotation>
                    <xs:documentation>This attribute is optional.</xs:documentation>
                  </xs:annotation>
                </xs:enumeration>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="version" type="xs:string">
      <xs:annotation>
        <xs:documentation>Version of the model, e.g. 1.0, 1.2, 2.2, etc.</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <!-- types for BioSample/Description -->

  <!-- Generic address (postal) -->
  <xs:complexType name="typeAddress">
    <xs:sequence>
      <xs:element name="Street" type="xs:string" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Street address: 123 Main St. Suite 104</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="City" type="xs:string" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>City: New York</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Sub" type="xs:string" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Subdivision of Country(state, province, etc.): New York
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Country" type="xs:string" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Country: USA</xs:documentation>
        </xs:annotation>
      </xs:element>

    </xs:sequence>
    <xs:attribute name="postal_code" type="xs:string" use="optional"/>
  </xs:complexType>

  <!-- Name of a person -->
  <xs:complexType name="typeName">
    <xs:sequence>
      <xs:element name="First" type="xs:string" minOccurs="0" maxOccurs="1"/>
      <xs:element name="Last" type="xs:string" minOccurs="1" maxOccurs="1"/>
      <xs:element name="Middle" type="xs:string" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Full middle name or initials </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <!-- Contact info - an address with email -->
  <xs:complexType name="typeContactInfo">
    <xs:sequence>
      <xs:element type="typeAddress" name="Address" minOccurs="0" maxOccurs="1"/>
      <xs:element type="typeName" name="Name" minOccurs="0" maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="email" type="xs:string" use="optional"/>
    <xs:attribute name="phone" type="xs:string"/>
    <xs:attribute name="fax" type="xs:string"/>
    <xs:attribute name="lab" type="xs:string"/>
    <!-- TODO - consider to add it to submission.xsd -->
    <xs:attribute name="department" type="xs:string"/>
    <!-- TODO - consider to add it to submission.xsd -->
  </xs:complexType>

  <!--
    Organization:
    we have people acting on behalf of organization (like lab or may be whole center or institute)
  -->
  <xs:complexType name="typeOrganization">
    <xs:sequence>
      <xs:element name="Name" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>Organization name.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:simpleContent>
            <xs:extension base="xs:string">
              <xs:attribute name="abbreviation" type="xs:string" use="optional">
                <xs:annotation>
                  <xs:documentation>Name abbreviation</xs:documentation>
                </xs:annotation>
              </xs:attribute>
              <xs:attribute name="url" type="xs:string"/>
            </xs:extension>
          </xs:simpleContent>
        </xs:complexType>
      </xs:element>
      <xs:element name="Contacts" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Contact(s) with the organization when known</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Contact" type="typeContactInfo" minOccurs="1" maxOccurs="unbounded">
              <xs:annotation>
                <xs:documentation>Contact within the organization</xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="typeFormattedText">
    <xs:annotation>
      <xs:documentation>Simple and light text formatting. We can add or remove formatting options here.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:choice minOccurs="1" maxOccurs="unbounded">
        <xs:element name="Paragraph" type="xs:string">
          <xs:annotation>
            <xs:documentation>Text formatted as one block.</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="Table" type="typeTable">
          <xs:annotation>
            <xs:documentation>Text formatted as a table.</xs:documentation>
          </xs:annotation>
        </xs:element>
      </xs:choice>
    </xs:sequence>
  </xs:complexType>



  <xs:complexType name="typeTable">
    <xs:annotation>
      <xs:documentation>Simple table for formatting part of sample description as a table.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="Caption" type="xs:string" minOccurs="0" maxOccurs="1">
        <xs:annotation>
          <xs:documentation>Caption of the table.</xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="Header" minOccurs="0">
        <xs:annotation>
          <xs:documentation>Header of the table.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Cell" type="xs:string" minOccurs="1" maxOccurs="unbounded">
              <xs:annotation>
                <xs:documentation>Field name.</xs:documentation>
              </xs:annotation>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="Body">
        <xs:annotation>
          <xs:documentation>Body of the table - data rows.</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Row" minOccurs="1" maxOccurs="unbounded">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="Cell" type="xs:string" minOccurs="1" maxOccurs="unbounded">
                    <xs:annotation>
                      <xs:documentation>Data cell. Each row consists of data cells.</xs:documentation>
                    </xs:annotation>
                  </xs:element>
                </xs:sequence>
              </xs:complexType>
            </xs:element>
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

</xs:schema>
