<?xml version="1.0" encoding="UTF-8"?>
<xs:schema 
targetNamespace="http://www.ruleml.org/0.91/xsd" 
xmlns="http://www.ruleml.org/0.91/xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>

	<xs:annotation>
		<xs:documentation xml:lang="en">
			XML Schema for a Datalog RuleML sublanguage, including negation as failure (NAF)
			File: nafdatalog.xsd
			Version: 0.91
			Last Modification: 2006-08-18
		</xs:documentation>
	</xs:annotation>

	<!-- nafdatalog includes the 'naf' module -->
	<xs:include schemaLocation="modules/naf_module.xsd"/>
	
	<!-- note the addition of Naf (negation as failure) from the negation module -->
	<xs:redefine schemaLocation="datalog.xsd">

		<!--
			add Naf so that body's content model is:
			(Atom | And | Or | Naf)
		-->
		<xs:group name="body.content">
			<xs:choice>
				<xs:group ref="body.content"/>
				<xs:element ref="Naf"/>
			</xs:choice>
		</xs:group>		
		<!--
			note that the above indirectly adds Naf to Implies so that its content model is:
			( oid?, (head, body) | (body, head) | ( (Atom | And | Or | Naf), Atom ) )
		-->			

		<!--
			add Naf so that Query's content model is:
			( oid?, (formula | Rulebase | Naf | Atom | And | Or | Entails | Exists)* )
		-->
		<xs:group name="formula-query.content">
			<xs:choice>
				<xs:group ref="formula-query.content"/>
				<xs:element ref="Naf"/>
			</xs:choice>	
		</xs:group>
	

		<!--
			add Naf so that formula's content model (when under And/Or) is:
			(Atom | And | Or | Naf)
		-->
		<xs:group name="formula-and-or.content">
			<xs:choice>
				<xs:group ref="formula-and-or.content"/>
				<xs:element ref="Naf"/>
			</xs:choice>	
		</xs:group>		
		<!-- 
			note that the above indirectly adds Naf to And/Or so their content models are:
			( oid?, (formula | Atom | And | Or | Naf)* )
		-->

		
	</xs:redefine>
	
</xs:schema>