<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.nexml.org/2009" xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.nexml.org/2009" elementFormDefault="qualified">
  <xs:annotation>
    <xs:documentation>
      This module constitutes in effect the 'main' class of the nexml schema.
      It defines the complex type for the root &lt;<a href="#Nexml">nex:nexml</a>&gt; 
      element and a simple type for the schema <a href="#Nexml1_0">"version" attribute</a> 
      of the root element. In addition, this module includes the main schema modules for 
      <a href="../taxa/taxa">OTUs</a>, <a href="../characters/characters">characters</a>, 
      <a href="../trees/trees">trees</a> and <a href="../meta/meta">metadata</a>. The data 
      type definitions in these included schema modules are then used to define element 
      instances in the child substructures of the &lt;nex:nexml&gt; root element.      
    </xs:documentation>
  </xs:annotation>

  <xs:include schemaLocation="taxa/taxa.xsd"/>
  <xs:include schemaLocation="characters/characters.xsd"/>
  <xs:include schemaLocation="trees/trees.xsd"/>
  <xs:include schemaLocation="meta/annotations.xsd"/>

  <xs:simpleType name="Nexml1_0">
    <xs:annotation>
      <xs:documentation>
        This simple type is the fixed version value, which in this
        iteration must be constrained to 0.9 (and will be incremented
        in future versions).
      </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:decimal">
      <xs:pattern value="0\.9"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="Nexml" mixed="false">
    <xs:annotation>
      <xs:documentation>
        The root element for nexml.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent mixed="false">
      <xs:extension base="Annotated">
        <xs:sequence maxOccurs="unbounded" minOccurs="0">          
          <xs:element maxOccurs="unbounded" minOccurs="1" name="otus" type="Taxa"/>                                          
          <xs:sequence maxOccurs="unbounded" minOccurs="0">
            <xs:choice>
              <xs:element maxOccurs="unbounded" minOccurs="0" name="characters" type="AbstractBlock"/>
              <xs:element maxOccurs="unbounded" minOccurs="0" name="trees" type="Trees"/>              
            </xs:choice>
          </xs:sequence>
        </xs:sequence>
        <xs:attribute name="version" type="Nexml1_0" use="required"/>
        <xs:attribute name="generator" type="xs:string" use="optional"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <!-- the root of the document -->
  <xs:element name="nexml" type="Nexml"/>
  
</xs:schema>
