<?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"
elementFormDefault="qualified"
>

<!-- note that elementFormDefault is qualified because of the local declaration of Ind -->

	<xs:annotation>
		<xs:documentation xml:lang="en">
			XML Schema for a Binary Ground-Datalog RuleML sublanguage
			File: bindatagroundlog.xsd
			Version: 0.89
			Last Modification: 2005-05-27
		</xs:documentation>
	</xs:annotation>
	
	<xs:redefine schemaLocation="bindatalog.xsd">
		<!--
			remove Var so that arg's content model is: (Ind | Data | Skolem | Reify)

			note that this automatically removes Var from Atom so that Atom's content model is:
			(
		   	   oid?,
	            	     ((opr|Rel),(slot)*,(arg|Ind|Data|Skolem|Reify),(arg|Ind|Data|Skolem|Reify),(slot)*) |
	            	     ( (slot)*, (arg|Ind|Data|Skolem|Reify), (arg|Ind|Data|Skolem|Reify), (slot)*, opr )
	     		)

	     		and also from slot so that its content model is:
			( (Ind|Data|Skolem|Reify), (Ind|Data|Skolem|Reify) )
		-->		
		<xs:group name="arg.content">
			<xs:choice>
				<xs:element name="Ind" type="Ind-normal.type"/>
				<xs:element ref="Data"/>
				<xs:element ref="Skolem"/>
				<xs:element ref="Reify"/>					
			</xs:choice>
		</xs:group>
		
		<!--
			remove Forall (since ground) so that And's content model (within Assert) is:
			( oid?, (formula | Atom | Implies | Equivalent)* )		
		-->
		<xs:group name="formula-top-and.content">
			<xs:choice>
				<xs:element ref="Atom"/>
				<xs:element ref="Implies"/>
				<xs:element ref="Equivalent"/>
			</xs:choice>
		</xs:group>	

		<!--
			similarly, remove Exists (since ground) so that Query's content model is:
			( content | Atom | And | Or )						
		-->
		<xs:group name="content-query.content">
			<xs:choice>
				<xs:element ref="Atom"/>
				<xs:element name="And" type="And-query.type"/>
				<xs:element name="Or" type="Or-query.type"/>					
			</xs:choice>
		</xs:group>	

	</xs:redefine>

</xs:schema>
