<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
-- this is the header necessary for all tei documents --
  <xs:element name="TEI.2">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="teiHeader"/>
        <xs:element ref="text"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="teiHeader">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="fileDesc"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="fileDesc">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="titleStmt"/>
        <xs:element ref="publicationStmt"/>
        <xs:element ref="sourceDesc"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="titleStmt">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="title"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="title" type="xs:string"/>
  <xs:element name="publicationStmt">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="publisher"/>
        <xs:element ref="date"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="publisher">
    <xs:complexType mixed="true">
      <xs:attribute name="n" use="required" type="xs:integer"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="date" type="xs:integer"/>
  <xs:element name="sourceDesc">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="p"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="p" type="xs:string"/>
  <xs:element name="text">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="body"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="body">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="div"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  -- div elements are used to carry the whole text, and divide it into books and chapters --
  -- each div can have a head, and will contain pb cb and lb elements, and ab elements--
  --fragmentary divs may also contain gap elements directly --
  <xs:element name="div">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="head"/>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element ref="cb"/>
          <xs:element ref="div"/>
          <xs:element ref="gap"/>
          <xs:element ref="lb"/>
          <xs:element ref="pb"/>
        </xs:choice>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="ab"/>
      </xs:sequence>
      --id n and type attributes give unique identifiers to each div, and n and type assign numbers and types, distinguishing books and chapters --
      <xs:attribute name="id" type="xs:NCName"/>
      <xs:attribute name="n" use="required" type="xs:NMTOKEN"/>
      <xs:attribute name="type" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="head" type="xs:NCName"/>
  <xs:element name="pb">
  -- pb is usually an empty element but may contain margin elements --
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="margin"/>
      </xs:sequence>
      <xs:attribute name="corres" use="required" type="xs:NCName"/>
      <xs:attribute name="id" use="required" type="xs:NCName"/>
      <xs:attribute name="n" type="xs:NMTOKEN"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="cb">
  -- usually empty, but may contain margin elements --
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="margin"/>
      </xs:sequence>
      <xs:attribute name="corres" use="required" type="xs:NCName"/>
      <xs:attribute name="id" use="required" type="xs:NCName"/>
      <xs:attribute name="n" type="xs:integer"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="gap">
  -- used to indicate text absent, for whatever reason.  extent and units attributes indicate: if units is lines then it is vertical material missing, measured in lines; if it is chars, then it is horizontal material missing, measured in characters.  extent indicates how many lines/characters --
    <xs:complexType>
      <xs:attribute name="extent" type="xs:integer"/>
      <xs:attribute name="extext" type="xs:integer"/> -- this is an error! --
      <xs:attribute name="units" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="lb">
    -- usually empty, but may contain note elements for eusebian canon numbers --

    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="note"/>
      </xs:sequence>
      <xs:attribute name="corres" type="xs:NCName"/>
      <xs:attribute name="corresp" type="xs:NCName"/>
      <xs:attribute name="id" type="xs:NCName"/>
      <xs:attribute name="n" type="xs:integer"/>
      <xs:attribute name="rend" type="xs:NCName"/>
      <xs:attribute name="vnumber" type="xs:NMTOKEN"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="note">
  -- used only to hold eusebian canon numbers --
    <xs:complexType mixed="true">
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="lb"/>
      </xs:sequence>
      <xs:attribute name="n" use="required" type="xs:decimal"/>
      <xs:attribute name="type" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="ab">
  -- used to hold text verses; typically holds w and app elements --
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element ref="ab"/>
        <xs:element ref="cb"/>
        <xs:element ref="gap"/>
        <xs:element ref="lb"/>
        <xs:element ref="pb"/>
        <xs:element ref="w"/>
        <xs:element ref="app"/>
      </xs:choice>
      <xs:attribute name="id" use="required" type="xs:NCName"/>
      <xs:attribute name="n" use="required" type="xs:integer"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="app">
  -- hold different readings in rdg elements --
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="rdg"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="rdg">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element ref="lb"/>
        <xs:element ref="w"/>
      </xs:choice>
      <xs:attribute name="id" type="xs:NCName"/>
      <xs:attribute name="n" type="xs:NCName"/>
      <xs:attribute name="type" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="margin">
  --may hold margin elements nested.  Within pb for the start of the page: margin elements may have the attributes topmargin and leftmargin;
  within pb for the bottom of the page, may have the attributes rightmargin and bottommargin.
  Within cb for the start of each column: may have attribute coltopmargin; within cb for the end of each column, may have the attribute colbottommargin (not instanced here)
  margin within margin elements: 
                                                    may have attributes right left center (for topmargin and bottom margin, and coltopmargin and colbottommargin)
  													may have attributes top center bottom (for rightmargin and leftmargin)
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="lb"/>
        <xs:element ref="margin"/>
        <xs:element ref="ptr"/> -- used to hold cross refererenced text , referring to text in the corrections --
      </xs:choice>
      <xs:attribute name="type" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="ptr">
  -- used to point at corrected element written in margin --
    <xs:complexType>
      <xs:attribute name="n" use="required" type="xs:NCName"/>
      <xs:attribute name="type" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="w">
    <xs:complexType mixed="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="cb"/>
        <xs:element ref="lb"/>
        <xs:element ref="hi"/>
        <xs:element ref="supplied"/>
      </xs:choice>
      <xs:attribute name="n" use="required" type="xs:integer"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="hi">
  -- may have attributes ul=underline; ol=joined-up-diaeresis; ol2=overline; ul-ol2=overline and underline; red=red; kwhyphen: this appears as an empty element and may be ignored. --
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:NMTOKEN">
          <xs:attribute name="rend" use="required" type="xs:NCName"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <xs:element name="supplied" type="xs:NCName"/>
</xs:schema>
