<?xml version="1.0" encoding="windows-1250"?>
<xsd:schema targetNamespace="http://www.mvcr.cz/archivy/evidence-nad/matriky"
            xmlns:mt="http://www.mvcr.cz/archivy/evidence-nad/matriky"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:nad="http://www.mvcr.cz/archivy/evidence-nad/nad"
                                                                            >

  <xsd:import namespace="http://www.mvcr.cz/archivy/evidence-nad/nad"
              schemaLocation="nad.xsd"/>

  <xsd:annotation>
    <xsd:documentation xml:lang="CZ">
############################################################################
###
### XML Schéma (XML Schema) pro XML výstupy záznamů matrik
### 
### Standard pro uložení a výměnu dat záznamů (popisu) matrik.
### AUTOR: Josef Hora (jhora@mvcr.cz), 
###        odbor archivní správy a spisové služby MV (arch@mvcr.cz)
### VERZE: 1.0 (30/05/2007)
###
############################################################################
###
### OBSAH:
### 1. Jednoduché datové typy
###  1.1..Definice typů odvozených z předdefinovaných typů 
###  1.2. Definice typů odvozených z předdefinovaných typů výčtem
###  1.3. Definice typů odvozených z typů definovaných v 1a+1b
###
### 2. Komplexní datové typy
###  2.1. Definice pomocných typů
###  2.2. Definice typů elementů, které tvoří kořenový element
###    2.2.1. Typ "typ_Matrika" - popis matriky
###    2.2.2. Typ "typ_Puvodce" - popis původce matriky
###    2.2.3. Typ "typ_Lokalita" - popis lokality, která se vyskytuje v matrice
###    2.2.4. Typ "typ_MistoUlozeni" - popis místa uložení matriky (archivu, původce)
###
### 3. Kořenový element "evidenceMatrik" dokumentu 
###  3.1. Elementy kořenového elementu a zajištění jedinečnosti hodnot
###    3.1.1. Element "zaznamyMatrik" - záznamy matrik
###    3.1.2. Element "zaznamyPuvodcu" - záznamy původců matrik
###    3.1.3. Element "zaznamyLokalit" - záznamy lokalit zapsaných v matrikách
###    3.1.4. Element "zaznamyMistUlozeni" - záznamy míst uložení matrik
###    3.1.5. Rozšiřitelnost dokumentu XML ("xsd:any")
###    3.1.6. Atributy kořenového elementu včetně "xsd:anyAttribute"
###  3.2. Referenční integrita
###    3.2.1. Klíče elementů 
###    3.2.2. Cizí klíče
###
############################################################################
Užití XML schématu:
XML schéma je navrženo tak, aby konečný dokument XML sloužil jako interní 
výměnný formát pro ukládání a zasílání záznamů matrik v digitální podobě 
mezi archivy a ministerstvem vnitra. 
Tvůrci schématu rezignovali na obecné, blížeji nespecifikované, deklarace a 
v povinné části dokumentu konkretizovali metodickou představu o popisu matriky, 
která poslouží zvláště konkrétnímu úkolu - orientaci badatele v lokálním i 
případném celostátním soupisu matrik.
Použití konkrétních, ale volitelných součástí, je dáno specifickými 
potřebami jednotlivých archivů a také typy popisovaných matrik (židovské, 
vojenské atd.).
############################################################################
Volitelné rozšíření dokumentu XML: 
Umožňuje doplnění dokument XML o informace 
např. potřebné pro konkrétní aplikaci, ve které se soupis matrik vytváří, 
případně o další informace o matrikách, které jsou potřebné z lokálního hlediska, 
ale v tomto schématu nejsou specifikována. 
Je zavedeno na dvou úrovních:
1. Na úrovni elementů ("xsd:any"): viz část schématu (3.1.5).
2. Na úrovni atributů ("xsd:anyAttribute"): Zde je zavedena na dvou úrovních. 
Pro kořenový element v části (3.1.6). V části 2.1, a zvláště 2.2, je dále 
umožněno volitelné zařazení atributů do elementů, které popisují jednotlivé 
objekty (matriky, původce, místa uložení a lokality a varianty jejich názvů).
Jenoduché užití je možné nahlédnout ve vzorovém příkladu u popisu lokalit. 
############################################################################
    </xsd:documentation>
  </xsd:annotation>

<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 1 Jednoduché datové typy
+++
+++ 1.1. Definice typů odvozených z předdefinovaných typů 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
  <xsd:simpleType name="typ_StringEmpty">
    <xsd:restriction base="xsd:string">
      <xsd:length value = "0"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_String10">
    <xsd:restriction base="xsd:string">
      <xsd:maxLength value = "10"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_String20">
    <xsd:restriction base="xsd:string">
      <xsd:maxLength value = "20"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_String50">
    <xsd:restriction base="xsd:string">
      <xsd:maxLength value = "50"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_String100">
    <xsd:restriction base="xsd:string">
      <xsd:maxLength value = "100"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_String254">
    <xsd:restriction base="xsd:string">
      <xsd:maxLength value = "254"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_String1000">
    <xsd:restriction base="xsd:string">
      <xsd:maxLength value = "1000"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_String2000">
    <xsd:restriction base="xsd:string">
      <xsd:maxLength value = "2000"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_RokZapisu">
    <xsd:restriction base="xsd:gYear">
      <xsd:minInclusive value = "1000"/>
      <xsd:maxInclusive value = "2100"/>
    </xsd:restriction>
  </xsd:simpleType>

<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 1.2. Definice typů odvozených z předdefinovaných typů výčtem
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
  <xsd:simpleType name="typ_Matrik">
    <xsd:restriction base="xsd:string" >
      <xsd:enumeration value = "N"/>    <!-- matrika narozených -->
      <xsd:enumeration value = "O"/>    <!-- matrika oddaných -->
      <xsd:enumeration value = "Z"/>    <!-- matrika zemřelých -->
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_Indexu">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value = "I-N"/>    <!-- index matriky narozených -->
      <xsd:enumeration value = "I-O"/>    <!-- index matriky oddaných -->
      <xsd:enumeration value = "I-Z"/>    <!-- index matriky zemřelých -->
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="verzeSch">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value = "1.0"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_StatCZ">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value = "Česká republika"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_KrajCZ">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value = "Hlavní město Praha"/>
      <xsd:enumeration value = "Středočeský kraj"/>
      <xsd:enumeration value = "Jihočeský kraj"/>
      <xsd:enumeration value = "Plzeňský kraj"/>
      <xsd:enumeration value = "Karlovarský kraj"/>
      <xsd:enumeration value = "Ústecký kraj"/>
      <xsd:enumeration value = "Liberecký kraj"/>
      <xsd:enumeration value = "Královéhradecký kraj"/>
      <xsd:enumeration value = "Pardubický kraj"/>
      <xsd:enumeration value = "Vysočina"/>
      <xsd:enumeration value = "Jihomoravský kraj"/>
      <xsd:enumeration value = "Olomoucký kraj"/>
      <xsd:enumeration value = "Zlínský kraj"/>
      <xsd:enumeration value = "Moravskoslezský kraj"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_OkresCZ">
    <xsd:restriction base="xsd:string">
      <!-- městské části Prahy na úrovni okresů -->
      <xsd:enumeration value = "Praha 1"/>
      <xsd:enumeration value = "Praha 2"/>
      <xsd:enumeration value = "Praha 3"/>
      <xsd:enumeration value = "Praha 4"/>
      <xsd:enumeration value = "Praha 5"/>
      <xsd:enumeration value = "Praha 6"/>
      <xsd:enumeration value = "Praha 7"/>
      <xsd:enumeration value = "Praha 8"/>
      <xsd:enumeration value = "Praha 9"/>
      <xsd:enumeration value = "Praha 10"/>
      <xsd:enumeration value = "Praha 11"/>
      <xsd:enumeration value = "Praha 12"/>
      <xsd:enumeration value = "Praha 13"/>
      <xsd:enumeration value = "Praha 14"/>
      <xsd:enumeration value = "Praha 15"/>
      <xsd:enumeration value = "Praha 16"/>
      <xsd:enumeration value = "Praha 18"/>
      <xsd:enumeration value = "Praha 19"/>
      <xsd:enumeration value = "Praha 20"/>
      <xsd:enumeration value = "Praha 21"/>
      <xsd:enumeration value = "Praha 22"/>
      <xsd:enumeration value = "Benešov"/>
      <xsd:enumeration value = "Beroun"/>
      <xsd:enumeration value = "Kladno"/>
      <xsd:enumeration value = "Kolín"/>
      <xsd:enumeration value = "Kutná Hora"/>
      <xsd:enumeration value = "Mělník"/>
      <xsd:enumeration value = "Mladá Boleslav"/>
      <xsd:enumeration value = "Nymburk"/>
      <xsd:enumeration value = "Praha-východ"/>
      <xsd:enumeration value = "Praha-západ"/>
      <xsd:enumeration value = "Příbram"/>
      <xsd:enumeration value = "Rakovník"/>
      <xsd:enumeration value = "České Budějovice"/>
      <xsd:enumeration value = "Český Krumlov"/>
      <xsd:enumeration value = "Jindřichův Hradec"/>
      <xsd:enumeration value = "Písek"/>
      <xsd:enumeration value = "Prachatice"/>
      <xsd:enumeration value = "Strakonice"/>
      <xsd:enumeration value = "Tábor"/>
      <xsd:enumeration value = "Domažlice"/>
      <xsd:enumeration value = "Klatovy"/>
      <xsd:enumeration value = "Plzeň"/>
      <xsd:enumeration value = "Plzeň-jih"/>
      <xsd:enumeration value = "Plzeň-sever"/>
      <xsd:enumeration value = "Rokycany"/>
      <xsd:enumeration value = "Tachov"/>
      <xsd:enumeration value = "Cheb"/>
      <xsd:enumeration value = "Karlovy Vary"/>
      <xsd:enumeration value = "Sokolov"/>
      <xsd:enumeration value = "Děčín"/>
      <xsd:enumeration value = "Chomutov"/>
      <xsd:enumeration value = "Litoměřice"/>
      <xsd:enumeration value = "Louny"/>
      <xsd:enumeration value = "Most"/>
      <xsd:enumeration value = "Teplice"/>
      <xsd:enumeration value = "Ústí nad Labem"/>
      <xsd:enumeration value = "Česká Lípa"/>
      <xsd:enumeration value = "Jablonec nad Nisou"/>
      <xsd:enumeration value = "Liberec"/>
      <xsd:enumeration value = "Semily"/>
      <xsd:enumeration value = "Hradec Králové"/>
      <xsd:enumeration value = "Jičín"/>
      <xsd:enumeration value = "Náchod"/>
      <xsd:enumeration value = "Rychnov nad Kněžnou"/>
      <xsd:enumeration value = "Trutnov"/>
      <xsd:enumeration value = "Chrudim"/>
      <xsd:enumeration value = "Pardubice"/>
      <xsd:enumeration value = "Svitavy"/>
      <xsd:enumeration value = "Ústí nad Orlicí"/>
      <xsd:enumeration value = "Havlíčkův Brod"/>
      <xsd:enumeration value = "Jihlava"/>
      <xsd:enumeration value = "Pelhřimov"/>
      <xsd:enumeration value = "Třebíč"/>
      <xsd:enumeration value = "Žďár nad Sázavou"/>
      <xsd:enumeration value = "Blansko"/>
      <xsd:enumeration value = "Brno"/>
      <xsd:enumeration value = "Brno-venkov"/>
      <xsd:enumeration value = "Břeclav"/>
      <xsd:enumeration value = "Hodonín"/>
      <xsd:enumeration value = "Vyškov"/>
      <xsd:enumeration value = "Znojmo"/>
      <xsd:enumeration value = "Jeseník"/>
      <xsd:enumeration value = "Olomouc"/>
      <xsd:enumeration value = "Prostějov"/>
      <xsd:enumeration value = "Přerov"/>
      <xsd:enumeration value = "Šumperk"/>
      <xsd:enumeration value = "Kroměříž"/>
      <xsd:enumeration value = "Uherské Hradiště"/>
      <xsd:enumeration value = "Vsetín"/>
      <xsd:enumeration value = "Zlín"/>
      <xsd:enumeration value = "Bruntál"/>
      <xsd:enumeration value = "Frýdek-Místek"/>
      <xsd:enumeration value = "Karviná"/>
      <xsd:enumeration value = "Nový Jičín"/>
      <xsd:enumeration value = "Opava"/>
      <xsd:enumeration value = "Ostrava"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_jazykVycet">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value = "čeština"/>
      <xsd:enumeration value = "němčina"/>
      <xsd:enumeration value = "latina"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="typ_typMatrikyVycet">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value = "katolická"/>
      <xsd:enumeration value = "evangelická"/>
      <xsd:enumeration value = "židovská"/>
      <xsd:enumeration value = "civilní (matričního úřadu)"/>
      <xsd:enumeration value = "vojenská"/>
      <xsd:enumeration value = "jiná"/>
    </xsd:restriction>
  </xsd:simpleType>


<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 1.3. Definice typů odvozených z typů definovaných v 1a+1b
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
  <xsd:simpleType name="typ_MatrikIndexu">
    <xsd:union memberTypes = "mt:typ_Matrik mt:typ_Indexu"/>
  </xsd:simpleType>

  <xsd:simpleType name = "typ_Stat">
    <xsd:union memberTypes = "mt:typ_StatCZ mt:typ_String50"/>
  </xsd:simpleType>

  <xsd:simpleType name = "typ_Kraj">
    <xsd:union memberTypes = "mt:typ_KrajCZ mt:typ_String50"/>
  </xsd:simpleType>

  <xsd:simpleType name = "typ_Okres">
    <xsd:union memberTypes = "mt:typ_OkresCZ mt:typ_String50"/>
  </xsd:simpleType>

  <xsd:simpleType name = "typ_druhyJazyku">
    <xsd:union memberTypes = "mt:typ_jazykVycet mt:typ_String20"/>
  </xsd:simpleType>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 2. Komplexní datové typy
++++
+++ 2.1. Definice pomocných typů
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
  <xsd:complexType  name = "typ_KlicMatriky">
    <xsd:sequence>
      <xsd:element  ref  = "nad:c_archivu"/>
      <xsd:element  name = "porCislo" 
                    type = "xsd:positiveInteger" />
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name = "typ_VazbaIndex">
    <xsd:complexContent>
      <xsd:extension base = "mt:typ_KlicMatriky">
          <xsd:sequence>
            <xsd:element  name = "poznVazba" 
                          type = "mt:typ_String100"
                          minOccurs = "0" maxOccurs = "1"/>
          </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>

  <xsd:complexType  name = "typ_VazbaIndexy">
    <xsd:sequence>
      <xsd:element  name = "klicIndexu" 
                    type = "mt:typ_VazbaIndex" 
                    minOccurs = "1" maxOccurs = "unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType  name = "typ_PropojLokalitu">
    <xsd:sequence>
      <xsd:element  name = "idLokality" 
                    type = "xsd:positiveInteger"/>
      <xsd:element  name = "casPropojLok" 
                    type = "mt:typ_String50" 
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "poznPropojLok" 
                    type = "mt:typ_String1000" 
                    minOccurs = "0" maxOccurs = "1"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name = "typ_PropojLokality">
    <xsd:sequence>
      <xsd:element name = "zLokalit" 
                   type = "mt:typ_PropojLokalitu" 
                   minOccurs = "1" maxOccurs = "unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType  name = "typ_OznaceniMatriky">
    <xsd:sequence>
      <xsd:element  name = "signPuv" 
                    type = "mt:typ_String50" 
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "signArch" 
                    type = "mt:typ_String50" 
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "invCislo" 
                    type = "mt:typ_String10" 
                    minOccurs = "0" maxOccurs = "1"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType  name = "typ_ObsahuMatriky">
    <xsd:sequence>
      <xsd:element  name = "casRozsahCasti" 
                    type = "mt:typ_String50" 
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "poznamkaCasti" 
                    type = "mt:typ_String1000" 
                    minOccurs = "0" maxOccurs = "1"/>
    </xsd:sequence>
    <xsd:attribute  name = "charakterObsahuMatriky" 
                    type = "mt:typ_MatrikIndexu" 
                    use  = "required"/>
  </xsd:complexType>

  <xsd:complexType  name = "typ_CasRozsah">
    <xsd:sequence>
      <xsd:element  name = "rokMin" 
                    type = "mt:typ_RokZapisu"/>
      <xsd:element  name = "rokMax" 
                    type = "mt:typ_RokZapisu"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType  name = "typ_jazykMatriky">
    <xsd:sequence>
      <xsd:element  name = "jazyk" 
                    type = "mt:typ_druhyJazyku" 
                    minOccurs = "1" maxOccurs = "unbounded"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType  name = "typ_VariantaLok">
    <xsd:sequence>
      <xsd:element  name = "lokObec" 
                    type = "mt:typ_String50"/>
      <xsd:element  name = "lokCastObce" 
                    type = "mt:typ_String50"
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "lokSamota" 
                    type = "mt:typ_String50"
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "lokPoz" 
                    type = "mt:typ_String1000" 
                    minOccurs = "0" maxOccurs = "1"/>
    </xsd:sequence>
    <xsd:anyAttribute 
                     namespace = "##any"
                     processContents = "lax"/>
  </xsd:complexType>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 2.2. Definice typů elementů, které tvoří kořenový element
+++ 
+++ 2.2.1. Typ "typ_Matrika" - popis matriky
+++ 
Atributy:
Specifikace "xsd:anyAttribute": Umožňuje volitelné rozšíření atributů tohoto 
typu elementu (popisu jednotlivé matriky).
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
  <xsd:complexType name = "typ_Matrika">
    <xsd:sequence>
      <xsd:element  name = "klicMatriky" 
                    type = "mt:typ_KlicMatriky"/>
      <xsd:element  ref  = "nad:c_karty"/>
      <xsd:element  name = "oznaceniMatriky" 
                    type = "mt:typ_OznaceniMatriky"/>
      <xsd:element  name = "idPuvodce" 
                    type = "xsd:positiveInteger"/>
      <xsd:element  name = "uzemniRozsah" 
                    type = "mt:typ_String2000" 
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "obsahMatriky" 
                    type = "mt:typ_ObsahuMatriky" 
                    minOccurs = "1" maxOccurs = "6"/>
      <xsd:element  name = "casRozsah" 
                    type = "mt:typ_CasRozsah"/>
      <xsd:element  name = "vazbaIndexy" 
                    type = "mt:typ_VazbaIndexy" 
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "propojLokality" 
                    type = "mt:typ_PropojLokality" 
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "stKopie" 
                    type = "mt:typ_String100" 
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "idMistaUlozeni" 
                    type = "xsd:positiveInteger"/>
      <xsd:element  name = "jazykMatriky" 
                    type = "mt:typ_jazykMatriky" 
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "matrListiny" 
                    type = "xsd:boolean" 
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "vybrano" 
                    type = "xsd:boolean"/>
      <xsd:element  name = "typMatriky" 
                    type = "mt:typ_typMatrikyVycet"/>
      <xsd:element  name = "poznamka" 
                    type = "mt:typ_String2000" 
                    minOccurs = "0" maxOccurs = "1"/>
    </xsd:sequence>
    <xsd:anyAttribute 
                     namespace = "##any"
                     processContents = "lax"/>
  </xsd:complexType>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 2.2.2. Typ "typ_Puvodce" - popis původce matriky
+++ 
Atributy:
Atribut "idPuvodce": jednoznačně identifikuje původce v dokumentu XML.
Specifikace "xsd:anyAttribute": Umožňuje volitelné rozšíření atributů tohoto 
typu elementu (popisu jednotlivého původce).
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
  <xsd:complexType  name = "typ_Puvodce">
    <xsd:sequence>
      <xsd:element  name = "nazevPuvodce" 
                    type = "mt:typ_String254"/>
      <xsd:element  name = "poznPuvodce" 
                    type = "mt:typ_String2000" 
                    minOccurs = "0" maxOccurs = "1"/>
    </xsd:sequence>
    <xsd:attribute  name = "idPuvodce" 
                    type = "xsd:positiveInteger" 
                    use  = "required"/>
    <xsd:anyAttribute 
                     namespace = "##any"
                     processContents = "lax"/>
  </xsd:complexType>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 2.2.3. Typ "typ_Lokalita" - popis lokality, která se vyskytuje v matrice
Atributy:
Atribut "idLokality": jednoznačně identifikuje lokalitu v dokumentu XML.
Specifikace "xsd:anyAttribute": Umožňuje volitelné rozšíření atributů tohoto 
typu elementu (popisu jednotlivé lokality).
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
  <xsd:complexType  name = "typ_Lokalita">
    <xsd:sequence>
      <xsd:element  name = "lokStat" 
                    type = "mt:typ_Stat"/>
      <xsd:element  name = "lokKraj" 
                    type = "mt:typ_Kraj"/>
      <xsd:element  name = "lokOkres" 
                    type = "mt:typ_Okres"/>
      <xsd:element  name = "lokObec" 
                    type = "mt:typ_String50"/>
      <xsd:element  name = "lokCastObce" 
                    type = "mt:typ_String50"/>
      <xsd:element  name = "lokSamota" 
                    type = "mt:typ_String50"/>
      <xsd:element  name = "lokPoz" 
                    type = "mt:typ_String1000" 
                    minOccurs = "0" maxOccurs = "1"/>
      <xsd:element  name = "variantaLokality" 
                    type = "mt:typ_VariantaLok" 
                    minOccurs = "0" maxOccurs = "unbounded"/>
    </xsd:sequence>
    <xsd:attribute  name = "idLokality" 
                    type = "xsd:positiveInteger" 
                    use  = "required"/>
    <xsd:anyAttribute 
                     namespace = "##any"
                     processContents = "lax"/>
  </xsd:complexType>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 2.2.4. Typ "typ_MistoUlozeni" - popis místa uložení matriky (archivu, 
+++ původce)
Atributy:
Atribut "idMistaUlozeni": jednoznačně identifikuje místo uložení v dokumentu XML.
Specifikace "xsd:anyAttribute": Umožňuje volitelné rozšíření atributů tohoto 
typu elementu (popisu jednotlivého místa uložení).
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
  <xsd:complexType  name = "typ_MistoUlozeni">
    <xsd:sequence>
      <xsd:element  name = "nazevMistaUlozeni"
                    type = "mt:typ_String50"/>
    </xsd:sequence>
    <xsd:attribute  name = "idMistaUlozeni" 
                    type = "xsd:positiveInteger"
                    use  = "required" />
    <xsd:anyAttribute 
                     namespace = "##any"
                     processContents = "lax"/>
  </xsd:complexType>

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 3. Kořenový element "evidenceMatrik" dokumentu 
+++ 
+++ 3.1. Elementy kořenového elementu a zajištění jedinečnosti hodnot
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
  <xsd:element  name = "evidenceMatrik">
    <xsd:complexType>
      <xsd:sequence>
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 3.1.1. Element "zaznamyMatrik" - záznamy matrik
+++
+++ Jedinečnost hodnot (v rámci elementu "matrika" - zápis jedné matriky): 
1. Podmínka "jedinecnostZapisuObsahuMatriky": Znemožní více elementů "obsahMatriky" 
se stejným atributem "charakterObsahuMatriky", tj. každy typ zápisu v matrice 
(N, O, Z, I-N, I-O, I-Z) je popsán maximálně jedním elementem "obsahMatriky".
2. Podmínka "jedinecnostOdkazuNaIndex": Znemožní duplicitní odkazy na záznamy 
(elementy "matrika") popisující samostatné indexy.
3. Podmínka "jedinecnostOdkazuNaLokality": Znemožní duplicitní odkazy na záznamy 
lokalit (elementy "lokalita").
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
        <xsd:element name = "zaznamyMatrik">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element  name = "matrika"
                            type = "mt:typ_Matrika"
                            minOccurs = "1" maxOccurs = "unbounded">
                <xsd:unique name = "jedinecnostZapisuObsahuMatriky">
                  <xsd:selector xpath = "mt:obsahMatriky"/>
                  <xsd:field xpath    = "@charakterObsahuMatriky"/>
                </xsd:unique>
                <xsd:unique name = "jedinecnostOdkazuNaIndex">
                  <xsd:selector xpath = "mt:vazbaIndexy/mt:klicIndexu"/>
                  <xsd:field xpath    = "nad:c_archivu"/>
                  <xsd:field xpath    = "mt:porCislo"/>
                </xsd:unique>
                <xsd:unique name = "jedinecnostOdkazuNaLokality">
                  <xsd:selector xpath = "mt:propojLokality/mt:zLokalit"/>
                  <xsd:field xpath    = "mt:idLokality"/>
                </xsd:unique>
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 3.1.2. Element "zaznamyPuvodcu" - záznamy původců matrik
+++
+++ Jedinečnost hodnot (v rámci elementu "zaznamyPuvodcu"): 
1. Podmínka "jedinecnostJmenaPuvodce": Zajistí jedinečnost jména původce.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
        <xsd:element  name = "zaznamyPuvodcu">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element  name = "puvodce"
                            type = "mt:typ_Puvodce"
                            minOccurs = "1" maxOccurs = "unbounded">
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
          <xsd:unique  name = "jedinecnostJmenaPuvodce">
            <xsd:selector xpath = "mt:puvodce"/>
            <xsd:field xpath = "mt:nazevPuvodce"/>
          </xsd:unique>
        </xsd:element>
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 3.1.3. Element "zaznamyLokalit" - záznamy lokalit zapsaných v matrikách
+++
+++ Jedinečnost hodnot: 
1. Podmínka "jedinecnostLokality": Zajistí jedinečnost zápisu lokality 
(v rámci elementu "zaznamyLokalit", tj. v rámci celého dokumentu XML).
2. Podmínka "jedinecnostVariLokality": Zajistí jedinečnost zápisu varianty 
jména lokality (v rámci elementu "lokalita", tj. v rámci zápisu jedné lokality).
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
        <xsd:element  name = "zaznamyLokalit">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element  name = "lokalita"
                            type = "mt:typ_Lokalita"
                            minOccurs = "0" maxOccurs = "unbounded">
                <xsd:unique name = "jedinecnostVariLokality">
                  <xsd:selector xpath = "mt:variantaLokality"/>
                  <xsd:field xpath = "mt:lokObec"/>
                  <xsd:field xpath = "mt:lokCastObce"/>
                  <xsd:field xpath = "mt:lokSamota"/>
                </xsd:unique>
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
          <xsd:unique  name = "jedinecnostLokality">
            <xsd:selector xpath = "mt:lokalita"/>
            <xsd:field xpath = "mt:lokStat"/>
            <xsd:field xpath = "mt:lokKraj"/>
            <xsd:field xpath = "mt:lokOkres"/>
            <xsd:field xpath = "mt:lokObec"/>
            <xsd:field xpath = "mt:lokCastObce"/>
            <xsd:field xpath = "mt:lokSamota"/>
          </xsd:unique>
        </xsd:element>
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 3.1.4. Element "zaznamyMistUlozeni" - záznamy míst uložení matrik
+++
+++ Jedinečnost hodnot: 
1. Podmínka "jedinecnostMistaUlozeni": Zajistí jedinečnost zápisu jména 
místa uložení (v rámci elementu "zaznamyMistUlozeni", tj. v rámci celého 
dokumentu XML).
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
        <xsd:element  name = "zaznamyMistUlozeni">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element  name = "mistoUlozeni"
                            type = "mt:typ_MistoUlozeni"
                            minOccurs = "0" maxOccurs = "unbounded"/>
            </xsd:sequence>
          </xsd:complexType>
          <xsd:unique  name = "jedinecnostMistaUlozeni">
            <xsd:selector xpath = "mt:mistoUlozeni"/>
            <xsd:field xpath    = "mt:nazevMistaUlozeni"/>
          </xsd:unique>
        </xsd:element>
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 3.1.5. Rozšiřitelnost dokumentu XML ("xsd:any")
+++
Umožňuje volitelně rozšířit dokument XML o informace potřebné např. pro 
konkrétní aplikaci, ve které se soupis matrik vytváří, případně o informace 
o matrikách, které jsou potřebné z lokálního hlediska, 
ale v tomto schématu nejsou specifikována.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
        <xsd:any  namespace = "##any"
                  processContents = "lax" 
                  minOccurs = "0" maxOccurs = "unbounded"/>
      </xsd:sequence>
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 3.1.6. Atributy kořenového elementu včetně "xsd:anyAttribute"
+++
Atribut "verzeSchematu": Povinný zápis verze schématu, podle které byl dokument 
XML vytvořen a která slouží k validaci dokumentu.
Atribut "datumVytvoreni": Datum vytvoření dokumentu ve tvaru daném ČSN ISO 8601, 
tj. ve tvaru rok-měsíc-den (rrrr-mm-dd).
Specifikace "xsd:anyAttribute": Umožňuje volitelné rozšíření atributů kořenového 
elementu.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
      <xsd:attribute  name = "verzeSchematu" 
                      type = "mt:verzeSch"
                      use  = "required"/>
      <xsd:attribute  name = "datumVytvoreni" 
                      type = "xsd:date"
                      use  = "required"/>
       <xsd:anyAttribute 
                       namespace = "##any"
                       processContents = "lax"/>
    </xsd:complexType>

<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 3.2. Referenční integrita
+++ 3.2.1. Klíče elementů 
1. Klíč "identifikaceMatriky": jednoznačná identifikace záznamu matriky 
(elementu "matrika"). Jde o jednoznačnost v celém systému evidence matrik. Klíč
musí být neměnný pro daný záznam matriky.
2. Klíč "identifikacePuvodce": jednoznačná identifikace záznamu původce 
(elementu "puvodce"). Záznam původce je takto jednoznačně identifikován
 v konkrétním dokumentu XML. Klíč nemusí být trvalý. Podobně i pro další 
 dva klíče.
3. Klíč "identifikaceLokality": jednoznačná identifikace záznamu lokality 
(elementu "lokality").
4. Klíč "identifikaceMistaUlozeni": jednoznačná identifikace záznamu místa 
uložení matriky (elementu "mistoUlozeni").
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
    <xsd:key  name = "identifikaceMatriky">
      <xsd:selector xpath = "mt:zaznamyMatrik/mt:matrika/mt:klicMatriky"/>
      <xsd:field xpath = "nad:c_archivu"/>
      <xsd:field xpath = "mt:porCislo"/>
    </xsd:key>
    
    <xsd:key  name = "identifikacePuvodce">
      <xsd:selector xpath = "mt:zaznamyPuvodcu/mt:puvodce"/>
      <xsd:field xpath    = "@idPuvodce"/>
    </xsd:key>

    <xsd:key  name = "identifikaceLokality">
      <xsd:selector xpath = "mt:zaznamyLokalit/mt:lokalita"/>
      <xsd:field xpath    = "@idLokality"/>
    </xsd:key>
    
    <xsd:key  name = "identifikaceMistaUlozeni">
      <xsd:selector xpath = "mt:zaznamyMistUlozeni/mt:mistoUlozeni"/>
      <xsd:field xpath    = "@idMistaUlozeni"/>
    </xsd:key>

<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++ 3.2.2. Cizí klíče
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
    <xsd:keyref name  = "odkazNaPuvodce" 
                refer = "mt:identifikacePuvodce">
        <xsd:selector xpath = "mt:zaznamyMatrik/mt:matrika"/>
        <xsd:field xpath    = "mt:idPuvodce"/>
    </xsd:keyref>

    <xsd:keyref name  = "odkazNaMistoUlozeni"
                refer = "mt:identifikaceMistaUlozeni">
        <xsd:selector xpath = "mt:zaznamyMatrik/mt:matrika"/>
        <xsd:field xpath    = "mt:idMistaUlozeni"/>
    </xsd:keyref>

<!--=========================================================================
=== Test této integrity může být součástí schématu, ale jen v případě,
=== že v evidující instituci neexistuje matrika popisovaná indexem, který 
=== v instituci není!
=============================================================================
    <xsd:keyref name  = "odkazNaSamIndex" 
                refer = "mt:identifikaceMatriky">
        <xsd:selector xpath = "mt:zaznamyMatrik/mt:matrika/mt:vazbaIndexy/mt:klicIndexu"/>
        <xsd:field xpath = "nad:c_archivu"/>
        <xsd:field xpath = "mt:porCislo"/>
    </xsd:keyref>
===========================================================================-->

    <xsd:keyref name  = "odkazNaLokalitu" 
                refer = "mt:identifikaceLokality">
        <xsd:selector xpath = "mt:zaznamyMatrik/mt:matrika/mt:propojLokality/mt:zLokalit"/>
        <xsd:field xpath    = "mt:idLokality"/>
    </xsd:keyref>

  </xsd:element>
</xsd:schema>
