<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 
targetNamespace="http://www.ruleml.org/0.89/xsd" 
xmlns="http://www.ruleml.org/0.89/xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>

	<xs:annotation>
		<xs:documentation xml:lang="en">
			XML Schema for a Datalog RuleML sublanguage, including both explicit
				and default (strong/weak) negation
			File: nafnegdatalog.xsd
			Version: 0.89
			Last Modification: 2005-03-22
		</xs:documentation>
	</xs:annotation>

	<!-- nafnegdatalog includes the 'neg' module-->
	<xs:include schemaLocation="modules/neg_module.xsd"/>
	
	<!-- nafnegdatalog includes the 'naf' module and redefines it slightly -->
	<xs:redefine schemaLocation="modules/naf_module.xsd">

		<!--
			add Neg so that weak's content model is:
			(Atom | Neg)
		-->
		<xs:group name="weak.content">
			<xs:choice>
				<xs:group ref="weak.content"/>
				<xs:element ref="Neg"/>
			</xs:choice>
		</xs:group>
		<!--
			note that the above indirectly adds Neg to Naf so that Naf's content model is:
			(weak | Atom | Neg)
		-->		

	</xs:redefine>
	
	<!--
		note the addition of Naf (Negation as failure) and Neg (classical Negation)
		from the negation modules
	-->
	<xs:redefine schemaLocation="datalog.xsd">

		<!--
			add Neg so that head's content model is:
			(Atom | Neg)
		-->
		<xs:group name="head.content">
			<xs:choice>
				<xs:group ref="head.content"/>
				<xs:element ref="Neg"/>
			</xs:choice>
		</xs:group>

		<!--
			add Naf and Neg so that body's content model is:
			(Atom | And | Or | Neg | Naf)
		-->
		<xs:group name="body.content">
			<xs:choice>
				<xs:group ref="body.content"/>
				<xs:element ref="Naf"/>
				<xs:element ref="Neg"/>
			</xs:choice>
		</xs:group>		
		<!--
			note that the above indirectly adds Naf and Neg to Implies so that its content model is:
			( oid?, ( head, body) | ( body, head) | ( (Atom | And | Or | Neg | Naf), (Atom | Neg) ) )
		-->	
		
		<!--
			add Naf and Neg so that content's content model (when under Query) is:
			( Atom | And | Or | Exists | Neg | Naf)
		-->
		<xs:group name="content-query.content">
			<xs:choice>
				<xs:group ref="content-query.content"/>
				<xs:element ref="Naf"/>	
				<xs:element ref="Neg"/>
			</xs:choice>	
		</xs:group>
		<!--
			note that the above indirectly adds Naf and Neg to Query so its content model is:
			(content | Atom | And | Or | Exists | Neg | Naf)
		-->

		<!--
			add Naf and Neg so that formula's content model (when under And/Or) is:
			(Atom | And | Or | Naf | Neg)
		-->
		<xs:group name="formula-and-or.content">
			<xs:choice>
				<xs:group ref="formula-and-or.content"/>
				<xs:element ref="Naf"/>
				<xs:element ref="Neg"/>				
			</xs:choice>	
		</xs:group>		
		<!--
			note that the above indirectly adds Naf and Neg to And and Or so their content models are:
			( (formula | Atom | And | Or | Naf | Neg)* )
		-->		

	</xs:redefine>
	
</xs:schema>
