<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:annotation>
	<xsd:documentation xml:lang="en">
	Pro/3 Knowledge Source Schema
	Copyright (c) 2006 Jens Holm
	Compatible with Pro/3 version 5.6
	Last updated 2006-04-11
	</xsd:documentation>
</xsd:annotation>

<!-- KNOWLEDGE ROOT ELEMENT -->

<!-- 
**************************** KNOWLEDGE ROOT ELEMENT ***************************
-->

<xsd:element name="pro3Knowledge" />
<xsd:complexType>
	<xsd:attribute name="version" type="xsd:integer" />
	<xsd:attribute name="release" type="xsd:integer" />
	<xsd:attribute name="build" type="xsd:integer" />
	<xsd:attribute name="createdTime" type="xsd:timeInstant" />
	<xsd:attribute name="author" type="xsd:string" />
	<xsd:choice minOccurs="1" maxOccurs="unbounded">
		<xsd:element name="sentence" type="sentenceType" />
		<xsd:element name="sentenceRule" type="sentenceRuleType" />
		<xsd:element name="inexactRule" type="inexactRuleType" />
		<xsd:element name="function" type="functionType" />
	</xsd:choice>
</xsd:complexType>	

<!-- 
********************************** SENTENCE ************************************
-->

<xsd:complexType name="sentenceType">
<!-- This element describes one sentence in NL or PR format -->  
	<xsd:attribute name="format" type="formatType" use="xsd:required" /> 
	<xsd:attribute name="realm" type="realmString" use="xsd:required" />
	<xsd:attribute name="realmNo" type="noInteger" use="xsd:required" />
	<xsd:sequence>
		<xsd:element name="PREDICATE" /> 
			<xsd:complexType>
				<xsd:sequence>
					<xsd:element name="NAME" type="token" /> 
					<xsd:sequence minOccurs="0" maxOccurs="1">
						<xsd:sequence minOccurs="1" maxOccurs="unbounded">
							<xsd:element name="DATA_ELEMENT" type="token" />
							<xsd:choice>
								<xsd:element name="VALUE" type="string" />
								<xsd:element name="LIST" />
									<xsd:complexType>
										<xsd:element name="VALUE" type="string" minOccurs="0" maxOccurs="unbounded" />
									</xsd:complexType>
							</xsd:choice> 
						</xsd:sequence>
						<xsd:choice minOccurs="0" maxOccurs="unbounded">
							<xsd:sequence>
								<xsd:element name="DATA_ELEMENT" type="token" />
								<xsd:choice>
									<xsd:element name="VALUE" type="string" />
									<xsd:element name="LIST" />
										<xsd:complexType>
											<xsd:element name="VALUE" type="string" minOccurs="0" maxOccurs="unbounded" />
										</xsd:complexType>
								</xsd:choice> 
							</xsd:sequence>
							<xsd:element name="COMPLEX" />
								<xsd:complexType>
									<xsd:sequence>
										<xsd:element name="NAME" type="token" /> 
										<xsd:sequence minOccurs="1" maxOccurs="unbounded">
											<xsd:element name="DATA_ELEMENT" type="token" />
											<xsd:choice>
												<xsd:element name="VALUE" type="string" />
												<xsd:element name="LIST" />
													<xsd:complexType>
														<xsd:element name="VALUE" type="string" minOccurs="0" maxOccurs="unbounded" />
													</xsd:complexType>
											</xsd:choice> 
										</xsd:sequence>
									</xsd:sequence>
								</xsd:complexType>
						</xsd:choice>
					</xsd:sequence>
				</xsd:sequence>
			</xsd:complexType>
		<xsd:element name="ENTITY" minOccurs="1" maxOccurs="2" />
			<xsd:complexType>
				<xsd:sequence>
					<xsd:element name="NAME" type="token" />
					<xsd:choice minOccurs="1" maxOccurs="unbounded">
						<xsd:sequence> 
							<xsd:element name="DATA_ELEMENT" type="token" />
							<xsd:choice>
								<xsd:element name="VALUE" type="string" />
								<xsd:element name="LIST" />
									<xsd:complexType>
										<xsd:element name="VALUE" type="string" minOccurs="0" maxOccurs="unbounded" />
									</xsd:complexType>
							</xsd:choice> 
						</xsd:sequence>
						<xsd:element name="COMPLEX" />
							<xsd:complexType>
								<xsd:sequence>
									<xsd:element name="NAME" type="token" />
									<xsd:sequence minOccurs="1" maxOccurs="unbounded">
										<xsd:element name="DATA_ELEMENT" type="token" />
										<xsd:choice>
											<xsd:element name="VALUE" type="string" />
											<xsd:element name="LIST" />
												<xsd:complexType>
													<xsd:element name="VALUE" type="string" minOccurs="0" maxOccurs="unbounded" />
												</xsd:complexType>
										</xsd:choice> 
									</xsd:sequence>
								</xsd:sequence>
							</xsd:complexType>
					</xsd:choice>
				</xsd:sequence>
			</xsd:complexType>
	</xsd:sequence>
</xsd:complexType>

<!-- 
***************************** FUNCTION ****************************************
-->

<xsd:complexType name="functionType">
<!-- 
This element describes one function which is specified either in NL or PR format, which refers to the representation
of names, values, statements, parameters etc.
-->  
	<xsd:attribute name="format" type="formatType" use="xsd:required" /> 
	<xsd:attribute name="realm" type="realmString" use="xsd:required" /> 
	<xsd:attribute name="segment" type="xsd:token" use="xsd:required" /> 
	<xsd:sequence>
		<xsd:element name="functionName" type="token" /> <!-- the name of the function -->
		<xsd:element name="determinism" type="determinismType" />
		<xsd:element name="domain" type="token" />
		<xsd:element name="parameter" type="token" minOccurs="0" maxOccurs="unbounded" />
		<xsd:element name="functionBody"  minOccurs="1" maxOccurs="unbounded" />  <!-- the function's bodies -->
			<xsd:complexType>
				<xsd:element name="statement" type="string" minOccurs="1" maxOccurs="unbounded" /> <!-- complete function statement -->
			</xsd:complexType>
	</xsd:sequence>
</xsd:complexType>	

<xsd:simpleType name="determinismType">
<xsd:restriction base="xsd:token">
	<xsd:enumeration value="DETERMINISTIC" />
	<xsd:enumeration value="NONDETERMINISTIC" />
</xsd:restriction>
</xsd:simpleType>	

<!-- 
*************************** INEXACT RULE *************************************
-->

<xsd:complexType name="inexactRuleType">
<!-- 
This element describes one inexact rule which is specified either in NL or PR format, 
which refers to the representation of names, values, queries, parameters etc.
-->  
	<xsd:attribute name="format" type="formatType" use="xsd:required" /> 
	<xsd:attribute name="realm" type="realmString" use="xsd:required" /> 
	<xsd:choice minOccurs="1" maxOccurs="1">
		<xsd:element name="andRule" type="andRuleType" />
		<xsd:element name="orRule" type="orRuleType" />
		<xsd:element name="notRule" type="notRuleType" />
		<xsd:element name="combinationRule" type="combinationRuleType" />
		<xsd:element name="bayesianRule" type="bayesianRuleType" />
		<xsd:element name="switchRule" type="switchRuleType" />
		<xsd:element name="parameterRule" type="parameterRuleType" />
		<xsd:element name="mapRule" type="mapRuleType" />
		<xsd:element name="queryRule" type="queryRuleType" />
		<xsd:element name="questionRule" type="questionRuleType" />
		<xsd:element name="fuzzySet" type="fuzzySetType" />
		<xsd:element name="fuzzyOWA_Set" type="fuzzyOWA_SetType" />
	</xsd:choice>
</xsd:complexType>	

<xsd:complexType name="fuzzySetType">
	<xsd:sequence>
		<xsd:element name="set" type="token" /> <!-- the name of the fuzzy set -->
		<xsd:element name="operation" type="fuzzyOperationType" />
		<xsd:element name="parameter" type="token" minOccurs="0" maxOccurs="unbounded" />
		<xsd:element name="combine" type="combineType" minOccurs="1" maxOccurs="unbounded" />
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="fuzzyOWA_SetType">
	<xsd:sequence>
		<xsd:element name="set" type="token" /> <!-- the name of the fuzzy set -->
		<xsd:element name="parameter" type="token" minOccurs="0" maxOccurs="unbounded" />
		<xsd:element name="OWA" type="OWA_Type" minOccurs="1" maxOccurs="unbounded" />
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="andRuleType">
	<xsd:sequence>
		<xsd:element name="heading" type="headingType" />
		<xsd:element name="call" type="callType" minOccurs="2" maxOccurs="unbounded" />
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="orRuleType">
	<xsd:sequence>
		<xsd:element name="heading" type="headingType" />
		<xsd:element name="call" type="callType" minOccurs="2" maxOccurs="unbounded" />
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="notRuleType">
	<xsd:sequence>
		<xsd:element name="heading" type="headingType" />
		<xsd:element name="call" type="callType" />
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="combinationRuleType">
	<xsd:sequence>
		<xsd:element name="heading" type="headingType" />
		<xsd:element name="call" type="callType" minOccurs="2" maxOccurs="unbounded" />
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="queryRuleType">
	<xsd:sequence>
		<xsd:element name="heading" type="headingType" />
		<xsd:element name="default" type="defaultType" />
		<xsd:element name="query" type="string"/>
		<xsd:element name="map" type="mapType" minOccurs="0" maxOccurs="1 "/>
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="questionRuleType">
	<xsd:sequence>
		<xsd:element name="heading" type="headingType" />
		<xsd:element name="default" type="defaultType" />
		<xsd:element name="questionDomain" type="domainType" />
		<xsd:element name="question" type="string"/>
		<xsd:element name="map" type="mapType" minOccurs="0" maxOccurs="1" />
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="mapRuleType">
	<xsd:sequence>
		<xsd:element name="heading" type="headingType" />
		<xsd:element name="default" type="defaultType" />
		<xsd:element name="call" type="callType" />
		<xsd:element name="map" type="mapType" />
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="bayRuleType">
	<xsd:sequence>
		<xsd:element name="heading" type="headingType" />
		<xsd:element name="bayCall" minOccurs="2" maxOccurs="unbounded" />
			<xsd:complexType>
				<xsd:sequence>
					<xsd:element name="increment" type="incrementType" />
					<xsd:element name="decrement" type="decrementType" />
					<xsd:element name="call" type="callType" />
				</xsd:sequence>
			</xsd:complexType>	
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="parameterRuleType">
	<xsd:sequence>
		<xsd:element name="heading" type="headingType" />
		<xsd:element name="ruleCall" type="callType" />
		<xsd:element name="parameterCall" minOccurs="1" maxOccurs="unbounded" />
			<xsd:complexType>
				<xsd:sequence>
					<xsd:element name="varVal" type="string" />
					<xsd:element name="call" type="callType" />
				</xsd:sequence>
			</xsd:complexType>
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="switchRuleType">
	<xsd:sequence>
		<xsd:element name="heading" type="headingType" />
		<xsd:element name="default" type="defaultType" />
		<xsd:element name="criterionCall" type="callType" />
		<xsd:element name="scCall" minOccurs="1" maxOccurs="unbounded" type="scCallType" />
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="headingType">
	<xsd:sequence>
		<xsd:element name="rule" type="token" /> <!-- the name of the inexact rule -->
		<xsd:element name="returnDomain" type="domainType" />
		<xsd:element name="parameter" type="token" minOccurs="0" maxOccurs="unbounded" />
		<xsd:element name="prior" type="probability" />  <!-- the rule's prior probability -->
		<xsd:element name="crContext" minOccurs="0" maxOccurs="1" />  <!-- the rule's optional context call(s) -->
			<xsd:complexType>
				<xsd:sequence>
					<xsd:element name="outOfContext" type="defaultType" />
					<xsd:element name="scCall" minOccurs="1" maxOccurs="unbounded" type="scCallType" />
				</xsd:sequence>
			</xsd:complexType>
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="scCallType">
	<xsd:choice>
		<xsd:element name="expression" /> <!-- switch-branch of type: value=V, value<V etc -->
			<xsd:complexType>
				<xsd:sequence>
					<xsd:element name="operator" type="operatorType" />
					<xsd:choice>
							<xsd:element name="intVal" type="integer" />
							<xsd:element name="fixVal" type="numeric" />
							<xsd:element name="strVal" type="string" />
							<xsd:element name="idVal" type="string" />
					</xsd:choice>
				<xsd:element name="call" type="callType" />
				</xsd:sequence>
			</xsd:complexType>
		<xsd:element name="range" /> <!-- switch-branch of type: value>Va & value<Vb -->
			<xsd:complexType>
				<xsd:sequence>
					<xsd:element name="operator" type="operatorType" />
					<xsd:choice>
							<xsd:element name="intVal" type="integer" />
							<xsd:element name="fixVal" type="numeric" />
							<xsd:element name="strVal" type="string" />
							<xsd:element name="idVal" type="string" />
					</xsd:choice>
					<xsd:element name="operator" type="operatorType" />
					<xsd:choice>
							<xsd:element name="intVal" type="integer" />
							<xsd:element name="fixVal" type="numeric" />
							<xsd:element name="strVal" type="string" />
							<xsd:element name="idVal" type="string" />
					</xsd:choice>
					<xsd:element name="call" type="callType" />
				</xsd:sequence>
			</xsd:complexType>
		<xsd:element name="defaultCall" type="callType" />  <!-- default switch-branch -->
	</xsd:choice>
</xsd:complexType>

<xsd:complexType name="mapType">
	<xsd:sequence>
		<xsd:element name="mapClass" type="mapClassType" />
		<xsd:sequence minOccurs="1" maxOccurs="unbounded">  
			<xsd:sequence>
				<xsd:choice minOccurs="2" maxOccurs="2">
						<xsd:element name="intVal" type="integer" />
						<xsd:element name="fixVal" type="numeric" />
						<xsd:element name="strVal" type="string" />
						<xsd:element name="idVal" type="string" />
				</xsd:choice>
			</xsd:sequence>
		</xsd:sequence>
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="defaultType">
	<xsd:choice>
			<xsd:element name="intVal" type="integer" />
			<xsd:element name="fixVal" type="numeric" />
			<xsd:element name="strVal" type="string" />
			<xsd:element name="idVal" type="string" />
	</xsd:choice>
</xsd:complexType>	

<xsd:complexType name="incrementType">
	<xsd:choice>
		<xsd:element name="inc" type="incValue" />
		<xsd:element name="call" type="callType" />
	</xsd:choice>
</xsd:complexType>	

<xsd:complexType name="decrementType">
	<xsd:choice>
		<xsd:element name="dec" type="decValue" />
		<xsd:element name="call" type="callType" />
	</xsd:choice>
</xsd:complexType>	

<xsd:complexType name="callType">
	<xsd:sequence>
		<xsd:element name="rule" type="token" />
		<xsd:sequence minOccurs="0" maxOccurs="unbounded" >
			<element name="parameter" type="token" />
			<xsd:choice>
				<xsd:element name="intVal" type="integer" />
				<xsd:element name="fixVal" type="numeric" />
				<xsd:element name="strVal" type="string" />
				<xsd:element name="idVal" type="string" />
				<xsd:element name="varVal" type="string" />
			</xsd:choice>
		</xsd:sequence>
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="combineType">
	<xsd:sequence>
		<xsd:element name="set" type="token" />
		<xsd:sequence minOccurs="0" maxOccurs="unbounded" >
			<element name="parameter" type="token" />
			<xsd:choice>
				<xsd:element name="intVal" type="integer" />
				<xsd:element name="fixVal" type="numeric" />
				<xsd:element name="strVal" type="string" />
				<xsd:element name="idVal" type="string" />
				<xsd:element name="varVal" type="string" />
			</xsd:choice>
		</xsd:sequence>
	</xsd:sequence>
</xsd:complexType>	

<xsd:complexType name="OWA_Type">
	<xsd:sequence>
		<xsd:choice>
			<element name="weight" type="numeric" />
			<element name="call" type="callType" />
		</xsd:choice>
		<xsd:element name="set" type="token" />
		<xsd:sequence minOccurs="0" maxOccurs="unbounded" >
			<element name="parameter" type="token" />
			<xsd:choice>
				<xsd:element name="intVal" type="integer" />
				<xsd:element name="fixVal" type="numeric" />
				<xsd:element name="strVal" type="string" />
				<xsd:element name="idVal" type="string" />
				<xsd:element name="varVal" type="string" />
			</xsd:choice>
		</xsd:sequence>
	</xsd:sequence>
</xsd:complexType>	

<xsd:simpleType name="mapClassType">
<xsd:restriction base="xsd:token">
	<xsd:enumeration value="DISCRETE" />
	<xsd:enumeration value="NUMERIC" />
</xsd:restriction>
</xsd:simpleType>	

<xsd:simpleType name="domainType">
<xsd:restriction base="xsd:token">
</xsd:restriction>
</xsd:simpleType>	

<xsd:simpleType name="operatorType">
<xsd:restriction base="xsd:token">
	<xsd:enumeration value="=" />
	<xsd:enumeration value="&lt;" />
	<xsd:enumeration value="&lt;=" />
	<xsd:enumeration value="&gt;" />
	<xsd:enumeration value="&gt;=" />
</xsd:restriction>
</xsd:simpleType>	

<xsd:simpleType name="fuzzyOperationType">
<xsd:restriction base="xsd:token">
	<xsd:enumeration value="FUZZY_SET_STANDARD_INTERSECTION" />
	<xsd:enumeration value="FUZZY_SET_ALGEBRAIC_PRODUCT_INTERSECTION" />
	<xsd:enumeration value="FUZZY_SET_BOUNDED_DIFFERENCE_INTERSECTION" />
	<xsd:enumeration value="FUZZY_SET_DRASTIC_INTERSECTION" />
	<xsd:enumeration value="FUZZY_SET_STANDARD_UNION" />
	<xsd:enumeration value="FUZZY_SET_ALGEBRAIC_SUM_UNION" />
	<xsd:enumeration value="FUZZY_SET_BOUNDED_SUM_UNION" />
	<xsd:enumeration value="FUZZY_SET_DRASTIC_UNION" />
	<xsd:enumeration value="FUZZY_SET_COMPLEMENT" />
	<xsd:enumeration value="FUZZY_SET_AVERAGE" />
</xsd:restriction>
</xsd:simpleType>	

<xsd:simpleType name="certainty">
<xsd:restriction base="xsd:decimal">
	<xsd:minInclusive value="-5.0" />
	<xsd:maxInclusive value="5.0" />
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="probability">
<xsd:restriction base="xsd:decimal">
	<xsd:minInclusive value="0.0" />
	<xsd:maxInclusive value="1.0" />
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="decValue">
<xsd:restriction base="xsd:decimal">
	<xsd:minExclusive value="0.0" />
	<xsd:maxExclusive value="1.0" />
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="incValue">
<xsd:restriction base="xsd:decimal">
	<xsd:minExclusive value="1.0" />
</xsd:restriction>
</xsd:simpleType>

<!-- 
**************************** COMMON SIMPLE ELEMENTS **************************** 
-->

<xsd:simpleType name="formatType">
<xsd:restriction base="xsd:token">
	<xsd:enumeration value="PR" />
	<xsd:enumeration value="NL" />
</xsd:restriction>
</xsd:simpleType>	

<!-- 
**********************************  SENTENCE RULE ****************************** 
-->

<xsd:complexType name="sentenceRuleType">
<!--
Represents one sentence rule in essentially internal format used for the purpose of source-level
backup. The format is not well suited for source-level editing.
Last updated: 13Jan04.
-->
	<xsd:attribute name="ruleType" type="ruleTypeInteger" use="xsd:required" />
	<xsd:attribute name="realm" type="realmString" use="xsd:required" />
	<xsd:attribute name="realmNo" type="noInteger" use="xsd:required" />
	<xsd:attribute name="realmSubNo" type="subNoInteger" use="xsd:required" />
	<xsd:element name="tree" type="treeType" />
</xsd:complexType>	

<xsd:complexType name="treeType">
	<xsd:attribute name="class" type="token" use="xsd:required" />
	<xsd:attribute name="label" type="token" use="xsd:required" />
	<xsd:attribute name="nlLabel" type="token" />
	<xsd:any minOccurs="1" maxOccurs="unbounded">
		<xsd:choice>
			<xsd:element name="tree" type="treeType" />
			<xsd:element name="node" />
				<xsd:complexType>
					<xsd:attribute name="class" type="token" use="xsd:required" />
					<xsd:attribute name="label" type="token" use="xsd:required" />
					<xsd:attribute name="nlLabel" type="token" />
				</xsd:complexType>
		</xsd:choice>
	</xsd:any>
</xsd:complexType>	

<xsd:simpleType name="ruleType">
<xsd:restriction base="xsd:integer">
	<xsd:enumeration value="1" />
	<xsd:enumeration value="4" />
	<xsd:enumeration value="21" />
	<xsd:enumeration value="22" />
	<xsd:enumeration value="61" />
	<xsd:enumeration value="62" />
	<xsd:enumeration value="63" />
	<xsd:enumeration value="64" />
	<xsd:enumeration value="65" />
	<xsd:enumeration value="66" />
	<xsd:enumeration value="67" />
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="noInteger">
<xsd:restriction base="xsd:integer">
	<xsd:minInclusive value="1" />
	<xsd:maxInclusive value="99999" />
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="realmString">
<xsd:restriction base="xsd:token">
	<xsd:pattern value="[A-Z]([A-Z]|[0-9]|-|_)*" />
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="subNoInteger">
<xsd:restriction base="xsd:integer">
	<xsd:minInclusive value="0" />
	<xsd:maxInclusive value="999" />
</xsd:restriction>
</xsd:simpleType>

</xsd:schema>