<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://ehis.ee/oppejoud/xml/dto" targetNamespace="http://ehis.ee/oppejoud/xml/dto">
 <!-- ============================================================================================================================= ROOT -->
 <xsd:element name="data">
  <xsd:complexType>
   <xsd:sequence>    
    <xsd:element name="oppejoud"            type="Oppejoud"         nillable="false" minOccurs="0" maxOccurs="10000"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
 <!-- -->
 <!-- -->
 <!-- ============================================================================================================================= OPPEJOUD -->
 <xsd:complexType name="OppejoudIsikuandmed">
  <xsd:sequence>
   <xsd:element name="eesnimi"               type="EHIS_LongString"                    nillable="false" minOccurs="1"/>
   <xsd:element name="perenimi"              type="EHIS_LongString"                    nillable="false" minOccurs="1"/>
   <xsd:element name="synni_kp"              type="EHIS_Date"                          nillable="false" minOccurs="1"/>      
   <xsd:element name="kl_sugu"               type="EHIS_LongString"                    nillable="false" minOccurs="1"/>
   <xsd:element name="kl_kodakondsus"        type="EHIS_LongString"                    nillable="false" minOccurs="1"/>
  </xsd:sequence>
 </xsd:complexType>
 
 <xsd:complexType name="Oppejoud">
  <xsd:sequence>
   <xsd:choice minOccurs="1">
    <xsd:element name="isikukood"            type="EHIS_Isikukood"                     nillable="false"/>
    <xsd:element name="isikuandmed"          type="OppejoudIsikuandmed"                nillable="false"/>
   </xsd:choice>     
   
   <xsd:element name="telefon"               type="EHIS_LongString"                    nillable="false" minOccurs="0"/>  
   <xsd:element name="email"                 type="EHIS_LongString"                    nillable="false" minOccurs="0"/>     
   
   <!-- children -->
   <xsd:element name="ametikoht"             type="Ametikoht"                          nillable="false" minOccurs="0" maxOccurs="50"/>
   <xsd:element name="kvalifikatsioon"       type="Kvalifikatsioon"                    nillable="false" minOccurs="0" maxOccurs="50"/>
   <xsd:element name="lyhiajaline_mobiilsus" type="Oppejoud_Lyhiajaline_Mobiilsus"     nillable="true"  minOccurs="0" maxOccurs="50"/>
   <xsd:element name="teaduseriala"          type="EHIS_LongString"                    nillable="false" minOccurs="0" maxOccurs="50"/>
  </xsd:sequence>
 </xsd:complexType>
 <!-- -->
 <!-- -->
 <!-- -->
 <!-- ============================================================================================================================= COMPLEX TYPES -->
 <!-- -->
 <!-- ============================================================================================================================= AMETIKOHT -->
 <xsd:complexType name="Ametikoht">
  <xsd:sequence>
   <!-- ........................................................................................................................... REQUIRED -->
   <!--õppeasutuse kood-->
   <xsd:element name="on_oppejoud"              type="EHIS_Boolean"     nillable="false" minOccurs="0"/>
   
   <xsd:element name="kl_ametikoht"             type="EHIS_LongString"  nillable="false" minOccurs="1"/>
   <xsd:element name="ametikoht_muu"            type="EHIS_LongString"  nillable="false" minOccurs="0"/>
   <xsd:element name="kl_toosuhe"               type="EHIS_LongString"  nillable="false" minOccurs="1"/>
   <xsd:element name="toosuhe_muu"              type="EHIS_LongString"  nillable="false" minOccurs="0"/>
   <xsd:element name="kl_lepingu_liik"          type="EHIS_LongString"  nillable="false" minOccurs="1"/>      
   <xsd:element name="leping_alg_kp"            type="EHIS_Date"        nillable="false" minOccurs="1"/>
   <xsd:element name="leping_lopp_kp"           type="EHIS_Date"        nillable="false" minOccurs="0"/>
   <xsd:element name="koormus"                                          nillable="false" minOccurs="1">
    <xsd:simpleType>
     <xsd:restriction base="xsd:double">
      <xsd:minInclusive value="0.0"/>
      <xsd:maxInclusive value="5.0"/>
     </xsd:restriction>
    </xsd:simpleType>
   </xsd:element>
   <!-- ........................................................................................................................... OPTIONAL -->
   <xsd:element name="leping_on_lopetatud"      type="EHIS_Boolean"     nillable="false" minOccurs="0"/>
   <xsd:element name="strukt_nimi"              type="EHIS_LongString"  nillable="false" minOccurs="0"/>
   <xsd:element name="strukt_kood"              type="EHIS_LongString"  nillable="false" minOccurs="0"/>
   
   <xsd:element name="toosuhe_kood"             type="EHIS_LongString"  nillable="false" minOccurs="0"/>
   <xsd:element name="ametikoht_tapsustus_en"   type="EHIS_LongString"  nillable="false" minOccurs="0"/>   
   
   <!-- ........................................................................................................................... SUBLIST -->
   <xsd:element name="oppeained"                type="Oppeaine"         nillable="false" minOccurs="0" maxOccurs="50"/>
  </xsd:sequence>
 </xsd:complexType>
 
 <xsd:complexType name="Oppeaine">
  <xsd:sequence>
   <xsd:element name="nimetus"                  type="EHIS_LongString"    nillable="false" minOccurs="1"/>
   <xsd:element name="kl_oppekeel"              type="EHIS_LongString"    nillable="false" minOccurs="1"/>
   <xsd:element name="aine_kood"                type="EHIS_LongString"    nillable="false" minOccurs="0"/>
   <xsd:element name="ok_kood"                  type="Integer"            nillable="false" minOccurs="0" maxOccurs="unbounded"/>
   <xsd:element name="maht"                     type="EHIS_LongString"    nillable="false" minOccurs="0"/>
  </xsd:sequence>
 </xsd:complexType>
  
 <!-- -->
 <!-- ============================================================================================================================= AMETIKOHT -->
 <xsd:complexType name="Kvalifikatsioon">
  <xsd:sequence>
   <!-- ........................................................................................................................... REQUIRED -->
   <xsd:element name="kl_kvalifikatsioon"          type="EHIS_LongString"  nillable="false" minOccurs="1"/>   
   <xsd:element name="kl_kvalifikatsioon_nimetus"  type="EHIS_LongString"  nillable="false" minOccurs="1"/>
   <xsd:element name="kvalifikatsioon_nimetus_muu" type="EHIS_LongString"  nillable="false" minOccurs="0"/>
   <xsd:element name="kl_riik"                     type="EHIS_LongString"  nillable="false" minOccurs="1"/>   
   <xsd:element name="aasta"                       type="Integer"          nillable="false" minOccurs="1"/>
   <xsd:element name="kl_eesti_oppeasutus"         type="EHIS_LongString"  nillable="false" minOccurs="0"/>
   <xsd:element name="kl_eesti_oppeasutus_endine"  type="EHIS_LongString"  nillable="false" minOccurs="0"/>   
   <xsd:element name="oppeasutus_muu"              type="EHIS_LongString"  nillable="false" minOccurs="0"/>   
  </xsd:sequence>
 </xsd:complexType>
  <!-- -->
 <!-- ============================================================================================================================= LYHIAJALINE MOBIILSUS -->
 <xsd:complexType name="Oppejoud_Lyhiajaline_Mobiilsus">
  <xsd:sequence>
   <xsd:element name="lyh_mob_kood"                type="EHIS_LongString"  nillable="true"  minOccurs="0"/>
   <xsd:element name="perioodi_algus"              type="EHIS_Date"        nillable="false" minOccurs="1"/>
   <xsd:element name="perioodi_lopp"               type="EHIS_Date"        nillable="false" minOccurs="1"/>
   <xsd:element name="kl_eesmark"                  type="EHIS_LongString"  nillable="false" minOccurs="1"/>
   <xsd:element name="sihtoppeasutus"              type="EHIS_LongString"  nillable="false" minOccurs="1"/>
   <xsd:element name="kl_sihtriik"                 type="EHIS_LongString"  nillable="false" minOccurs="1"/>
   <xsd:element name="kustutatud"                  type="EHIS_Boolean"  nillable="true"  minOccurs="0"/>
  </xsd:sequence>
 </xsd:complexType>
 <!-- -->
 <!-- -->
 <!-- -->
 <!-- ============================================================================================================================= SIMPLE TYPES -->
 <xsd:simpleType name="EHIS_Isikukood">
  <xsd:restriction base="xsd:string">
   <xsd:pattern value="\d{11}"/>
  </xsd:restriction>
 </xsd:simpleType>
 <xsd:simpleType name="EHIS_Boolean">
  <xsd:restriction base="xsd:string">
   <xsd:pattern value="(J|j)ah"/>
   <xsd:pattern value="(E|e)i"/>
  </xsd:restriction>
 </xsd:simpleType>
 <xsd:simpleType name="EHIS_LongString">
  <xsd:restriction base="xsd:string">
   <xsd:minLength value="1"/>
   <xsd:maxLength value="200"/>
  </xsd:restriction>
 </xsd:simpleType>
 <xsd:simpleType name="EHIS_Date">
  <xsd:restriction base="xsd:string">
   <xsd:pattern value="((0[1-9]|[1-2][0-9]|3[0-1])\.(0[1-9]|1[0-2])\.([1-2][0-9][0-9][0-9]))"/>
  </xsd:restriction>
 </xsd:simpleType>
 <xsd:simpleType name="Integer">
  <xsd:restriction base="xsd:positiveInteger"/>
 </xsd:simpleType>
</xsd:schema>