<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://schemas.microsoft.com/appx/manifest/desktop/windows10/8"
           xmlns="http://schemas.microsoft.com/appx/manifest/desktop/windows10/8"
           xmlns:t="http://schemas.microsoft.com/appx/manifest/types"
           xmlns:f="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
           xmlns:uap10="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"
           xmlns:uap11="http://schemas.microsoft.com/appx/manifest/uap/windows10/11"
           xmlns:desktop6="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"
           >

  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/types"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/foundation/windows10"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/uap/windows10/10"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/uap/windows10/11"/>
  <xs:import namespace="http://schemas.microsoft.com/appx/manifest/desktop/windows10/6"/>

  <xs:element name="Extension" substitutionGroup="f:ExtensionChoice">
    <xs:complexType>
      <xs:choice minOccurs="0">
        <xs:element name="MutablePackageDirectories" type="CT_MutablePackageDirectories"/>
        <xs:element name="UserMutablePackageDirectories" type="CT_UserMutablePackageDirectories"/>
        <xs:element name="EventTracing" type="CT_EventTracing"/>
      </xs:choice>
      <xs:attribute name="Category" type="t:ST_ExtensionCategory_Desktop8" use="required"/>
      <xs:attributeGroup ref="t:ExtensionBaseAttributes"/>
      <xs:attributeGroup ref="uap10:TrustLevelGroup"/>
      <xs:attributeGroup ref="uap11:ManganeseExtensionAttributesGroup"/>
    </xs:complexType>
  </xs:element>
  
  <xs:complexType name="CT_MutablePackageDirectories">
    <xs:sequence minOccurs="1">
      <xs:element name="MutablePackageDirectory" maxOccurs="1" >
        <xs:complexType>
          <xs:attribute name="Target" type="t:ST_MutableDirectoryTarget" use="required"/>
          <xs:attribute name="Shared" type="xs:boolean" use="optional"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="CT_UserMutablePackageDirectories">
    <xs:all>
      <xs:element name="UserMutablePackageDirectory">
        <xs:complexType>
          <xs:attribute name="Target" type="t:ST_FileNameSegment" use="required" />
        </xs:complexType>
      </xs:element>
    </xs:all>
  </xs:complexType>

  <xs:attribute name="RunAsUser" type="xs:boolean" />

  <xs:complexType name="CT_EventTracing">
    <xs:choice minOccurs="0" maxOccurs="1000">
      <xs:element name="Provider" type="CT_Provider"/>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="CT_Provider">
    <xs:choice minOccurs="0" maxOccurs="1000">
      <xs:element name="Channels" type="CT_Channels"/>
    </xs:choice>  
    <xs:attribute name="Id" type="t:ST_GUID" use="required"/>
    <xs:attribute name="Name" type="t:ST_URI" use="required" />
    <xs:attribute name="ResourceFile" type="t:ST_FileName" use="required" />
    <xs:attribute name="MessageFile" type="t:ST_FileName" use="optional" />
  </xs:complexType>

  <xs:complexType name="CT_Channels">
    <xs:choice minOccurs="0" maxOccurs="1000">
      <xs:element name="ImportChannel" type="CT_ImportChannel"/>
      <xs:element name="Channel" type="CT_Channel"/>
    </xs:choice>
  </xs:complexType>

  <xs:complexType name="CT_ImportChannel">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="Name" type="t:ST_URI" use="required"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:complexType name="CT_Channel" mixed="true">
    <xs:sequence>
      <xs:element name="Logging" type="CT_Logging" minOccurs="0"/>
      <xs:element name="Publishing" type="CT_Publishing" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute name="Name" type="t:ST_URI" use="required"/>
    <xs:attribute name="Type" type="ST_ChannelType" use="required"/>
    <xs:attribute name="Access" type="t:ST_PermissionsCom" use="optional"/>
    <xs:attribute name="Isolation" type="ST_Isolation" use="optional" />
    <xs:attribute name="Enabled" type="xs:boolean" use="optional" default="false"/>
  </xs:complexType>

  <xs:complexType name="CT_Logging">
    <xs:attribute name="AutoBackup" type="xs:boolean" use="optional" />
    <xs:attribute name="Retention" type="xs:boolean" use="optional" />
    <xs:attribute name="MaxSize" type="t:ST_UInt64" use="optional" />
  </xs:complexType>

  <xs:complexType name="CT_Publishing">
    <xs:attribute name="Level" type="t:ST_UInt8" use="optional" />
    <xs:attribute name="Keywords" type="t:ST_UInt64" use="optional" />
    <xs:attribute name="ControlGuid" type="t:ST_GUID" use="optional" />
    <xs:attribute name="BufferSize" type="t:ST_UInt32" use="optional" />
    <xs:attribute name="FileMax" type="t:ST_UInt32" use="optional" />
    <xs:attribute name="MinBuffers" type="t:ST_UInt32" use="optional" />
    <xs:attribute name="MaxBuffers" type="t:ST_UInt32" use="optional" />
    <xs:attribute name="Latency" type="t:ST_UInt32" use="optional" />
    <xs:attribute name="ClockType" type="ST_ClockType" default="systemTime" use="optional" />
    <xs:attribute name="SidType" type="ST_SidType" use="optional" />
  </xs:complexType>

  <xs:simpleType name="ST_ChannelType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="admin"/>
      <xs:enumeration value="operational"/>
      <xs:enumeration value="analytic"/>
      <xs:enumeration value="analytic"/>
      <xs:enumeration value="debug"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="ST_Isolation">
    <xs:restriction base="xs:string">
      <xs:enumeration value="application"/>
      <xs:enumeration value="system"/>
      <xs:enumeration value="custom"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="ST_SidType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="none"/>
      <xs:enumeration value="publishing"/>
    </xs:restriction>
  </xs:simpleType>
  
  <xs:simpleType name="ST_ClockType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="systemTime"/>
      <xs:enumeration value="queryPerformanceCounter"/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>

