<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="urn:mesquite"
    xmlns:msq="urn:mesquite"
    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:msq="urn:mesquite" attribute does. The prefix 'msq'
            is now associated with the urn:mesquite 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="../xsd/nexml.xsd"/>
    
    <!-- You then import the main schema and specify what namespace the 
        entities in that schema should be associated with. -->
    
    <xs:simpleType name="ColorKey"> <!-- here we define a restricted dictionary key -->        
        <xs:restriction base="xs:string">
            <xs:pattern value="color"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="ColorVal"> <!-- here we define a restricted dictionary value -->
        <xs:restriction base="xs:string">
            <xs:pattern value="red|green|blue"/>
        </xs:restriction>
    </xs:simpleType> 
    <xs:complexType name="MesquiteColor"> <!-- 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="msq:ColorKey" minOccurs="1" maxOccurs="1"/>
                    <xs:element name="string" type="msq:ColorVal" minOccurs="1" maxOccurs="1"/>                  
                </xs:sequence>
            </xs:restriction>
        </xs:complexContent>
    </xs:complexType>

</xs:schema>