<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.fb10.uni-bremen.de/anglistik/langpro/kpml/README.html"
            xmlns="http://www.fb10.uni-bremen.de/anglistik/langpro/kpml/README.html"
            elementFormDefault="qualified">

<xsd:element name="CHOOSERS">
    <xsd:complexType>  
            <xsd:sequence>
                <xsd:element name="COMMENTS" type="xsd:string">
                </xsd:element>
                <xsd:element name="IN-REGION" type="xsd:string">
                </xsd:element>
                <xsd:element name="IN-LANGUAGE">
                    <xsd:simpleType>
                        <xsd:list itemType="xsd:string"/>
                    </xsd:simpleType>
                </xsd:element>                
                <xsd:element name="CHOOSER" minOccurs="1" maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="NAME" type="xsd:string"/>
                            <xsd:element name="DEFINITION" type="chooserDefinitionType"/>
                            <xsd:element name="COMMENTS" type="xsd:string" minOccurs="0"/>
                            <xsd:element name="EDITOR" type="xsd:string" minOccurs="0"/>
                            <xsd:element name="DATE" type="xsd:string" minOccurs="0"/>
                        </xsd:sequence>
                    </xsd:complexType>    
                </xsd:element>    
            </xsd:sequence>
        </xsd:complexType>              
    </xsd:element>
    
    <xsd:complexType name="chooserDefinitionType">
        <xsd:choice minOccurs="1" maxOccurs="unbounded">
            <xsd:element ref="realization"/>
            <xsd:element name="choose" type="xsd:string"/>                      
            <xsd:element name="ask" type="qInquiryType"/>
            <xsd:element name="identify" type="identifyExpressionType"/>
            <xsd:element name="copyhub" type="copyhubExpressionType"/>
            <xsd:element name="pledge" type="pledgeExpressionType"/>
            <xsd:element name="comment" type="xsd:string"/>
        </xsd:choice>
    </xsd:complexType>
    
    <xsd:complexType name="qInquiryType">
        <xsd:sequence>
            <xsd:element name="q">
                <xsd:complexType>
                    <xsd:sequence>
                        <xsd:element name="qName" type="xsd:string"/>
                        <xsd:element name="qArg" type="xsd:string"
                            minOccurs="1" maxOccurs="unbounded"/>
                    </xsd:sequence>
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="qRslt" type="genericQInquiryResultType"
              minOccurs="1" maxOccurs="unbounded"/>
            <xsd:element name="comment" type="xsd:string"
              minOccurs="0" maxOccurs="1"/>  
        </xsd:sequence>
    </xsd:complexType>   
    
    <xsd:complexType name="genericQInquiryResultType">
        <xsd:sequence>
            <xsd:element name="feature" type="xsd:string"/>
            <xsd:element name="outcome">
                <xsd:complexType>
                    <xsd:choice minOccurs="1" maxOccurs="unbounded">
                        <xsd:element ref="realization"/>
                        <xsd:element name="choose" type="xsd:string"/>                      
                        <xsd:element name="ask" type="qInquiryType"/>
                        <xsd:element name="identify" type="identifyExpressionType"/>
                        <xsd:element name="copyhub" type="copyhubExpressionType"/>
                        <xsd:element name="pledge" type="pledgeExpressionType"/>
                        <xsd:element name="comment" type="xsd:string"/>
                    </xsd:choice>
                </xsd:complexType>    
            </xsd:element>    
        </xsd:sequence>
    </xsd:complexType>
    
    <xsd:complexType name="pledgeExpressionType">
        <xsd:annotation><xsd:documentation>
        Note to John: I'm not totally clear on the semantics
        of pledge yet: I have guessed the two arguments should
        be called "feature" and "when".  Let me know if this 
        needs to be changed.
        </xsd:documentation></xsd:annotation>
        <xsd:sequence>
            <xsd:element name="feature" type="xsd:string"/>
            <xsd:element name="when" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
          
    <xsd:complexType name="identifyExpressionType">
        <xsd:sequence>     
            <xsd:element name="feature" type="xsd:string"/>                
            <xsd:element name="using" type="idInquiryType"/>
        </xsd:sequence>
    </xsd:complexType>
    
    <xsd:complexType name="idInquiryType">
        <xsd:sequence>
            <xsd:element name="idName" type="xsd:string"/>
            <xsd:element name="idArg" type="xsd:string"
                minOccurs="1" maxOccurs="unbounded"/>
        </xsd:sequence>
    </xsd:complexType>   
    
    <xsd:complexType name="copyhubExpressionType">
        <xsd:sequence>     
            <xsd:element name="from" type="xsd:string"/>                
            <xsd:element name="to" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
    
    <!--FOLLOWING GIVES SPECIFICATION OF REALIZATION OPERATORS,
        THAT ARE EMBEDDED IN THE OUTPUT EXPRESSIONS-->
                        
    <xsd:element name="realization" type="realizationType" abstract="true"/>
    <xsd:complexType name="realizationType" abstract="true">
    <xsd:sequence>        
    </xsd:sequence>
    </xsd:complexType>  

    <xsd:element name="insert" 
    type="insertType" substitutionGroup="realization"/>
    <xsd:complexType name="insertType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="order-at-front" 
    type="order-at-frontType" substitutionGroup="realization"/>
    <xsd:complexType name="order-at-frontType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="order-at-end" 
    type="order-at-endType" substitutionGroup="realization"/>
    <xsd:complexType name="order-at-endType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="expand" 
    type="expandType" substitutionGroup="realization"/>
    <xsd:complexType name="expandType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
                <xsd:element name="b" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="conflate" 
    type="conflateType" substitutionGroup="realization"/>
    <xsd:complexType name="conflateType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
                <xsd:element name="b" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="preselect" 
    type="preselectType" substitutionGroup="realization"/>
    <xsd:complexType name="preselectType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
                <xsd:element name="b" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="partition" 
    type="partitionType" substitutionGroup="realization"/>
    <xsd:complexType name="partitionType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
                <xsd:element name="b" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="order" 
    type="orderType" substitutionGroup="realization"/>
    <xsd:complexType name="orderType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
                <xsd:element name="b" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="classify" 
    type="classifyType" substitutionGroup="realization"/>
    <xsd:complexType name="classifyType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
                <xsd:element name="b" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="outclassify" 
    type="outclassifyType" substitutionGroup="realization"/>
    <xsd:complexType name="outclassifyType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
                <xsd:element name="b" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="inflectify" 
    type="inflectifyType" substitutionGroup="realization"/>
    <xsd:complexType name="inflectifyType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
                <xsd:element name="b" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="lexify" 
    type="lexifyType" substitutionGroup="realization"/>
    <xsd:complexType name="lexifyType">
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>
                <xsd:element name="b" type="xsd:string"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="agreement" 
    type="agreementType" substitutionGroup="realization"/>               
    <xsd:complexType name="agreementType">
    <xsd:annotation><xsd:documentation>
            An agreement realization statement has the most complex
            syntax: it accepts a single string argument (the feature
            to which the agreement is applied, followed by at least
            one realization expression, which can be either one or
            two argument functions.
            ? can agreement accept another agreement as argument ?
    </xsd:documentation></xsd:annotation>
    <xsd:complexContent>
        <xsd:extension base="realizationType" >
            <xsd:sequence>
                <xsd:element name="a" type="xsd:string"/>    
                <xsd:element name="b"  type="xsd:string"/>
                <xsd:element ref="realization" minOccurs="1" maxOccurs="unbounded"/>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>    
    </xsd:complexType>           


</xsd:schema>
