<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns="http://www.ivoa.net/xml/VOEvent/v1.0"
   xmlns:stc="http://www.ivoa.net/xml/STC/stc-v1.20.xsd"
   targetNamespace="http://www.ivoa.net/xml/VOEvent/v1.0" elementFormDefault="qualified"
   xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <!-- Import the STC schema -->
   <xs:import namespace="http://www.ivoa.net/xml/STC/stc-v1.20.xsd"
      schemaLocation="http://hea-www.harvard.edu/~arots/nvometa/v1.2/stc-v1.20.xsd"/>
   <!-- The VOEvent root element 
   This 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="WhereWhen" minOccurs="0"/>
            <xs:element ref="What" 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>
         <!-- Each VOEvent must have an ID attribute -->
         <xs:attribute name="id" type="xs:anyURI" use="required"/>
         <!-- Each VOEvent must have a role attribute -->
         <xs:attribute name="role" default="observation">
            <xs:simpleType>
               <xs:restriction base="xs:token">
                  <xs:enumeration value="observation"/>
                  <xs:enumeration value="prediction"/>
                  <xs:enumeration value="test"/>
               </xs:restriction>
            </xs:simpleType>
         </xs:attribute>
         <!-- Each VOEvent must have a role attribute -->
         <xs:attribute name="version" type="xs:token" fixed="1.0" use="required"/>
      </xs:complexType>
   </xs:element>
   <!-- The Who section defines who is publishing this event -->
   <xs:element name="Who">
      <xs:complexType>
         <xs:choice maxOccurs="unbounded">
            <xs:element name="PublisherID" type="xs:anyURI"/>
            <xs:element name="Date" type="xs:dateTime"/>
            <xs:element ref="Description"/>
            <xs:element name="Contact">
               <xs:complexType>
                  <xs:choice maxOccurs="unbounded">
                     <xs:element name="Username" type="xs:string"/>
                     <xs:element name="Name" type="xs:string"/>
                     <xs:element name="LastName" type="xs:string"/>
                     <xs:element name="FirstName" type="xs:string"/>
                     <xs:element name="Institution" type="xs:string"/>
                     <xs:element name="Communication">
                        <xs:complexType>
                           <xs:choice minOccurs="0" maxOccurs="unbounded">
                              <xs:element name="AddressLine" type="xs:string"/>
                              <xs:element name="CountryCode" type="xs:token"/>
                              <xs:element name="Email" type="xs:anyURI"/>
                              <xs:element name="Fax" type="xs:token"/>
                              <xs:element name="Telephone" type="xs:token"/>
                              <xs:element name="Uri" type="xs:anyURI"/>
                           </xs:choice>
                        </xs:complexType>
                     </xs:element>
                  </xs:choice>
                  <xs:attribute name="principalInvestigator" type="xs:boolean" default="false"/>
                  <xs:attribute name="principalContact" type="xs:boolean" default="false"/>
               </xs:complexType>
            </xs:element>
         </xs:choice>
      </xs:complexType>
   </xs:element>
   <!-- The WhereWhen section uses the STC schema to define space-time coordinates -->
   <xs:element name="WhereWhen">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="ObservationLocation" type="stc:observationLocationType"/>
         </xs:sequence>
      </xs:complexType>
   </xs:element>
   <!-- The What section says what was observed objectively. 
   It is Params, References, and Groups of those -->
   <xs:element name="What">
      <xs:complexType>
         <xs:choice minOccurs="1" maxOccurs="unbounded">
            <xs:element ref="Param"/>
            <xs:element ref="Group"/>
            <xs:element ref="Reference"/>
            <xs:element ref="Description"/>
         </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="Reference"/>
            <xs:element ref="Description"/>
         </xs:choice>
         <xs:attribute name="name" type="xs:string"/>
         <xs:attribute name="type" type="xs:string"/>
      </xs:complexType>
   </xs:element>
   <!-- The How element expresses the instrument(s) used to get the data -->
   <xs:element name="How">
      <xs:complexType>
         <xs:sequence minOccurs="1" maxOccurs="unbounded">
            <xs:element name="Instrument">
               <xs:complexType>
                  <xs:choice minOccurs="0" maxOccurs="unbounded">
                     <xs:element ref="Description"/>
                     <xs:element ref="Reference"/>
                  </xs:choice>
               </xs:complexType>
            </xs:element>
         </xs:sequence>
      </xs:complexType>
   </xs:element>
   <!-- The Why element is interpretaion of what is defined in the What section.
   A Name and Concept combine to make Inference.   -->
   <xs:element name="Why">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="Name" type="xs:string" minOccurs="0"/>
            <xs:element name="Concept" type="xs:string" minOccurs="0"/>
            <xs:element ref="Inference" minOccurs="0" maxOccurs="unbounded"/>
            <xs:element ref="Description" minOccurs="0" maxOccurs="unbounded"/>
         </xs:sequence>
         <xs:attribute name="importance" type="xs:float"/>
         <xs:attribute name="expires" type="xs:dateTime"/>
      </xs:complexType>
   </xs:element>
   <xs:element name="Inference">
      <xs:complexType>
         <xs:sequence>
            <xs:element name="Name" type="xs:string" minOccurs="0"/>
            <xs:element name="Concept" type="xs:string" minOccurs="0"/>
         </xs:sequence>
         <xs:attribute name="probability" type="xs:float"/>
         <xs:attribute name="relation" type="xs:string"/>
      </xs:complexType>
   </xs:element>
   <!-- Citattions are pointers to other VOEvents. -->
   <xs:element name="Citations">
      <xs:complexType>
         <xs:choice minOccurs="1" maxOccurs="unbounded">
            <xs:element name="EventID">
               <xs:complexType>
                  <xs:simpleContent>
                     <xs:extension base="xs:anyURI">
                        <xs:attribute name="cite">
                           <xs:simpleType>
                              <xs:restriction base="xs:token">
                                 <xs:enumeration value="followup"/>
                                 <xs:enumeration value="supercedes"/>
                                 <xs:enumeration value="retraction"/>
                              </xs:restriction>
                           </xs:simpleType>
                        </xs:attribute>
                     </xs:extension>
                  </xs:simpleContent>
               </xs:complexType>
            </xs:element>
            <xs:element ref="Description"/>
         </xs:choice>
      </xs:complexType>
   </xs:element>
   <!-- The Description element has human-readable text -->
   <xs:element name="Description" type="xs:string"/>
   <!-- The Reference element points to a URI with possibly a type -->
   <xs:element name="Reference" fixed="">
      <xs:complexType>
         <xs:simpleContent>
            <xs:extension base="xs:string">
               <xs:attribute name="uri" type="xs:anyURI"/>
               <xs:attribute name="type" type="xs:string"/>
               <xs:attribute name="name" type="xs:string"/>
            </xs:extension>
         </xs:simpleContent>
      </xs:complexType>
   </xs:element>
</xs:schema>

