<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="xri://$xrd*($v*2.0)"
           elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:xrd="xri://$xrd*($v*2.0)"
           xmlns:ds="http://www.w3.org/2000/09/xmldsig#">

  <!-- Utility patterns -->
  <xs:attributeGroup name="otherattribute">
    <xs:anyAttribute namespace="##other" processContents="lax"/>
  </xs:attributeGroup>
  <xs:group name="otherelement">
    <xs:choice>
      <xs:any namespace="##other" processContents="lax"/>
      <xs:any namespace="##local" processContents="lax"/>
    </xs:choice>
  </xs:group>
  <xs:complexType name="URIpattern">
    <xs:simpleContent>
      <xs:extension base="xs:anyURI">
        <xs:attributeGroup ref="xrd:otherattribute"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <xs:complexType name="Stringpattern">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attributeGroup ref="xrd:otherattribute"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
  <!-- Patterns for elements -->
  <xs:element name="XRD">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="xrd:Query" minOccurs="0"/>
        <xs:element ref="xrd:Expires" minOccurs="0"/>
        <xs:element ref="xrd:Synonym" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="xrd:XSynonym" minOccurs="0" maxOccurs="unbounded"/>

        <xs:element ref="xrd:ProviderID"/>
        <xs:element ref="xrd:Service" minOccurs="0" maxOccurs="unbounded"/>
        <xs:group ref="xrd:otherelement" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attribute ref="xrd:id"/>
      <xs:attribute ref="xrd:version"/>
      <xs:attributeGroup ref="xrd:otherattribute"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="Query" type="xrd:Stringpattern"/>
  <xs:element name="Expires">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:dateTime">
          <xs:attributeGroup ref="xrd:otherattribute"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
  <xs:element name="Synonym" type="xrd:URIpattern"/>
  <xs:element name="XSynonym" type="xrd:URIpattern"/>
  <xs:element name="ProviderID" type="xrd:URIpattern"/>
  <xs:element name="Service">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="xrd:Type" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="xrd:MediaType" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="xrd:Pattern" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="xrd:URI" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element ref="xrd:ProviderID" minOccurs="0"/>
        <xs:group ref="xrd:otherelement" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attributeGroup ref="xrd:otherattribute"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="Type" type="xrd:URIpattern"/>
  <xs:element name="MediaType" type="xrd:Stringpattern"/>
  <xs:element name="Pattern" type="xrd:Stringpattern"/>
  <xs:element name="URI" type="xrd:URIpattern"/>
  <xs:attribute name="priority" type="xs:nonNegativeInteger"/>
  <xs:attribute name="version" type="xs:string" fixed="2.0"/>
  <xs:attribute name="id" type="xs:ID"/>
</xs:schema>

