<?xml version="1.0" encoding="UTF-8"?>
<!--
::===========================================================================::
Bayesian Advisor Project :: Preference Elicitation Tool - Input XML Schema
Started May-2002 by Christina Knapp (ck38@csr.uky.edu)
Version 1, 5/29/02  Finished Version, 6/7/02

This is the XML Schema for the archetype/hierarchy preference 
elicitation tool.  For more information about XML Schema see 
http://www.w3.org/XML/Schema.
::===========================================================================::
-->

<xs:schema version="0.1" 
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   targetNamespace="http://www.cs.uky.edu/bap/prefs/"
   xmlns="http://www.cs.uky.edu/bap/prefs/"
   elementFormDefault="qualified">

<!-- 
::===========================================================================::
             Definition of Frequently Used Simple Elements 
::===========================================================================::
-->

<!-- Since these are often used in the GUI, these elements are tokens in 
order to take out embedded and leading tabs, linefeeds, and carriage 
returns. -->
<xs:element name="description" type="xs:token"/> 
<xs:element name="prompt" type="xs:token"/> 

<!--
::===========================================================================::
			Definition of Complex Types 
::===========================================================================::
-->

<!--The <value> element is valid inside <attribute> only.  This is used to 
describe possible values in the domain of each attribute. -->

<xs:element name="value">  
   <xs:complexType>
      <xs:element ref="description" minOccurs="1" maxOccurs="1"/>
      
<!-- The following element allows the XML instance document to be able 
to modify the presenation of the interface more.  However, it isn't 
included as of 6/7/02 for simplicity of use.  It can be used at any time; 
however, I recommend adding enumeration values to properly define how the 
slider can be used. 

      <xs:element name="slider" minOccurs="0" maxOccurs="1">
         <xs:complexContent>
            <xs:attribute name="left" type="xs:string" use="required"/>
            <xs:attribute name="mid" type="xs:string" use="required"/>
            <xs:attribute name="right" type="xs:string" use="required"/>
         </xs:complexContent>
      </xs:element>
-->

   </xs:complexType>
   <xs:attribute name="name" type="xs:token" use="required"/>
</xs:element>
 
<!-- The <attribute> element is valid inside <model> only.  It models an 
attribute, that contains values, that a user can have a preference about. 
-->

<xs:element name="attribute"> 
   <xs:complexType>
      <xs:sequence>
         <xs:element ref="description" minOccurs="1" maxOccurs="1"/>
	 <xs:element ref="prompt" minOccurs="1" maxOccurs="1"/>
         <xs:element ref="value" minOccurs="1" maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>
   <xs:attribute name="name" type="xs:token" use="required"/>
</xs:element>

<!-- The <attributes> element is valid inside <archetype> only.  It outlines 
combinations of values and attributes that are acceptable or not for an 
instance of a <archetype>. -->

<xs:element name="attributes"> 
   <xs:complexType>
      <xs:element name="allow" minOccurs="0" maxOccurs="unbounded">
         <xs:complexType/>
            <xs:attribute name="order" type="xs:nonNegativeInteger" 
		use="optional"/>
            <xs:attribute name="attribute" type="xs:string" use="optional"/>
            <xs:attribute name="value" type="xs:string" use="optional"/>
            <xs:attribute name="utility" use="optional">   
               <xs:simpleType>
                  <xs:restriction base="xs:integer">
                     <xs:minInclusive value="0"/>
                     <xs:maxInclusive value="6"/>
                  </xs:restriction>
               </xs:simpleType>
            </xs:attribute>
            <xs:attribute name="dependentvalue" type="xs:string" use="optional"/>   
	    <xs:attribute name="dependentattribute" type="xs:string" use="optional"/>
      </xs:element>
      <xs:element name="warn" type="xs:string" minOccurs="0" maxOccurs="unbounded">
         <xs:complexType/> 
            <xs:attribute name="order" type="xs:nonNegativeInteger" use="optional"/>
            <xs:attribute name="attribute" type="xs:string" use="optional"/>
            <xs:attribute name="value" type="xs:string" use="optional"/>
            <xs:attribute name="utility" use="optional">
               <xs:simpleType>
                  <xs:restriction base="xs:integer">
                     <xs:minInclusive value="0"/>
                     <xs:maxInclusive value="6"/>
                  </xs:restriction>
               </xs:simpleType>
            </xs:attribute>
      </xs:element>
   </xs:complexType>
</xs:element>


<!-- The <archetype> element is valid inside <model> only.  Its used to 
outline an overall scheme of preferences for a user. This includes preset 
utility for attributes and values (which can be changed by the user). Its 
intended use is to simplify the amount of information needed from the user. -->

<xs:element name="archetype"> 
   <xs:complexType>
      <xs:sequence>
         <xs:element ref="description" minOccurs="1" maxOccurs="1"/>
         <xs:element ref="prompt" minOccurs="1" maxOccurs="1"/>
         <xs:element ref="attributes" minOccurs="0" maxOcurs="1"/>
      </xs:sequence>
   </xs:complexType>
   <xs:attribute name="name" type="xs:token" use="required"/>
</xs:element>  

<!-- The <model> element is the ROOT for all valid instance documents -->
<xs:element name="model">
   <xs:complexType>
      <xs:sequence>
         <xs:element ref="attribute" minOccurs="1" maxOccurs="unbounded"/>
         <xs:element ref="archetype" minOccurs="1" maxOccurs="unbounded"/>
      </xs:sequence>
   </xs:complexType>
      <xs:attribute name="type" use="required">
         <xs:simpleType>
            <xs:restriction base="xs:string">
               <xs:enumeration value="input"/>
               <xs:enumeration value="output"/>
            </xs:restriction>
         </xs:simpleType>
      </xs:attribute>
      <xs:attribute name="version" type="xs:token" use="required"/>

<!-- The 'name' attributes of <attribute>, <value>, and <archetype> are keys
 meaning that 'name' must be non-null for each instance of these elements; 
further, 'name' must be unique within the scope of the entire instance 
document.  The <allow> and <warn> elements are keyrefs pointing to names 
specified in <value> and <attribute> elements. -->

   <xs:key name="keyAttributeName">
      <xs:selector xpath="attribute"/>
      <xs:field xpath="@name"/>
   </xs:key>

   <xs:key name="keyValueName">
      <xs:selector xpath="value"/>
      <xs:field xpath="@name"/>
   </xs:key>

<!-- archetype/@name is never keyref'd; this is only for non-null 
uniqueness -->

   <xs:key name="keyArchetypeName">
      <xs:selector xpath="archetype"/>
      <xs:field xpath="@name"/>
   </xs:key>


   <xs:keyref name="keyrefValueAllow" refer="keyValueName">
      <xs:selector xpath="archetype/allow"/>
      <xs:field xpath="@value"/>
   </xs:keyref>

   <xs:keyref name="keyrefValueAllow" refer="keyValueName">
      <xs:selector xpath="archetype/allow"/>
      <xs:field xpath="@dependentvalue"/>
   </xs:keyref>

   <xs:keyref name="keyrefValueWarn" refer="keyValueName">
      <xs:selector xpath="archetype/warn"/>
      <xs:field xpath="@value"/>
   </xs:keyref>

   <xs:keyref name="keyrefAttributeAllow" refer="keyAttributeName">
      <xs:selector xpath="archetype/allow"/>
      <xs:field xpath="@attribute"/>
   </xs:keyref>

   <xs:keyref name="keyrefAttributeAllow" refer="keyAttributeName">
      <xs:selector xpath="archetype/allow"/>
      <xs:field xpath="@dependentattribute"/>
   </xs:keyref>

   <xs:keyref name="keyrefAttributeWarn" refer="keyAttributeName">
      <xs:selector xpath="archetype/warn"/>
      <xs:field xpath="@attribute"/>
   </xs:keyref>


</xs:element>


<!-- THE END -->
</xs:schema>
