<?xml version = "1.0"?>

<!-- Scheme to validate My Hobby distributed systems coursework -->

<Schema xmlns ="urn:schemas-microsoft-com:xml-data">
   
   <ElementType name = "myhobby" content = "mixed">
      <!-- Defines the top level element myhobby -->
      <AttributeType name = "activity"/>
      <attribute type ="activity"/>
      <element type = "takesplace" minOccurs ="1" maxOccurs = "*"/>
	
	<!-- We could go swimming at more than one place so takes 
	     place can occur more than once -->

      <element type = "practiseon" minOccurs ="1" maxOccurs = "1"/>
        <!-- Practiseon can appear only once-->
      <element type = "friend" minOccurs ="1" maxOccurs ="*"/>   
	<!-- I might go with other friends -->
   </ElementType>
   
   <ElementType name = "takesplace" content = "mixed">
	   <AttributeType name = "location"/>
	   <attribute type ="location"/>
		<!-- I am allowing for flexibility in the address structure The only required                      statments are the first line of the address and the postcode -->	   		
	   <element type = "road" minOccurs = "1" maxOccurs = "1"/>
	   <element type = "address" minOccurs ="0" maxOccurs = "1"/>		
	   <element type = "town" minOccurs ="0" maxOccurs = "1"/>
	   <element type = "county" minOccurs ="0" maxOccurs = "1"/>
           <element type = "postcode" minOccurs ="1" maxOccurs = "1"/>
	   <element type = "telephone" minOccurs = "0" maxOccurs = "1"/>
	   <element type = "email" minOccurs = "0" maxOccurs = "*"/>
	   <element type = "website" minOccurs = "0" maxOccurs = "1"/>
   </ElementType>
      <ElementType name = "road" content = "mixed">
	   <AttributeType name = "number"/>
	   <attribute type ="number"/>
      </ElementType> 
      <ElementType name = "address" content = "textOnly"/>
      <ElementType name = "town" content = "textOnly"/>
      <ElementType name = "county" content = "textOnly"/>
      <ElementType name = "postcode" content = "textOnly"/>
      <ElementType name = "website" content = "textOnly"/>

      <!-- Both telephone and email can have multiple instances	so have an attribute which         deferenciates between them -->

      <ElementType name = "telephone" content = "textOnly">
	 <AttributeType name = "type" default="work"/>
	 <attribute type = "type"/>
      </ElementType>	
      <ElementType name = "email" content = "textOnly">  
	 <AttributeType name = "type" default="work"/>
	 <attribute type = "type"/>
      </ElementType>
     <ElementType name = "practiseon" content = "eltOnly">
		<!-- Mutliple sessions are allowed to exist but there must be at least one-->
	<element type = "session" minOccurs = "1" maxOccurs = "*"/>
     </ElementType>

     <ElementType name = "session" content = "mixed">
         <AttributeType name = "day" required = "yes"/>
	 <attribute type = "day"/>
         <element type = "time" minOccurs = "1" maxOccurs = "1"/>
         <element type = "duration" minOccurs = "1" maxOccurs = "1"/>	
     </ElementType>	   	 
     <ElementType name = "time" content = "textOnly"/>
     <ElementType name = "duration" content = "textOnly">
	<AttributeType name = "unit" default = "minutes"/>
	<attribute type ="unit"/>
     </ElementType>	
     
   <ElementType name = "friend" content = "mixed">
	   <AttributeType name = "name"/>
	   <attribute type ="name"/>
		<!-- I am allowing for flexibility in the address structure 
		The only required statments are the first line of the address the postcode
		and the friends telephone numnber and email address -->	
	   <element type = "road" minOccurs = "1" maxOccurs = "1"/>
	   <element type = "address" minOccurs ="1" maxOccurs = "*"/>
	   <element type = "town" minOccurs = "0" maxOccurs = "1"/>
	   <element type = "county" minOccurs = "0" maxOccurs = "1"/>
           <element type = "postcode" minOccurs = "1" maxOccurs = "1"/>
	   <element type = "telephone" minOccurs = "1" maxOccurs = "*"/>
	   <element type = "email" minOccurs = "1" maxOccurs = "*"/>
   </ElementType>
      
      
     
</Schema>  