<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="urn:liberty:disco:2003-08" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns:md="urn:liberty:metadata:2003-08" 
    xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" 
    xmlns="urn:liberty:disco:2003-08" 
    elementFormDefault="qualified" 
    attributeFormDefault="unqualified">

   <xs:include schemaLocation="liberty-idwsf-utility-v1.1.xsd"/>

   <xs:import namespace="urn:liberty:metadata:2003-08" 
    schemaLocation="liberty-metadata-v1.1.xsd"/>

   <xs:import namespace="http://www.w3.org/2001/04/xmlenc#" 
    schemaLocation="http://www.w3.org/TR/2002/REC-xmlenc-core-20021210/xenc-schema.xsd"/>
   <xs:annotation>
      <xs:documentation>

        XML Schema from Liberty Discovery Service Specification.

        ### NOTICE ###   

        Copyright (c) 2004 Liberty Alliance participants, see
        http://www.projectliberty.org/specs/idwsf_1_1_copyrights.php

      </xs:documentation>
   </xs:annotation>
   <xs:element name="ServiceType" type="xs:anyURI"/>

   <xs:complexType name="ResourceIDType">
      <xs:simpleContent>
         <xs:extension base="xs:anyURI">
            <xs:attribute name="id" type="xs:ID" use="optional"/>
         </xs:extension>
      </xs:simpleContent>
   </xs:complexType>

   <xs:complexType name="EncryptedResourceIDType">
      <xs:sequence>
         <xs:element ref="xenc:EncryptedData"/>
         <xs:element ref="xenc:EncryptedKey"/>
      </xs:sequence>
   </xs:complexType>

   <xs:element name="ResourceID" type="ResourceIDType"/>
   <xs:element name="EncryptedResourceID" type="EncryptedResourceIDType"/>

   <!--
        if not present, equivalent to
        <ResourceID>urn:liberty:isf:implied-resource</ResourceID>
        (see specification text for details)
     -->

   <xs:group name="ResourceIDGroup">
      <xs:sequence>
         <xs:choice minOccurs="0" maxOccurs="1">
            <xs:element ref="ResourceID"/>
            <xs:element ref="EncryptedResourceID"/>
         </xs:choice>
      </xs:sequence>
   </xs:group>

   <xs:complexType name="DescriptionType">
      <xs:sequence>
         <xs:element name="SecurityMechID" type="xs:anyURI" minOccurs="1" maxOccurs="unbounded"/>
         <xs:element name="CredentialRef" type="xs:IDREF" minOccurs="0" maxOccurs="unbounded"/>
         <xs:choice>
            <xs:group ref="WsdlRef"/>
            <xs:group ref="BriefSoapHttpDescription"/>
         </xs:choice>
      </xs:sequence>
      <xs:attribute name="id" type="xs:ID" use="optional"/>
   </xs:complexType>

   <xs:complexType name="ServiceInstanceType">
      <xs:sequence>
         <xs:element ref="ServiceType"/>
         <xs:element name="ProviderID" type="md:entityIDType"/>
         <xs:element name="Description" type="DescriptionType" minOccurs="1" maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>
   <xs:group name="WsdlRef">
      <xs:sequence>
         <xs:element name="WsdlURI" type="xs:anyURI"/>
         <xs:element name="ServiceNameRef" type="xs:QName"/>
      </xs:sequence>
   </xs:group>
   <xs:group name="BriefSoapHttpDescription">
      <xs:sequence>
         <xs:element name="Endpoint" type="xs:anyURI"/>
         <xs:element name="SoapAction" type="xs:anyURI" minOccurs="0"/>
      </xs:sequence>
   </xs:group>
   <xs:element name="ResourceOffering" type="ResourceOfferingType"/>
   <xs:complexType name="ResourceOfferingType">
      <xs:sequence>
         <xs:group ref="ResourceIDGroup"/>
         <xs:element name="ServiceInstance" type="ServiceInstanceType"/>
         <xs:element ref="Options" minOccurs="0"/>
         <xs:element name="Abstract" type="xs:string" minOccurs="0"/>
      </xs:sequence>
      <xs:attribute name="entryID" type="IDType" use="optional"/>
   </xs:complexType>
   <xs:element name="Options" type="OptionsType"/>
   <xs:complexType name="OptionsType">
      <xs:sequence>
         <xs:element name="Option" type="xs:anyURI" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>
   <xs:element name="Query" type="QueryType"/>
   <xs:complexType name="QueryType">
      <xs:sequence>
         <xs:group ref="ResourceIDGroup"/>
         <xs:element name="RequestedServiceType" minOccurs="0" maxOccurs="unbounded">
            <xs:complexType>
               <xs:sequence>
                  <xs:element ref="ServiceType"/>
                  <xs:element ref="Options" minOccurs="0"/>
               </xs:sequence>
            </xs:complexType>
         </xs:element>
      </xs:sequence>
      <xs:attribute name="id" type="xs:ID" use="optional"/>
   </xs:complexType>
   <xs:element name="QueryResponse" type="QueryResponseType"/>
   <xs:complexType name="QueryResponseType">
      <xs:sequence>
         <xs:element ref="Status"/>
         <xs:element ref="ResourceOffering" minOccurs="0" maxOccurs="unbounded"/>
         <xs:element name="Credentials" minOccurs="0">
            <xs:complexType>
               <xs:sequence>
                  <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
               </xs:sequence>
            </xs:complexType>
         </xs:element>
      </xs:sequence>
      <xs:attribute name="id" type="xs:ID" use="optional"/>
   </xs:complexType>
   <xs:complexType name="InsertEntryType">
      <xs:sequence>
         <xs:element ref="ResourceOffering"/>
         <xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>

   <xs:complexType name="RemoveEntryType">
      <xs:attribute name="entryID" type="IDReferenceType" use="required"/>
   </xs:complexType>

   <xs:element name="Modify" type="ModifyType"/>
   <xs:complexType name="ModifyType">
      <xs:sequence>
         <xs:group ref="ResourceIDGroup"/>
         <xs:element name="InsertEntry" type="InsertEntryType" minOccurs="0" maxOccurs="unbounded"/>
         <xs:element name="RemoveEntry" type="RemoveEntryType" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute name="id" type="xs:ID" use="optional"/>
   </xs:complexType>
   <xs:complexType name="DirectiveType">
     <xs:attribute name="descriptionIDRefs" type="xs:IDREFS" use="optional"/>
   </xs:complexType>
   <xs:element name="AuthenticateRequester" type="DirectiveType"/>
   <xs:element name="AuthorizeRequester" type="DirectiveType"/>
   <xs:element name="AuthenticateSessionContext" type="DirectiveType"/>
   <xs:element name="EncryptResourceID" type="DirectiveType"/>
   <xs:element name="ModifyResponse" type="ModifyResponseType"/>
   <xs:complexType name="ModifyResponseType">
      <xs:sequence>
         <xs:element ref="Status"/>
	 <xs:element ref="Extension" minOccurs="0" maxOccurs="1"/>
      </xs:sequence>
      <xs:attribute name="id" type="xs:ID" use="optional"/>
      <xs:attribute name="newEntryIDs" use="optional">
         <xs:simpleType>
            <xs:list itemType="IDReferenceType"/>
         </xs:simpleType>
      </xs:attribute>
   </xs:complexType>
</xs:schema>

