<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	targetNamespace="http://www.ansys.com/ekm/workflow"
	xmlns:ekmWorkflow="http://www.ansys.com/ekm/workflow"
	xmlns:ekmScript="http://www.ansys.com/ekm/script"
	>

	<xsd:import namespace="http://www.ansys.com/ekm/script" schemaLocation="script.xsd"/>

	<xsd:complexType name="Constraint">
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="value" type="xsd:string" use="required" />
	</xsd:complexType>

	<xsd:simpleType name="intHeight" id="intHeight">
		<xsd:restriction base="xsd:long">
			<xsd:minInclusive value="450"/>
 		</xsd:restriction>
	</xsd:simpleType>
	
	<xsd:simpleType name="intWidth" id="intWidth">
		<xsd:restriction base="xsd:long">
			<xsd:minInclusive value="600"/>
 		</xsd:restriction>
	</xsd:simpleType>
	
	<xsd:attributeGroup name="commonAttributes">
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="id" type="xsd:string" use="optional" />
		<xsd:attribute name="displayStyle" type="xsd:string" use="optional" />
	</xsd:attributeGroup>

	<xsd:complexType name="Variable">
		<xsd:sequence>
			<xsd:element name="enumeration" type="xsd:string"
				minOccurs="0" maxOccurs="unbounded" />
			<xsd:element name="constraint" type="ekmWorkflow:Constraint"
				minOccurs="0" maxOccurs="unbounded" />
		</xsd:sequence>
		<xsd:attributeGroup ref="ekmWorkflow:commonAttributes"/>
		<xsd:attribute name="description" type="xsd:string"
			use="required" />
		<xsd:attribute name="type" use="required">
			<xsd:simpleType>
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="Double" />
					<xsd:enumeration value="Long" />
					<xsd:enumeration value="String" />
					<xsd:enumeration value="Boolean" />
					<xsd:enumeration value="Date" />
					<xsd:enumeration value="Reference" />
				</xsd:restriction>
			</xsd:simpleType>
		</xsd:attribute>
		<xsd:attribute name="default" type="xsd:string" use="optional" />
		<xsd:attribute name="multivalued" type="xsd:boolean"
			use="optional" />
		<xsd:attribute name="updateOnChange" type="xsd:string" use="optional" />
		<xsd:attribute name="onChangeMacro" type="xsd:string" use="optional" />
		<xsd:attribute name="readOnly" type="xsd:boolean" use="optional" default="false"/>
		<xsd:attribute name="public" type="xsd:boolean" use="optional" default="false"/>
	</xsd:complexType>

	<xsd:complexType name="Image">
		<xsd:attribute name="id" type="xsd:string" use="required" />
		<xsd:attribute name="var" type="xsd:string" use="optional" />
		<xsd:attribute name="path" type="xsd:string" use="optional" />
		<xsd:attribute name="height" type="xsd:string" use="optional" />
		<xsd:attribute name="width" type="xsd:string" use="optional" />
		<xsd:attribute name="displayStyle" type="xsd:string" use="optional" />
	</xsd:complexType>
	
	<xsd:complexType name="Spacer">
		<xsd:attribute name="id" type="xsd:string" use="required" />
		<xsd:attribute name="height" type="xsd:string" use="optional" />
		<xsd:attribute name="width" type="xsd:string" use="optional" />
		<xsd:attribute name="displayStyle" type="xsd:string" use="optional" />
	</xsd:complexType>
	
	<xsd:complexType name="UploadFile">
		<xsd:attributeGroup ref="ekmWorkflow:commonAttributes" />
	</xsd:complexType>
	
	<xsd:complexType name="CommandLink">
		<xsd:attributeGroup ref="ekmWorkflow:commonAttributes" />
		<xsd:attribute name="macro" type="xsd:string" use="required" />
		<xsd:attribute name="updateOnChange" type="xsd:string" use="optional" />
	</xsd:complexType>

	<xsd:complexType name="CommandButton">
		<xsd:attributeGroup ref="ekmWorkflow:commonAttributes" />
		<xsd:attribute name="macro" type="xsd:string" use="required" />
		<xsd:attribute name="updateOnChange" type="xsd:string" use="optional" />
	</xsd:complexType>
	
	<xsd:complexType name="Table">
		<xsd:sequence>
				<xsd:element name="column" type="ekmWorkflow:Column" minOccurs="1" maxOccurs="unbounded" />	
		</xsd:sequence>
		<xsd:attributeGroup ref="ekmWorkflow:commonAttributes"/>
	</xsd:complexType>
	
	<xsd:complexType name="Column">
		<xsd:sequence>
			<xsd:element name="var" type="xsd:string"/>
			<xsd:element name="name" type="xsd:string"/>
		</xsd:sequence>
	</xsd:complexType>

	<xsd:complexType name="VarMap">
		<xsd:attribute name="processVarName" type="xsd:string"
			use="required" />
		<xsd:attribute name="itemVarName" type="xsd:string"
			use="required" />
	</xsd:complexType>

	<xsd:complexType name="NestedWorkflowVarMap">
		<xsd:attribute name="processVarName" type="xsd:string"
			use="required" />
		<xsd:attribute name="nestedProcessVarName" type="xsd:string"
			use="required" />
	</xsd:complexType>
	
	<xsd:complexType name="Validation">
		<xsd:attribute name="expression" type="xsd:string"
			use="required" />
		<xsd:attribute name="errorMessage" type="xsd:string"
			use="required" />
	</xsd:complexType>

	<xsd:complexType name="OutputVar">
	    <xsd:simpleContent>
    	  	<xsd:extension base="xsd:string">
        		<xsd:attribute name="displayOrder" type="xsd:int" use="optional"/>
      		</xsd:extension>
    	</xsd:simpleContent>
	</xsd:complexType>

	<xsd:complexType name="DialogStep">
		<xsd:sequence>
			<xsd:element name="panel" type="ekmWorkflow:PanelGrid" minOccurs="1" maxOccurs="1" />
		</xsd:sequence>
		<xsd:attribute name="name" type="xsd:string" use="optional" />
		<xsd:attribute name="description" type="xsd:string" use="optional" />
		<xsd:attribute name="updateMacro" type="xsd:string"/>
		<xsd:attribute name="actionMacro" type="xsd:string"/>
	</xsd:complexType>
	
	<xsd:complexType name="CustomDialogNode">
		<xsd:sequence>
			<xsd:element name="step" type="ekmWorkflow:DialogStep" minOccurs="0" maxOccurs="unbounded" />
			<xsd:element name="validation" type="ekmWorkflow:Validation" minOccurs="0"	maxOccurs="unbounded" />	
		</xsd:sequence>
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="description" type="xsd:string"/>	
		<xsd:attribute name="assignee" type="xsd:string" use="optional" />
		<xsd:attribute name="assigneeModifiable" type="xsd:boolean" use="optional" default="true" />
	</xsd:complexType>
	
	<xsd:complexType name="Node">
		<xsd:sequence>
			<xsd:element name="inputVar" type="xsd:string" minOccurs="0"
				maxOccurs="unbounded" />
			<xsd:element name="outputVar" type="ekmWorkflow:OutputVar"
				minOccurs="0" maxOccurs="unbounded" />
			<xsd:element name="validation" type="ekmWorkflow:Validation" minOccurs="0"
				maxOccurs="unbounded" />
		</xsd:sequence>
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="description" type="xsd:string"
			use="required" />
		<xsd:attribute name="assignee" type="xsd:string" use="optional" />
		<xsd:attribute name="completionMacro" type="xsd:string"
			use="optional" />
		<xsd:attribute name="assigneeModifiable" type="xsd:boolean" use="optional" default="true" />
	</xsd:complexType>

	<xsd:complexType name="AutoNode">
		<xsd:sequence>
			<xsd:element name="inputVar" type="ekmWorkflow:VarMap" minOccurs="0" maxOccurs="unbounded" />
			<xsd:element name="outputVar" type="ekmWorkflow:VarMap" minOccurs="0" maxOccurs="unbounded" />
		</xsd:sequence>
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="macro" type="xsd:string" use="optional" />
		<xsd:attribute name="description" type="xsd:string" use="required" />
		<xsd:attribute name="assignee" use="optional">
			<xsd:simpleType>
				<xsd:restriction base="xsd:string">
					<xsd:enumeration value="ProcessCreator" />
					<xsd:enumeration value="PreviousNodeAssignee" />
				</xsd:restriction>
			</xsd:simpleType>
		</xsd:attribute>
	</xsd:complexType>
	
	<xsd:complexType name="WorkflowReferenceNode">
		<xsd:sequence>
			<xsd:element name="inputVar" type="ekmWorkflow:NestedWorkflowVarMap" minOccurs="0" maxOccurs="unbounded" />
			<xsd:element name="outputVar" type="ekmWorkflow:NestedWorkflowVarMap" minOccurs="0" maxOccurs="unbounded" />
		</xsd:sequence>
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="description" type="xsd:string" use="required" />
		<xsd:attribute name="wfReference" type="xsd:string" use="required" />
	</xsd:complexType>	

	<xsd:complexType name="MonitorNode">
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="description" type="xsd:string" use="required" />
		<xsd:attribute name="monitoredProcessesVar" type="xsd:string" use="required"/>
	</xsd:complexType>

	<xsd:complexType name="BatchNode">
		<xsd:sequence>
			<xsd:element name="appKey" type="ekmWorkflow:BatchNodeVar" minOccurs="0" maxOccurs="1" />
			<xsd:element name="cores" minOccurs="0" maxOccurs="1" type="ekmWorkflow:BatchNodeVar"/>
			<xsd:element name="param" minOccurs="0" maxOccurs="unbounded" type="ekmWorkflow:BatchNodeVar" />
			<xsd:element name="exportFile" minOccurs="0" maxOccurs="unbounded" type="ekmWorkflow:BatchNodeExportFile" />
			<xsd:element name="exportFileFromJob" minOccurs="0" maxOccurs="unbounded" 
                type="ekmWorkflow:BatchNodeExportFileFromJob" />
			<xsd:element name="outputFolder" type="ekmWorkflow:BatchNodeVar" />
			<xsd:element name="importFile" minOccurs="0" maxOccurs="unbounded"  type="ekmWorkflow:BatchNodeImportFile" />
			<xsd:element name="importedFileType" minOccurs="0" maxOccurs="unbounded" type="ekmWorkflow:BatchNodeImportedFileType" />
			<xsd:element name="transcript" minOccurs="0" maxOccurs="1" type="ekmWorkflow:BatchNodeVar" />
			<xsd:element name="autoStart" minOccurs="0" maxOccurs="1" type="xsd:boolean" />
			<xsd:element name="autoComplete" minOccurs="0" maxOccurs="1" type="xsd:boolean" />
			<xsd:element name="jobTemplate" type="ekmWorkflow:BatchNodeVar" minOccurs="0" maxOccurs="1" />
			<xsd:element name="showWorkingDirectory" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="true"/>
			<xsd:element name="workingDirectory" type="ekmWorkflow:WorkingDirectory" minOccurs="0" maxOccurs="1" />
		</xsd:sequence>
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="description" type="xsd:string" use="required" />
		<xsd:attribute name="assignee" type="xsd:string" use="optional" />
		<xsd:attribute name="assigneeModifiable" type="xsd:boolean" use="optional" default="true" />
	</xsd:complexType>
	
	<xsd:complexType name="WorkingDirectory" mixed="true">
		<xsd:attribute name="specificationMethod" type="xsd:string" use="optional" />
	</xsd:complexType>
	
	<xsd:complexType name="DoeNode">
		<xsd:sequence>
			<xsd:element name="wbApp" minOccurs="0" maxOccurs="1" type="ekmWorkflow:DoeNodeVar" />
			<xsd:element name="designPoints" minOccurs="1" maxOccurs="1" type="ekmWorkflow:DoeNodeVar" />
			<xsd:element name="outputFolder" minOccurs="1" maxOccurs="1" type="ekmWorkflow:DoeNodeVar" />
			<xsd:element name="doeInputFile" minOccurs="0" maxOccurs="1" type="ekmWorkflow:DoeNodeVar" />
			<xsd:element name="workbenchProject" minOccurs="0" maxOccurs="1" type="ekmWorkflow:DoeNodeVar" />
			<xsd:element name="performOptimization" minOccurs="0" maxOccurs="1" type="ekmWorkflow:DoeNodeVar" />
			<xsd:element name="runOptimalDesignPoints" minOccurs="0" maxOccurs="1" type="ekmWorkflow:DoeNodeVar" />
			<xsd:element name="simultaneousBatchTasks" minOccurs="0" maxOccurs="1" type="ekmWorkflow:DoeNodeVar" />
			<xsd:element name="inputParameters" minOccurs="0" maxOccurs="1" type="ekmWorkflow:DoeNodeVar" />
			<xsd:element name="workflow" minOccurs="0" maxOccurs="1" type="ekmWorkflow:DoeNodeVar" />
		</xsd:sequence>
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="description" type="xsd:string" use="optional" />
		<xsd:attribute name="batchNode" type="xsd:string" use="optional" />
		<xsd:attribute name="runSimulationsInWb" type="xsd:boolean" use="optional" />
	</xsd:complexType>	
	
	<xsd:complexType name="OptimizationNode">
		<xsd:sequence>
			<xsd:element name="wbApp" minOccurs="0" maxOccurs="1" type="ekmWorkflow:OptimizationNodeVar" />
			<xsd:element name="designPoints" minOccurs="1" maxOccurs="1" type="ekmWorkflow:OptimizationNodeVar" />
			<xsd:element name="outputFolder" minOccurs="1" maxOccurs="1" type="ekmWorkflow:OptimizationNodeVar" />
			<xsd:element name="doeInputFile" minOccurs="0" maxOccurs="1" type="ekmWorkflow:OptimizationNodeVar" />
			<xsd:element name="designPointsFile" minOccurs="1" maxOccurs="1" type="ekmWorkflow:OptimizationNodeVar" />
			<xsd:element name="optimizationGoalsFile" minOccurs="0" maxOccurs="1" type="ekmWorkflow:OptimizationNodeVar" />
			<xsd:element name="workbenchProject" minOccurs="0" maxOccurs="1" type="ekmWorkflow:OptimizationNodeVar" />
			<xsd:element name="workflow" minOccurs="0" maxOccurs="1" type="ekmWorkflow:OptimizationNodeVar" />
		</xsd:sequence>
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="description" type="xsd:string" use="optional" />
	</xsd:complexType>	

	<xsd:complexType name="BatchNodeVar" mixed="true">
		<xsd:attribute name="literal" type="xsd:boolean" use="optional" />
	</xsd:complexType>
	
	<xsd:complexType name="DoeNodeVar" mixed="true">
			<xsd:attribute name="literal" type="xsd:boolean" use="optional" />
	</xsd:complexType>
	
	<xsd:complexType name="OptimizationNodeVar" mixed="true">
			<xsd:attribute name="literal" type="xsd:boolean" use="optional" />
	</xsd:complexType>

	<xsd:complexType name="BatchNodeExportFile" mixed="true">
		<xsd:attribute name="exportedFileName" type="xsd:string" use="optional" />
		<xsd:attribute name="literalExportedFileName" type="xsd:boolean" use="optional" />
		<xsd:attribute name="literal" type="xsd:boolean" use="optional" />
		<xsd:attribute name="template" type="xsd:boolean" use="optional" />
		<xsd:attribute name="temporary" type="xsd:boolean" use="optional" />
		<xsd:attribute name="nonEkmFile" type="xsd:boolean" use="optional" />
		<xsd:attribute name="includes" type="xsd:string" use="optional" />
		<xsd:attribute name="excludes" type="xsd:string" use="optional" />
	</xsd:complexType>

	<xsd:complexType name="BatchNodeExportFileFromJob" mixed="true">
		<xsd:attribute name="batchNode" type="xsd:string" use="required" />
		<xsd:attribute name="exportedFileName" type="xsd:string" use="optional" />
		<xsd:attribute name="literalExportedFileName" type="xsd:boolean" use="optional" />
		<xsd:attribute name="literal" type="xsd:boolean" use="optional" />
		<xsd:attribute name="includes" type="xsd:string" use="optional" />
		<xsd:attribute name="excludes" type="xsd:string" use="optional" />
	</xsd:complexType>

    <xsd:complexType name="BatchNodeImportFile" mixed="true">
        <xsd:attribute name="literal" type="xsd:boolean" use="optional" />
        <xsd:attribute name="includes" type="xsd:string" use="optional" />
        <xsd:attribute name="excludes" type="xsd:string" use="optional" />
        <xsd:attribute name="retrieveOnFailure" type="xsd:string" use="optional" />
    </xsd:complexType>
    
	<xsd:complexType name="BatchNodeImportedFileType">
		<xsd:attribute name="pattern" type="xsd:string" use="required" />
		<xsd:attribute name="type" type="xsd:string" use="required" />
	</xsd:complexType>

	<xsd:complexType name="IterationNode">
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="block" type="xsd:string" use="required" />
		<xsd:attribute name="iterationExpression" type="xsd:string"
			use="required" />
		<xsd:attribute name="description" type="xsd:string"
			use="required" />
	</xsd:complexType>

	<xsd:complexType name="UpdateAnalysisProjectNode">
		<xsd:sequence>
			<xsd:element name="analysisProjectVar" type="xsd:string" minOccurs="1" maxOccurs="1" />
		</xsd:sequence>
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="description" type="xsd:string" use="required" />
	</xsd:complexType>

	<xsd:complexType name="Transition">
		<xsd:attribute name="name" type="xsd:string" use="required" />
		<xsd:attribute name="source" type="xsd:string" use="required" />
		<xsd:attribute name="destination" type="xsd:string"
			use="required" />
		<xsd:attribute name="triggerExpression" type="xsd:string"
			use="optional" />
	</xsd:complexType>

	<xsd:complexType name="Layout">
		<xsd:sequence>
			<xsd:element name="location" type="ekmWorkflow:Location" minOccurs="0" maxOccurs="unbounded" />
		</xsd:sequence>
	</xsd:complexType>
	
	<xsd:complexType name="Location">
		<xsd:attribute name="nodeName" type="xsd:string" use="optional" />
		<xsd:attribute name="x" type="xsd:integer" use="optional" />
		<xsd:attribute name="y" type="xsd:integer" use="optional" />
	</xsd:complexType>
	
	<xsd:group name="Block">
		<xsd:sequence>
			<xsd:element name="blocks" minOccurs="0" maxOccurs="1">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="block"
							type="ekmWorkflow:WorkflowBlock" minOccurs="0"
							maxOccurs="unbounded" />
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>

			<xsd:element name="nodes">
				<xsd:complexType>
					<xsd:choice maxOccurs="unbounded" minOccurs="0">
						<xsd:element name="node"
							type="ekmWorkflow:Node" />
						<xsd:element name="auto-node"
							type="ekmWorkflow:AutoNode" />
						<xsd:element name="iteration-node"
							type="ekmWorkflow:IterationNode" />
						<xsd:element name="batch-node"
							type="ekmWorkflow:BatchNode" />
						<xsd:element name="doe-node"
							type="ekmWorkflow:DoeNode" />
						<xsd:element name="optimization-node"
							type="ekmWorkflow:OptimizationNode" />							
						<xsd:element name="monitor-node"
							type="ekmWorkflow:MonitorNode" />
						<xsd:element name="update-analysis-project-node"
							type="ekmWorkflow:UpdateAnalysisProjectNode" />
						<xsd:element name="custom-dialog-node"
							type="ekmWorkflow:CustomDialogNode" />
						<xsd:element name="workflow-reference-node"
							type="ekmWorkflow:WorkflowReferenceNode" />							
					</xsd:choice>
				</xsd:complexType>
			</xsd:element>

			<xsd:element name="transitions">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="transition"
							type="ekmWorkflow:Transition" minOccurs="0"
							maxOccurs="unbounded" />
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>

		</xsd:sequence>
	</xsd:group>

	<xsd:complexType name="WorkflowBlock">
		<xsd:group ref="ekmWorkflow:Block" />
	</xsd:complexType>

	<xsd:complexType name="PanelGrid">
		<xsd:sequence>
			 <xsd:choice minOccurs="0" maxOccurs="unbounded">
				<xsd:element name="var" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
				<xsd:element name="image" type="ekmWorkflow:Image" minOccurs="0" maxOccurs="unbounded"/>
				<xsd:element name="spacer" type="ekmWorkflow:Spacer" minOccurs="0" maxOccurs="unbounded"/>
				<xsd:element name="uploadFile" type="ekmWorkflow:UploadFile" minOccurs="0" maxOccurs="unbounded"/>
				<xsd:element name="table" type="ekmWorkflow:Table" minOccurs="0" maxOccurs="unbounded"/>
				<xsd:element name="commandLink" type="ekmWorkflow:CommandLink" minOccurs="0" maxOccurs="unbounded"/>
				<xsd:element name="commandButton" type="ekmWorkflow:CommandButton" minOccurs="0" maxOccurs="unbounded"/>
				<xsd:element name="panelGrid" minOccurs="0" maxOccurs="unbounded" type="ekmWorkflow:PanelGrid" />
			</xsd:choice>
		</xsd:sequence>
		<xsd:attribute name="columnCount" type="xsd:int"/>
		<xsd:attribute name="id" type="xsd:string"/>
		<xsd:attribute name="displayStyle" type="xsd:string" />
	</xsd:complexType>
	
	<xsd:complexType name="WorkflowDefinition">
		<xsd:sequence>
		    <xsd:element name="ekmVersion" type="xsd:string" minOccurs="0"/>
			<xsd:element name="script" type="ekmScript:Script" minOccurs="0"/>
			<xsd:element name="customUiForSettingAssignee" type="ekmWorkflow:WorkflowDefinitionVar" minOccurs="0" maxOccurs="1" />
			<xsd:element name="variables" minOccurs="0">
				<xsd:complexType>
					<xsd:sequence>
						<xsd:element name="variable"
							type="ekmWorkflow:Variable" minOccurs="0" maxOccurs="unbounded" />
					</xsd:sequence>
				</xsd:complexType>
			</xsd:element>

			<xsd:group ref="ekmWorkflow:Block" />

			<xsd:element name="layout" type="ekmWorkflow:Layout" minOccurs="0"
							maxOccurs="1" />

			<xsd:element name="requiredVar" minOccurs="0"
				type="xsd:string" maxOccurs="unbounded" />
			<xsd:element name="validation" type="ekmWorkflow:Validation" minOccurs="0"
				maxOccurs="unbounded" />
		</xsd:sequence>
		<xsd:attribute name="name" use="required" type="xsd:string" />
		<xsd:attribute name="description" use="required"
			type="xsd:string" />
		<xsd:attribute name="height" use="optional" default="450" type="ekmWorkflow:intHeight"/>
		<xsd:attribute name="width" use="optional" default="600" type="ekmWorkflow:intWidth" />
		
	</xsd:complexType>
	
	<xsd:complexType name="WorkflowDefinitionVar" mixed="true">
		<xsd:attribute name="literal" type="xsd:boolean" use="optional" />
	</xsd:complexType>

	<xsd:element name="workflow" type="ekmWorkflow:WorkflowDefinition" />

</xsd:schema>