<!ENTITY % accepted
    "OK|Created|Accepted|PartialInformation|NoResponse">
<!ENTITY % redirected 
    "Moved|Found|Method|NotModified">
<!ENTITY % client-error
    "BadRequest|Unauthorized|PaymentRequired|Forbidden|NotFound|NoSuchGroup">
<!ENTITY % server-error
    "InternalError|NotImplemented">
<!ENTITY % HTTP-result
    "(%accepted;|%redirected;|%client-error;|%server-error;|other)">

<!ENTITY % QName "NMTOKEN">
<!ENTITY % QNames "NMTOKENS">
<!ENTITY % Name "NMTOKEN">
<!ENTITY % URI "CDATA">
<!ENTITY % Media-type "CDATA">
<!ENTITY % String "CDATA">
<!ENTITY % XPath "CDATA">

<!ELEMENT types (resourceType|representationType)*>
<!ATTLIST types xmlns %URI; #FIXED "http://www.prescod.net/rest/wrdl"
                targetNamespace %URI; #IMPLIED>

<!ENTITY % methods "(GET?,POST?,PUT?,DELETE?, otherMethod?)">

<!ELEMENT resourceType (%methods;)>
<!ATTLIST resourceType 
            representations NMTOKENS #REQUIRED
            name %Name; #REQUIRED>

<!ELEMENT GET (input?, output?)>
<!ELEMENT POST (input?, output?)>
<!ATTLIST POST createdResourceType %QName; #IMPLIED>
<!ELEMENT PUT (input?, output?)>
<!ELEMENT DELETE (input?, output?)>
<!ELEMENT otherMethod (input?, output?)>
<!ATTLIST otherMethod name %Name; #REQUIRED
                createdResourceType %QName; #IMPLIED>

<!ELEMENT input (query*, header*)>
<!ATTLIST input representations %QNames; #IMPLIED>

<!ELEMENT output (header*)>
<!ATTLIST output representations %QNames; #IMPLIED 
                 status %HTTP-result; #IMPLIED>

<!ELEMENT query (documentation?, appinfo?)>
<!ATTLIST query name %Name; #REQUIRED
                apiName %Name; #REQUIRED
                type %QName; "xsd:string"
                default %String; #IMPLIED
                use (optional|prohibited|required) "optional">

<!ELEMENT header (documentation?, appinfo?)>
<!ATTLIST header name  %Name; #IMPLIED
                apiName %Name; #IMPLIED
                type %QName; #IMPLIED
                default %String; #IMPLIED
                use (optional|prohibited|required) "optional">

<!ELEMENT urlEncodedRepresentation (query+)>
<!ATTLIST urlEncodedRepresentation name %Name; #REQUIRED>

<!ELEMENT formDataRepresentation (formData+)>
<!ATTLIST formDataRepresentation 
            name %Name; #REQUIRED
            mediaType %Media-type; "multipart/form-data">

<!ELEMENT formData (representationType?,documentation?,appinfo?)>
<!ATTLIST formData name %Name; #REQUIRED
                   apiName %Name; #REQUIRED
                   use (optional|prohibited|required) "optional">

<!ELEMENT representationType ((documentation|appinfo)*,
                                    referenceType*,schema*)>
<!ATTLIST representationType
            name %Name; #IMPLIED
            namespace %URI; #IMPLIED
            mediaType %Media-type; #IMPLIED>

<!ELEMENT schema (documentation?, appinfo?)>
<!ATTLIST schema 
            type %URI; #IMPLIED
            href %URI; #REQUIRED>
<!-- if applicable, use one of these types:

    * http://www.w3.org/2001/XMLSchema
    * http://relaxng.org/ns/structure/1.0
    * http://www.isi.edu/in-notes/iana/assignments/media-types/application/xml-dt
    * http://www.ascc.net/xml/schematron

Or else use a new URI.
-->

<!ELEMENT referenceType (documentation?, appinfo?)>

<!ATTLIST referenceType name %Name; #REQUIRED 
                    minOccurs NMTOKEN #REQUIRED
                    maxOccurs NMTOKEN #REQUIRED
                    match %XPath; #REQUIRED
                    key %XPath; #IMPLIED
                    resourceType %QName; #REQUIRED>

<!ELEMENT documentation (#PCDATA|p|b|a)>
<!-- in the future, just refer to HTML -->
<!ELEMENT appinfo (ANY)>
<!ELEMENT p (#PCDATA|b|a)>
<!ELEMENT b (#PCDATA|a)>
<!ELEMENT a (#PCDATA|b)>
<!ATTLIST a href %URI; #REQUIRED>


