<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.ivoa.net/xml/VOEvent/v1.1"
  xmlns:stc="http://www.ivoa.net/xml/STC/stc-v1.30.xsd"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"

  targetNamespace="http://www.ivoa.net/xml/VOEvent/v1.1"
  elementFormDefault="qualified">

  <xs:import namespace="http://www.ivoa.net/xml/STC/stc-v1.30.xsd"
    schemaLocation="http://www.ivoa.net/xml/STC/stc-v1.30.xsd"/>
  
  
  <!-- VOEvent is the root element for describing observations
    of immediate astronomical events. For more information, see
    http://www.ivoa.net/twiki/bin/view/IVOA/IvoaVOEvent -->

  <xs:element name="VOEvent">
    <xs:complexType>

      <xs:all>
        <xs:element ref="Who" minOccurs="0" />
        <xs:element ref="What" minOccurs="0" />
        <xs:element ref="WhereWhen" minOccurs="0" />
        <xs:element ref="How" minOccurs="0" />
        <xs:element ref="Why" minOccurs="0" />
        <xs:element ref="Citations" minOccurs="0" />
        <xs:element ref="Description" minOccurs="0" />
        <xs:element ref="Reference" minOccurs="0" />
      </xs:all>

      <xs:attribute name="version" type="xs:token" fixed="1.1" use="required" />

      <xs:attribute name="ivorn" type="xs:anyURI" use="required" />

      <xs:attribute name="role" default="observation"/>

    </xs:complexType>
  </xs:element>


  <!-- Who: Curation Metadata -->
  <xs:element name="Who">
    <xs:complexType>

      <xs:choice maxOccurs="unbounded">
        <xs:element name="AuthorIVORN" type="xs:anyURI" />
        <xs:element name="Date" type="xs:dateTime" />
        <xs:element ref="Description" />
        <xs:element ref="Reference" />

        <xs:element name="Author">
          <xs:complexType>

            <xs:choice maxOccurs="unbounded">
              <xs:element name="title" type="xs:string" />
              <xs:element name="shortName" type="xs:string" />
              <xs:element name="logoURL" type="xs:string" />
              <xs:element name="contactName" type="xs:string" />
              <xs:element name="contactEmail" type="xs:string" />
              <xs:element name="contactPhone" type="xs:string" />
              <xs:element name="contributor" type="xs:string" />
            </xs:choice>
          </xs:complexType>
        </xs:element>
      </xs:choice>

    </xs:complexType>
  </xs:element>


  <!-- What: Event Characterization -->
  <xs:element name="What">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element ref="Param" />
        <xs:element ref="Group" />
        <xs:element ref="Description" />
        <xs:element ref="Reference" />
      </xs:choice>
    </xs:complexType>
  </xs:element>

  <xs:element name="Param">
    <xs:complexType>
      <xs:attribute name="name" type="xs:token" />
      <xs:attribute name="ucd" type="xs:token" />
      <xs:attribute name="value" type="xs:string" />
      <xs:attribute name="unit" type="xs:string" />
    </xs:complexType>
  </xs:element>

  <xs:element name="Group">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element ref="Param" />
        <xs:element ref="Description" />
        <xs:element ref="Reference" />
      </xs:choice>
      <xs:attribute name="name" type="xs:string" />
      <xs:attribute name="type" type="xs:string" />
    </xs:complexType>
  </xs:element>


  <!-- WhereWhen: Space-Time Coordinates, uses the VO STC schema -->
  <xs:element name="WhereWhen">
    <xs:complexType>
      <xs:all>
	<xs:element ref="stc:ObsDataLocation" minOccurs="0"/>
        <xs:element ref="Description" minOccurs="0" />
        <xs:element ref="Reference" minOccurs="0" />
      </xs:all>
    </xs:complexType>
  </xs:element>


  <!-- How: Instrument Configuration, references to RTML documents -->
  <xs:element name="How">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element ref="Description" />
        <xs:element ref="Reference" />
      </xs:choice>
    </xs:complexType>
  </xs:element>


  <!-- Why: Initial Scientific Assessment -->
  <xs:element name="Why">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="Name" type="xs:string" />
        <xs:element name="Concept" type="xs:string" />
        <xs:element ref="Inference" />
        <xs:element ref="Description" />
        <xs:element ref="Reference" />
      </xs:choice>
      <xs:attribute name="importance" type="smallFloat" />
      <xs:attribute name="expires" type="xs:dateTime" />
    </xs:complexType>
  </xs:element>

  <xs:element name="Inference">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="Name" type="xs:string" />
        <xs:element name="Concept" type="xs:string" />
        <xs:element ref="Description" />
        <xs:element ref="Reference" />
      </xs:choice>
      <xs:attribute name="probability" type="smallFloat" />
      <xs:attribute name="relation" type="xs:string" />
    </xs:complexType>
  </xs:element>


  <!-- Citations: Follow-up Observations -->
  <xs:element name="Citations">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">

        <xs:element name="EventIVORN">
          <xs:complexType>
            <xs:simpleContent>
              <xs:extension base="xs:anyURI">
                <xs:attribute name="cite" use="required">
                  <xs:simpleType>
                    <xs:restriction base="xs:token">
                      <xs:enumeration value="followup" />
                      <xs:enumeration value="supersedes" />
                      <xs:enumeration value="retraction" />
                    </xs:restriction>
                  </xs:simpleType>
                </xs:attribute>
              </xs:extension>
            </xs:simpleContent>
          </xs:complexType>
        </xs:element>

        <xs:element ref="Description" />
        <xs:element ref="Reference" />

      </xs:choice>
    </xs:complexType>
  </xs:element>


  <!-- Description: Human Oriented Content -->
  <xs:element name="Description" type="xs:string" />


  <!-- Reference: External Content -->
  <xs:element name="Reference" fixed="">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:string">
          <xs:attribute name="uri" type="xs:anyURI" use="required" />
          <xs:attribute name="type" type="xs:string" />
          <xs:attribute name="name" type="xs:string" />
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>


  <!-- smallFloat: floating point value between zero and one, inclusive -->
  <xs:simpleType name="smallFloat">
    <xs:restriction base="xs:float">
      <xs:minInclusive value="0" />
      <xs:maxInclusive value="1" />
    </xs:restriction>
  </xs:simpleType>

</xs:schema>

