Index: DCWoRMS/branches/coolemall/simulator/xslt/debb/DEBBComponentTranslator.xsl
===================================================================
--- DCWoRMS/branches/coolemall/simulator/xslt/debb/DEBBComponentTranslator.xsl	(revision 1228)
+++ DCWoRMS/branches/coolemall/simulator/xslt/debb/DEBBComponentTranslator.xsl	(revision 1228)
@@ -0,0 +1,887 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="2.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:plm="http://www.plmxml.org/Schemas/PLMXMLSchema"
+	xmlns:cim="http://www.coolemall.eu/DEBBComponent" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+	<!-- Specification of the output document -->		
+	<xsl:output method="xml" version="1.0" encoding="UTF-8"
+		indent="yes" />
+	
+	<xsl:param name="plmxmlFileName" select="plmxmlFileName" />	
+
+	<xsl:template match="//*[ComponentId]" mode="component">
+		<xsl:param name="instanceRefs"/>
+		<xsl:call-template name="translateComputingElement">
+			<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+		</xsl:call-template>
+	</xsl:template>
+	
+	<xsl:template match="//*[ComponentId]"  mode="coolingDevice">
+		<xsl:param name="instanceRefs"/>
+		<xsl:call-template name="translateCoolingDevice">
+			<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+		</xsl:call-template>
+	</xsl:template>
+	
+	<xsl:template match="//*[ComponentId]"  mode="fan">
+		<xsl:param name="instanceRefs"/>
+		<xsl:call-template name="translateFan">
+			<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+		</xsl:call-template>
+	</xsl:template>
+	
+	<xsl:template match="//*[ComponentId]"  mode="heatsink">
+		<xsl:param name="instanceRefs"/>
+		<xsl:call-template name="translateHeatsink">
+			<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+		</xsl:call-template>
+	</xsl:template>
+
+	<xsl:template name="translateComputingElement">
+		<xsl:param name="instanceRefs"/>
+
+		<xsl:call-template name="BasicDEBBPhysicalElementParameters" />
+		
+		<xsl:if test="Memory">
+			<xsl:apply-templates select="Memory" />
+		</xsl:if>
+		
+		<xsl:if test="Baseboard">
+			<xsl:apply-templates select="Baseboard" />
+		</xsl:if>
+		
+		<xsl:if test="Sensor">
+			<xsl:apply-templates select="Sensor" />
+		</xsl:if>
+		
+		<xsl:if test="PowerSupply">
+			<xsl:apply-templates select="PowerSupply" />
+		</xsl:if>
+		
+		<xsl:if test="Processor">
+			<xsl:apply-templates select="Processor" />
+		</xsl:if>
+
+					 	
+		<!--
+		<xsl:if test="Heatsink">
+			<xsl:apply-templates select="Heatsink" mode="device">
+				<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+			</xsl:apply-templates>
+		</xsl:if>	
+		 -->		
+		 
+		 <!--
+		<xsl:if test="Inlet">
+			<xsl:apply-templates select="Inlet" mode="device">
+				<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+			</xsl:apply-templates>
+		</xsl:if>	
+		
+		<xsl:if test="Outlet">
+			<xsl:apply-templates select="Outlet" mode="device">
+				<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+			</xsl:apply-templates>
+		</xsl:if>	
+		 -->	
+		<xsl:if test="Slot">
+			<xsl:apply-templates select="Slot" />
+		</xsl:if>	
+
+		<xsl:if test="Size">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">size</xsl:attribute>	
+					<xsl:element name="value">
+					<xsl:value-of select="Size" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>	
+
+		<xsl:if test="Network">
+			<xsl:apply-templates select="Network" />
+		</xsl:if>
+		
+	</xsl:template>
+
+	<xsl:template match="Baseboard">
+		<xsl:element name="parameter">
+			<xsl:attribute name="name">baseboard</xsl:attribute>
+			<!-- Don't call BasicDEBBPhysicalElementParameters, because parameter 
+				cannot contain parameters. Must be parameter containing properties. -->
+			<xsl:call-template name="BasicDEBBPhysicalElementProperties" />
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template match="Sensor">
+		<xsl:element name="parameter">
+			<xsl:attribute name="name">sensor</xsl:attribute>
+			<xsl:element name="property">
+				<xsl:attribute name="name">class</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Class" />
+				</xsl:element>
+			</xsl:element>
+			<xsl:element name="property">
+				<xsl:attribute name="name">unit</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Unit" />
+				</xsl:element>
+			</xsl:element>
+			<xsl:if test="MinValue">
+				<xsl:element name="property">
+					<xsl:attribute name="name">minValue</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="MinValue" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:if>
+			<xsl:if test="MaxValue">
+				<xsl:element name="property">
+					<xsl:attribute name="name">maxValue</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="MaxValue" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:if>
+			<xsl:if test="Factor">
+				<xsl:element name="property">
+					<xsl:attribute name="name">factor</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="Factor" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:if>
+			<xsl:if test="Accuracy">
+				<xsl:element name="property">
+					<xsl:attribute name="name">accuracy</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="Accuracy" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:if>
+
+			<!-- Don't call BasicDEBBPhysicalElementParameters, because parameter 
+				cannot contain parameters. Must be parameter containing properties. -->
+			<xsl:call-template name="BasicDEBBPhysicalElementProperties" />
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template match="Processor">
+		<xsl:element name="computingResource">
+			<xsl:attribute name="class">Processor</xsl:attribute>
+			<xsl:call-template name="BasicDEBBPhysicalElementParameters" />
+			<xsl:if test="Cores">
+				<xsl:element name="computingResource">
+					<xsl:attribute name="class">Core</xsl:attribute>
+					<xsl:attribute name="count">
+						<xsl:value-of select="Cores" />
+					</xsl:attribute>
+				</xsl:element>
+			</xsl:if>
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">speed</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="MaxClockSpeed" />
+				</xsl:element>
+			</xsl:element>
+			<xsl:if test="PState | CState">
+				<!-- If PState or CState elements present add powerProfile element -->
+				<xsl:element name="profile">
+					<xsl:element name="powerProfile">
+						
+						<xsl:if test="CState">
+							<!-- If any CState is present add powerStates element -->
+							<xsl:element name="powerStates">
+								<xsl:apply-templates select="CState" />
+							</xsl:element>
+						</xsl:if>
+						
+						<!--  
+						<xsl:if test="PState/LoadPowerUsage">
+							<xsl:apply-templates select="PState/LoadPowerUsage" />
+						</xsl:if>
+						-->
+						<xsl:apply-templates select="PState" />						
+					</xsl:element>
+				</xsl:element>
+			</xsl:if>
+			
+			<xsl:if test="TDP">
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">tdp</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="TDP" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:if>
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template match="PState">
+		<xsl:element name="parameter">
+			<xsl:attribute name="name">pState</xsl:attribute>
+			<xsl:element name="property">
+				<xsl:attribute name="name">name</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="State" />
+				</xsl:element>
+			</xsl:element>
+			<xsl:element name="property">
+				<xsl:attribute name="name">frequency</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Frequency" />
+				</xsl:element>
+			</xsl:element>
+			<xsl:element name="property">
+				<xsl:attribute name="name">voltage</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Voltage" />
+				</xsl:element>
+			</xsl:element>
+			<!-- 	
+			<xsl:element name="property">
+				<xsl:attribute name="name">powerUsageMin</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="PowerUsageMin" />
+				</xsl:element>
+			</xsl:element>
+			<xsl:element name="property">
+				<xsl:attribute name="name">powerUsageMax</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="PowerUsageMax" />
+				</xsl:element>
+			</xsl:element>
+			-->	
+			<xsl:apply-templates select="LoadPowerUsage" mode="parameter" />
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template match="CState">
+
+		<xsl:element name="powerState">
+			<xsl:element name="name">
+				<xsl:value-of select="State" />
+			</xsl:element>
+			<xsl:element name="powerUsage">
+				<xsl:value-of select="PowerUsage" />
+			</xsl:element>			
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template match="LoadPowerUsage" mode="parameter">
+		<xsl:element name="property">
+			<xsl:attribute name="name">loadPowerUsage</xsl:attribute>
+			<xsl:element name="value">
+				<xsl:value-of select="Load" />
+			</xsl:element>
+			<xsl:element name="value">
+				<xsl:value-of select="PowerUsage" />
+			</xsl:element>
+		</xsl:element>
+	</xsl:template>
+	
+	<xsl:template match="LoadPowerUsage" mode="element">
+		<xsl:element name="loadPowerUsage">
+			<xsl:element name="load">
+				<xsl:value-of select="Load" />
+			</xsl:element>
+			<xsl:element name="powerUsage">
+				<xsl:value-of select="PowerUsage" />
+			</xsl:element>
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template match="PowerSupply">
+		<xsl:element name="parameter">
+			<xsl:attribute name="name">powerSupply</xsl:attribute>
+			
+			<xsl:element name="property">
+				<xsl:attribute name="name">class</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Class" />
+				</xsl:element>
+			</xsl:element>
+
+			<xsl:element name="property">
+				<xsl:attribute name="name">totalOutputPower</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="TotalOutputPower" />
+				</xsl:element>
+			</xsl:element>
+		
+			<xsl:element name="property">
+				<xsl:attribute name="name">efficiency</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Efficiency" />
+				</xsl:element>
+			</xsl:element>
+			
+			<!-- TODO: PowerProfile -->
+			
+			<!-- Don't call BasicDEBBPhysicalElementParameters, because parameter 
+				cannot contain parameters. Must be parameter containing properties. -->
+			<xsl:call-template name="BasicDEBBPhysicalElementProperties" />
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template match="Memory">
+		<xsl:element name="resourceUnit">
+			<xsl:attribute name="class">Memory</xsl:attribute>
+			<xsl:element name="amount">
+				<xsl:value-of select="Capacity" />
+			</xsl:element>
+			<xsl:call-template name="BasicDEBBPhysicalElementParameters" />
+		</xsl:element>
+	</xsl:template>
+
+	
+	<xsl:template name="translateCoolingDevice">
+		<xsl:param name="instanceRefs"/>
+		<xsl:call-template name="CoolingDeviceType" >
+			<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+		</xsl:call-template>
+	</xsl:template>	
+	
+	<xsl:template name="CoolingDeviceType">
+ 		<xsl:param name="instanceRefs"/>
+		<xsl:call-template name="BasicDEBBPhysicalElementParameters" />
+		
+		<xsl:if test="Class">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">class</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Class" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+		<xsl:if test="MaxCoolingCapacity">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">maxCoolingCapacity</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="MaxCoolingCapacity" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+		<xsl:if test="MaxAirThroughput">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">maxAirThroughput</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="MaxAirThroughput" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+		<xsl:if test="CRAHFanEfficiency">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">CRAHFanEfficiency</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="CRAHFanEfficiency" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		 
+		 <xsl:if test="CoolingCoilEfficiency">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">coolingCoilEfficiency</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="CoolingCoilEfficiency" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+		 <xsl:if test="DeltaThEx">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">deltaThEx</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="DeltaThEx" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+		<xsl:if test="CWT">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">CWT</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="CWT" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+
+		<xsl:if test="DeltaThDryCooler">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">deltaThDryCooler</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="DeltaThDryCooler" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+
+
+		<xsl:if test="CoolingCapacityRated">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">coolingCapacityRated</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="CoolingCapacityRated" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+		<xsl:if test="EERRated">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">EERRated</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="EERRated" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+  
+		<xsl:apply-templates select="EnergyEfficiencyRatio/Item"/>
+				
+		<!-- Air throughput connected, advanced, technical data -->					
+		<xsl:apply-templates select="AirThroughputProfile" />
+		
+		<xsl:variable name="tokenizedText" select="tokenize($instanceRefs, ' ')" />
+		<xsl:variable name="outsideDoc" select="document($plmxmlFileName)" />
+		<xsl:for-each select="$tokenizedText">
+			<xsl:variable name="componentId" select="." />
+			<xsl:apply-templates select="$outsideDoc/plm:PLMXML/plm:ProductDef/plm:InstanceGraph/plm:ProductInstance[@partRef=$componentId]" mode="updateCoolingDevice">
+			</xsl:apply-templates>
+		</xsl:for-each>	
+		
+	</xsl:template>
+
+	<xsl:template match="Item">
+		<xsl:element name="parameter">
+			<xsl:attribute name="name">EnergyEfficiencyRatio</xsl:attribute>
+			<xsl:element name="property">
+				<xsl:attribute name="name">LWT</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="LWT" />
+				</xsl:element>
+			</xsl:element>
+			<xsl:element name="property">
+				<xsl:attribute name="name">CWT</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="CWT" />
+				</xsl:element>
+			</xsl:element>
+			<xsl:element name="property">
+				<xsl:attribute name="name">Capacity</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Capacity" />
+				</xsl:element>
+			</xsl:element>
+			<xsl:element name="property">
+				<xsl:attribute name="name">PowerUsage</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="PowerUsage" />
+				</xsl:element>
+			</xsl:element>
+			<xsl:element name="property">
+				<xsl:attribute name="name">EER</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="EER" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:element>
+	</xsl:template>
+	
+	
+	<xsl:template match="AirThroughputProfile">
+		<xsl:element name="profile">
+			<xsl:element name="airThroughputProfile">
+				<xsl:element name="airThroughputStates">
+					<xsl:apply-templates select="FlowState" mode="air"/>
+				</xsl:element>
+			</xsl:element>						
+		</xsl:element>
+	</xsl:template>
+	
+	<!--
+	<xsl:template match="PowerUsageProfile" mode="air">
+		<xsl:element name="profile">
+				<xsl:element name="airThroughputProfile">
+					<xsl:element name="airThroughputStates">
+						<xsl:apply-templates select="FlowState" mode="air"/>
+					</xsl:element>
+				</xsl:element>						
+			</xsl:element>
+	</xsl:template>	
+	-->
+	
+	<xsl:template match="PowerUsageProfile" mode="air">
+		<xsl:element name="airThroughputStates">
+			<xsl:apply-templates select="FlowState" mode="air"/>
+		</xsl:element>
+	</xsl:template>	
+	
+	<xsl:template match="PowerUsageProfile" mode="power">
+		<xsl:element name="profile">
+				<xsl:element name="powerProfile">
+					<xsl:element name="powerStates">
+						<xsl:apply-templates select="FlowState" mode="power"/>
+					</xsl:element>
+				</xsl:element>						
+			</xsl:element>
+	</xsl:template>	
+
+	
+	<xsl:template match="FlowState" mode="power">
+		<xsl:element name="powerState">
+			<xsl:call-template name="FlowStateItem"/>
+		</xsl:element>
+	</xsl:template>
+	
+	<xsl:template match="FlowState" mode="air">
+		<xsl:element name="airThroughputState">
+			<xsl:call-template name="FlowStateItem"/>
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template name ="FlowStateItem">
+		<xsl:element name="name">
+			<xsl:value-of select="State" />
+		</xsl:element>
+		<xsl:if test="Flow">
+			<xsl:element name="value">
+				<xsl:value-of select="Flow" />
+			</xsl:element>
+		</xsl:if>
+		<xsl:if test="PowerUsage">
+			<xsl:element name="powerUsage">
+				<xsl:value-of select="PowerUsage" />
+			</xsl:element>
+		</xsl:if>
+	</xsl:template>
+	
+
+
+	<xsl:template name="translateHeatsink">
+		<xsl:param name="instanceRefs"/>
+		<xsl:call-template name="HeatsinkType" >
+			<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+		</xsl:call-template>
+	</xsl:template>	
+	
+	<xsl:template name="HeatsinkType">
+		<xsl:param name="instanceRefs"/>
+		<xsl:call-template name="BasicDEBBPhysicalElementParameters" />
+
+		<xsl:if test="TransferRate">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">efficiency</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Efficiency" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>	
+		
+		<xsl:variable name="tokenizedText" select="tokenize($instanceRefs, ' ')" />
+		<xsl:variable name="outsideDoc" select="document($plmxmlFileName)" />
+		<xsl:for-each select="$tokenizedText">
+			<xsl:variable name="componentId" select="." />
+			<xsl:apply-templates select="$outsideDoc/plm:PLMXML/plm:ProductDef/plm:InstanceGraph/plm:ProductInstance[@partRef=$componentId]" mode="updateHeatsinkDevice">
+			</xsl:apply-templates>
+		</xsl:for-each>		
+		
+	</xsl:template>
+
+	
+	<xsl:template name="FlowPumpType">
+		<xsl:param name="instanceRefs"/>
+		<xsl:call-template name="BasicDEBBPhysicalElementParameters" />
+
+		<xsl:if test="MaxRPM">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">maxRPM</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="MaxRPM" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+			
+		<xsl:if test="Efficiency">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">efficiency</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Efficiency" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>	
+
+		<xsl:variable name="tokenizedText" select="tokenize($instanceRefs, ' ')" />
+		<xsl:variable name="outsideDoc" select="document($plmxmlFileName)" />
+		<xsl:for-each select="$tokenizedText">
+			<xsl:variable name="componentId" select="." />
+			<xsl:apply-templates select="$outsideDoc/plm:PLMXML/plm:ProductDef/plm:InstanceGraph/plm:ProductInstance[@partRef=$componentId]" mode="updateCoolingDevice">
+			</xsl:apply-templates>
+		</xsl:for-each>		
+		
+		<xsl:element name="profile">
+			<xsl:element name="airThroughputProfile">
+				<xsl:apply-templates select="PowerUsageProfile" mode="air"/>
+			</xsl:element>					
+		</xsl:element>
+		
+		<!--
+		<xsl:element name="profile">
+			<xsl:element name="airThroughputProfile">
+				<xsl:element name="airThroughputStates">
+					<xsl:apply-templates select="PowerUsageProfile/FlowState" mode="air"/>
+				</xsl:element>
+			</xsl:element>					
+		</xsl:element>
+		-->
+		<!--		
+		<xsl:apply-templates select="PowerUsageProfile" mode="air" />
+		-->	
+	</xsl:template>
+	
+	<!-- Template for transforming basic parameters of all devices of any type -->
+	<xsl:template name="BasicDEBBPhysicalElementParameters">
+		<xsl:if test="Label">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">label</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Label" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+	
+		<xsl:if test="Manufacturer">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">manufacturer</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Manufacturer" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		<xsl:if test="Product">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">product</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Product" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		<xsl:if test="MaxPower">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">maxPower</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="MaxPower" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+		<xsl:if test="PowerUsage">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">powerUsage</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="PowerUsage" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+
+		<!-- TODO: PowerUsageProfile -->
+
+		<xsl:if test="Type">
+			<xsl:element name="parameter">
+				<xsl:attribute name="name">type</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Type" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>	
+	</xsl:template>
+
+	<xsl:template name="BasicDEBBPhysicalElementProperties">
+		
+		<xsl:if test="Label">
+			<xsl:element name="property">
+				<xsl:attribute name="name">label</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Label" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+		<xsl:if test="Manufacturer">
+			<xsl:element name="property">
+				<xsl:attribute name="name">manufacturer</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Manufacturer" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+		<xsl:if test="Product">
+			<xsl:element name="property">
+				<xsl:attribute name="name">product</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Product" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+		<xsl:if test="MaxPower">
+			<xsl:element name="property">
+				<xsl:attribute name="name">maxPower</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="MaxPower" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+		
+		<xsl:if test="PowerUsage">
+			<xsl:element name="property">
+				<xsl:attribute name="name">powerUsage</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="PowerUsage" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+	
+		<xsl:if test="Type">
+			<xsl:element name="property">
+				<xsl:attribute name="name">type</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Type" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+
+	</xsl:template>
+
+
+	<xsl:template name="translateFan">
+		<xsl:param name="instanceRefs"/>
+		<xsl:call-template name="FlowPumpType" >
+			<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+		</xsl:call-template>
+	</xsl:template>	
+		
+	<!--
+	<xsl:template match="Heatsink" mode="device">
+		<xsl:param name="instanceRefs"/>
+		<xsl:element name="device">
+			<xsl:attribute name="class">Heatsink</xsl:attribute>
+			<xsl:attribute name="name">
+				<xsl:value-of select="Label" />
+			</xsl:attribute>
+
+			<xsl:call-template name="HeatsinkType" >
+				<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+			</xsl:call-template>
+		</xsl:element>
+		
+	</xsl:template>	
+	
+		
+	<xsl:template match="Inlet" mode="device">
+		<xsl:param name="instanceRefs"/>
+		<xsl:element name="device">
+			<xsl:attribute name="class">Inlet</xsl:attribute>
+			<xsl:attribute name="name">
+				<xsl:value-of select="Label" />
+			</xsl:attribute>
+
+			<xsl:call-template name="FlowPumpType" >
+				<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+			</xsl:call-template>
+		</xsl:element>
+	</xsl:template>	
+	
+	<xsl:template match="Outlet" mode="device">
+		<xsl:param name="instanceRefs"/>
+		<xsl:element name="device">
+			<xsl:attribute name="class">Outlet</xsl:attribute>
+			<xsl:attribute name="name">
+				<xsl:value-of select="Label" />
+			</xsl:attribute>
+
+			<xsl:call-template name="FlowPumpType" >
+				<xsl:with-param name="instanceRefs" select="$instanceRefs" />
+			</xsl:call-template>
+		</xsl:element>
+	</xsl:template>	
+		 -->	
+
+	<xsl:template match="Slot">
+		<xsl:element name="parameter">
+			<xsl:attribute name="name">slot</xsl:attribute>	
+			
+			<xsl:call-template name="BasicDEBBConnectorTypeProperties"/>
+		</xsl:element>	
+	</xsl:template>
+	
+	<xsl:template name="BasicDEBBConnectorTypeProperties">
+		<xsl:if test="Number">
+			<xsl:element name="property">
+				<xsl:attribute name="name">number</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="Number" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>
+
+		<xsl:element name="property">
+			<xsl:attribute name="name">connectorType</xsl:attribute>
+			<xsl:element name="value">
+				<xsl:value-of select="ConnectorType" />
+			</xsl:element>
+		</xsl:element>
+
+		<xsl:element name="property">
+			<xsl:attribute name="name">label</xsl:attribute>
+			<xsl:element name="value">
+				<xsl:value-of select="Label" />
+			</xsl:element>
+		</xsl:element>
+		
+		<xsl:if test="AvailSpace">
+			<xsl:element name="property">
+				<xsl:attribute name="name">availSpace</xsl:attribute>
+				<xsl:element name="value">
+					<xsl:value-of select="AvailSpace" />
+				</xsl:element>
+			</xsl:element>
+		</xsl:if>	
+	</xsl:template>
+	
+	<xsl:template match="Network">
+		<xsl:element name="parameter">
+			<xsl:attribute name="name">network</xsl:attribute>
+			
+			<xsl:if test="Interface">
+				<xsl:element name="property">
+					<xsl:attribute name="name">interface</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="Interface" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:if>
+			<xsl:if test="Technology">
+				<xsl:element name="property">
+					<xsl:attribute name="name">technology</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="Technology" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:if>
+			<xsl:if test="MaxBandwidth">
+				<xsl:element name="property">
+					<xsl:attribute name="name">maxBandwidth</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="MaxBandwidth" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:if>
+	
+			<!-- Don't call BasicDEBBPhysicalElementParameters, because parameter 
+				cannot contain parameters. Must be parameter containing properties. -->
+			<xsl:call-template name="BasicDEBBPhysicalElementProperties" />
+		</xsl:element>
+	</xsl:template>
+</xsl:stylesheet>
Index: DCWoRMS/branches/coolemall/simulator/xslt/debb/DCwormsDEBBUpdater.xsl
===================================================================
--- DCWoRMS/branches/coolemall/simulator/xslt/debb/DCwormsDEBBUpdater.xsl	(revision 1228)
+++ DCWoRMS/branches/coolemall/simulator/xslt/debb/DCwormsDEBBUpdater.xsl	(revision 1228)
@@ -0,0 +1,411 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="2.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dcworms="DCWormsResSchema.xsd"
+	xmlns:debb2dcworms="../../debb2dcworms.xsd"
+	xmlns:fun="http://whatever">
+
+	<!-- Specification of the output document -->
+	<xsl:output method="xml" version="1.0" encoding="UTF-8"
+		indent="yes" />
+
+	<!-- Root of the DCWoRMS XML document -->
+	<xsl:variable name="rootDoc" select="/" />
+
+	<!-- Information about schedulers and estimators -->
+	<xsl:param name="additionalInformationFileName" select="additionalInformationFileName" />
+
+
+	<xsl:variable name="nestedDoc"
+		select="document($additionalInformationFileName)" />
+
+	<xsl:template match="/">
+		<xsl:comment>
+			This is DEBB information (taken from PLM XML and DEBBComponent
+			files), updated by schedulers and estimators. Moreover, all elements
+			are sorted and appear in correct order, according to the schema.
+		</xsl:comment>
+		<xsl:comment>
+			Schedulers and estimators information is loaded from
+			<xsl:value-of select="$additionalInformationFileName" />
+			file
+		</xsl:comment>
+
+		<xsl:apply-templates select="environment" />
+
+	</xsl:template>
+
+	<xsl:template match="environment">
+		<xsl:copy>
+			<xsl:copy-of select="@*" />
+			<xsl:apply-templates select="$nestedDoc//timeEstimationPlugin" />
+			<xsl:apply-templates select="resources" />
+			<xsl:apply-templates select="templates"/>
+		</xsl:copy>
+	</xsl:template>
+
+	<xsl:template match="resources">
+		<xsl:copy copy-namespaces="no">
+		<xsl:copy-of select="@*" />
+			<xsl:apply-templates select="//resources/computingResource" />
+			<xsl:element name="scheduler">
+				<xsl:attribute name="class">Cluster</xsl:attribute>
+				<xsl:attribute name="name">cluster</xsl:attribute>
+				<!-- In first version, for simplicity, we assume we have only one scheduler 
+					and one scheduling plugin. If $additionalInformationFileName contains more 
+					than one, the rest is ignored -->
+				<xsl:apply-templates select="$nestedDoc//schedulingPlugin[1]" />
+			</xsl:element>
+		</xsl:copy>
+	</xsl:template>
+
+	<xsl:template match="timeEstimationPlugin">
+		<xsl:element name="timeEstimationPlugin">
+			<xsl:element name="name">
+				<xsl:value-of select="name" />
+			</xsl:element>
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template match="schedulingPlugin">
+		<xsl:variable name="pluginName" select="name" />
+		<xsl:element name="schedulingPlugin">
+			<xsl:element name="name">
+				<xsl:value-of select="$pluginName" />
+			</xsl:element>
+			<xsl:if test="frequency != ''">
+				<xsl:element name="frequency">
+					<xsl:value-of select="frequency" />
+				</xsl:element>
+			</xsl:if>
+		</xsl:element>
+	
+		<xsl:element name="managedComputingResources">
+			<!-- TODO: This parameter should be taken from somewhere. -->
+			<xsl:attribute name="include">false</xsl:attribute>
+
+			<!-- Find appropriate resources (identified by class, type and name(s)) 
+				and add their names here -->
+			<xsl:variable name="resourceClass">
+				<xsl:value-of select="resources/class" />
+			</xsl:variable>
+			<xsl:variable name="resourceType">
+				<xsl:value-of select="resources/type" />
+			</xsl:variable>
+
+			<!-- Not clear why it does not work this way :/ -->
+			<!-- <xsl:variable name="resourceNames"><xsl:value-of select="resources/name"/></xsl:variable> -->
+			<xsl:variable name="resourceNames"
+				select="$nestedDoc//schedulingPlugin[name=$pluginName]/resources/name" />
+			
+			<xsl:choose>
+				<!-- Resource names are present -->
+				<xsl:when test="count($resourceNames) > 0">
+					<xsl:for-each select="$resourceNames">
+						<xsl:variable name="index" select="position()" />
+						<xsl:variable name="resourceName" select="." />
+						
+						<xsl:apply-templates select="$rootDoc//computingResource[(@name=$resourceName and @class=$resourceClass) or 
+							(@name=$resourceName and @class=$resourceClass and @type=$resourceType)]" mode="addManagedResorceName"/>
+					</xsl:for-each>
+				</xsl:when>
+				<!-- Resource names are NOT present -->					
+				<xsl:otherwise>
+					<xsl:apply-templates select="$rootDoc//computingResource[(@class=$resourceClass) or 
+							(@class=$resourceClass and @type=$resourceType)]" mode="addManagedResorceName"/>				
+				</xsl:otherwise>
+			</xsl:choose>	
+		</xsl:element>
+	</xsl:template>
+	
+	<xsl:template match="energyEstimationPlugin">
+		<xsl:element name="energyEstimationPlugin">
+			<xsl:element name="name">
+				<xsl:value-of select="name" />
+			</xsl:element>
+		</xsl:element>
+	</xsl:template>
+
+
+	<xsl:template match="computingResourceTemplate | computingResource">
+		<xsl:copy copy-namespaces="no">
+			<xsl:copy-of select="@*" />
+			<!-- Find nested elements in appropriate order and copy them -->
+			
+			<!-- templateId -->
+			<xsl:apply-templates select="templateId" />
+			
+			<!-- location -->
+			<xsl:apply-templates select="location" />
+			<!-- parameter -->
+			<xsl:apply-templates select="parameter" />
+						
+			<xsl:variable name="debbFullPath" select="fun:getFullPath(.)"/>
+			<xsl:variable name="ancestors" select="ancestor::computingResourceTemplate"/>
+				
+			
+			<xsl:if test="$debbFullPath != '' and name(.) = 'computingResource' and count($ancestors) = 0 and @name">
+				<!-- fullPath parameter should be added only for computingResource nodes; for computingResourceTemplate it is not needed;
+				for computingResource nodes embedded in computingResourceTemplate nodes fullPath is not needed either -->
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">fullPath</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="$debbFullPath" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:if>				
+			
+			
+			<xsl:variable name="resourceClass" select="@class"/>
+			<xsl:variable name="resourceType" select="@type"/>
+			<xsl:variable name="resourceName" select="@name"/>
+			
+			<xsl:if test="not(templateId)">
+				<!-- Don't add energyEstimationPlugin information if there is a template defined for the computingResource.
+				 It will appear in the template. -->
+				<xsl:variable name="estimationPluginName" select="fun:getEnergyEstimator($resourceClass, $resourceType, $resourceName)"/>
+				<xsl:variable name="hasProfile" select="profile != ''"/>
+	
+				<xsl:if test="$hasProfile = false() and $estimationPluginName != ''">
+					<xsl:element name="profile">
+						<xsl:element name="powerProfile">
+							<xsl:element name="energyEstimationPlugin">
+								<xsl:element name="name">
+									<xsl:value-of select="$estimationPluginName"/>
+								</xsl:element>
+							</xsl:element>
+						</xsl:element>
+					</xsl:element>
+				</xsl:if>
+			</xsl:if>
+			
+			<!-- profile -->
+			<xsl:apply-templates select="profile" />
+			<!-- device -->
+			<xsl:apply-templates select="device" />
+			<!-- resourceUnit -->
+			<xsl:apply-templates select="resourceUnit" />
+			
+			<!-- computingResource -->
+			<xsl:apply-templates select="computingResource" />
+						
+		</xsl:copy>
+	</xsl:template>
+	
+	
+	<xsl:template match="device">
+		<xsl:copy copy-namespaces="no">
+			<xsl:copy-of select="@*" />
+			<!-- Find nested elements in appropriate order and copy them -->
+			
+			<!-- templateId -->
+			<xsl:apply-templates select="templateId" />
+			
+			<!-- location -->
+			<xsl:apply-templates select="location" />
+			<!-- parameter -->
+			<xsl:apply-templates select="parameter" />
+						
+								
+			<xsl:variable name="debbFullPath" select="fun:getFullPath(.)"/>
+				
+			
+			<xsl:if test="$debbFullPath != '' and name(.) = 'device' and @name">
+				<!-- fullPath parameter should be added only for computingResource nodes; for computingResourceTemplate it is not needed;
+				for computingResource nodes embedded in computingResourceTemplate nodes fullPath is not needed either -->
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">fullPath</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="$debbFullPath" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:if>	
+			
+			<xsl:variable name="resourceClass" select="@class"/>
+			<xsl:variable name="resourceType" select="@type"/>
+			<xsl:variable name="resourceName" select="@name"/>
+			
+			<xsl:if test="not(templateId)">
+				<!-- Don't add energyEstimationPlugin information if there is a template defined for the computingResource.
+				 It will appear in the template. -->
+				<xsl:variable name="estimationPluginName" select="fun:getEnergyEstimator($resourceClass, $resourceType, $resourceName)"/>
+				<xsl:variable name="hasProfile" select="profile != ''"/>
+				<xsl:variable name="hasPowerProfile" select="profile/powerProfile != ''"/>
+	
+				<xsl:if test="$hasProfile = false() and $estimationPluginName != ''">
+					<xsl:element name="profile">
+						<xsl:element name="powerProfile">
+							<xsl:element name="energyEstimationPlugin">
+								<xsl:element name="name">
+									<xsl:value-of select="$estimationPluginName"/>
+								</xsl:element>
+							</xsl:element>
+						</xsl:element>
+					</xsl:element>
+				</xsl:if>
+			</xsl:if>
+			
+			<!-- profile -->
+			<xsl:apply-templates select="profile" />
+						
+		</xsl:copy>
+	</xsl:template>
+	
+
+	<xsl:function name="fun:getEnergyEstimator">
+		<xsl:param name="computingResourceClass"/>
+		<xsl:param name="computingResourceType"/>
+		<xsl:param name="computingResourceName"/>
+		
+   
+		<xsl:variable name="estimatorName" >
+			<xsl:choose>
+				<xsl:when test="$nestedDoc//energyEstimationPlugin[resources/class=$computingResourceClass and resources/name=$computingResourceName]/name !=''">
+					<xsl:value-of select="$nestedDoc//energyEstimationPlugin[resources/class=$computingResourceClass and resources/name=$computingResourceName]/name"/>
+				</xsl:when>
+				<xsl:when test="$nestedDoc//energyEstimationPlugin[resources/class=$computingResourceClass]/name !=''">
+					<xsl:value-of  select="$nestedDoc//energyEstimationPlugin[resources/class=$computingResourceClass ]/name"/>
+				</xsl:when>
+				<xsl:otherwise>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:variable>
+		<xsl:value-of select="$estimatorName"/>
+	</xsl:function>
+	
+	<xsl:template match="computingResource" mode="addManagedResorceName">
+		<xsl:variable name="debbFullPath" select="fun:getFullPath(.)"/>
+		<xsl:choose>
+			<xsl:when test="$debbFullPath != '' and @name">
+				<xsl:element name="resourceName">
+					<xsl:value-of select="$debbFullPath"></xsl:value-of>
+				</xsl:element>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:element name="resourceName">
+					<xsl:value-of select="@name"></xsl:value-of>
+				</xsl:element>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
+	<xsl:function name="fun:getFullPath">
+		<xsl:param name="currentComputingResource"/>
+		<xsl:variable name="ancestors" select="$currentComputingResource/ancestor::computingResource/@name"/>
+
+		
+		<xsl:variable name="fullPath">
+			<xsl:for-each select="1 to count($ancestors)">
+				<xsl:variable name="index" select="." />
+				<xsl:value-of select="$ancestors[$index]"/>
+				<xsl:text>/</xsl:text>
+			</xsl:for-each>	
+			<xsl:value-of select="$currentComputingResource/@name"></xsl:value-of>	
+		</xsl:variable>
+		
+		<xsl:value-of select="$fullPath"/>
+	</xsl:function>
+	
+	<xsl:template match="resourceUnit | parameter | location">
+		<xsl:copy-of select="." copy-namespaces="no" />
+	</xsl:template>
+
+	<xsl:template match="profile">
+		<xsl:copy copy-namespaces="no">
+			<xsl:copy-of select="@*" />
+			
+			
+			<xsl:variable name="resourceClass" select="../@class"/>
+			<xsl:variable name="resourceType" select="../@type"/>
+			<xsl:variable name="resourceName" select="../@name"/>
+			
+
+			<!-- Don't add energyEstimationPlugin information if there is a template defined for the computingResource.
+			 It will appear in the template. -->
+			<xsl:variable name="estimationPluginName" select="fun:getEnergyEstimator($resourceClass, $resourceType, $resourceName)"/>
+			<xsl:variable name="hasPowerProfile" select="powerProfile != ''"/>
+
+			<xsl:if test="$hasPowerProfile = false() and $estimationPluginName != ''">
+					<xsl:element name="powerProfile">
+						<xsl:element name="energyEstimationPlugin">
+							<xsl:element name="name">
+								<xsl:value-of select="$estimationPluginName"/>
+							</xsl:element>
+						</xsl:element>
+					</xsl:element>
+			</xsl:if>
+			
+			<xsl:apply-templates select="powerProfile" />
+			<xsl:apply-templates select="airThroughputProfile" />
+
+		</xsl:copy>
+	</xsl:template>
+
+	<xsl:template match="powerProfile">
+		<xsl:copy copy-namespaces="no">
+			<xsl:variable name="resourceClass" select="../../@class"></xsl:variable>
+			<xsl:variable name="resourceType" select="../../@type"></xsl:variable>
+			<xsl:variable name="resourceNames" select="../../@name"></xsl:variable>
+
+			<xsl:choose>
+				<!-- Resource names are present -->
+				<xsl:when test="count($resourceNames) > 0">
+					<xsl:for-each select="$resourceNames">
+						<xsl:variable name="index" select="position()" />
+						<xsl:variable name="resourceName" select="." />
+						<xsl:choose>
+							<!-- Resource type is present -->
+							<xsl:when test="$resourceType != ''">
+								<xsl:apply-templates
+									select="$nestedDoc//energyEstimationPlugin[resources/class=$resourceClass and resources/type=$resourceType and resources/name=$resourceName]" />
+							</xsl:when>
+							<xsl:otherwise>
+								<xsl:apply-templates
+									select="$nestedDoc//energyEstimationPlugin[resources/class=$resourceClass and resources/name=$resourceName]" />
+							</xsl:otherwise>
+						</xsl:choose>
+					</xsl:for-each>
+				</xsl:when>
+				<!-- No resource names -->
+				<xsl:otherwise>
+					<xsl:choose>
+						<!-- Resource type is present -->
+						<xsl:when test="$resourceType != ''">
+							<xsl:apply-templates
+								select="$nestedDoc//energyEstimationPlugin[resources/class=$resourceClass and resources/type=$resourceType]" />
+						</xsl:when>
+						<xsl:otherwise>
+							<xsl:apply-templates
+								select="$nestedDoc//energyEstimationPlugin[resources/class=$resourceClass]" />
+						</xsl:otherwise>
+					</xsl:choose>
+				</xsl:otherwise>
+			</xsl:choose>
+			
+			<!-- Copy all children of powerProfile -->
+			<xsl:copy-of select="@*|node()" />
+		</xsl:copy>
+
+	</xsl:template>
+
+	<xsl:template match="airThroughputProfile">
+		<xsl:copy copy-namespaces="no">
+			<!-- Copy all children of airThroughputProfile -->
+			<xsl:copy-of select="@*|node()" />
+		</xsl:copy>		
+	</xsl:template>
+
+	<xsl:template match="templates">
+		<xsl:copy copy-namespaces="no">
+			<xsl:apply-templates/>	
+		</xsl:copy>
+		
+	</xsl:template>
+	
+	<xsl:template match="@*|node()">
+		<xsl:copy>
+			<xsl:apply-templates select="@*" />
+			<xsl:apply-templates />
+		</xsl:copy>
+	</xsl:template>
+
+</xsl:stylesheet>
Index: DCWoRMS/branches/coolemall/simulator/xslt/debb/PLMXMLTranslator.xsl
===================================================================
--- DCWoRMS/branches/coolemall/simulator/xslt/debb/PLMXMLTranslator.xsl	(revision 1228)
+++ DCWoRMS/branches/coolemall/simulator/xslt/debb/PLMXMLTranslator.xsl	(revision 1228)
@@ -0,0 +1,359 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="2.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:plm="http://www.plmxml.org/Schemas/PLMXMLSchema"
+	xmlns:cim="http://www.coolemall.eu/DEBBComponent" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:fun="http://whatever">
+
+	<!-- Importing xslt for translating debb components -->
+	<xsl:import href="DEBBComponentTranslator.xsl" />
+
+	<!-- Information from which level the translator should start moving information to templates -->
+	<xsl:param name="templateStartLevel" select="templateStartLevel" />
+	
+	<xsl:param name="plmxmlFileName" select="plmxmlFileName" />
+		
+	<!-- Specification of the output document -->
+	<xsl:output method="xml" version="1.0" encoding="UTF-8"
+		indent="yes" />
+
+	<!-- Root of the PLM XML document -->
+	<xsl:variable name="rootDoc" select="/" />
+
+
+
+	<xsl:template match="/">
+		<xsl:element name="environment">
+			<xsl:attribute name="xsi:noNamespaceSchemaLocation">../DCwormsResSchema.xsd</xsl:attribute>
+			
+			<xsl:element name="resources">
+				<xsl:attribute name="mode">CoolEmAll</xsl:attribute>
+			
+				<!-- Iterate the document, create hierarchy and "links" to templates -->
+				<xsl:apply-templates select="//plm:InstanceGraph" mode="createHierarchy"/>
+								
+				<!-- Create main scheduler -->
+				<xsl:element name="scheduler"></xsl:element>
+			</xsl:element>
+			
+			<!-- Create templates (if needed) -->
+			<xsl:if test="fun:containsTemplates() = true()">
+				<xsl:element name="templates">
+					<!-- Iterate the document and createTemplates -->
+					<xsl:apply-templates select="//plm:InstanceGraph" mode="createTemplates"/>
+				</xsl:element>			
+			</xsl:if>
+			
+		</xsl:element>
+	</xsl:template>
+
+	<xsl:template match="plm:InstanceGraph" mode="createHierarchy">
+		<!-- Finding root DEBB -->
+		<xsl:variable name="rootRef" select="@rootRefs" />
+		<xsl:apply-templates select="plm:ProductInstance[@id=$rootRef]" mode="createHierarchy"/>
+	</xsl:template>
+
+	<xsl:template match="plm:InstanceGraph" mode="createTemplates">
+     <xsl:apply-templates select="//plm:ProductRevisionView[plm:UserData/plm:UserValue/@title='DEBBLevel' and plm:UserData/plm:UserValue/@value=$templateStartLevel]" mode="createTemplates"/>
+
+		
+	</xsl:template>
+
+	<xsl:template match="plm:ProductInstance" mode="createHierarchy">
+		<xsl:variable name="partRef" select="@partRef" />
+		<!-- Get rid of # at the beginning -->
+		<xsl:variable name="productInstanceId" select="translate($partRef, '#', '')" />
+
+		<xsl:variable name="productInstanceType" select="../plm:ProductRevisionView[@id=$productInstanceId]/plm:UserData/plm:UserValue[@title='DEBBLevel']/@value"/>
+		<xsl:if test="not ($productInstanceType = 'Sensor' or $productInstanceType ='Heatsink' or $productInstanceType ='Inlet' or $productInstanceType = 'Outlet' or $productInstanceType = 'CoolingDevice' or $productInstanceType ='Powersupply' or $productInstanceType ='Wall')">
+			<!-- We have to get rid of sensors, heatsinks, inlets, outlets, which make only problems here -->
+						
+			<xsl:element name="computingResource">
+				<xsl:attribute name="name"><xsl:value-of select="@name" /></xsl:attribute>
+
+				<!-- Find corresponding ProductRevisionView and let it translate itself -->
+				<xsl:apply-templates select="//plm:ProductRevisionView[@id=$productInstanceId]" mode="createHierarchy"/>
+
+				<!-- Add hostnames, labels, locations, sequences, etc. -->
+				<xsl:variable name="debbHostname"
+					select="plm:UserData/plm:UserValue[@title='hostname']/@value" />
+				<xsl:if test="$debbHostname != ''">
+					<xsl:element name="parameter">
+						<xsl:attribute name="name">hostname</xsl:attribute>
+						<xsl:element name="value">
+							<xsl:value-of select="$debbHostname" />
+						</xsl:element>
+					</xsl:element>
+				</xsl:if>
+
+			</xsl:element>
+		</xsl:if>
+		<xsl:if test="$productInstanceType = 'CoolingDevice' or $productInstanceType ='Heatsink' or $productInstanceType ='Inlet' or $productInstanceType = 'Outlet'">
+			<xsl:element name="device">
+				<xsl:attribute name="name">
+					<xsl:value-of select="@name" />
+				</xsl:attribute>
+
+				<!-- Find corresponding ProductRevisionView and let it translate itself -->
+				<xsl:apply-templates select="//plm:ProductRevisionView[@id=$productInstanceId]" mode="createDevice"/>
+					
+			</xsl:element>
+		</xsl:if>		
+	</xsl:template>
+	
+
+	<xsl:template match="plm:ProductRevisionView" mode="createHierarchy">
+
+		<!-- instanceRefs contain space separated ids of nested DEBBs -->
+		<xsl:variable name="tokenizedText" select="tokenize(@instanceRefs, ' ')" />
+	
+		<!-- DEBBLevel -->
+		<xsl:variable name="debbLevel"
+			select="plm:UserData/plm:UserValue[@title='DEBBLevel']/@value" />
+		<!-- DEBBComponentId -->
+		<xsl:variable name="debbComponentId"
+			select="plm:UserData/plm:UserValue[@title='DEBBComponentId']/@value" />
+
+		<xsl:variable name="debbComponentFile"
+			select="plm:UserData/plm:UserValue[@title='DEBBComponentFile']/@value" />
+
+					
+		<xsl:attribute name="class">
+			<xsl:value-of select="$debbLevel"/>
+		</xsl:attribute>
+		
+		<xsl:choose>
+			<xsl:when test="$debbLevel = $templateStartLevel">
+				<!-- Change into template. The rest of the hierarchy will be in a corresponding template. -->
+				<xsl:element name="templateId">
+					<xsl:value-of select="$debbLevel"/>
+					<xsl:text>-</xsl:text>
+					<xsl:value-of select="$debbComponentId"/>
+				</xsl:element>		
+			</xsl:when>
+			<xsl:otherwise>
+			
+				<!-- Read information from DEBBComponent file -->	
+				<xsl:choose>
+					 <!-- DEBB Components file is defined  -->
+					<xsl:when test="$debbComponentFile != ''">
+						<xsl:variable name="nestedDoc" select="document($debbComponentFile)" />
+						<xsl:apply-templates select="$nestedDoc//*[ComponentId=$debbComponentId]" mode="component">
+							<xsl:with-param name="instanceRefs" select="@instanceRefs" />		
+						</xsl:apply-templates>
+					</xsl:when>
+
+				</xsl:choose>			
+			
+				<!-- Iterate children and ask them to translate themselves -->
+				<xsl:for-each select="1 to count($tokenizedText)">
+					<xsl:variable name="index" select="." />
+					<xsl:apply-templates
+						select="$rootDoc//plm:ProductInstance[@id=$tokenizedText[$index]]" mode="createHierarchy"/>
+				</xsl:for-each>			
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
+	
+	<xsl:template match="plm:ProductRevisionView" mode="createDevice">
+	
+		<!-- DEBBLevel -->
+		<xsl:variable name="debbLevel"
+			select="plm:UserData/plm:UserValue[@title='DEBBLevel']/@value" />
+		<!-- DEBBComponentId -->
+		<xsl:variable name="debbComponentId"
+			select="plm:UserData/plm:UserValue[@title='DEBBComponentId']/@value" />
+
+		<xsl:variable name="debbComponentFile"
+			select="plm:UserData/plm:UserValue[@title='DEBBComponentFile']/@value" />
+
+					
+		<xsl:attribute name="class">
+			<xsl:value-of select="$debbLevel"/>
+		</xsl:attribute>
+
+		 <!-- DEBB Components file is defined  -->
+		<xsl:if test="$debbComponentFile != ''">
+			<xsl:variable name="nestedDoc" select="document($debbComponentFile)" />
+
+			<xsl:if test="$debbLevel = 'CoolingDevice'">
+				<xsl:apply-templates select="$nestedDoc//*[ComponentId=$debbComponentId]" mode="coolingDevice">
+					<xsl:with-param name="instanceRefs" select="@id" />		
+				</xsl:apply-templates>
+			</xsl:if>	
+			<xsl:if test="$debbLevel = 'Inlet' or $debbLevel = 'Outlet'">
+				<xsl:apply-templates select="$nestedDoc//*[ComponentId=$debbComponentId]" mode="fan">
+					<xsl:with-param name="instanceRefs" select="@id" />		
+				</xsl:apply-templates>
+			</xsl:if>
+			<xsl:if test="$debbLevel = 'Heatsink'">
+				<xsl:apply-templates select="$nestedDoc//*[ComponentId=$debbComponentId]" mode="heatsink">
+					<xsl:with-param name="instanceRefs" select="@id" />		
+				</xsl:apply-templates>
+			</xsl:if>
+		</xsl:if>
+	</xsl:template>
+	
+	<xsl:template match="plm:ProductRevisionView" mode="createTemplates">
+
+		<!-- instanceRefs contain space separated ids of nested DEBBs -->
+		<xsl:variable name="tokenizedText" select="tokenize(@instanceRefs, ' ')" />
+	
+		<xsl:variable name="debbLevel"
+			select="plm:UserData/plm:UserValue[@title='DEBBLevel']/@value" />
+			
+		<xsl:variable name="debbComponentId"
+			select="plm:UserData/plm:UserValue[@title='DEBBComponentId']/@value" />
+
+		<xsl:variable name="debbComponentFile"
+			select="plm:UserData/plm:UserValue[@title='DEBBComponentFile']/@value" />
+
+	
+		<xsl:if test="$debbLevel">
+			<xsl:element name="computingResourceTemplate">
+				<xsl:attribute name="name">
+					<xsl:value-of select="$debbLevel"/>
+					<xsl:text>-</xsl:text>
+					<xsl:value-of select="$debbComponentId"/>
+				</xsl:attribute>
+				<xsl:attribute name="class">
+					<xsl:value-of select="$debbLevel"/>
+				</xsl:attribute>
+				
+				<!-- Read information from DEBBComponent file -->	
+				<xsl:choose>
+					 <!-- DEBB Components file is defined  -->
+					<xsl:when test="$debbComponentFile != ''">
+						<xsl:variable name="nestedDoc" select="document($debbComponentFile)" />
+
+						<xsl:apply-templates select="$nestedDoc//*[ComponentId=$debbComponentId]" mode="component"> 
+							<xsl:with-param name="instanceRefs" select="@instanceRefs" />							
+						</xsl:apply-templates>
+					
+					</xsl:when>
+
+				</xsl:choose>
+				
+				<!-- Iterate children and ask them to translate themselves -->
+				<xsl:for-each select="1 to count($tokenizedText)">
+					<xsl:variable name="index" select="." />
+					<xsl:apply-templates
+						select="$rootDoc//plm:ProductInstance[@id=$tokenizedText[$index]]" mode="createHierarchy"/>
+				</xsl:for-each>			
+							
+			</xsl:element>
+		</xsl:if>
+	</xsl:template>
+	
+	<xsl:template match="plm:ProductInstance" mode="updateHeatsinkDevice">
+
+		<xsl:variable name="power-sensor"
+			select="plm:UserData/plm:UserValue[@title='power-sensor']/@value" />
+		<xsl:choose>
+	    	<xsl:when test="$power-sensor != ''">
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">power-sensor</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="$power-sensor" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">power-sensor</xsl:attribute>
+					<xsl:element name="value">power</xsl:element>
+				</xsl:element>
+			</xsl:otherwise>
+		</xsl:choose>
+	
+		<!-- 
+		<xsl:variable name="temperature-sensor"
+			select="plm:UserData/plm:UserValue[@title='temperature-sensor']/@value" />
+		<xsl:choose>
+			<xsl:when test="$temperature-sensor != ''">
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">temperature-sensor</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="$temperature-sensor" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">temperature-sensor</xsl:attribute>
+					<xsl:element name="value">temperature</xsl:element>
+				</xsl:element>
+			</xsl:otherwise>
+		</xsl:choose>
+		-->
+	</xsl:template>
+	
+	<xsl:template match="plm:ProductInstance" mode="updateCoolingDevice">
+
+		<xsl:variable name="airflow_volume-sensor"
+			select="plm:UserData/plm:UserValue[@title='airflow_volume-sensor']/@value" />
+		<xsl:choose>
+			<xsl:when test="$airflow_volume-sensor != ''">
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">airflow_volume-sensor</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="$airflow_volume-sensor" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">airflow_volume-sensor</xsl:attribute>
+					<xsl:element name="value">airflow_volume</xsl:element>
+				</xsl:element>
+			</xsl:otherwise>
+		</xsl:choose>
+		
+		<xsl:variable name="airflow_speed-sensor"
+			select="plm:UserData/plm:UserValue[@title='airflow_speed-sensor']/@value" />
+		<xsl:choose>	
+			<xsl:when test="$airflow_speed-sensor != ''">
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">airflow_speed-sensor</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="$airflow_speed-sensor" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">airflow_speed-sensor</xsl:attribute>
+					<xsl:element name="value">airflow_speed</xsl:element>
+				</xsl:element>
+			</xsl:otherwise>
+		</xsl:choose>
+
+		<xsl:variable name="temperature-sensor"
+			select="plm:UserData/plm:UserValue[@title='temperature-sensor']/@value" />
+		<xsl:choose>
+			<xsl:when test="$temperature-sensor != ''">
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">temperature-sensor</xsl:attribute>
+					<xsl:element name="value">
+						<xsl:value-of select="$temperature-sensor" />
+					</xsl:element>
+				</xsl:element>
+			</xsl:when>
+			<xsl:otherwise>
+				<xsl:element name="parameter">
+					<xsl:attribute name="name">temperature-sensor</xsl:attribute>
+					<xsl:element name="value">temperature</xsl:element>
+				</xsl:element>
+			</xsl:otherwise>
+		</xsl:choose>
+	</xsl:template>
+	
+	<xsl:function name="fun:containsTemplates">
+		<xsl:variable name="productRevisionViews" select="$rootDoc//plm:ProductRevisionView[plm:UserData/plm:UserValue/@title='DEBBLevel' and plm:UserData/plm:UserValue/@value=$templateStartLevel]"/>
+		<xsl:variable name="numberOfTemplates" select="count($productRevisionViews)"/>
+
+		<xsl:value-of select="$numberOfTemplates &gt; 0"/>
+	</xsl:function>	
+	
+</xsl:stylesheet>
+
Index: DCWoRMS/branches/coolemall/simulator/xslt/debb/coolemallPlugins.xml
===================================================================
--- DCWoRMS/branches/coolemall/simulator/xslt/debb/coolemallPlugins.xml	(revision 1228)
+++ DCWoRMS/branches/coolemall/simulator/xslt/debb/coolemallPlugins.xml	(revision 1228)
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugins xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
+	xsi:noNamespaceSchemaLocation="../debb2dcworms.xsd">
+	<timeEstimationPlugin>
+		<name>example.timeestimation.coolemall.PhaseTimeEstimationPlugin</name>
+	</timeEstimationPlugin>
+	
+	<schedulingPlugin>
+		<name>example.localplugin.coolemall.computebox1.CB1_FCFS_Random_SP</name>
+		<resources>
+			<class>Rack</class>
+		</resources>
+	</schedulingPlugin>
+	
+	<energyEstimationPlugin>
+		<name>example.energy.coolemall.CB2EnergyEstimationPlugin</name>
+		<resources>
+			<class>ComputeBox2</class>
+			<class>Room</class>
+		</resources>
+	</energyEstimationPlugin>
+	
+	<energyEstimationPlugin>
+		<name>example.energy.coolemall.CB1EnergyEstimationPlugin</name>
+		<resources>
+			<class>ComputeBox1</class>
+			<class>Rack</class>
+		</resources>
+	</energyEstimationPlugin>
+	
+	<energyEstimationPlugin>
+		<name>example.energy.coolemall.NodeGroupEnergyEstimationPlugin</name>
+		<resources>
+			<class>NodeGroup</class>
+		</resources>
+	</energyEstimationPlugin>
+	
+	<energyEstimationPlugin>
+		<name>example.energy.coolemall.NodeEnergyEstimationPlugin</name>
+		<resources>
+			<class>Node</class>
+		</resources>
+	</energyEstimationPlugin>
+	
+	<energyEstimationPlugin>
+		<name>example.energy.coolemall.ProcessorEnergyEstimationPlugin</name>
+		<resources>
+			<class>Processor</class>
+		</resources>
+	</energyEstimationPlugin>
+	
+	<energyEstimationPlugin>
+		<name>example.energy.coolemall.HeatsinkEnergyEstimationPlugin</name>
+		<resources>
+			<class>Heatsink</class>
+		</resources>
+	</energyEstimationPlugin>
+	
+	<energyEstimationPlugin>
+		<name>example.energy.coolemall.FanEnergyEstimationPlugin</name>
+		<resources>
+			<class>Inlet</class>
+			<name>Inlet_1</name>
+			<name>Inlet_2</name>
+			<name>Inlet_3</name>
+			<name>Inlet_4</name>
+			<name>Inlet_5</name>
+			<name>Inlet_6</name>
+			<name>Inlet_7</name>
+			<name>Inlet_8</name>
+			<name>Inlet_9</name>			
+		</resources>
+	</energyEstimationPlugin>
+	
+	<energyEstimationPlugin>
+		<name>example.energy.coolemall.FanEnergyEstimationPlugin</name>
+		<resources>
+			<class>Outlet</class>
+			<name>Outlet_1</name>
+			<name>Outlet_2</name>
+			<name>Outlet_3</name>
+			<name>Outlet_4</name>
+			<name>Outlet_5</name>
+			<name>Outlet_6</name>
+			<name>Outlet_7</name>
+			<name>Outlet_8</name>
+			<name>Outlet_9</name>		
+		</resources>
+	</energyEstimationPlugin>
+	
+		<energyEstimationPlugin>
+		<name>example.energy.coolemall.FlowPumpInletEnergyEstimationPlugin</name>
+		<resources>
+			<class>Inlet</class>
+			<name>FlowPump1</name>
+		</resources>
+	</energyEstimationPlugin>
+	
+	<energyEstimationPlugin>
+		<name>example.energy.coolemall.FlowPumpOutletEnergyEstimationPlugin</name>
+		<resources>
+			<class>Outlet</class>
+			<name>FlowPump2</name>
+		</resources>
+	</energyEstimationPlugin>
+	
+	<energyEstimationPlugin>
+		<name>example.energy.coolemall.CoolingDeviceEnergyEstimationPlugin</name>
+		<resources>
+			<class>CoolingDevice</class>
+		</resources>
+	</energyEstimationPlugin>
+</plugins>
