<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema
   targetNamespace="http://www.opengis.net/wrs"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns:ogc="http://www.opengis.net/ogc"
   xmlns:wrs="http://www.opengis.net/wrs"
   elementFormDefault="qualified"
   version="0.7.1">

  <xsd:annotation>
    <xsd:appinfo source="urn:opengis:specification:wrs:schema-xsd:query:v0.7.1"/>
    <xsd:documentation xml:lang="en">
    This schema defines request and response messages for WRSQuery operations.
    Copyright (c) 2002 OGC, All Rights Reserved.
    </xsd:documentation>
  </xsd:annotation>
  <!-- import filter components -->
  <xsd:import namespace="http://www.opengis.net/ogc" schemaLocation="../../filter/1.0.20/filter.xsd"/>
  <!-- message components -->
  <xsd:element name="GetCapabilities" type="wrs:GetCapabilitiesType"/>
  <xsd:element name="GetCapabilitiesResponse" type="wrs:GetCapabilitiesResponseType"/>
  <xsd:element name="DescribeType" type="wrs:DescribeType"/>
  <xsd:element name="DescribeTypeResponse" type="wrs:DescribeTypeResponseType"/>
  <xsd:element name="GetRecord" type="wrs:GetRecordType"/>
  <xsd:element name="GetRecordResponse" type="wrs:GetRecordResponseType"/>
  <xsd:element name="GetResourceByID" type="wrs:GetResourceByIDType"/>
  <xsd:element name="GetResourceByIDResponse" type="wrs:GetResourceByIDResponseType"/>
  <xsd:element name="Query" type="wrs:QueryType"/>
  <xsd:element name="PropertySetName" type="wrs:PropertySetNameType" default="Brief"/>
  <!-- type definitions -->
  <xsd:complexType name="GetCapabilitiesType">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
      Requests the capability profile for the service.
      serviceType : a URI reference to request the profile for a
                    particular service type;
      version     : the version of the request syntax;
      timeStamp   : a dateTime stamp (ISO 8601 format) that requests the
                    profile in effect at the specified instant.
      xpath       : an XPath 1.0 expression that specifies a set of nodes in
                    the capability profile;
      view        : a named view that specifies a subset of the profile.
      id          : a list of xsd:anyURI values that selects specific elements
                    of the capability profile by their unique identifier.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="serviceType" type="xsd:anyURI" default="http://www.opengis.net/wrs" minOccurs="0"/>
      <xsd:element name="timeStamp" type="xsd:dateTime" minOccurs="0"/>
      <xsd:choice minOccurs="0">
        <xsd:element name="xpath" type="xsd:string"/>
        <xsd:element name="view" type="xsd:QName"/>
      </xsd:choice>
      <xsd:element name="id" type="wrs:IDListType" minOccurs="0"/>
    </xsd:sequence>
    <xsd:attribute name="version" type="xsd:string" use="optional" default="0.7.1"/>
  </xsd:complexType>
  <xsd:complexType name="GetCapabilitiesResponseType">
    <xsd:annotation>
      <xsd:documentation>
      Response contains an OGC capabilities document, or fragments thereof.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:any namespace="http://www.opengis.net/ows" processContents="lax" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="GetResourceByIDType">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
      Requests a specific resource by identifier.
      id : a URI value specifiying the id of the repository item.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="id" type="xsd:anyURI"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="GetResourceByIDResponseType">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
      Response contains either the XML resource or a URL to fetch it.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:choice>
      <xsd:any namespace="##other" maxOccurs="unbounded"/>
      <xsd:element name="contentURL" type="xsd:anyURI"/>
    </xsd:choice>
  </xsd:complexType>
  <xsd:complexType name="GetRecordType">
      <xsd:annotation>
         <xsd:documentation xml:lang="en">
            The GetRecord element contains one or more Query elements
            that define queries on registry objects.  The defined
            attributes have the following meanings:

            version       - the version of the spec to which this request
                            conforms; should be 0.7.1 for this version of
                            the DIPR
            serviceType   - a URI indicating the type of service being
                            invoked; this is used by servers that implement
                            multiple services in a single executable and need
                            a way to indicate which service to invoke
            handle        - a mnemonic string to identify the operation for 
                            error handling purposes; the intent is to be able
                            to report the handle in the event of an exception
                            to identify the specific operation that failed
            outputFormat  - defines the format of the output; XML, TEXT,
                            HTML (default should be XML)
            outputRecType - defines the schema of the output; for example,
                            registries that use the ogcrim as the external
                            model should define the outputRecType, OGCRIM
                            to indicate that that schema should be used for
                            the response (default should be OGCRIM)
            startPosition - indicates the number of the record in the result
                            set from which to begin reporting response
                            instances; eg. start at the 10th record
            maxRecords    - defines the maximum number of record that should
                            displayed regardless of the number of records 
                            actually identified
         </xsd:documentation>
      </xsd:annotation>
    <xsd:sequence>
      <xsd:element ref="wrs:Query" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute name="version" type="xsd:string" use="optional" default="0.7.1"/>
    <xsd:attribute name="serviceType" type="xsd:anyURI" use="optional" default="http://www.opengis.net/services#WRS"/>
    <xsd:attribute name="handle" type="xsd:string" use="optional"/>
    <xsd:attribute name="outputFormat" type="xsd:string" use="optional" default="XML"/>
    <xsd:attribute name="outputRecType" type="xsd:string" use="optional"/>
    <xsd:attribute name="startPosition" type="xsd:positiveInteger" use="optional"/>
    <xsd:attribute name="maxRecords" type="xsd:nonNegativeInteger" use="optional"/>
  </xsd:complexType>
  <xsd:complexType name="QueryType">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
      Specifies a query to execute against one or more object types.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:choice>
        <xsd:element ref="wrs:PropertySetName" minOccurs="0"/>
        <xsd:element ref="ogc:PropertyName" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:choice>
      <xsd:element name="QueryConstraint" type="wrs:QueryConstraintType" minOccurs="0"/>
    </xsd:sequence>
    <xsd:attribute name="handle" type="xsd:string" use="optional"/>
    <xsd:attribute name="typeName" type="wrs:TypeNameListType" use="required"/>
  </xsd:complexType>
  <xsd:complexType name="DescribeType">
    <xsd:annotation>
      <xsd:documentation xml:lang="en">
      Request type definitions.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:element name="TypeName" type="xsd:QName" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    <xsd:attribute name="version" type="xsd:string" use="optional"/>
    <xsd:attribute name="service" type="xsd:string" use="optional"/>
    <xsd:attribute name="outputFormat" type="xsd:string" use="optional" default="XMLSCHEMA"/>
  </xsd:complexType>
  <xsd:complexType name="QueryConstraintType">
    <xsd:choice>
      <xsd:element ref="ogc:Filter"/>
      <xsd:element name="CqlText" type="xsd:string"/>
      <xsd:element name="SfSql" type="xsd:string"/>
      <xsd:element name="SqlMM" type="xsd:string"/>
    </xsd:choice>
  </xsd:complexType>
  <xsd:simpleType name="TypeNameListType">
    <xsd:list itemType="xsd:QName"/>
  </xsd:simpleType>
  <xsd:complexType name="GetRecordResponseType">
    <xsd:sequence>
      <xsd:element name="searchParameter" type="wrs:SearchParameterType" minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element name="searchStatus" type="wrs:SearchStatusType"/>
      <xsd:element name="searchResults" type="wrs:SearchResultsType"/>
    </xsd:sequence>
    <xsd:attribute name="version" type="xsd:string" fixed="0.6.20"/>
  </xsd:complexType>
  <xsd:complexType name="SearchParameterType">
    <xsd:simpleContent>
      <xsd:extension base="xsd:string">
        <xsd:attribute name="name" type="xsd:string" use="required"/>
      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>
  <xsd:complexType name="SearchStatusType">
    <xsd:annotation>
      <xsd:documentation>
      This element contains a number of attributes that detail
      the status of the search.
      elementSetName  - The element set that has been returned
                        (e.g. brief, summary, full)
      numberOfRecords - The number of hits returned in this
                        result.
      schema          - The type of response returned (e.g.
                        OGCService, FGDC)
      success         - Was the search successful (true,
                        false)
      timestamp       - The date and time at the completion
                        of the search.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:attribute name="elementSetName" type="wrs:PropertySetNameType" use="optional"/>
    <xsd:attribute name="success" type="xsd:boolean" default="true"/>
    <xsd:attribute name="numberOfRecords" type="xsd:positiveInteger"/>
    <xsd:attribute name="schema" type="xsd:string" use="optional"/>
    <xsd:attribute name="timestamp" type="xsd:string" use="optional"/>
  </xsd:complexType>
  <xsd:complexType name="SearchResultsType">
    <xsd:annotation>
      <xsd:documentation>
      The holder for the results from the catalog.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence>
      <xsd:any namespace="##other" processContents="lax"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="DescribeTypeResponseType">
    <xsd:sequence>
      <xsd:element name="SchemaComponent" type="wrs:SchemaComponentType" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>
  <xsd:complexType name="SchemaComponentType">
    <xsd:sequence>
      <xsd:any namespace="http://www.w3.org/2001/XMLSchema"/>
    </xsd:sequence>
    <xsd:attribute name="targetNamespace" type="xsd:anyURI" use="required"/>
  </xsd:complexType>
  <xsd:simpleType name="PropertySetNameType">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="Brief"/>
      <xsd:enumeration value="Summary"/>
      <xsd:enumeration value="Full"/>
    </xsd:restriction>
  </xsd:simpleType>
  <xsd:simpleType name="IDListType">
    <xsd:list itemType="xsd:anyURI"/>
  </xsd:simpleType>
</xsd:schema>
