<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:gml="http://www.opengis.net/gml/3.2"
  xmlns:swe="http://www.opengis.net/swe/2.0" xmlns:wml2dr="http://www.opengis.net/waterml-dr/2.0"
  xmlns:wml2="http://www.opengis.net/waterml/2.0"
  xmlns:gmlcov="http://www.opengis.net/gmlcov/1.0"
  xmlns:om="http://www.opengis.net/om/2.0" targetNamespace="http://www.opengis.net/waterml-dr/2.0"
  elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.0.2">

  <annotation>
    <documentation>This schema describes the domain-range timeseries result structures for WaterML2.0. This is
      only an informative schema and has not been adopted as a standard XML encoding. This is an implementation 
      of the domain-range timeseries conceptual model.  This implementation only covers timeseries of measurements and categorical values
      (string with codespaces). Subsequent versions of schema may support more complex results such as multi-result (compound), vectors etc. 
      
      OGC WaterML 2.0 is an OGC Standard.
      Copyright (c) 2012,2014 Open Geospatial Consortium.
      To obtain additional rights of use, visit http://www.opengeospatial.org/legal/ .
    </documentation>
  </annotation>

  <import namespace="http://www.opengis.net/gml/3.2"
    schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd"/>
  
  <import namespace="http://www.opengis.net/gmlcov/1.0"
  schemaLocation="http://schemas.opengis.net/gmlcov/1.0/coverage.xsd"/>
  
  <import namespace="http://www.opengis.net/waterml/2.0"
    schemaLocation="http://schemas.opengis.net/waterml/2.0/waterml2.xsd"/>
  
  <import namespace="http://www.opengis.net/swe/2.0" 
    schemaLocation="http://schemas.opengis.net/sweCommon/2.0/swe.xsd"/>
  
  <!-- ====================================================================== -->
  <!-- Supporting types for domain-range encodings: time lists                --> 
  <!-- ====================================================================== -->
  <simpleType name="TimeListSimpleType">
    <annotation>
      <documentation>A list of dateTime instances</documentation>
    </annotation>
    <list itemType="dateTime"></list>
  </simpleType>
  
  <complexType name="TimePositionListType">
    <complexContent>
      <extension base="gml:AbstractTimeObjectType">
        <sequence>
          <element name="timePositionList" type="wml2dr:TimeListSimpleType"></element>
        </sequence>
      </extension>
    </complexContent>
  </complexType>
  
  <element name="TimePositionList" type="wml2dr:TimePositionListType" substitutionGroup="gml:AbstractTimeObject">
    <annotation>
      <documentation>gml:TimeInstant acts as a zero-dimensional geometric primitive that represents an identifiable position in time.</documentation>
    </annotation>
  </element>
  
  <!-- Annotation coverages --> 
  <element name="AnnotationCoverage" type="wml2dr:AnnotationCoverageType" substitutionGroup="gmlcov:AbstractDiscreteCoverage">
    <annotation>
      <documentation>A coverage that describes metadata about another temporal coverage. </documentation>
    </annotation>
  </element>
  <complexType name="AnnotationCoverageType">
    <complexContent>
      <extension base="gmlcov:AbstractDiscreteCoverageType">
      </extension>
    </complexContent>
  </complexType>
  
  <complexType name="AnnotationCoveragePropertyType">
    <sequence>
      <element ref="wml2dr:AnnotationCoverage"></element>
    </sequence>
  </complexType>
  
  <!-- ====================================================================== -->
  <!-- Base level timeseries (domain-range) types --> 
  <!-- ====================================================================== -->
  <complexType name="TimeseriesCoverageType">
    <complexContent>
      <extension base="gmlcov:AbstractDiscreteCoverageType">
        <sequence>
          <!--element name="annotation" type="wml2:AnnotationCoveragePropertyType" minOccurs="0" maxOccurs="unbounded"></element-->
        </sequence>
      </extension>
    </complexContent>
  </complexType>
  <element name="TimeseriesDomainRange" type="wml2dr:TimeseriesCoverageType" substitutionGroup="gmlcov:AbstractDiscreteCoverage">
    <annotation>
      <documentation>A coverage with a domainSet composed of time instants (a time list). Restriction performed in schematron (the gml cov schema does not restrict the types directly in schema, just through requirements clauses and tests).</documentation>
    </annotation>
  </element>
  
  <!-- ====================================================================== -->
  <!-- Measurement timeseries (domain-range) types --> 
  <!-- ====================================================================== -->
  <complexType name="MeasurementTimeseriesCoverageType">
    <complexContent>
      <extension base="wml2dr:TimeseriesCoverageType">
      </extension>
    </complexContent>
  </complexType>
  <element name="MeasurementTimeseriesDomainRange" type="wml2dr:MeasurementTimeseriesCoverageType" substitutionGroup="gmlcov:AbstractDiscreteCoverage">
    <annotation>
      <documentation>A further restriction of the base domain-range timeseries type that restricts the rangeSet to be a measurement (quantity)</documentation>
    </annotation>
  </element>
  
  <!-- ====================================================================== -->
  <!-- Categorical timeseries (domain-range) types --> 
  <!-- ====================================================================== -->
  <complexType name="CategoricalTimeseriesCoverageType">
    <complexContent>
      <extension base="wml2dr:TimeseriesCoverageType">
      </extension>
    </complexContent>
  </complexType>
  <element name="CategoricalTimeseriesDomainRange" type="wml2dr:CategoricalTimeseriesCoverageType" substitutionGroup="gmlcov:AbstractDiscreteCoverage">
    <annotation>
      <documentation>A further restriction of the base domain-range timeseries type that restricts the rangeSet to be a category (scoped text)</documentation>
    </annotation>
  </element>
  
  
  <complexType name="MeasurementTimeseriesMetadataExtensionType">
    <sequence maxOccurs="unbounded" minOccurs="0">
      <element name="defaultMetadata" type="wml2:DefaultTVPMetadataPropertyType"></element>
      <element name="timeseriesMetadata" type="wml2:MeasurementTSMetadataPropertyType" minOccurs="0"></element>
      <element name="annotation"  type="wml2dr:AnnotationCoveragePropertyType" maxOccurs="unbounded" minOccurs="0"></element>
    </sequence>
  </complexType>
  
  <element name="MeasurementTimeseriesMetadataExtension" type="wml2dr:MeasurementTimeseriesMetadataExtensionType"/>
  
  <complexType name="CategoricalTimeseriesMetadataExtensionType">
    <sequence maxOccurs="unbounded" minOccurs="0">
      <!-- Uses the same default for DR as we don't require the codeSpace (it is available in the value encoding) -->
      <element name="defaultMetadata" type="wml2:DefaultTVPMetadataPropertyType" minOccurs="0"></element>
      <element name="timeseriesMetadata" type="wml2:TimeseriesMetadataPropertyType" minOccurs="0"></element>
      <element name="annotation"  type="wml2dr:AnnotationCoveragePropertyType" maxOccurs="unbounded" minOccurs="0"></element>
    </sequence>
  </complexType>
  
  <element name="CategoricalTimeseriesMetadataExtension" type="wml2dr:MeasurementTimeseriesMetadataExtensionType"/>

</schema>
