<!--
  This is a first attempt to give a W3C's XML schema for Gramp's database files.
-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://gramps.sourceforge.net/database"
xmlns:g="http://gramps.sourceforge.net/database"
elementFormDefault="qualified">
  <xsd:element name="database" type="g:Database" />
  <xsd:complexType name="Address">
    <xsd:sequence>
      <xsd:group ref="g:Date" minOccurs="0" />
      <xsd:element name="street" minOccurs='0' type="xsd:string" />
      <xsd:element name="city" minOccurs='0' type="xsd:string" />
      <xsd:element name="state" minOccurs='0' type="xsd:string" />
      <xsd:element name="country" minOccurs='0'
      type="xsd:string" />
      <xsd:element name="postal" minOccurs='0' type="xsd:string" />
      <xsd:element name="note" type="g:Note" minOccurs='0' />
      <xsd:element name="sourceref" type="g:SourceReference"
      minOccurs='0' />
    </xsd:sequence>
    <xsd:attributeGroup ref="g:Property" />
  </xsd:complexType>
  <xsd:complexType name="Attribute">
    <xsd:all>
      <xsd:element name="note" type="g:Note" minOccurs="0" />
      <xsd:element name="sourceref" type="g:SourceReference"
      minOccurs="0" />
    </xsd:all>
    <xsd:attribute name="type" type="xsd:string" use="optional" />
    <xsd:attribute name="value" type="xsd:string" use="optional" />
    <xsd:attributeGroup ref="g:Property" />
  </xsd:complexType>
  <xsd:complexType name="Bookmarks">
    <xsd:sequence>
      <xsd:element name="bookmark" type="g:RefType" minOccurs="0"
      maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="ChildOf">
    <xsd:sequence />
    <xsd:attribute name="ref" type="g:ID" />
    <xsd:attribute name="mrel" type="g:RelationType"
    use="optional" />
    <xsd:attribute name="frel" type="g:RelationType"
    use="optional" />
  </xsd:complexType>
  <xsd:complexType name="Coordinate">
    <xsd:sequence />
    <xsd:attribute name="long" type="xsd:decimal" />
    <xsd:attribute name="lat" type="xsd:decimal" />
  </xsd:complexType>
  <xsd:complexType name="Created">
    <xsd:sequence />
    <xsd:attribute name="date" type="xsd:string" />
    <xsd:attribute name="version" type="xsd:string" />
    <xsd:attribute name="people" type="xsd:nonNegativeInteger" />
    <xsd:attribute name="families" type="xsd:nonNegativeInteger" />
    <xsd:attribute name="sources" type="xsd:nonNegativeInteger" />
    <xsd:attribute name="places" type="xsd:nonNegativeInteger" />
  </xsd:complexType>
  <xsd:complexType name="Database">
    <xsd:all>
      <xsd:element name="header" type="g:Header" minOccurs="1"
      maxOccurs="1" />
      <xsd:element name="people" type="g:People" minOccurs="0"
      maxOccurs="1" />
      <xsd:element name="families" type="g:Families" minOccurs="0"
      maxOccurs="1" />
      <xsd:element name="sources" type="g:Sources" minOccurs="0"
      maxOccurs="1" />
      <xsd:element name="places" type="g:Places" minOccurs="0"
      maxOccurs="1" />
      <xsd:element name="objects" type="g:Objects" minOccurs="0"
      maxOccurs="1" />
      <xsd:element name="bookmarks" type="g:Bookmarks"
      minOccurs="0" maxOccurs="1" />
    </xsd:all>
  </xsd:complexType>
  <xsd:complexType name="DateValue">
    <xsd:sequence />
    <xsd:attribute name="val" type="g:DateValueType" />
    <xsd:attribute name="type" type="g:DateType" use="optional" />
  </xsd:complexType>
  <xsd:complexType name="DateRange">
    <xsd:sequence />
    <xsd:attribute name="start" type="g:DateValueType" />
    <xsd:attribute name="stop" type="g:DateValueType" />
  </xsd:complexType>
  <xsd:complexType name="DateString">
    <xsd:sequence />
  </xsd:complexType>
  <xsd:complexType name="Event">
    <xsd:sequence>
      <xsd:group ref="g:Date" minOccurs="0" />
      <xsd:element name="place" type="g:RefType" minOccurs="0" />
      <xsd:element name="description" minOccurs="0"
      type="xsd:string" />
      <xsd:element name="cause" minOccurs="0" type="xsd:string" />
      <xsd:element name="note" type="g:Note" minOccurs="0" />
      <xsd:element name="sourceref" type="g:SourceReference"
      minOccurs="0" maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="type" type="g:EventType" />
  </xsd:complexType>
  <xsd:complexType name="Families">
    <xsd:sequence>
      <xsd:element name="family" type="g:Family" minOccurs="0"
      maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="Family">
    <xsd:sequence>
      <xsd:element name="father" minOccurs="0" type="g:RefType" />
      <xsd:element name="mother" minOccurs="0" type="g:RefType" />
      <xsd:element name="event" type="g:Event" minOccurs="0"
      maxOccurs="unbounded" />
      <xsd:element name="objref" type="g:ID" minOccurs="0"
      maxOccurs="unbounded" />
      <xsd:element name="child" minOccurs="0" maxOccurs="unbounded"
      type="g:RefType" />
      <xsd:element name="attribute" type="g:Attribute"
      minOccurs="0" maxOccurs="unbounded" />
      <xsd:element name="note" type="g:Note" minOccurs="0" />
    </xsd:sequence>
    <xsd:attribute name="id" type="g:ID" />
    <xsd:attribute name="type" type="g:MarriageType"
    use="optional" />
  </xsd:complexType>
  <xsd:complexType name="Header">
    <xsd:all>
      <xsd:element name="created" type="g:Created" minOccurs="1"
      maxOccurs="1" />
      <xsd:element name="researcher" type="g:Researcher"
      minOccurs="0" maxOccurs="1" />
    </xsd:all>
  </xsd:complexType>
  <xsd:complexType name="Location">
    <xsd:sequence />
    <xsd:attribute name="city" type="xsd:string" use="optional" />
    <xsd:attribute name="county" type="xsd:string"
    use="optional" />
    <xsd:attribute name="state" type="xsd:string" use="optional" />
    <xsd:attribute name="country" type="xsd:string"
    use="optional" />
    <xsd:attribute name="parish" type="xsd:string"
    use="optional" />
  </xsd:complexType>
  <xsd:complexType name="Name">
    <xsd:all>
      <xsd:element name="first" minOccurs='0' type="xsd:string" />
      <xsd:element name="last" minOccurs='0' type="xsd:string" />
      <xsd:element name="suffix" minOccurs='0' type="xsd:string" />
      <xsd:element name="title" minOccurs='0' type="xsd:string" />
      <xsd:element name="note" minOccurs='0' type="xsd:string" />
      <xsd:element name="sourceref" type="g:SourceReference"
      minOccurs="0" />
    </xsd:all>
    <xsd:attribute name="type" type="g:NameType" />
    <xsd:attributeGroup ref="g:Property" />
  </xsd:complexType>
  <xsd:complexType name="Objects">
    <xsd:sequence>
      <xsd:element name="object" type="g:Object" minOccurs="0"
      maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="Object">
    <xsd:sequence>
      <xsd:element name="attribute" type="g:Attribute"
      minOccurs="0" maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="id" type="g:ID" />
    <xsd:attribute name="src" type="xsd:string" use="optional" />
    <xsd:attribute name="mime" type="xsd:string" use="optional" />
    <xsd:attribute name="description" type="xsd:string"
    use="optional" />
  </xsd:complexType>
  <xsd:complexType name="People">
    <xsd:sequence>
      <xsd:element name="person" type="g:Person" minOccurs="0"
      maxOccurs="unbounded" />
    </xsd:sequence>
    <xsd:attribute name="default" type="g:ID" use="optional" />
  </xsd:complexType>
  <xsd:complexType name="Person">
    <xsd:sequence>
      <xsd:element name="gender" type="g:Gender" minOccurs="1"
      maxOccurs="1" />
      <xsd:element name="name" type="g:Name" minOccurs='0' />
      <xsd:element name="aka" type="g:Name" minOccurs='0'
      maxOccurs='unbounded' />
      <xsd:element name="nick" type="xsd:string" minOccurs="0" />
      <xsd:element name="uid" type="xsd:string" minOccurs="0" />
      <xsd:element name="event" type="g:Event" minOccurs='0'
      maxOccurs='unbounded' />
      <xsd:element name="objref" type="g:RefType" minOccurs='0'
      maxOccurs='unbounded' />
      <xsd:element name="url" type="g:Url" minOccurs='0'
      maxOccurs='unbounded' />
      <xsd:element name="address" type="g:Address" minOccurs='0'
      maxOccurs='unbounded' />
      <xsd:element name="childof" type="g:ChildOf" minOccurs='0'
      maxOccurs='unbounded' />
      <xsd:element name="parentin" minOccurs='0'
      maxOccurs='unbounded' type="g:RefType" />
      <xsd:element name="sourceref" type="g:SourceReference"
      minOccurs='0' />
      <xsd:element name="attribute" type="g:Attribute"
      minOccurs='0' maxOccurs='unbounded' />
      <xsd:element name="note" type="g:Note" minOccurs='0' />
    </xsd:sequence>
    <xsd:attribute name="id" type="g:ID" />
  </xsd:complexType>
  <xsd:complexType name="Places">
    <xsd:sequence>
      <xsd:element name="placeobj" type="g:Place" minOccurs="0"
      maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="Place">
    <xsd:sequence>
      <xsd:element name="coord" type="g:Coordinate"
      minOccurs="0" />
      <xsd:element name="location" type="g:Location" minOccurs="0"
      maxOccurs="unbounded" />
      <xsd:element name="objref" type="g:ID" minOccurs="0"
      maxOccurs="unbounded" />
      <xsd:element name="url" type="g:Url" minOccurs="0"
      maxOccurs="unbounded" />
      <xsd:element name="note" type="g:Note" minOccurs="0" />
    </xsd:sequence>
    <xsd:attribute name="id" type="g:ID" />
    <xsd:attribute name="title" type="xsd:string" />
  </xsd:complexType>
  <xsd:complexType name="RefType">
    <xsd:sequence />
    <xsd:attribute name="ref" type="g:ID" />
  </xsd:complexType>
  <xsd:complexType name="Researcher">
    <xsd:sequence>
      <xsd:element name="resname" minOccurs="1" maxOccurs="1"
      type="xsd:string" />
      <xsd:element name="resaddr" minOccurs="0" maxOccurs="1"
      type="xsd:string" />
      <xsd:element name="rescity" minOccurs="0" maxOccurs="1"
      type="xsd:string" />
      <xsd:element name="resstate" minOccurs="0" maxOccurs="1"
      type="xsd:string" />
      <xsd:element name="rescountry" minOccurs="0" maxOccurs="1"
      type="xsd:string" />
      <xsd:element name="respostal" minOccurs="0" maxOccurs="1"
      type="xsd:string" />
      <xsd:element name="resphone" minOccurs="0" maxOccurs="1"
      type="xsd:string" />
      <xsd:element name="resemail" minOccurs="0" maxOccurs="1"
      type="xsd:string" />
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="Sources">
    <xsd:sequence>
      <xsd:element name="source" type="g:Source" minOccurs="0"
      maxOccurs="unbounded" />
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="Source">
    <xsd:all>
      <xsd:element name="sauthor" minOccurs="0"
      type="xsd:string" />
      <xsd:element name="stitle" minOccurs="0" type="xsd:string" />
      <xsd:element name="spubinfo" minOccurs="0"
      type="xsd:string" />
      <xsd:element name="scallno" minOccurs="0"
      type="xsd:string" />
    </xsd:all>
    <xsd:attribute name="id" type="g:ID" />
  </xsd:complexType>
  <xsd:complexType name="SourceReference">
    <xsd:sequence>
      <xsd:element name="spage" type="xsd:string" minOccurs="0" />
      <xsd:element name="scomments" type="xsd:string"
      minOccurs="0" />
      <xsd:element name="stext" type="xsd:string" minOccurs="0" />
      <xsd:group ref="g:Date" minOccurs="0" />
    </xsd:sequence>
    <xsd:attribute name="ref" type="g:ID" />
  </xsd:complexType>
  <xsd:complexType name="Url">
    <xsd:sequence />
    <xsd:attribute name="href" type="xsd:string" />
    <xsd:attribute name="description" type="xsd:string"
    use="optional" />
    <xsd:attributeGroup ref="g:Property" />
  </xsd:complexType>
  <!--
                  ==================== 
                         GROUPS
                  ==================== 
    -->
  <xsd:group name="Date">
    <xsd:choice>
      <xsd:element name="dateval" type="g:DateValue" />
      <xsd:element name="datestr" type="g:DateString" />
      <xsd:element name="daterange" type="g:DateRange" />
    </xsd:choice>
  </xsd:group>
  <xsd:attributeGroup name="Property">
    <xsd:attribute name="confidence" type="xsd:integer"
    use="optional" />
    <xsd:attribute name="privacy" type="xsd:integer"
    use="optional" />
  </xsd:attributeGroup>
  <!--
                  ==================== 
                     SIMPLE TYPES 
                  ==================== 
    -->
  <xsd:simpleType name="DateType">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="about" />
      <xsd:enumeration value="before" />
      <xsd:enumeration value="after" />
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="DateValueType">
    <xsd:restriction base="xsd:string" />
  </xsd:simpleType>
  <xsd:simpleType name="EventType">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="Annulment" />
      <xsd:enumeration value="Baptism" />
      <xsd:enumeration value="Birth" />
      <xsd:enumeration value="Burial" />
      <xsd:enumeration value="Christening" />
      <xsd:enumeration value="Cremation" />
      <xsd:enumeration value="Death" />
      <xsd:enumeration value="Degree" />
      <xsd:enumeration value="Divorce" />
      <xsd:enumeration value="Education" />
      <xsd:enumeration value="Engagement" />
      <xsd:enumeration value="Graduation" />
      <xsd:enumeration value="Immi" />
      <xsd:enumeration value="Marriage" />
      <xsd:enumeration value="Occupation" />
      <xsd:enumeration value="Religion" />
      <xsd:enumeration value="SUBM" />
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="Gender">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="M" />
      <xsd:enumeration value="F" />
      <xsd:enumeration value="U" />
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="ID">
    <xsd:restriction base="xsd:string" />
  </xsd:simpleType>
  <xsd:simpleType name="MarriageType">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="Married" />
      <xsd:enumeration value="Unmarried" />
      <xsd:enumeration value="Partners" />
      <xsd:enumeration value="Other" />
      <xsd:enumeration value="Unknown" />
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="NameType">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="Birth Name" />
      <xsd:enumeration value="Also Known As" />
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="Note">
    <xsd:restriction base="xsd:string" />
  </xsd:simpleType>
  <xsd:simpleType name="RelationType">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="Adopted" />
      <xsd:enumeration value="Birth" />
      <xsd:enumeration value="Foster" />
      <xsd:enumeration value="Other" />
      <xsd:enumeration value="Stepchild" />
      <xsd:enumeration value="Unknown" />
    </xsd:restriction>
  </xsd:simpleType>
</xsd:schema>
