<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE schema  PUBLIC "-//W3C//DTD XMLSchema 200102//EN"
 "http://www.w3.org/2001/XMLSchema.dtd"
 [
   <!ATTLIST schema
     xmlns:enc CDATA #FIXED 'http://www.w3.org/2001/04/xmlenc#'
     xmlns:ds CDATA #FIXED 'http://www.w3.org/2000/09/xmldsig#'>
   <!ENTITY % p ''>
   <!ENTITY % s ''>
  ]>
  
<schema xmlns='http://www.w3.org/2001/XMLSchema' version='0.1'
        xmlns:ds='http://www.w3.org/2000/09/xmldsig#'
        xmlns:enc='http://www.w3.org/2001/04/xmlenc#'
        targetNamespace='http://www.w3.org/2001/04/xmlenc#'
        elementFormDefault='qualified'>

  <import namespace='http://www.w3.org/2000/09/xmldsig#'
          schemaLocation='http://www.w3.org/TR/2001/CR-xmldsig-core-20010419/xmldsig-core-schema.xsd'/>

  <complexType name='EncryptedType' abstract='true'>
    <sequence>
      <element name='EncryptionMethod' type='ds:DigestMethodType'
       minOccurs='0'/>
      <element ref='ds:KeyInfo' minOccurs='0'/>
      <element ref='enc:CipherData'/>
    </sequence>
    <attribute name='Id' type='ID' use='optional'/>
  </complexType>

  
  <element name='CipherData' type='enc:CipherDataType'/>
  <complexType name='CipherDataType'>
    <sequence>
      <choice>
        <element name='CipherValue' type='ds:CryptoBinary'/>
        <element ref='enc:CipherReference'/>
      </choice>
      <sequence minOccurs='0'>
        <element ref='ds:DigestMethod'/> 
        <element ref='ds:DigestValue'/> 
      </sequence>
     </sequence>
   </complexType>

   <element name='CipherReference' type='enc:CipherReferenceType'/>
   <complexType name='CipherReferenceType'>
       <choice>
         <element name='Transforms' minOccurs='0'/>
       </choice>
       <attribute name='URI' type='anyURI' use='required'/>
   </complexType>


     <element name="Transforms" type="ds:TransformsType"/>
     <complexType name="TransformsType">
       <sequence>
         <element ref="ds:Transform" maxOccurs="unbounded"/> 
       </sequence>
     </complexType>


  <element name='EncryptedData' type='enc:EncryptedDataType'/>
  <complexType name='EncryptedDataType'>
    <complexContent>
      <extension base='enc:EncryptedType'>
        <attribute name='Type' type='anyURI' use='optional'/>
      </extension>
    </complexContent>
  </complexType>

  <!-- Children of ds:KeyInfo -->
  
  <element name='EncryptedKey' type='enc:EncryptedKeyType'/>
  <complexType name='EncryptedKeyType'>
    <complexContent>
      <extension base='enc:EncryptedType'>
        <sequence>
          <element ref='enc:ReferenceList' minOccurs='0'/>
        </sequence>
        <attribute name='CarriedKeyName' type='string'
         use='optional'/>
        <attribute name='Recipient' type='string'
         use='optional'/>
      </extension>
    </complexContent>   
  </complexType>

   <element name='KeyRetrievalMethod' type='enc:KeyRetrievalMethodType' />
   <complexType name='KeyRetrievalMethodType'>
     <complexContent>
       <restriction base='ds:RetrievalMethodType'>
         <sequence>
           <element name='Transforms' type='ds:TransformsType' minOccurs='0'/> 
         </sequence>  
         <attribute name='URI' type='anyURI'/>
         <attribute name='Type' type='anyURI' use='optional'
          fixed='http://www.w3.org/2001/04/xmlenc#EncryptedKey' />
       </restriction>
     </complexContent>
   </complexType>

  <!-- End Children of ds:KeyInfo -->

  <element name='ReferenceList'>
    <complexType>
      <sequence>
        <element name='DataReference' type='enc:ReferenceType'
         minOccurs='0' maxOccurs='unbounded'/>
        <element name='KeyReference' type='enc:ReferenceType'
         minOccurs='0' maxOccurs='unbounded'/>
      </sequence>
    </complexType>
  </element>

  <complexType name='ReferenceType'>
    <sequence>
      <any namespace='##other' minOccurs='0' maxOccurs='unbounded'/>
    </sequence>
    <attribute name='URI' type='anyURI' use='optional'/>
  </complexType>

</schema>

