<#--
   ******************************************************
   *
   *                       NOTICE
   *
   *  THIS SOFTWARE IS THE PROPERTY OF AND CONTAINS
   *  CONFIDENTIAL INFORMATION OF SSA GLOBAL 
   *  TECHNOLOGIES, INC., AND SHALL NOT BE COPIED,
   *  USED, NOR DISCLOSED WITHOUT EXPRESS WRITTEN
   *  AUTHORIZATION.  ALTHOUGH PUBLICATION IS NOT
   *  INTENDED, IN THE EVENT OF PUBLICATION, THE
   *  FOLLOWING NOTICE IS APPLICABLE:
   *
   *  (c) COPYRIGHT 2005 SSA GLOBAL TECHNOLOGIES, INC.
   *
   *           SSA GLOBAL TECHNOLOGIES, INC.
   *
   ******************************************************
 -->

<#import "wsdl.common.ftl" as common/>
<#assign datatypes=[]>

<#macro copyright>
<!-- 
   ******************************************************
   Copyright Infor, Inc. 2000-2007.
   All rights reserved.
  
   Generated by generator,
   Name    : ${versionhelper.templatename}
   Id      : ${versionhelper.templateid}
   version : ${versionhelper.templateversion} 
   version : ${versionhelper.generatorversion} (framework)
 
   on ${today?datetime}. 
   Please: DO NOT EDIT THIS GENERATED SOURCE 
!-->
</#macro>

<#--
	Generates the entire ControlArea for a certain method. The macro will either
	generate <Method>RequestControlArea or <Method>ResponseControlArea based upon
	the iInput argument.

	@param	iMethod		a method object
	@param	iInput		a boolean indicating whether to return all input or output method arguments	
-->
<#macro generateControlArea iMethod iInput>
	<#if common.hasControllingAttributes(iMethod,iInput)>
					<xsd:element name="ControlArea" minOccurs="0">
						<xsd:complexType>
							<xsd:sequence>								
		<#if iInput==true>
			<#switch iMethod.name>
			
				<#case "List">
								<xsd:element name="Selection" type="bo:SelectionType" minOccurs="0"/>
								<xsd:element name="Filter" type="bo:FilterType" minOccurs="0"/>
								<xsd:element name="sortingExpression" type="xsd:string" minOccurs="0"/>
								<xsd:element name="languageID" type="xsd:language" minOccurs="0" maxOccurs="unbounded"/>
								<xsd:element name="suppressDefaultLanguageBehavior" type="xsd:boolean" minOccurs="0"/>
								<xsd:element name="maxNumberOfObjects" type="xsd:long" minOccurs="0"/>
								<xsd:element name="iteratorID" type="xsd:long" minOccurs="0"/>
								<xsd:element name="iteratorFetchSize" type="xsd:long" minOccurs="0"/>
					<#break>
				<#case "Show">
								<xsd:element name="Selection" type="bo:SelectionType" minOccurs="0"/>
								<xsd:element name="Filter" type="bo:FilterType" minOccurs="0"/>
								<xsd:element name="sortingExpression" type="xsd:string" minOccurs="0"/>
								<xsd:element name="languageID" type="xsd:language" minOccurs="0" maxOccurs="unbounded"/>
								<xsd:element name="suppressDefaultLanguageBehavior" type="xsd:boolean" minOccurs="0"/>
								<xsd:element name="createRef" type="xsd:boolean" minOccurs="0"/>										
					<#break>
				<#case "DeleteRef">
								<xsd:element name="referenceID" type="xsd:string"/>
					<#break>
				<#case "SubscribeList">
								<xsd:element name="Selection" type="bo:SelectionType" minOccurs="0"/>
								<xsd:element name="Filter" type="bo:FilterType" minOccurs="0"/>
								<xsd:element name="sortingExpression" type="xsd:string" minOccurs="0"/>
								<xsd:element name="languageID" type="xsd:language" minOccurs="0" maxOccurs="unbounded"/>
								<xsd:element name="maxNumberOfObjects" type="xsd:long" minOccurs="0"/>
								<xsd:element name="eventBatchSize" type="xsd:long" minOccurs="0"/>
								<xsd:element name="eventConsumer" minOccurs="1">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="50"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>
								<xsd:element name="destination" minOccurs="0" maxOccurs="1">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="256"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>	
					<#break>						
				<#case "SubscribeEvent">
								<xsd:element name="Selection" type="bo:SelectionType" minOccurs="0"/>
								<xsd:element name="Filter" type="bo:FilterType" minOccurs="0"/>
								<xsd:element name="sortingExpression" type="xsd:string" minOccurs="0"/>	
								<xsd:element name="eventAction" minOccurs="0" maxOccurs="unbounded">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="50"/>
											<xsd:pattern value="[a-zA-Z][\w_\.]*"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>									
								<xsd:element name="languageID" type="xsd:language" minOccurs="0" maxOccurs="unbounded"/>
								<xsd:element name="eventConsumer" minOccurs="1">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="50"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>									
								<xsd:element name="destination" minOccurs="0" maxOccurs="1">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="256"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>																		
					<#break>						
				<#case "unSubscribeEvent">
								<xsd:element name="eventConsumer" minOccurs="0" minOccurs="1">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="50"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>									
					<#break>										
				<#case "PublishEvent">
								<xsd:element name="eventAction">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="50"/>
											<xsd:pattern value="[a-zA-Z][\w_\.]*"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>									
								<xsd:element name="eventPriority" minOccurs="0">
									<xsd:simpleType>
										<xsd:restriction base="xsd:long">
											<xsd:minInclusive value="0"/>
											<xsd:maxInclusive value="9"/>
										</xsd:restriction>				
									</xsd:simpleType>
								</xsd:element>									
								<xsd:element name="eventTimeStamp" type="xsd:dateTime" minOccurs="0" maxOccurs="1"/>
								<xsd:element name="eventTimeStampSequenceNr" type="xsd:long" minOccurs="0"/>
								<xsd:element name="eventConsumer" minOccurs="0">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="50"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>																		
								<xsd:element name="eventHasMoreBatches" type="xsd:boolean" minOccurs="0"/>
								<xsd:element name="destination" minOccurs="0" maxOccurs="1">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="256"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>								
								<xsd:element name="EventReference" minOccurs="0">
									<xsd:complexType>
										<xsd:sequence>
											<xsd:element name="eventReferenceType" type="xsd:string"/>
											<xsd:element name="eventReferenceInfo" type="xsd:anySimpleType"/>
										</xsd:sequence>
									</xsd:complexType>
								</xsd:element>								
					<#break>
				<#case "OnEvent">
								<xsd:element name="eventEntity">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="50"/>
											<xsd:pattern value="[a-zA-Z][\w_\.]*"/>
										</xsd:restriction>
									</xsd:simpleType>					
								</xsd:element>									
								<xsd:element name="eventAction">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="50"/>
											<xsd:pattern value="[a-zA-Z][\w_\.]*"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>									
								<xsd:element name="eventPriority" minOccurs="0">
									<xsd:simpleType>
										<xsd:restriction base="xsd:long">
											<xsd:minInclusive value="0"/>
											<xsd:maxInclusive value="9"/>
										</xsd:restriction>				
									</xsd:simpleType>
								</xsd:element>									
								<xsd:element name="eventContentType" default="bde" minOccurs="0" maxOccurs="1">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:enumeration value="bde"/>
											<xsd:enumeration value="other"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>									
								<xsd:element name="eventRequestID" type="xsd:ID" maxOccurs="1" minOccurs="0"/>
								<xsd:element name="eventTimeStamp" type="xsd:dateTime"/>
								<xsd:element name="eventTimeStampSequenceNr" type="xsd:long" minOccurs="0"/>
								<xsd:element name="eventConsumer" minOccurs="0">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="50"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>									
								<xsd:element name="eventSupplier">
									<xsd:simpleType>
										<xsd:restriction base="xsd:string">
											<xsd:maxLength value="50"/>
										</xsd:restriction>
									</xsd:simpleType>
								</xsd:element>									
								<xsd:element name="eventHasMoreBatches" type="xsd:boolean" minOccurs="0"/>
								<xsd:element name="EventReference" minOccurs="0">
									<xsd:complexType>
										<xsd:sequence>
											<xsd:element name="eventReferenceType" type="xsd:string"/>
											<xsd:element name="eventReferenceInfo" type="xsd:anySimpleType"/>
										</xsd:sequence>
									</xsd:complexType>
								</xsd:element>								
					<#break>						
				<#case "CreateRef">
				<#case "SupportsReferentialIntegrity">
				<#case "SupportsProcessingScope">
					<#break>
				<#case "Create">
				<#case "Change">
				<#case "Delete">
				<#default>
								<xsd:element name="processingScope" type="bo:processingScope" default="request" minOccurs="0"/>
					<#break>		
			</#switch>
		<#else>
			<#switch iMethod.name>
				<#case "List">
								<xsd:element name="iteratorID" type="xsd:long" minOccurs="0"/>
								<xsd:element name="iteratorFetchSize" type="xsd:long" minOccurs="0"/>
					<#break>
				<#case "CreateRef">
				<#case "Show">
								<xsd:element name="referenceID" type="xsd:string"/>
					<#break>
				<#case "SupportsReferentialIntegrity">
				<#case "SupportsProcessingScope">
								<xsd:element name="supported" type="xsd:boolean"/>			
					<#break>
				<#case "Create">
				<#case "Change">
				<#case "Delete">
				<#case "DeleteRef">
				<#case "SubscribeList">
				<#case "SubscribeEvent">
				<#case "unSubscribeEvent">
				<#case "PublishEvent">
				<#case "OnEvent">
				<#default>
					<#break>		
			</#switch>
		</#if>
		<#list common.listSpecificControllingAttributes(iMethod, iInput) as ma>
			<@generateMethodArgument iMethod=iMethod iMethodArgument=ma iInput=iInput iPrefix="			"/>
		</#list>
							</xsd:sequence>
						</xsd:complexType>
					</xsd:element>
	</#if>			
</#macro>

<#--
	Helper functions to keep track of a list of datatype to be generated
-->

<#macro addDatatype iDatatype>
	<#if !datatypes?seq_contains(iDatatype)>
		<#assign datatypes=datatypes+[iDatatype]>
	</#if>
</#macro>

<#function getSchemaType iDatatype>
	<#if iDatatype.facet?size==0>
		<#local schemaType="xsd:"+iDatatype.primitiveDatatype>
		<#if schemaType=="xsd:anyType">
			<#local schemaType="xsd:string">
		</#if>
	<#else>
		<@addDatatype iDatatype=iDatatype/>
		<#local schemaType="bo:"+iDatatype.name>
	</#if>
	<#return schemaType>
</#function>

<#--
	Generates all commonly used simple and complex types
-->

<#macro generateTypes>
			<xsd:simpleType name="processingScope">
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="not_applicable"/>
					<xsd:enumeration value="request"/>
					<xsd:enumeration value="business_entity"/>
					<xsd:enumeration value="business_entity_component"/>
				</xsd:restriction>
			</xsd:simpleType>
			<xsd:simpleType name="actionType">
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="create"/>
					<xsd:enumeration value="createOrChange"/>
					<xsd:enumeration value="change"/>
					<xsd:enumeration value="delete"/>
					<xsd:enumeration value="unchanged"/>
				</xsd:restriction>
			</xsd:simpleType>
	<#list datatypes as dt>
			<xsd:simpleType name="${dt.name}">
				<xsd:restriction base="xsd:${dt.primitiveDatatype}">
		<#list dt.facet as f>
					<xsd:${f.type} value="${f.value}"/>
		</#list>
				</xsd:restriction>
			</xsd:simpleType>
	</#list>
</#macro>

<#--
	Generates the default xsd:element code for a method argument
	
	@param		iMethod				a method object
	@param		imethodArgument		a method argument object
	@param		iPrefix				a prefix
-->
<#macro generateMethodArgument iMethod iMethodArgument iInput iPrefix="">
	<#if !iMethodArgument.attribute?exists>
		<#-- controlling attributes -->
		<#local datatype=common.getDatatypeFromMethodArgument(iMethodArgument)>
			<#if datatype != "">
				<#local schemaType=getSchemaType(datatype)>
			<#else>
				<#local schemaType="unknown">
			</#if>
			<#local defaultValue=common.getDefaultValueFromMethodArgument(iMethod,iMethodArgument)>
${iPrefix}					<xsd:element name="${iMethodArgument.name}" type="${schemaType}"<#if defaultValue!=""> default="${defaultValue}"</#if><#if iMethodArgument.isMandatory> minOccurs="1"<#else> minOccurs="0"</#if>/>
	<#else>
			<@generateAttribute iMethod=iMethod iComponent=iMethodArgument.component.idref iAttribute=iMethodArgument.attribute.idref iPrefix=iPrefix iProcessSubComponents=false/>
	</#if>
</#macro>

<#--
	Generates the entire DataArea for a certain method. The macro will either
	generate <Method>RequestDataArea or <Method>ResponseDataArea based upon
	the iInput argument.
	
	@param	iMethod		a method object
	@param	iInput		a boolean indicating whether to return all input or output method arguments	
-->
<#macro generateDataArea iMethod iInput>
	<#if common.hasPublicAttributes(iMethod, iInput)>
					<xsd:element name="DataArea"<#if iInput && iMethod.name=="Show"> minOccurs="1"<#else> minOccurs="0"</#if>>
						<xsd:complexType>
							<xsd:sequence>
			<@generateComponent iMethod=iMethod iComponent=object iRelationship="" iInput=iInput iPrefix="						"/>
							</xsd:sequence>
						</xsd:complexType>
					</xsd:element>
	</#if>
</#macro>


<#--
	Generates the entire Component for a certain method. 
	
	@param	iMethod			a method object
	@param	iComponent		a component object
	@param	iRelationship	a relationship object
	@param	iInput			a boolean indicating whether to return all input or output method arguments	
	@param	iPrefix			a prefix
	@param	iDone			a list of already processed components
-->
<#macro generateComponent iMethod iComponent iRelationship="" iInput="" iPrefix="" iDone=[]>
	<#if common.listPublicAttributes(iMethod,iComponent,iInput)?size!=0>
		<#-- check for circular dependencies-->
		<#list iDone as dc>
			<#if dc==iComponent>
				<!-- CIRCULAR DEPENDENCY [${iPrefix}.*] SKIPPED -->
				<#return>
			</#if>
		</#list>
		<#local iDone=iDone+[iComponent]>
		<#if iComponent.isHidden>
			<#return>
		</#if>
		<#-- continue generating selection attributes -->	
		<#if iRelationship!="">
			<#if iRelationship.type=="aggregation">
${iPrefix}		<xsd:element name="${iComponent.name}"<#if iRelationship.multiplicity=="zeroToMany"> minOccurs="0"<#else> minOccurs="1"</#if> maxOccurs="unbounded">
			<#else>
${iPrefix}		<xsd:element name="${iRelationship.name}"<#if iRelationship.multiplicity=="zeroToOne"> minOccurs="0"<#else> minOccurs="1"</#if> maxOccurs="1">				
			</#if>
		<#else>
			<#if iMethod.name=="Show">
${iPrefix}		<xsd:element name="${iComponent.name}"<#if iInput> minOccurs="1"<#else> minOccurs="0"</#if> maxOccurs="1">
			<#else>
${iPrefix}		<xsd:element name="${iComponent.name}" minOccurs="0" maxOccurs="unbounded">
			</#if>
		</#if>
${iPrefix}			<xsd:complexType>
${iPrefix}				<xsd:sequence>
		<#local prefix=iPrefix+"			">
		<@generateComponentNotRelatedWithAttribute iLocation="before" iMethod=iMethod iComponent=iComponent iInput=iInput iPrefix=prefix iDone=iDone/>
		<#list common.listPublicAttributes(iMethod,iComponent,iInput) as a>
			<#if a.type!="qualifier">
				<@generateComponentRelatedWithAttribute iLocation="before" iAttributeName=a.name iMethod=iMethod iComponent=iComponent iInput=iInput iPrefix=prefix iDone=iDone/>
				<@generateAttribute iMethod=iMethod iComponent=iComponent iAttribute=a iPrefix=iPrefix iInput=iInput iDone=iDone iProcessSubComponents=true/>
				<@generateComponentRelatedWithAttribute iLocation="after" iAttributeName=a.name iMethod=iMethod iComponent=iComponent iInput=iInput iPrefix=prefix iDone=iDone/>
			</#if>
		</#list>			
		<@generateComponentNotRelatedWithAttribute iLocation="after" iMethod=iMethod iComponent=iComponent iInput=iInput iPrefix=prefix iDone=iDone/>
		<#list iComponent.relationship as r>
			<#if r.type!="aggregation">
				<#if !iInput && (iMethod.name=="List" || iMethod.name=="Show")>
					<#local bid=r.toBusinessInterface.idref>
					<#local method=common.getPublicMethod(bid,"Show")>
					<#if method!="">
						<@generateComponent iMethod=method iComponent=bid iRelationship=r iInput=false iPrefix=prefix iDone=iDone/>
					</#if>
				</#if>		
			</#if>
		</#list>
${iPrefix}				</xsd:sequence>
		<#local actionTypeExists=false>
		<#list common.listPublicAttributes(iMethod,iComponent,iInput) as q>
			<#if q.type=="qualifier">
				<#if q.name=="actionType">
					<#local actionTypeExists=true>
				</#if>
				<@generateAttribute iMethod=iMethod iComponent=iComponent iAttribute=q iPrefix=iPrefix iInput=iInput iDone=iDone iProcessSubComponents=true/>
			</#if>
		</#list>			
		<#if !actionTypeExists && (iComponent!=object) && (iMethod.name=="Change" || iMethod.name=="PublishEvent") && iInput>				
${iPrefix}				<xsd:attribute name="actionType" type="bo:actionType" use="optional" default="change"/>
		</#if>
${iPrefix}			</xsd:complexType>
${iPrefix}		</xsd:element>
	</#if>
</#macro>

<#--
	Generates the entire anchored Component (related with an attribute or attribute group) for a certain method.
	
	@param	iLocation		an anchorLocation ("before" or "after")
	@param	iAttributeName	an attribute name
	@param	iMethod			a method object
	@param	iComponent		a component object
	@param	iInput			a boolean indicating whether to return all input or output method arguments	
	@param	iPrefix			a prefix
	@param	iDone			a list of already processed components
-->
<#macro generateComponentRelatedWithAttribute iLocation iAttributeName iMethod iComponent iInput iPrefix iDone>
	<#list iComponent.relationship as r>
		<#if r.type=="aggregation">
			<#if r.anchorLocation==iLocation && r.anchorAttribute?exists && r.anchorAttribute.idref.name == iAttributeName>
				<@generateComponent iMethod=iMethod iComponent=r.component iRelationship=r iInput=iInput iPrefix=iPrefix iDone=iDone/>
			</#if>
		</#if>
	</#list>
</#macro>

<#--
	Generates the entire anchored Component (related with a group) for a certain method.
	
	@param	iLocation		an anchorLocation ("before" or "after")
	@param	iGroupName		an attribute group name
	@param	iMethod			a method object
	@param	iComponent		a component object
	@param	iInput			a boolean indicating whether to return all input or output method arguments	
	@param	iPrefix			a prefix
	@param	iDone			a list of already processed components
-->
<#macro generateComponentRelatedWithGroup iLocation iGroupName iMethod iComponent iInput iPrefix iDone>
	<#list iComponent.relationship as r>
		<#if r.type=="aggregation">
			<#if r.anchorLocation==iLocation && r.anchorGroup?exists && r.anchorGroup.idref.name == iGroupName>
				<@generateComponent iMethod=iMethod iComponent=r.component iRelationship=r iInput=iInput iPrefix=iPrefix iDone=iDone/>
			</#if>
		</#if>
	</#list>
</#macro>

<#--
	Generates the entire anchored Component (NOT related with an attribute or attribute group) for a certain method.
	
	@param	iLocation		an anchorLocation ("before" or "after")
	@param	iMethod			a method object
	@param	iComponent		a component object
	@param	iRelationship	a relationship object
	@param	iInput			a boolean indicating whether to return all input or output method arguments	
	@param	iPrefix			a prefix
	@param	iDone			a list of already processed components
-->
<#macro generateComponentNotRelatedWithAttribute iLocation iMethod iComponent iInput iPrefix iDone>
	<#list iComponent.relationship as r>
		<#if r.type=="aggregation">
			<#if r.anchorLocation==iLocation && !r.anchorAttribute?exists && !r.anchorGroup?exists>
				<@generateComponent iMethod=iMethod iComponent=r.component iRelationship=r iInput=iInput iPrefix=iPrefix iDone=iDone/>
			</#if>
		</#if>
	</#list>
</#macro>

<#--
	Generates the default xsd:element code for an attribute
	
	@param		iComponent		a component object
	@param		iAttribute		an attribute object
	@param		iAlias			an alias
	@param		iMethod			a method object
	@param		iPrefix			a prefix
	@param		iInput			a boolean indicating whether to return all input or output method arguments	
	@param		iDone			a list of already processed components
-->
<#macro generateAttribute iComponent iAttribute iAlias="" iMethod="" iPrefix="" iInput="" iDone=[] iProcessSubComponents=true>
	<#if iAttribute.isHidden>
		<#return>
	</#if>
	<#local mandatory=false>
	<#local defaultValue="">
	<#local nillable=false>
	<#if iMethod!="">
		<#local mandatory=common.getIsMandatory(iMethod, iComponent, iAttribute)>
		<#local defaultValue=common.getDefaultValue(iMethod, iComponent, iAttribute)>
	</#if>
	<#local name=iAttribute.name>
	<#if iAlias!="">
		<#local name=iAlias>
	</#if>
	<#switch iAttribute.type>
		<#case "simple">
			<#local datatype=iAttribute.datatype.idref>
			<#local schemaType=getSchemaType(datatype)>
			<#if ((datatype.isTranslatable) || (iAttribute.attributeRelationship?size!=0))>
${iPrefix}					<xsd:element name="${name}"<#if defaultValue!=""> default="${defaultValue}"</#if><#if mandatory> minOccurs="1"<#else> minOccurs="0"</#if><#if ((datatype.isTranslatable) || (datatype.dimensions?exists))> maxOccurs="unbounded"</#if>>
${iPrefix}						<xsd:complexType>	<!-- ${datatype.name} -->
${iPrefix}							<xsd:simpleContent>										
${iPrefix}								<xsd:extension base="${schemaType}">
				<#local prefix=iPrefix+"					">
				<#list iAttribute.attributeRelationship as ar>
					<#if ar.attribute.idref.type=="qualifier">
						<@generateAttribute iComponent=iComponent iAttribute=ar.attribute.idref iAlias=ar.name iMethod=iMethod iPrefix=prefix iInput=iInput iDone=iDone iProcessSubComponents=iProcessSubComponents/>
					</#if>
				</#list>							
				<#if datatype.isTranslatable>
${iPrefix}									<xsd:attribute name="languageID" type="xsd:language"/>
				</#if>
${iPrefix}								</xsd:extension>
${iPrefix}							</xsd:simpleContent>										
${iPrefix}						</xsd:complexType>						
${iPrefix}					</xsd:element>
			<#else>
				<#if schemaType=="xsd:dateTime" || schemaType=="xsd:date" || schemaType=="xsd:time">
					<#local nillable=true>
				</#if>
${iPrefix}					<xsd:element name="${name}" type="${schemaType}"<#if defaultValue!=""> default="${defaultValue}"</#if><#if nillable> nillable="true"</#if><#if mandatory> minOccurs="1"<#else> minOccurs="0"</#if>/>
			</#if>
			<#break>
		<#case "qualifier">
			<#local datatype=iAttribute.datatype.idref>
			<#local schemaType=getSchemaType(datatype)>
${iPrefix}				<xsd:attribute name="${name}" type="${schemaType}"<#if defaultValue!=""> default="${defaultValue}"</#if><#if mandatory> use="required"<#else> use="optional"</#if>/>
			<#break>
		<#case "group">			
		<#case "complex">
${iPrefix}					<xsd:element name="${name}"<#if mandatory> minOccurs="1"<#else> minOccurs="0"</#if>>				
${iPrefix}						<xsd:complexType>
${iPrefix}							<xsd:sequence>
			<#local prefix=iPrefix+"			">
			<#local prefix2=prefix+"			">
			<@generateComponentRelatedWithGroup iLocation="before" iGroupName=name iMethod=iMethod iComponent=iComponent iInput=iInput iPrefix=prefix2 iDone=iDone/>
			<#list iAttribute.attributeRelationship as ar>
				<#if ar.attribute.idref.type!="qualifier">
					<#if iProcessSubComponents>
						<@generateComponentRelatedWithAttribute iLocation="before" iAttributeName=ar.attribute.idref.name iMethod=iMethod iComponent=iComponent iInput=iInput iPrefix=prefix2 iDone=iDone/>
					</#if>
					<@generateAttribute iComponent=iComponent iAttribute=ar.attribute.idref iAlias=ar.name iMethod=iMethod iPrefix=prefix iInput=iInput iDone=iDone iProcessSubComponents=iProcessSubComponents/>
					<#if iProcessSubComponents>
						<@generateComponentRelatedWithAttribute iLocation="after" iAttributeName=ar.attribute.idref.name iMethod=iMethod iComponent=iComponent iInput=iInput iPrefix=prefix2 iDone=iDone/>
					</#if>
				</#if>
			</#list>							
			<@generateComponentRelatedWithGroup iLocation="after" iGroupName=name iMethod=iMethod iComponent=iComponent iInput=iInput iPrefix=prefix2 iDone=iDone/>
${iPrefix}							</xsd:sequence>
			<#list iAttribute.attributeRelationship as ar>
				<#if ar.attribute.idref.type=="qualifier">
					<@generateAttribute iComponent=iComponent iAttribute=ar.attribute.idref iAlias=ar.name iMethod=iMethod iPrefix=prefix iInput=iInput iDone=iDone iProcessSubComponents=iProcessSubComponents/>
				</#if>
			</#list>							
${iPrefix}						</xsd:complexType>				
${iPrefix}					</xsd:element>									
			<#break>
	</#switch>  
</#macro>

<#--
	generateInformationArea
	=======================
-->
<#macro generateInformationArea>
			<xsd:complexType name="InformationArea">
				<xsd:sequence>
					<xsd:element name="Message" maxOccurs="unbounded" type="bo:InformationMessage"/>
				</xsd:sequence>
			</xsd:complexType>
</#macro>

<#--
	generateMessageTypes
	====================
-->
<#macro generateMessageTypes>
			<xsd:complexType name="Message">
				<xsd:sequence>
					<xsd:element name="messageIndex" type="xsd:integer" minOccurs="0"/>
					<xsd:element name="messageCode" type="xsd:string"/>
					<xsd:element name="messageType">
						<xsd:simpleType>
							<xsd:restriction base="xsd:string">
								<xsd:enumeration value="Error"/>
								<xsd:enumeration value="Warning"/>
								<xsd:enumeration value="Information"/>
							</xsd:restriction>
						</xsd:simpleType>
					</xsd:element>
					<xsd:element name="messageText" type="xsd:string"/>
					<xsd:element name="messageSource" type="xsd:string"/>
					<xsd:element name="MessageDetails" minOccurs="0">
						<xsd:complexType>
							<xsd:sequence>
								<xsd:element name="Message" maxOccurs="unbounded" type="bo:DetailMessage"/>
							</xsd:sequence>
						</xsd:complexType>
					</xsd:element>
					<xsd:element name="messageCorrectiveAction" type="xsd:string" minOccurs="0"/>
					<xsd:choice>
						<xsd:element name="messageAdditionalHelpText" type="xsd:string" minOccurs="0"/>
						<xsd:element name="messageAdditionalHelpURI" type="xsd:anyURI" minOccurs="0"/>
					</xsd:choice>
					<xsd:element name="MessageReference" minOccurs="0">
						<xsd:complexType>
							<xsd:sequence>
								<xsd:element name="messageReferenceType" type="xsd:string"/>
								<xsd:element name="messageReferenceInfo" type="xsd:string"/>
							</xsd:sequence>
						</xsd:complexType>
					</xsd:element>
				</xsd:sequence>
			</xsd:complexType>
			<xsd:complexType name="DetailMessage">
				<xsd:complexContent>
					<xsd:extension base="bo:Message">
						<xsd:attribute name="ID" type="xsd:ID" use="optional"/>
					</xsd:extension>
				</xsd:complexContent>
			</xsd:complexType>
			<xsd:complexType name="InformationMessage">
				<xsd:complexContent>
					<xsd:extension base="bo:Message">
						<xsd:attribute name="ID" type="xsd:ID" use="required"/>
					</xsd:extension>
				</xsd:complexContent>
			</xsd:complexType>
</#macro>

<#--
	generateFilterType
	==================
-->
<#macro generateFilterType>
			<xsd:complexType name="FilterType">
				<xsd:choice>
					<xsd:element name="LogicalExpression" type="bo:LogicalExpressionType"/>
					<xsd:element name="ComparisonExpression" type="bo:ComparisonExpressionType"/>
				</xsd:choice>
			</xsd:complexType>
			<xsd:complexType name="LogicalExpressionType">
				<xsd:sequence>
					<xsd:element name="logicalOperator">
						<xsd:simpleType>
							<xsd:restriction base="xsd:string">
								<xsd:enumeration value="or"/>
								<xsd:enumeration value="and"/>
							</xsd:restriction>
						</xsd:simpleType>
					</xsd:element>
					<xsd:choice minOccurs="2" maxOccurs="unbounded">
						<xsd:element maxOccurs="unbounded" name="LogicalExpression" type="bo:LogicalExpressionType"/>
						<xsd:element maxOccurs="unbounded" name="ComparisonExpression" type="bo:ComparisonExpressionType"/>
					</xsd:choice>
				</xsd:sequence>
			</xsd:complexType>
			<xsd:complexType name="ComparisonExpressionType">
				<xsd:sequence>
					<xsd:element name="comparisonOperator">
						<xsd:simpleType>
							<xsd:restriction base="xsd:string">
								<xsd:enumeration value="le"/>
								<xsd:enumeration value="lt"/>
								<xsd:enumeration value="ge"/>
								<xsd:enumeration value="gt"/>
								<xsd:enumeration value="ne"/>
								<xsd:enumeration value="eq"/>
								<xsd:enumeration value="like"/>
							</xsd:restriction>
						</xsd:simpleType>
					</xsd:element>
					<xsd:choice>
						<xsd:element name="attributeName" type="bo:filterAttributeListDT"/>
						<xsd:element name="emptyValue" type="bo:EmptyValueType"/>
						<xsd:element name="instanceValue" type="xsd:string"/>
					</xsd:choice>
					<xsd:choice>
						<xsd:element name="attributeName" type="bo:filterAttributeListDT"/>
						<xsd:element name="emptyValue" type="bo:EmptyValueType"/>
						<xsd:element name="instanceValue" type="xsd:string"/>
					</xsd:choice>
				</xsd:sequence>
			</xsd:complexType>
			<xsd:complexType name="EmptyValueType"/>
	<@generateFilterAttributeList/>				
</#macro>


<#--
	generateFilterAttributeList
	===========================
-->
<#macro generateFilterAttributeList>
			<xsd:simpleType name="filterAttributeListDT">
				<xsd:restriction base="xsd:string">
	<@generateFilterAttributeListComponent iComponent=object/>				
				</xsd:restriction>
			</xsd:simpleType>
</#macro>

<#--
	generateFilterAttributeListComponent
	====================================
-->
<#macro generateFilterAttributeListComponent iComponent iPrefix="">
	<#if iComponent.isHidden>
		<#return>
	</#if>
	<#local prefix=iPrefix+iComponent.name+".">
	<#list iComponent.attribute as a>
		<#if !a.parentAttribute?has_content>
			<@generateFilterAttributeListAttribute iComponent=iComponent iAttribute=a iPrefix=prefix/>
		</#if>
	</#list>
	<#list iComponent.relationship as r>
		<#if r.type=="aggregation">
			<#local prefix=iPrefix+iComponent.name+".">
			<@generateFilterAttributeListComponent iComponent=r.component iPrefix=prefix/>				
		</#if>
	</#list>
</#macro>

<#--
	generateFilterAttributeListAttribute
	====================================
-->
<#macro generateFilterAttributeListAttribute iComponent iAttribute iAlias="" iPrefix="">
	<#if iAttribute.isHidden>
		<#return>
	</#if>
	<#local name=iAttribute.name>
	<#if iAlias!="">
		<#local name=iAlias>
	</#if>
	<#switch iAttribute.type>
		<#case "simple">
		<#case "qualifier">
					<xsd:enumeration value="${iPrefix}${name}"/>
		<#case "group">			
		<#case "complex">
			<#local prefix=iPrefix+name+"."/>
			<#list iAttribute.attributeRelationship as ar>
				<@generateFilterAttributeListAttribute iComponent=iComponent iAttribute=ar.attribute.idref iAlias=ar.name iPrefix=prefix/>
			</#list>							
			<#break>
	</#switch>  
</#macro>

<#--
	generateSelectionType
	=====================
-->
<#macro generateSelectionType>
			<xsd:complexType name="SelectionType">
				<xsd:sequence>
					<xsd:element name="selectionAttribute" maxOccurs="unbounded">
						<xsd:simpleType>
							<xsd:restriction base="xsd:string">
	<@generateSelectionAttributeListComponent iComponent=object/>
							</xsd:restriction>
						</xsd:simpleType>
					</xsd:element>
				</xsd:sequence>
			</xsd:complexType>
</#macro>

<#--
	generateSelectionAttributeListComponent
	=======================================
-->
<#macro generateSelectionAttributeListComponent iComponent iDone=[] iPrefix="">
	<#-- check for circular dependencies-->
	<#list iDone as dc>
		<#if dc==iComponent>
			<!-- CIRCULAR DEPENDENCY [${iPrefix}*] SKIPPED -->
			<#return>
		</#if>
	</#list>
	<#local iDone=iDone+[iComponent]>
	<#if iComponent.isHidden>
		<#return>
	</#if>
	<#-- continue generating selection attributes -->
	<#local prefix=iPrefix+iComponent.name+".">
	<#if iComponent.schemaVersion?exists>
								<xsd:enumeration value="${iPrefix}*"/>	
	</#if>
								<xsd:enumeration value="${prefix}*"/>
	<#list iComponent.attribute as a>
		<#if !a.parentAttribute?has_content>
			<@generateSelectionAttributeListAttribute iComponent=iComponent iAttribute=a iPrefix=prefix/>
		</#if>
	</#list>
	<#list iComponent.relationship as r>
		<#if r.type=="aggregation">
			<@generateSelectionAttributeListComponent iComponent=r.component iDone=iDone iPrefix=prefix/>
		<#else>
			<#local bid=r.toBusinessInterface.idref>
			<#local prefix1=prefix+r.name+".">
			<@generateSelectionAttributeListComponent iComponent=bid iDone=iDone iPrefix=prefix1/>
		</#if>
	</#list>
</#macro>

<#--
	generateSelectionAttributeListAttribute
	=======================================
-->
<#macro generateSelectionAttributeListAttribute iComponent iAttribute iAlias="" iPrefix="">
	<#if iAttribute.isHidden>
		<#return>
	</#if>
	<#local name=iAttribute.name>
	<#if iAlias!="">
		<#local name=iAlias>
	</#if>
	<#switch iAttribute.type>
		<#case "simple">
								<xsd:enumeration value="${iPrefix}${name}"/>
			<#break>
		<#case "group">			
		<#case "complex">
								<xsd:enumeration value="${iPrefix}${name}.*"/>
			<#local prefix=iPrefix+name+"."/>
			<#list iAttribute.attributeRelationship as ar>
				<@generateSelectionAttributeListAttribute iComponent=iComponent iAttribute=ar.attribute.idref iAlias=ar.name iPrefix=prefix/>
			</#list>							
			<#break>
		<#case "qualifier">
			<#break>
	</#switch>  
</#macro>
