<?xml version="1.0"?>
<xsd:schema 
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://cmcs.ca.sandia.gov/schema/featureML"
      xmlns="http://cmcs.ca.sandia.gov/schema/featureML"
      elementFormDefault="qualified"	
>

<xsd:annotation>
   <xsd:documentation>
      Schema for feature datasets.
      AUG-19-2002. Created by Wendy Koegler
   </xsd:documentation>
</xsd:annotation>

<!-- Global element declarations -->

<!-- Root element -->

<xsd:element name="featureDataset" type="FeatureDatasetType"/>

<!-- 1st level elements = major organization categories -->

<!-- FIX? do we really want these global? -->
<xsd:element name="pedigreeInfo" type="PedigreeInfoType"/>
<xsd:element name="generalInfo" type="GeneralInfoType"/>
<xsd:element name="timeList" type="TimeListType"/>
<xsd:element name="featureList" type="FeatureListType"/>
<xsd:element name="eventList" type="EventListType"/>
<xsd:element name="ROIList" type="ROIListType"/>

<!-- 1st level Type definitions -->

<xsd:complexType name="FeatureDatasetType">
   <xsd:sequence>
      <xsd:element ref="pedigreeInfo" minOccurs="0"/>
      <xsd:element ref="generalInfo"/>
      <xsd:element ref="timeList"/>
      <xsd:element ref="featureList"/>
      <xsd:element ref="eventList" minOccurs="0"/>
      <xsd:element ref="ROIList"/>
   </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="PedigreeInfoType">
   <xsd:sequence>
      <xsd:any processContents="skip" maxOccurs="unbounded" />
   </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="GeneralInfoType">
   <xsd:sequence>
      <xsd:element name="dimensionality" type="xsd:nonNegativeInteger"/>
      <xsd:element name="numTime" type="xsd:nonNegativeInteger"/>
      <xsd:element name="numROI" type="xsd:nonNegativeInteger"/>
      <xsd:element name="numFeature" type="xsd:nonNegativeInteger"/>
      <xsd:element name="featureDefinition">
	 <xsd:complexType>
            <xsd:sequence>
               <xsd:element name="thresholdVariable" type="xsd:string"/>
	       <xsd:element name="thresholdType">
                  <xsd:simpleType>
	             <xsd:restriction base="xsd:string">
	                <xsd:pattern value="absolute|fraction"/>
                     </xsd:restriction>
                  </xsd:simpleType>
               </xsd:element>
               <xsd:element name="lowerThreshold" type="xsd:float"/>
	       <xsd:element name="upperThreshold" type="xsd:float"/>
	    </xsd:sequence>
         </xsd:complexType>
       </xsd:element>
   </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="TimeListType">	
   <xsd:sequence>
      <xsd:element name="timestep" minOccurs="0" maxOccurs="unbounded">
	 <xsd:complexType>
            <xsd:simpleContent>
	       <xsd:extension base="xsd:float">
                  <xsd:attribute name="TimeId" type="xsd:ID" use="required"/>
	       </xsd:extension>
	    </xsd:simpleContent>
         </xsd:complexType>
      </xsd:element>
   </xsd:sequence>
   <xsd:attribute name="numTime" type="xsd:nonNegativeInteger" use="optional"/>
</xsd:complexType>

<xsd:complexType name="FeatureListType">
   <xsd:sequence>
      <xsd:element name="feature" minOccurs="0" maxOccurs="unbounded">
         <xsd:complexType>
	    <xsd:sequence>
	       <xsd:element name="startTime" type="xsd:float"/>
	       <xsd:element name="endTime" type="xsd:float"/>
	       <xsd:element name="boundingBox" type="BoundingBoxType"/>
	       <xsd:element name="parents" type="IntListType"/>
	       <xsd:element name="children" type="IntListType"/>
	       <xsd:element name="memberROIs" type="IntListType"/>
            </xsd:sequence>
	    <xsd:attribute name="FeatureId" type="xsd:ID" use="required"/>
	    <xsd:attribute name="numParent" type="xsd:nonNegativeInteger" use="required"/>
	    <xsd:attribute name="numChild" type="xsd:nonNegativeInteger" use="required"/>
	    <xsd:attribute name="numROI" type="xsd:nonNegativeInteger" use="required"/>
         </xsd:complexType>
      </xsd:element>
   </xsd:sequence>
   <xsd:attribute name="numFeature" type="xsd:nonNegativeInteger" use="optional"/>
</xsd:complexType>

<xsd:complexType name="EventListType">
   <xsd:sequence>
      <xsd:element name="event" minOccurs="0" maxOccurs="unbounded">
         <xsd:complexType>
	    <xsd:sequence>
	       <xsd:element name="type" type="xsd:string"/>
	       <xsd:element name="parents" type="IntListType"/>
	       <xsd:element name="children" type="IntListType"/>
            </xsd:sequence>
         </xsd:complexType>
      </xsd:element>
   </xsd:sequence>
   <xsd:attribute name="numEvent" type="xsd:nonNegativeInteger" use="optional"/>
</xsd:complexType>

<xsd:complexType name="ROIListType">
   <xsd:sequence>
      <xsd:element name="ROIperTimeList" minOccurs="0">
         <xsd:simpleType>
	    <xsd:list itemType="xsd:nonNegativeInteger"/>
         </xsd:simpleType>
      </xsd:element>
      <xsd:element name="ROI" minOccurs="0" maxOccurs="unbounded">
         <xsd:complexType>
            <xsd:sequence>
               <xsd:element name="time" type="xsd:float"/>
	       <xsd:element name="size" type="xsd:float"/>
	       <xsd:element name="boundingBox" type="BoundingBoxType"/>
               <xsd:element name="variable" minOccurs="0" maxOccurs="unbounded">
 		  <xsd:complexType>
	             <xsd:sequence>
	                <xsd:element name="name" type="xsd:string"/>
                        <xsd:element name="value" type="xsd:float"/>
                     </xsd:sequence>
                  </xsd:complexType>
               </xsd:element>
               <xsd:element name="cells" minOccurs="0">
	          <xsd:complexType>
                     <xsd:sequence>
                        <xsd:element name="cellCenterCoords" maxOccurs="unbounded">
	                   <xsd:complexType>
                              <xsd:simpleContent>
	                         <xsd:extension base="CoordinateType">
                                    <xsd:attribute name="CellId" type="xsd:nonNegativeInteger" use="optional"/>
                                 </xsd:extension>
                              </xsd:simpleContent>
	                   </xsd:complexType>
                        </xsd:element>
                     </xsd:sequence>
		     <xsd:attribute name="numCell" type="xsd:positiveInteger" use="required"/>
	          </xsd:complexType>
               </xsd:element>
            </xsd:sequence>
	    <xsd:attribute name="ROI_Id" type="xsd:ID" use="required"/>
	    <xsd:attribute name="TimeRef" type="xsd:IDREF" use="required"/>
         </xsd:complexType>
      </xsd:element>
   </xsd:sequence>
   <xsd:attribute name="numTime" type="xsd:nonNegativeInteger" use="optional"/>
   <xsd:attribute name="numROI" type="xsd:nonNegativeInteger" use="optional"/>
</xsd:complexType>

<!-- Support types (i.e. things used more than once -->

<!-- FIX? limits on the length of this list-->
<xsd:simpleType name="CoordinateType">
   <xsd:list itemType="xsd:float"/>
</xsd:simpleType>

<xsd:complexType name="BoundingBoxType">
   <xsd:sequence>
      <xsd:element name="lowerCoords" type="CoordinateType"/>
      <xsd:element name="upperCoords" type="CoordinateType"/>
   </xsd:sequence>
</xsd:complexType>

<!-- An integer list with the attribute 'num' specifying how many in list -->
<xsd:simpleType name="SimpleIntListType">
   <xsd:list itemType="xsd:nonNegativeInteger"/>
</xsd:simpleType>

<xsd:complexType name="IntListType">
   <xsd:simpleContent>
      <xsd:extension base="SimpleIntListType">
         <xsd:attribute name="num" type="xsd:nonNegativeInteger" use="required"/>
      </xsd:extension>
   </xsd:simpleContent>
</xsd:complexType>

</xsd:schema>
