<?xml version="1.0" encoding="UTF-8"?>
<!-- For a list of all released XSD files, visit http://www.drools.org/xsd/ -->
<!-- Do NOT change the version number 6.0.0 in the targetNamespace because that breaks old clients! -->
<!-- The targetNamespace has changed to http://drools.org/xsd/kmodule in the new kmodule.xsd to become versionless -->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            elementFormDefault="qualified" attributeFormDefault="unqualified"
            targetNamespace="http://jboss.org/kie/6.0.0/kmodule" xmlns="http://jboss.org/kie/6.0.0/kmodule">

  <!-- xsd:import namespace="http://www.w3.org/2001/XMLSchema-instance" / -->

  <xsd:element name="kmodule">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="configuration" minOccurs="0" maxOccurs="1"/>
        <xsd:element ref="kbase" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="configuration">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="property">
    <xsd:complexType>
      <xsd:simpleContent>
        <xsd:extension base="xsd:string">
          <xsd:attribute name="key" use="required" type="xsd:string"/>
          <xsd:attribute name="value" use="required" type="xsd:string"/>
        </xsd:extension>
      </xsd:simpleContent>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="kbase">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="ruleTemplate" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="ksession" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
      <xsd:attribute name="name" use="required" type="xsd:ID"/>
      <xsd:attribute name="includes" type="xsd:string"/>
      <xsd:attribute name="packages" type="xsd:string"/>
      <xsd:attribute name="default" type="xsd:boolean"/>
      <xsd:attribute name="scope" type="xsd:string"/>
      <xsd:attribute name="equalsBehavior" type="insertBehaviorEnum"/>
      <xsd:attribute name="eventProcessingMode" type="eventModeEnum"/>
      <xsd:attribute name="declarativeAgenda" type="declarativeAgendaEnum"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="ruleTemplate">
    <xsd:complexType>
      <xsd:attribute name="dtable" use="required" type="xsd:string"/>
      <xsd:attribute name="template" use="required" type="xsd:string"/>
      <xsd:attribute name="row" use="required" type="xsd:int"/>
      <xsd:attribute name="col" use="required" type="xsd:int"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="ksession">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:choice minOccurs="0" maxOccurs="1">
          <xsd:element ref="consoleLogger"/>
          <xsd:element ref="fileLogger"/>
        </xsd:choice>
        <xsd:element ref="workItemHandlers" minOccurs="0" maxOccurs="1"/>
        <xsd:element ref="listeners" minOccurs="0" maxOccurs="1"/>
      </xsd:sequence>
      <xsd:attribute name="name" use="required" type="xsd:ID"/>
      <xsd:attribute name="type" type="ksessionType"/>
      <xsd:attribute name="default" type="xsd:boolean"/>
      <xsd:attribute name="scope" type="xsd:string"/>
      <xsd:attribute name="clockType" type="clockTypeEnum"/>
      <xsd:attribute name="beliefSystem" type="beliefSystemEnum"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="consoleLogger">
    <xsd:complexType>
      <xsd:attribute name="name" type="xsd:ID"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="fileLogger">
    <xsd:complexType>
      <xsd:attribute name="name" type="xsd:ID"/>
      <xsd:attribute name="file" use="required" type="xsd:string"/>
      <xsd:attribute name="threaded" type="xsd:boolean" default="false"/>
      <xsd:attribute name="interval" type="xsd:int" default="30"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="listeners">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="ruleRuntimeEventListener" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="agendaEventListener" minOccurs="0" maxOccurs="unbounded"/>
        <xsd:element ref="processEventListener" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="workItemHandlers">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element ref="workItemHandler" minOccurs="0" maxOccurs="unbounded"/>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="workItemHandler">
    <xsd:complexType>
      <xsd:attribute name="name" use="required" type="xsd:string"/>
      <xsd:attribute name="type" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="ruleRuntimeEventListener">
    <xsd:complexType>
      <xsd:attribute name="type" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="agendaEventListener">
    <xsd:complexType>
      <xsd:attribute name="type" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:element name="processEventListener">
    <xsd:complexType>
      <xsd:attribute name="type" use="required" type="xsd:string"/>
    </xsd:complexType>
  </xsd:element>

  <xsd:simpleType name="ksessionType">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="stateless"/>
      <xsd:enumeration value="stateful"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="eventModeEnum">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="stream"/>
      <xsd:enumeration value="cloud"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="insertBehaviorEnum">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="identity"/>
      <xsd:enumeration value="equality"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="declarativeAgendaEnum">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="enabled"/>
      <xsd:enumeration value="disabled"/>
      <xsd:enumeration value="true"/>
      <xsd:enumeration value="false"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="clockTypeEnum">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="realtime"/>
      <xsd:enumeration value="pseudo"/>
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="beliefSystemEnum">
    <xsd:restriction base="xsd:string">
      <xsd:enumeration value="simple"/>
      <xsd:enumeration value="jtms"/>
      <xsd:enumeration value="defeasible"/>
    </xsd:restriction>
  </xsd:simpleType>

</xsd:schema>
