<?xml version="1.0"?>

<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">
			Data RuleML elements module.
			This is the XML Schema data module for RuleML.
			File: data_module.xsd
			Version: 0.89
			Last Modification: 2005-05-27
			
			This module declares the following data RuleML elements/attributes:
			* arg
			* Ind
			* Data
			* Var
			* Skolem
			* Reify
			* @type
			* @index
			
			The approach is modelled after that used in "Modularization of XHTML in XML Schema"
			WD [http://www.w3.org/TR/xhtml-m12n-schema/], which will soon be integrated with
			"Modularization of XHTML" (REC-xhtml-modularization-20010410)
			[http://www.w3.org/TR/xhtml-modularization/].
		</xs:documentation>
	</xs:annotation>

	<!--
		*** arg ***
		content model: ( Ind | Data | Var | Skolem | Reify)

		This is a role for the positional arguments of an Atom.  It is usually left implicit.
		Requires an "index" attribute.
	-->
	<xs:attributeGroup name="arg.attlist">
		<xs:attributeGroup ref="index.attrib"/>
	</xs:attributeGroup>
	<xs:group name="arg.content">
		<xs:choice>
			<xs:element name="Ind" type="Ind-normal.type"/>
			<xs:element ref="Data"/>
			<xs:element ref="Var"/>
			<xs:element ref="Skolem"/>
			<xs:element ref="Reify"/>			
		</xs:choice>
	</xs:group>
	<xs:complexType name="arg.type">
		<xs:group ref="arg.content"/>
		<xs:attributeGroup ref="arg.attlist"/>
	</xs:complexType>
	<xs:element name="arg" type="arg.type"/>

	<!--
		*** Ind ***
		Note that this element's content model is context-sensitive, so it is locally declared.
		See http://www.w3.org/2000/04/26-csrules.html.

		content model: (#PCDATA)

		An individual constant, as in predicate logic.
		
		A fixed argument like RDF resources.  It can be viewed logically as a logical
		function whose arity is zero.

		Individuals may have an optional 'type' attribute for term typing, as well
		as either 'wlab' (if within an oid) or 'wlab' (otherwise) for webizing.
	-->

       <!-- when Ind is inside an oid, allow @wlab but not @wref -->
	<xs:attributeGroup name="Ind-oid.attlist">
		<xs:attributeGroup ref="type.attrib"/>
               <xs:attributeGroup ref="wlab.attrib"/>		
	</xs:attributeGroup>
       <!-- when Ind is not inside an oid, allow @wref but not @wlab -->
       <xs:attributeGroup name="Ind-normal.attlist">
               <xs:attributeGroup ref="type.attrib"/>
               <xs:attributeGroup ref="wref.attrib"/>
       </xs:attributeGroup>
	<xs:group name="Ind.content">
		<xs:sequence/>
	</xs:group>	
	<xs:complexType name="Ind-oid.type" mixed="true">
		<xs:group ref="Ind.content"/>
		<xs:attributeGroup ref="Ind-oid.attlist"/>
	</xs:complexType>
	<xs:complexType name="Ind-normal.type" mixed="true">
		<xs:group ref="Ind.content"/>
		<xs:attributeGroup ref="Ind-normal.attlist"/>
	</xs:complexType>
	<xs:element name="Ind" type="Ind-normal.type"/>


	<!--
		*** Data ***
		content model: (#PCDATA) [optionally datatyped]

		A fixed argument like RDF literals.  It may be optionally associated with an XML Schema
		built-in datatype (see http://www.w3.org/TR/xmlschema-2/#built-in-datatypes) using the
		xsi:type attribute.

		For example, <Data xsi:type="xs:dateTime"> specifies that the supplied data must be valid
		dateTime (see http://www.w3.org/TR/xmlschema-2/#dateTime), so

		<Data xsi:type="xs:dateTime">2002-10-10T17:00:00Z</Data> 

		is valid, while the following is not:

		<Data xsi:type="xs:dateTime">tomorrow</Data>

		Note, however, that <Data>tomorrow</Data> is valid because no built-in datatype is given.
	-->
	<xs:element name="Data" type="xs:anySimpleType"/>


	<!--
		*** Var ***
		content model: (#PCDATA)

		A logical variable, as in logic programming.

		Variables may have an optional 'type' attribute for term typing.
	-->
	<xs:attributeGroup name="Var.attlist">
		<xs:attributeGroup ref="type.attrib"/>
	</xs:attributeGroup>
	<xs:group name="Var.content">
		<xs:sequence/>
	</xs:group>
	<xs:complexType name="Var.type" mixed="true">
		<xs:group ref="Var.content"/>
		<xs:attributeGroup ref="Var.attlist"/>
	</xs:complexType>
	<xs:element name="Var" type="Var.type"/>

	<!--
		*** Skolem ***
		content model: (#PCDATA)

		A Skolem individual constant, like RDF's blank nodes.
		See http://www.ruleml.org/posl/poslintweb-talk.pdf for more information.

		Skolems may have an optional 'type' attribute for term typing.
	-->
	<xs:attributeGroup name="Skolem.attlist">
		<xs:attributeGroup ref="type.attrib"/>
	</xs:attributeGroup>
	<xs:group name="Skolem.content">
		<xs:sequence/>
	</xs:group>
	<xs:complexType name="Skolem.type" mixed="true">
		<xs:group ref="Skolem.content"/>
		<xs:attributeGroup ref="Skolem.attlist"/>
	</xs:complexType>
	<xs:element name="Skolem" type="Skolem.type"/>

	<!--
		*** Reify ***
		content model: ( <xs:any>? )

		Supports reification (a kind of instantiation or quasi-quotation) as needed by SWSL.

		It is permitted anywhere a regular term (e.g. Ind or Var) is, in all sublanguages, and
		allows any RuleML tag available within the current sublanguage as content, treating it as a term for 				performing reasoning on.
	-->
	<xs:attributeGroup name="Reify.attlist"/>
	<xs:group name="Reify.content">
		<xs:sequence>
			<!-- anything under <Reify> must have a definition and be valid -->
			<xs:any minOccurs="0" processContents="strict"/>
		</xs:sequence>
	</xs:group>
	<xs:complexType name="Reify.type">
		<xs:group ref="Reify.content"/>
		<xs:attributeGroup ref="Reify.attlist"/>
	</xs:complexType>
	<xs:element name="Reify" type="Reify.type"/>

	<!--
		*** @type ***
		
		Optionally specifies the term's (user-defined) type.
	-->
	<xs:attributeGroup name="type.attrib">
		<xs:attribute name="type" type="xs:string" use="optional"/>
	</xs:attributeGroup>

	<!--
		*** @index ***
		
		Specifies the position of a positional argument within an Atom.
	-->
	<xs:attributeGroup name="index.attrib">
		<xs:attribute name="index" type="xs:positiveInteger" use="required"/>
	</xs:attributeGroup>

</xs:schema>
