﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Microsoft.Fpc.Sqm.Agent.Configuration"
             xmlns="" 
             xmlns:xs="http://www.w3.org/2001/XMLSchema" 
             xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" 
             targetNamespace="http://www.microsoft.com/isaserver/MsFpcSqmConfiguration.xsd" 
             xmlns:fpcsqm="http://www.microsoft.com/isaserver/MsFpcSqmConfiguration.xsd">

  <!--The configuration data points container-->
  <xs:complexType name="Configuration">
    <xs:sequence>
       <xs:element name="DataPoints" type="fpcsqm:DataPoints"/> 
    </xs:sequence>
  </xs:complexType>
  
  <xs:complexType name="DataPoints">
    <xs:sequence>
      <xs:element name="DataPoint" type="fpcsqm:DataPoint" minOccurs="1" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  
  <!--A configuration data point-->
  <xs:complexType name="DataPoint">
    <xs:all>
      <xs:element name="Script" type="fpcsqm:Code" nillable="false"/>
    </xs:all>
    <xs:attribute name="Id" type="xs:positiveInteger" use="required" />
    <xs:attribute name="Name" type="xs:string" use="required" />
    <xs:attribute name="Operation" type="fpcsqm:NumericOperation" use="optional" />
    <xs:attribute name="Property" type="xs:string" use="optional"/>
  </xs:complexType>
  
  <!--Allowed numeric operations-->
  <xs:simpleType name="NumericOperation">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Set"/>
      <xs:enumeration value="BitField"/>
      <xs:enumeration value="Increment"/>
      <xs:enumeration value="Average"/>
      <xs:enumeration value="Min"/>
      <xs:enumeration value="Max"/>
    </xs:restriction>
  </xs:simpleType>

  <!--Script code type definition-->
  <xs:simpleType name="Code">
    <xs:restriction base="xs:string">
      <xs:minLength value="10"/>
      <!--max length: 100 lines of 100 characters-->
      <xs:maxLength value="10000"/>
    </xs:restriction>
  </xs:simpleType>

  <!--The root element-->
  <xs:element name="Configuration" type="fpcsqm:Configuration">
    <xs:unique name="UniqueDataPointId">
       <xs:selector xpath="DataPoints/DataPoint" /> 
      <xs:field xpath="@Id" />
    </xs:unique>
    <xs:unique name="UniqueDataPointName">
       <xs:selector xpath="DataPoints/DataPoint" /> 
      <xs:field xpath="@Name" />
    </xs:unique>
  </xs:element>
  
</xs:schema>
