<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSpy v2008 rel. 2 sp2 (http://www.altova.com) by APX Employee (APX Inc.) -->
<!-- edited with XMLSPY v2004 rel. 3 U (http://www.xmlspy.com) by Roy Gvirtsman (APX Inc.) -->
<!-- Schema for APX API. 
	 
	 Author: Roy Gvirtsman	 
	 Revision 	4.0
	 History:	
        Jun 18, 2008 Merge 3 separate namespaces into a single common API.
	 			Jul 20, 2008 Add optional status and a "Retrieve" element for GetStatus
	 			Jul 24, 2008 make MarketStage a required attribute. Remove 5,10 & 30 min durations from Bilateral. 
	 			             Change submitToISO default	from True to False.
        Nov 26, 2008 David Peak Added NonNegativeDecimal that has a minInclusive value of 0.00.
	 			Jun 10, 2009 Andrew Thornton Added ERCOT Region. Changed BidCurve MW attribute from apx:NonNegativeDecimal to xs:decimal. 
                                     Removed RRS ProductType.
        Aug 13, 2009 Andrew Thornton Added FileStatus attribute to <Response> element.
        Aug 21, 2009 Andrew Thornton bounded MarketParticipantData element to MaxOccurs="1"
        Sep 08, 2009 Andrew Thornton bounded MarketParticipantData element to MinOccurs="0"
        Nov 11, 2009 Andrew Thornton for element name="Parameter" changed attribute name="Value" from from use="required" to use="optional"
                                     for element name="Point" changed attribute name="X" from use="required" to use="optional"/>
                                     for element name="Point" changed attribute name="Y" from use="required" to use="optional"/> 
        Feb 01, 2010 Andrew Thornton made ProductType a required (vs. optional with default=energy) attribute throughout XSD
        Mar 19, 2010 Andrew Thornton made many updates for TX Nodal including:
                                     changed Region from 'TX_Nodal' to 'TX'
                                     added OffNSpin ProductType to support 'TX'
        Apr 30, 2010 Andrew Thornton added <Price> attribute to <SelfScheduleType> element for use to return Post-Market prices in response to GetScheduleData request
                                     added <xs:documentation> sections to highlight all of the attributes that are NOT applicable for inbound submissions
                                     removed ExternalId attribute from <ResourceParameters> element because it is not applicable
        May 12, 2010 Andrew Thonton  added ScheduleType attribute to <SelfSchedule> element to support A/S Obligations
                                     added Obligation to the enumerated list for ScheduleType
        May 19, 2010 David Peak / Andrew Thornton
                                     added two new decimal types <MWdecimal> and <Pricedecimal> and updated references to <xs:decimal> to reference these new types
                                     added MarketStatus attribute to Header for return in GetScheduleData responses
        Jun 01, 2010 Andrew Thornton added "Reason" attribute to the <MarketSchedule> element
                                     Removed default value from "CooptimizedWithAS' attribute of the <MarketSchedule> element
                                     Added "UntCntg" Product Type
        Jun 15, 2010 Andrew Thornton Moved "CooptimizedWithAS" and "Reason" attributes from the <MarketSchedule> element to the <Curve> element
        Jul 15, 2010 Andrew Thornton Added "SourceSink" enumeration to TransactionType attribute to support BidsOffers with 2 locations
                                     Added optional "SinkLocation" attribute to the BidsOffers element to support BidsOFfers with 2 locations
        Aug 05, 2010 Andrew Thornton Added 'SASM' and 'SASM2' market stage which will be used only in TX Nodal GetScheduleData responses
        Aug 19, 2010 Andrew Thornton Added "Z" attribute to single parameter curve point definition to support ramp rate curves in TX Nodal
        Oct 16, 2010 Andrew Thornton Added "DART" MarketStage for TX Nodal
                                     Added "SelfProvision" ScheduleType
        Oct 18, 2010 Andrew Thornton Changed "SourceLocation" and "SinkLocation" attributes to the <BilateralSchedule> element to be required
        Dec 13, 2010 Andrew Thornton Added "BidName" attribute under the "BidsOffers" element
        Dec 20, 2010 Andrew Thornton Added SASM3, 4, and 5 to the <MarketStage> element enumeration
        Feb 02, 2011 Andrew Thornton Added "CntrlLoad to the <TransactionType> element enumeration
                                     
  -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:apx="http://service.apx.com/schedule" targetNamespace="http://service.apx.com/schedule" elementFormDefault="qualified" attributeFormDefault="unqualified">
	<!-- Non-empty string -->
	<xs:simpleType name="NonEmptyString">
		<xs:restriction base="xs:string">
			<xs:minLength value="1"/>
			<xs:pattern value=".*[^\s].*"/>
			<xs:whiteSpace value="replace"/>
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="NonNegativeDecimal">
		<xs:restriction base="xs:decimal">
			<xs:minInclusive value="0.00"/>
			<xs:totalDigits value="10"/>
			<xs:fractionDigits value="3"/>
		</xs:restriction>
	</xs:simpleType>
  <xs:simpleType name="Pricedecimal">
    <xs:restriction base="xs:decimal">
      <xs:totalDigits value="10"/>
      <xs:fractionDigits value="4"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="MWdecimal">
    <xs:restriction base="xs:decimal">
      <xs:totalDigits value="10"/>
      <xs:fractionDigits value="3"/>
    </xs:restriction>
  </xs:simpleType>
	<!-- ControlArea-->
	<xs:simpleType name="Region">
		<xs:restriction base="xs:NMTOKEN">
			<xs:enumeration value="MRTU"/>
			<xs:enumeration value="TX"/>
			<xs:enumeration value="MISO"/>
			<xs:enumeration value="PJM"/>
			<xs:enumeration value="ERCOT"/>
		</xs:restriction>
	</xs:simpleType>
	<!--MarketType-->
	<xs:simpleType name="MarketStage">
		<xs:restriction base="xs:NMTOKEN">
			<xs:enumeration value="DA"/>
			<xs:enumeration value="HA"/>
			<xs:enumeration value="RT"/>
      <xs:enumeration value="DART"/>
      <xs:enumeration value="SASM"/> 
      <xs:enumeration value="SASM2"/>
      <xs:enumeration value="SASM3"/>
      <xs:enumeration value="SASM4"/>
      <xs:enumeration value="SASM5"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- TransactionType-->
	<xs:simpleType name="TransactionType">
		<xs:restriction base="xs:NMTOKEN">
			<xs:enumeration value="Load"/>
			<xs:enumeration value="Gen"/>
			<xs:enumeration value="Import"/>
			<xs:enumeration value="Export"/>
			<xs:enumeration value="VirtualBid"/>
			<xs:enumeration value="VirtualOffer"/>
			<xs:enumeration value="ParticipatingLoad"/>
			<xs:enumeration value="LoadResource"/>
			<xs:enumeration value="Buy"/>
			<xs:enumeration value="Sell"/>
      <xs:enumeration value="SourceSink"/>      
		</xs:restriction>
	</xs:simpleType>
	<!--ProductType-->
	<xs:simpleType name="ProductType">
		<xs:restriction base="xs:NMTOKEN">
			<xs:enumeration value="Energy"/>
			<xs:enumeration value="NonFirmEnergy"/>
			<xs:enumeration value="RegUp"/>
			<xs:enumeration value="RegDn"/>
			<xs:enumeration value="Spin"/>
			<xs:enumeration value="NSpin"/>
			<xs:enumeration value="RUC"/>
			<xs:enumeration value="Capacity"/>
			<xs:enumeration value="OffNSpin"/>
      <xs:enumeration value="UntCntg"/>
		</xs:restriction>
	</xs:simpleType>
	<!--ScheduleType-->
	<xs:simpleType name="ScheduleType">
		<xs:restriction base="xs:NMTOKEN">
			<xs:enumeration value="FinancialTrade"/>
			<xs:enumeration value="PhysicalTrade"/>
			<xs:enumeration value="UpliftCostTrade"/>
			<xs:enumeration value="GrandfatheredTrade"/>
			<xs:enumeration value="PseudoTieTrade"/>
			<xs:enumeration value="RetailLoad"/>
			<xs:enumeration value="WholesaleLoad"/>
			<xs:enumeration value="Generation"/>
			<xs:enumeration value="Obligation"/>
      <xs:enumeration value="SelfProvision"/>
      <xs:enumeration value="CntrlLoad"/>      
		</xs:restriction>
	</xs:simpleType>
	<!-- ScalarParameterType-->
	<xs:complexType name="ScalarParameterType">
		<xs:attribute name="FromInterval" type="xs:positiveInteger" use="optional"/>
		<xs:attribute name="Name" type="apx:NonEmptyString" use="required"/>
		<xs:attribute name="Value" type="apx:NonEmptyString" use="optional"/>
		<xs:attribute name="Status" type="apx:NonEmptyString" use="optional">
			<xs:annotation>
				<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="Message" type="apx:NonEmptyString" use="optional">
			<xs:annotation>
				<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<!--Parameter single curve point-->
	<xs:complexType name="Point">
		<xs:attribute name="X" type="apx:NonEmptyString" use="optional"/>
		<xs:attribute name="Y" type="apx:NonEmptyString" use="optional"/>
    <xs:attribute name="Z" type="apx:NonEmptyString" use="optional"/>
	</xs:complexType>
	<!-- Curve Parameter Type-->
	<xs:complexType name="ParameterCurveType">
		<xs:sequence>
			<xs:element name="Point" type="apx:Point" maxOccurs="16"/>
		</xs:sequence>
		<xs:attribute name="FromInterval" type="xs:positiveInteger" use="optional"/>
		<xs:attribute name="Name" type="apx:NonEmptyString" use="required"/>
		<xs:attribute name="Status" type="apx:NonEmptyString" use="optional">
			<xs:annotation>
				<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="Message" type="apx:NonEmptyString" use="optional">
			<xs:annotation>
				<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<!-- Resource Parameters-->
	<xs:complexType name="ResourceParameters">
		<xs:choice maxOccurs="unbounded">
			<xs:element name="Parameter" type="apx:ScalarParameterType"/>
			<xs:element name="ParameterCurve" type="apx:ParameterCurveType"/>
		</xs:choice>
		<xs:attribute name="IntervalLength" use="optional" default="PT1H">
			<xs:simpleType>
				<xs:restriction base="xs:duration">
					<xs:enumeration value="P1D"/>
					<xs:enumeration value="PT1H"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="Location" type="apx:NonEmptyString" use="required"/>
	</xs:complexType>
	<!--     ==========================
		    Bilateral Schedule Specific parts 
	           ==========================   -->
	<!-- BilateralScheduleDetail -->
	<xs:complexType name="BilateralScheduleDetail">
		<xs:attribute name="FromInterval" type="xs:positiveInteger" use="required">
			<xs:annotation>
				<xs:documentation source="combined with interval length, this may span 23-25 hours. "/>
				<xs:documentation source="This means i is between 23 and 25 for intervalLength=60 or between 92 and 100 for intervalLength=15"/>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="MW" type="apx:NonNegativeDecimal" use="optional"/>
		<xs:attribute name="CounterPartyMW" type="apx:NonNegativeDecimal" use="optional">
			<xs:annotation>
				<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="Status" type="apx:NonEmptyString" use="optional">
			<xs:annotation>
				<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="Message" type="apx:NonEmptyString" use="optional">
			<xs:annotation>
				<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<!-- BilateralSchedule-->
	<xs:complexType name="BilateralSchedule">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:element name="BilateralScheduleDetail" type="apx:BilateralScheduleDetail"/>
		</xs:sequence>
		<xs:attribute name="IntervalLength" use="optional" default="PT1H">
			<xs:simpleType>
				<xs:annotation>
					<xs:documentation>In minutes. Represents how long each interval in ScheduleDetail is.</xs:documentation>
				</xs:annotation>
				<xs:restriction base="xs:duration">
					<xs:enumeration value="PT15M"/>
					<xs:enumeration value="PT1H"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="TransactionType" type="apx:TransactionType" use="required"/>
		<xs:attribute name="SourceLocation" type="apx:NonEmptyString" use="required"/>
		<xs:attribute name="SinkLocation" type="apx:NonEmptyString" use="required"/>
		<xs:attribute name="CounterParty" type="apx:NonEmptyString" use="optional"/>
		<xs:attribute name="TradeName" type="apx:NonEmptyString" use="optional"/>
		<xs:attribute name="DependOnTradeName" type="apx:NonEmptyString" use="optional"/>
		<xs:attribute name="ScheduleType" type="apx:ScheduleType" use="optional"/>
		<xs:attribute name="ProductType" type="apx:ProductType" use="required"/>
		<xs:attribute name="ExternalId" type="apx:NonEmptyString" use="optional"/>
	</xs:complexType>
	<!--   ==========================
			 BidOffer Specific parts 
	        ===========================     -->
	<!-- CurveType -->
	<xs:simpleType name="CurveType">
		<xs:restriction base="xs:NMTOKEN">
			<xs:enumeration value="Block"/>
			<xs:enumeration value="Slope"/>
			<xs:enumeration value="Fixed"/>
		</xs:restriction>
	</xs:simpleType>
	<!-- BidCurve-->
	<xs:complexType name="BidCurve">
		<xs:attribute name="MW" type="apx:MWdecimal" use="optional"/>
		<xs:attribute name="Price" type="apx:Pricedecimal" use="optional"/>
	</xs:complexType>
	<!--  SelfScheduleType -->
	<xs:complexType name="SelfScheduleType">
		<xs:attribute name="FromInterval" type="xs:positiveInteger" use="required"/>
		<xs:attribute name="MW" type="apx:NonNegativeDecimal" use="optional"/>
		<xs:attribute name="Price" type="apx:Pricedecimal" use="optional">
			<xs:annotation>
				<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="Status" type="apx:NonEmptyString" use="optional">
			<xs:annotation>
				<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
			</xs:annotation>
		</xs:attribute>
		<xs:attribute name="Message" type="apx:NonEmptyString" use="optional">
			<xs:annotation>
				<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<!-- MarketScheduleType-->
	<xs:complexType name="MarketScheduleType">
		<xs:sequence minOccurs="0" maxOccurs="unbounded">
			<xs:element name="Curve">
				<xs:complexType>
					<xs:sequence>
						<xs:element name="CurvePoint" type="apx:BidCurve" maxOccurs="16"/>
					</xs:sequence>
					<xs:attribute name="LinkedHours" type="apx:NonEmptyString" use="optional"/>
					<xs:attribute name="CurveType" type="apx:CurveType" use="optional"/>
					<xs:attribute name="FromInterval" type="xs:positiveInteger" use="required"/>
					<xs:attribute name="Status" type="apx:NonEmptyString" use="optional">
						<xs:annotation>
							<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
						</xs:annotation>
					</xs:attribute>
					<xs:attribute name="Message" type="apx:NonEmptyString" use="optional">
						<xs:annotation>
							<xs:documentation>Used by Outbound methods only. Do not Submit</xs:documentation>
						</xs:annotation>
					</xs:attribute>
          <xs:attribute name="CooptimizedWithAS" type="xs:boolean" use="optional"/>
          <xs:attribute name="Reason" type="apx:NonEmptyString" use="optional"/>
        </xs:complexType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<!-- SubmitBid -->
	<xs:complexType name="BidsOffers">
		<xs:choice minOccurs="0" maxOccurs="unbounded">
			<xs:element name="SelfSchedule">
				<xs:complexType>
					<xs:sequence minOccurs="0" maxOccurs="unbounded">
						<xs:element name="Schedule" type="apx:SelfScheduleType"/>
					</xs:sequence>
					<xs:attribute name="ProductType" type="apx:ProductType" use="required"/>
					<xs:attribute name="ScheduleType" type="apx:ScheduleType" use="optional"/>
				</xs:complexType>
			</xs:element>
			<xs:element name="MarketSchedule">
				<xs:complexType>
					<xs:complexContent>
						<xs:extension base="apx:MarketScheduleType">
							<xs:attribute name="ProductType" type="apx:ProductType" use="required"/>
							<xs:attribute name="LinkedOfferID" type="apx:NonEmptyString" use="optional"/>         
						</xs:extension>
					</xs:complexContent>
				</xs:complexType>
			</xs:element>
		</xs:choice>
		<xs:attribute name="IntervalLength" use="optional" default="PT1H">
			<xs:simpleType>
				<xs:restriction base="xs:duration">
					<xs:enumeration value="PT5M"/>
					<xs:enumeration value="PT15M"/>
					<xs:enumeration value="PT1H"/>
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="TransactionType" type="apx:TransactionType" use="required"/>
		<xs:attribute name="Location" type="apx:NonEmptyString" use="required"/>
    <xs:attribute name="SinkLocation" type="apx:NonEmptyString" use="optional"/>    
		<xs:attribute name="WheelId" type="apx:NonEmptyString" use="optional"/>
		<xs:attribute name="ContractId" type="apx:NonEmptyString" use="optional"/>
		<xs:attribute name="SupportingResource" type="apx:NonEmptyString" use="optional"/>
		<xs:attribute name="NERCTag" type="apx:NonEmptyString" use="optional"/>
		<xs:attribute name="ExternalId" type="apx:NonEmptyString" use="optional"/>
		<xs:attribute name="ExpirationTime" type="xs:dateTime" use="optional"/>
    <xs:attribute name="BidName" type="apx:NonEmptyString" use="optional"/>
	</xs:complexType>
	<!-- Common API parent element-->
	<xs:complexType name="Header">
		<xs:sequence minOccurs="0" maxOccurs="1">
			<xs:element name="MarketParticipantData">
				<xs:complexType>
					<xs:choice minOccurs="0" maxOccurs="unbounded">
						<xs:element name="BilateralSchedule" type="apx:BilateralSchedule"/>
						<xs:element name="BidsOffers" type="apx:BidsOffers"/>
						<xs:element name="ResourceParameters" type="apx:ResourceParameters"/>
					</xs:choice>
					<xs:attribute name="Region" type="apx:Region" use="required"/>
					<xs:attribute name="MarketParticipant" type="apx:NonEmptyString" use="required"/>
					<xs:attribute name="MarketStage" type="apx:MarketStage" use="required"/>
					<xs:attribute name="FirstIntervalBegin" type="xs:dateTime" use="required"/>
					<xs:attribute name="LastIntervalEnd" type="xs:dateTime" use="required"/>
				</xs:complexType>
			</xs:element>
		</xs:sequence>
		<xs:attribute name="Version" type="xs:decimal" use="optional" default="2.1"/>
		<xs:attribute name="SourceSystem" type="apx:NonEmptyString" use="required"/>
		<xs:attribute name="CreateDate" type="xs:dateTime" use="required"/>
	</xs:complexType>
	<!-- Entry Points:-->
	<!-- Submit should not include status elements -->
	<xs:element name="Submit">
		<xs:complexType>
			<xs:complexContent>
				<xs:extension base="apx:Header">
					<xs:attribute name="SubmitToISO" type="xs:boolean" use="optional" default="false"/>
				</xs:extension>
			</xs:complexContent>
		</xs:complexType>
	</xs:element>
	<!-- Result includes status elements -->
	<xs:element name="Response">
		<xs:complexType>
			<xs:complexContent>
				<xs:extension base="apx:Header">
					<xs:attribute name="FileStatus" type="apx:NonEmptyString" use="optional">
						<xs:annotation>
							<xs:documentation>Used by Outbound GetStatus responses only. Do not Submit or expect in GetScheduleData responses</xs:documentation>
						</xs:annotation>
					</xs:attribute>
          <xs:attribute name="MarketStatus" type="apx:NonEmptyString" use="optional">
            <xs:annotation>
              <xs:documentation>Used by Outbound GetScheduleData responses only. Do not Submit or expect in GetStatus responses</xs:documentation>
            </xs:annotation>
          </xs:attribute>
				</xs:extension>
			</xs:complexContent>
		</xs:complexType>
	</xs:element>
</xs:schema>


