<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:import namespace="http://www.w3.org/XML/1998/namespace"
    schemaLocation="http://www.w3.org/2001/xml.xsd"/>
  <xs:import namespace="http://www.w3.org/2001/XInclude"
    schemaLocation="http://www.w3.org/2001/XInclude/XInclude.xsd"/>
  <xs:include schemaLocation="common.xsd"/>

  <xs:element name="generic_document">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="meta"/>
        <xs:element ref="generate_index"/>
        <xs:element ref="section" maxOccurs="unbounded"/>
        <xs:element ref="appendix" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="meta">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="title"/>
        <xs:element ref="subtitle" minOccurs="0"/>
        <xs:element ref="collaborators"/>
        <xs:element ref="classification"/>
        <xs:element ref="version_history"/>
        <xs:element ref="company"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="subtitle" type="xs:string"/>

  <xs:element name="collaborators">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="reviewers"/>
        <xs:element ref="approver"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="reviewers">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="reviewer"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="reviewer" type="xs:string"/>

  <xs:element name="approver">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="name"/>
        <xs:element ref="bio"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="bio" type="xs:string"/>
  <xs:element name="classification" type="xs:NCName"/>

  <xs:element name="section">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="title"/>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
          <xs:element ref="pre"/>
          <xs:element ref="code"/>
          <xs:element name="p" type="block"/>
          <xs:element ref="section"/>
          <xs:element ref="table"/>
          <xs:element ref="ul"/>
          <xs:element ref="ol"/>
          <xs:element ref="img"/>
          <xs:element ref="div"/>
          <xs:element ref="biblioentries"/>
        </xs:choice>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute ref="break" use="optional"/>
      <xs:attribute ref="visibility" use="optional"/>
      <xs:attribute ref="xml:base"/>
    </xs:complexType>
  </xs:element>

  <xs:element name="appendix">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="title"/>
        <xs:choice maxOccurs="unbounded">
          <xs:element name="p" type="block"/>
          <xs:element ref="pre"/>
          <xs:element ref="code"/>
          <xs:element ref="table"/>
          <xs:element ref="ol"/>
          <xs:element ref="ul"/>
          <xs:element ref="img"/>
          <xs:element ref="div"/>
          <xs:element ref="section"/>
        </xs:choice>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:ID"/>
      <xs:attribute ref="visibility" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="block" mixed="true">
    <xs:choice maxOccurs="unbounded">
      <xs:group ref="inline-all"/>
      <xs:group ref="placeholders"/>
    </xs:choice>
    <xs:attribute ref="xml:base"/>
  </xs:complexType>

  <!-- Placeholders -->

  <xs:group name="placeholders">
    <xs:choice/>
  </xs:group>
</xs:schema>
