<?xml version="1.0"?>
<!-- 
    Xsd schema defining Entish formula and term. 
    Authors: S. Ambroszkiewicz, D. Mikulowski, D. Pawluczuk, M. Calka, and P. Izdebski
    http://www.ipipan.waw.pl/mas 
    Last modified April 2, 2003
-->
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 targetNamespace="http://ii5.ap.siedlce.pl/entish"
 xmlns="http://ii5.ap.siedlce.pl/entish"
 elementFormDefault="qualified">

  <xsd:element name="formula" type="Formula"/>
  <xsd:complexType name="Formula">
    <xsd:sequence>
      <xsd:choice>
        <xsd:sequence>
          <xsd:element ref="relationName"/>
          <xsd:element ref="term" minOccurs="0" maxOccurs="unbounded"/>
        </xsd:sequence>
        <xsd:sequence>
          <xsd:element name="operator">
            <xsd:simpleType>
              <xsd:restriction base="xsd:string">
                <xsd:enumeration value="or"/>
                <xsd:enumeration value="and"/>
                <xsd:enumeration value="implies"/>
              </xsd:restriction>
            </xsd:simpleType>
          </xsd:element>         
          <xsd:element ref="formula" minOccurs="2" maxOccurs="unbounded"/>
        </xsd:sequence>
      </xsd:choice>
    </xsd:sequence>
  </xsd:complexType> 
<!-- 
    Note that the following three elements of type Concept MUST correspond to the appropriate elements of 
    relationDefinition, functionDefinition and typeDefinition defined in definitions.xsd. 
    Moreover, the signature of relationName, or functionName MUST agree with the signature defined in the 
    relationDefinition, or functionDefinition. The element longName of relationName, or functionName, 
    or typeName MUST be the URI of the document (an instance of definitions.xsd) where the Name was defined. 
-->
  <xsd:element name="relationName" type="Concept"/>
  <xsd:element name="functionName" type="Concept"/> 
  <xsd:element name="typeName" type="Concept"/>  
  <xsd:complexType name="Concept">
    <xsd:sequence>
      <xsd:element name="shortName" type="xsd:string"/>
      <xsd:element name="longName" type="xsd:anyURI" minOccurs="0"/>
    </xsd:sequence>
  </xsd:complexType>
  
  <xsd:element name="term" type="Term"/>
  <xsd:complexType name="Term">
    <xsd:sequence>  
      <xsd:choice>
        <xsd:sequence>   
          <xsd:choice>
            <xsd:element ref="variable"/>
            <xsd:element ref="constant"/>
          </xsd:choice>  
        </xsd:sequence>        
        <xsd:sequence> 
          <xsd:element ref="functionName"/> 
          <xsd:element ref="typeName"/> 
          <xsd:element ref="term" minOccurs="0" maxOccurs="unbounded"/> 
        </xsd:sequence>
      </xsd:choice>
    </xsd:sequence>     
  </xsd:complexType>
  
  <xsd:element name="variable" type="Variable"/>
  <xsd:complexType name="Variable">
    <xsd:sequence>
      <xsd:element name="variableName" type="xsd:string"/>
      <xsd:element ref="typeName" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>   
  
  <xsd:element name="constant" type="Constant"/>
  <xsd:complexType name="Constant">
    <xsd:sequence>
      <xsd:element name="constantName" type="Concept"/>
      <xsd:element ref="typeName"/>
    </xsd:sequence>
  </xsd:complexType>   

</xsd:schema>
