<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
           xmlns:vr="http://www.ivoa.net/xml/VOResource/v1.0"
           xmlns:vs="http://www.ivoa.net/xml/VODataService/v1.0"
           xmlns:sn="http://www.ivoa.net/xml/SkyNode/v0.2"
           xmlns:vm="http://www.ivoa.net/xml/VOMetadata/v0.1"
           targetNamespace="http://www.ivoa.net/xml/SkyNode/v0.2"
           elementFormDefault="unqualified" attributeFormDefault="unqualified"
           version="0.2r1">
   
   <xs:annotation>
      <xs:appinfo>
        <vm:schemaName>SkyNode</vm:schemaName>
        <vm:schemaPrefix>xs</vm:schemaPrefix>
        <vm:targetPrefix>sn</vm:targetPrefix>
      </xs:appinfo>
      <xs:documentation>
        Implementation of an XML Schema describing a SkyNode Service.
        Based on 
        http://www.ivoa.net/internal/IVOA/IvoaVOQL/SkyNodeInterface-0.7.4.pdf
      </xs:documentation>
   </xs:annotation>

   <xs:import namespace="http://www.ivoa.net/xml/VOResource/v1.0"
            schemaLocation="http://www.ivoa.net/xml/VOResource/v1.0"/>
   <xs:import namespace="http://www.ivoa.net/xml/VODataService/v1.0"
            schemaLocation="http://www.ivoa.net/xml/VODataService/v1.0"/>

   <xs:complexType name="SNCapRestriction" abstract="true">
      <xs:annotation>
         <xs:documentation>
            an abstract capability that sets the standardID to the
            IVOA ID for the Open SkyNode interface standard definition.
         </xs:documentation>
         <xs:documentation>
            See vr:Capability for documentation on inherited children.
         </xs:documentation>
      </xs:annotation>
      
      <xs:complexContent>
         <xs:restriction base="vr:Capability">
            <xs:sequence>
               <xs:element name="validationLevel" type="vr:Validation"
                        minOccurs="0" maxOccurs="unbounded"/>
               <xs:element name="description" type="xs:token" 
                        minOccurs="0"/>
               <xs:element name="interface" type="vr:Interface" 
                        minOccurs="0" maxOccurs="unbounded"/>            
            </xs:sequence>
            <xs:attribute name="standardID" type="vr:IdentifierURI"
                       use="required" 
                       fixed="ivo://ivoa.net/std/OpenSkyNode"/>
         </xs:restriction>
      </xs:complexContent>
   </xs:complexType>
   
   <xs:complexType name="OpenSkyNode">
      <xs:annotation>
         <xs:documentation>
            The capabilities of an OpenSkynode interface.
            The standard OpenSkyNode interface is defined to be WebService; 
            the specifics of this interface (e.g. the supported inputs)
            can be given using xsi:type="WebService" with the Interface 
            element.  
         </xs:documentation>
      </xs:annotation>

      <xs:complexContent>
         <xs:extension base="sn:SNCapRestriction">
            <xs:sequence>
               <xs:element name="compliance" type="sn:Compliance">
                  <xs:annotation>
                     <xs:documentation>
                       The functionality supported by this implementation
                     </xs:documentation>
<!--
                     <xs:documentation>
                        Use Basic is there is not compliance.
                     </xs:documentation>
  -->
                  </xs:annotation>
               </xs:element>
               
               <xs:element name="longitude" type="xs:double">
                  <xs:annotation>
                     <xs:documentation>
                        The longitude Earth position of the 
                        machine hosting this service.
                     </xs:documentation>
                     <xs:documentation>
                        This is used for graphical display purpose
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>
               
               <xs:element name="latitude" type="xs:double">
                  <xs:annotation>
                     <xs:documentation>
                        The approximate latitude Earth position of the 
                        machine hosting this service.
                     </xs:documentation>
                     <xs:documentation>
                        This is used for graphical display purpose
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>
                              
               <xs:element name="maxRecords" type="xs:int" >
                  <xs:annotation>
                     <xs:documentation>
                        The largest number of records that the service will 
                        return. 
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>
               
               <xs:element name="primaryTable" type="xs:string" 
                           minOccurs="1" maxOccurs="1">
                  <xs:annotation>
                     <xs:documentation>
                        Table name which contains the main positions and key
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>
               
               <xs:element name="primaryKey" type="xs:string"  
                           minOccurs="1" maxOccurs="1">
                  <xs:annotation>
                     <xs:documentation>
                       The primary key of the primary Table
                     </xs:documentation>
                  </xs:annotation>
               </xs:element>

            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>

   <xs:simpleType name="Compliance">
     <xs:restriction base="xs:token">
         <xs:enumeration value="Basic">
           <xs:annotation>
             <xs:documentation>
                This service complies with the Basic SkyNode functionality 
                as described in the SkyNode specificaiton.  In general, it 
                responds to the processQuery function but not to the 
                executePlan function.
             </xs:documentation>
           </xs:annotation>
         </xs:enumeration>
         <xs:enumeration value="Full">
           <xs:annotation>
             <xs:documentation>
                This service complies with the Full SkyNode functionality 
                as described in the SkyNode specificaiton, responding correctly
                to all defined functions--most notably, executePlan.
             </xs:documentation>
           </xs:annotation>
         </xs:enumeration>
<!--
         <xs:enumeration value="Partial">
           <xs:annotation>
             <xs:documentation>
                This service complies with the Partial SkyNode functionality 
                as described in the SkyNode specificaiton.  [Further 
                clarification needed here.]
             </xs:documentation>
           </xs:annotation>
         </xs:enumeration>
  -->
      </xs:restriction>
   </xs:simpleType>

</xs:schema>
