<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.phenote.org"
    xmlns:phe="http://www.phenote.org"
    xmlns:nex="http://www.nexml.org/1.0">
    
    <!-- 
        How to extend dictionaries? Here's how:
        
        - you pick a targetNameSpace, and put that as an attribute
        in the <xs:schema> top level element. You can choose to have
        this namespace be defined by a URL, or by an urn (as here)
        
        - you associate a prefix with that namespace. This is what
        the xmlns:phe="http://www.phenote.org" attribute does. The 
        prefix 'phe' is now associated with the http://www.phenote.org 
        namespace
        
        - you define the main nexml namespace and prefix, which is
        what the xmlns:nex="http://www.nexml.org" does. The purpose
        of these three steps is to separate 'core' language features
        and extensions.
    -->
    
    <xs:import namespace="http://www.nexml.org/1.0" schemaLocation="http://www.nexml.org/1.0/nexml.xsd"/>
    
    <!-- You then import the main schema and specify what namespace the 
        entities in that schema should be associated with. -->
    
    <xs:simpleType name="TaxonIDKey"> <!-- here we define a restricted dictionary key -->        
        <xs:restriction base="xs:string">
            <xs:pattern value="taxonID"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="TaxonIDVal"> <!-- here we define a restricted dictionary value -->
        <xs:restriction base="xs:string">
            <xs:pattern value="TTO:[0-9]*"/>
        </xs:restriction>
    </xs:simpleType> 
    <xs:complexType name="TaxonID"> <!-- here we turn key and value into a subclass of the core 
        dictionary subclass nex:Dict -->
        <xs:complexContent>
            <xs:restriction base="nex:Dict">
                <xs:sequence minOccurs="1" maxOccurs="1">
                    <xs:element name="key" type="phe:TaxonIDKey" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="string" type="phe:TaxonIDVal" minOccurs="1" maxOccurs="1"/>                  
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>
    
</xs:schema>