<?xml version="1.0" encoding="ISO-8859-1"?>

<schema targetNamespace="http://crr.caiso.org/download/xml" 
        xmlns="http://www.w3.org/2001/XMLSchema"
        xmlns:CRRDownload="http://crr.caiso.org/download/xml"
        attributeFormDefault="qualified"
        elementFormDefault="qualified">

<!--
Element Name         | Allowed Nested Elements

PTPs:

existingCRRs      | crr
  crr             | CRRID, SegmentID, MarketName, AssetOwner/MarketParticipant, Category, Source, Sink, MW, StartDate, EndDate, HedgeType, CRRType, TimeOfUse, MarketType
    CRRID         | n/a
    SegmentID     | n/a
    MarketName    | n/a
    MarketParticipant
    AssetOwnwer   | n/a
    Category      | n/a
    Source        | n/a
    Sink          | n/a
    MW            | n/a    
    StartDate     | n/a
    EndDate       | n/a
    HedgeType     | n/a
    CRRType       | n/a    
    TimeOfUse     | n/a
    MarketType    | n/a


NSRs:

existingCRRs         | crr
  crr                | CRRID, SegmentID, MarketName, AssetOwner/MarketParticipant, Category, Source/Sink, Designator, Index, MW, StartDate, EndDate, HedgeType, CRRType, TimeOfUse, MarketType
    CRRID            | n/a
    SegmentID        | n/a
    MarketName       | n/a
    MarketParticipant
    AssetOwnwer      | n/a
    Category         | n/a
    SourceSinks      | SourceSink
      SourceSink     | Name, Designator, MW
        Name         | n/a
        Designator	 | n/a
        Index        | n/a
        MW           | n/a
    StartDate        | n/a
    EndDate          | n/a
    HedgeType        | n/a
    CRRType          | n/a    
    TimeOfUse        | n/a
    MarketType       | n/a

-->

<element name="existingCRRs">
  <complexType>
    <choice>
      <element name="crr" type="CRRDownload:existingCRRType" minOccurs="0" maxOccurs="unbounded" />
    </choice>
  </complexType>
</element>

<complexType name="existingCRRType">
  <sequence>
    <element name="CRRID" type="long" />
    <element name="SegmentID" type="int" />
    <element name="MarketName" type="string"/>
    <element name="MarketParticipant" type="string" minOccurs="0" maxOccurs="1"/>
    <element name="AssetOwner" type="string" minOccurs="0" maxOccurs="1"/>
    <element name="Category" type="CRRDownload:categoryDefType" />
    <choice>
      <element name="SourceSinks" type="CRRDownload:sourceSinksType" />
      <sequence>
         <element name="Source" type="string" />
         <element name="Sink" type="string" />
         <element name="MW" type="double" />
      </sequence>
    </choice>

    <element name="StartDate" type="date" />
    <element name="EndDate" type="date" />    
    <element name="HedgeType" type="CRRDownload:hedgeDefType" />
    <element name="CRRType" type="string" />
    <element name="TimeOfUse" type="string" />
    <element name="MarketType" type="string" />
  </sequence>
</complexType>

<complexType name="sourceSinksType">
  <sequence>
    <element name="SourceSink" minOccurs="2" maxOccurs="unbounded">
      <complexType>
        <all>
           <element name="Name" type="string" />
           <element name="Designator" type="CRRDownload:designatorDefType"/>
           <element name="Index" type="int" />
           <element name="MW" type="double" />
        </all>
      </complexType>
    </element>
  </sequence>
</complexType>

<simpleType name="hedgeDefType">
  <restriction base="string">
    <enumeration value="OPT" />
    <enumeration value="OBL" />
  </restriction>
</simpleType>

<simpleType name="categoryDefType">
  <restriction base="string">
    <enumeration value="PTP" />
    <enumeration value="NSR" />
  </restriction>
</simpleType>

<simpleType name="designatorDefType">
  <restriction base="string">
    <enumeration value="SOURCE"/>
    <enumeration value="SINK"/>
  </restriction>
</simpleType>

</schema>
