<?xml version="1.0" encoding="$xmlEncoding"?>
<!-- 
    Attention: Generated code! Do not modify by hand!
    Generated by: XmlSchema.vsl in andromda-xmlschema-cartridge.
    
    Temp [remove this line], useful info at: http://www.andromda.org/andromda-xmlschema-cartridge/apidocs/ 
    http://www.andromda.org/andromda-metafacades-uml/apidocs/
  -->
<xsd:schema 
    targetNamespace="http://fuge.org/core"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:fuge="http://fuge.org/core"
    elementFormDefault="qualified">
#foreach ($type in $types)
#set ($typeName = "${type.fullyQualifiedName}Type")
  <xsd:complexType name="$typeName" abstract = "${type.abstract}">
     <xsd:annotation>
          <xsd:documentation>${type.getDocumentation("")}</xsd:documentation>
		 </xsd:annotation>
#if ($type.generalization) 
    <xsd:complexContent>
     <xsd:extension base="fuge:${type.generalization.fullyQualifiedName}Type">
#end
#set( $doSeq = true)
#set($assocExtends = false)
#if ($type.associationEnds)
#foreach ($associationEnd in $type.associationEnds) 
#set ($otherEnd = $associationEnd.otherEnd)
#if ($otherEnd.navigable)
#if ($doSeq) 
   <xsd:sequence>
#set ($doSeq = false)
#end
#if($otherEnd.hasExactStereotype("AbstractAssociation") == true)
<xsd:element ref="fuge:_${otherEnd.name}" minOccurs="0" maxOccurs="0"/>
#else
<xsd:element ref="fuge:_${otherEnd.name}" minOccurs="$otherEnd.minOccurs" maxOccurs="1"/>
#end	
#end
#end
#end
  		


#if (!$doSeq) 
    </xsd:sequence> 
#set ($doSeq = true)
#end


#foreach  ($attribute in $type.attributes)
#if($attribute.name == "action" && $typeName == "FuGE.Common.Audit.AuditType")
 	<xsd:attribute name="action" use="required">
 	  <xsd:annotation>
      <xsd:documentation>${attribute.getDocumentation("")}</xsd:documentation>
	 </xsd:annotation>
   	 <xsd:simpleType>
	  <xsd:restriction base="xsd:string">
	   <xsd:enumeration value="creation"/>
	   <xsd:enumeration value="modification"/>
	   <xsd:enumeration value="deletion"/>
	  </xsd:restriction>
	 </xsd:simpleType>
	</xsd:attribute>
#elseif($attribute.type.fullyQualifiedName  == "anyType[]")
	  <xsd:sequence>
       <xsd:element  name="${attribute.name}" type="xsd:anyType">	
 	    <xsd:annotation>
         <xsd:documentation>${attribute.getDocumentation("")}</xsd:documentation>
	    </xsd:annotation>
       </xsd:element>	
      </xsd:sequence>
#else
#if($attribute.required) 
    <xsd:attribute name="${attribute.name}" use="required" type="xsd:${attribute.type.fullyQualifiedName}">
#else
    <xsd:attribute name="${attribute.name}" type="xsd:${attribute.type.fullyQualifiedName}">
#end
     <xsd:annotation>
      <xsd:documentation>${attribute.getDocumentation("")}</xsd:documentation>
	 </xsd:annotation>
    </xsd:attribute>	 
#end
#end

#if ($type.generalization) 
    </xsd:extension>
    </xsd:complexContent>
#end

  </xsd:complexType>
#end

#foreach ($type in $types)
#foreach ($associationEnd in $type.associationEnds) 
#set ($otherEnd = $associationEnd.otherEnd)
#set ($association = $associationEnd.getAssociation())
#if($otherEnd.hasExactStereotype("AbstractAssociation") == true)
#set ($abstractAssoc = "true")
#else
#set ($abstractAssoc = "false")
#end	
#if ($otherEnd.navigable)
#set ($assocName = "_${otherEnd.Name}Type")
   <xsd:complexType name="$assocName" abstract = "$abstractAssoc">
    <xsd:annotation>
      <xsd:documentation>${otherEnd.association.getDocumentation("")} 
        </xsd:documentation>
	 </xsd:annotation>
#if($association.generalization)
#set($parentAssocEnd1 = $association.generalization.getAssociationEnds().get(0))
#set($parentAssocEnd2 = $association.generalization.getAssociationEnds().get(1))
#if($parentAssocEnd1.navigable && $parentAssocEnd2.navigable)
	<!-- Error! Both ends of the association are navigable, don't know which end to extend from -->
#else
	#if($parentAssocEnd1.navigable)
		#set($parentEnd = $parentAssocEnd1)
	#elseif($parentAssocEnd2.navigable)
		#set($parentEnd = $parentAssocEnd2)
	#else
		<!-- Error! No navigable ends on the association, don't know what to extend from -->
	#end
#end			
      <xsd:complexContent>
 		<xsd:extension base="fuge:_${parentEnd.name}Type">
#end
#if($otherEnd.hasExactStereotype("AbstractAssociation") == true)
 	<xsd:sequence/>
#else
#if($associationEnd.composition)
       	  <xsd:sequence> 
           <xsd:element ref="fuge:${otherEnd.type.name}" minOccurs="1" maxOccurs="${otherEnd.maxOccurs}"/>
          </xsd:sequence>
#else
          <xsd:sequence> 
           <xsd:element name="${otherEnd.type.name}_ref"  minOccurs="1" maxOccurs="${otherEnd.maxOccurs}">
          		  <xsd:complexType>
        			   <xsd:attribute name="identifier_ref" use="required" type="xsd:string"/>
        		</xsd:complexType>
         	</xsd:element>	
           </xsd:sequence>
#end
#end
#if($association.generalization)
         	</xsd:extension> 
         </xsd:complexContent>
#end
        </xsd:complexType>
#end        
#end
#end

#foreach ($element in $types)
	#set ($typeName = "${element.fullyQualifiedName}Type")
	#set( $isFixed = "true")
	#if($element.abstract)
		#set( $isFixed = "false")
	#end
	#if ($element.generalization) 
 <xsd:element name="$element.name" type="fuge:$typeName" abstract="$element.abstract" substitutionGroup="fuge:${element.generalization.name}"/>
	#else
 <xsd:element name="$element.name" type="fuge:$typeName" abstract="$element.abstract"/>
	#end
#end

#foreach ($type in $types)
	#foreach ($associationEnd in $type.associationEnds) 
		#set ($otherEnd = $associationEnd.otherEnd)
		#if ($otherEnd.navigable)
			#set ($assocName = "_${otherEnd.Name}Type")
 <xsd:element name="_$otherEnd.name" type="fuge:$assocName"/>
		#end
	#end
#end



</xsd:schema>     
