Index: DCWoRMS/trunk/src/test/DEBBTranslator/xml/DCWoRMSDEBBUpdater.xsl
===================================================================
--- DCWoRMS/trunk/src/test/DEBBTranslator/xml/DCWoRMSDEBBUpdater.xsl	(revision 892)
+++ DCWoRMS/trunk/src/test/DEBBTranslator/xml/DCWoRMSDEBBUpdater.xsl	(revision 918)
@@ -2,5 +2,6 @@
 <xsl:stylesheet version="2.0"
 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dcworms="DCWormsResSchema.xsd"
-	xmlns:debb2dcworms="../../debb2dcworms.xsd">
+	xmlns:debb2dcworms="../../debb2dcworms.xsd"
+	xmlns:fun="http://whatever">
 
 	<!-- Specification of the output document -->
@@ -146,4 +147,63 @@
 	</xsl:template>
 
+<!-- 	<xsl:template match="energyEstimationPlugin">
+			<xsl:variable name="pluginName" select="name" />
+
+			 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:value-of select="$resourceClass"/> 
+			<xsl:variable name="resourceType">
+				<xsl:value-of select="resources/type" />
+			</xsl:variable>
+			 <xsl:value-of select="$resourceType"/> 
+
+			 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//energyEstimationPlugin[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:choose>
+							 Resource type is present 
+							<xsl:when test="$resourceType != ''">
+								<xsl:apply-templates
+									select="$rootDoc//computingResource[@class=$resourceClass and @type=$resourceType and @name=$resourceName]"
+									mode="addEnergyEstimationPlugin" />
+							</xsl:when>
+							<xsl:otherwise>
+								<xsl:apply-templates
+									select="$rootDoc//computingResource[@class=$resourceClass and @name=$resourceName]"
+									mode="addEnergyEstimationPlugin" />
+							</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="$rootDoc//computingResource[@class=$resourceClass and @type=$resourceType]"
+								mode="addEnergyEstimationPlugin" />
+						</xsl:when>
+						<xsl:otherwise>
+							<xsl:apply-templates
+								select="$rootDoc//computingResource[@class=$resourceClass]"
+								mode="addEnergyEstimationPlugin" />
+						</xsl:otherwise>
+					</xsl:choose>
+				</xsl:otherwise>
+			</xsl:choose>
+	</xsl:template> -->
+
 	<xsl:template match="computingResource">
 		<xsl:copy copy-namespaces="no">
@@ -154,4 +214,25 @@
 			<!-- parameter -->
 			<xsl:apply-templates select="parameter" />
+			
+			<xsl:variable name="resourceClass" select="@class"/>
+			<xsl:variable name="resourceType" select="@type"/>
+			<xsl:variable name="resourceName" select="@name"/>
+			
+			<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>
+			
 			<!-- profile -->
 			<xsl:apply-templates select="profile" />
@@ -163,4 +244,17 @@
 	</xsl:template>
 
+	<xsl:function name="fun:getEnergyEstimator">
+		<xsl:param name="computingResourceClass"/>
+		<xsl:param name="computingResourceType"/>
+		<xsl:param name="computingResourceName"/>
+		
+		<xsl:variable name="estimatorName" select="$nestedDoc//energyEstimationPlugin[(resources/class=$computingResourceClass and resources/type=$computingResourceType and resources/name=$computingResourceName) or
+		(resources/class=$computingResourceClass and resources/type=$computingResourceType) or
+		(resources/class=$computingResourceClass and resources/name=$computingResourceName) or
+		resources/class=$computingResourceClass]/name"/>
+
+		<xsl:value-of select="$estimatorName"/>
+	</xsl:function>
+	
 	<xsl:template match="computingResource" mode="addResorceName">
 		<xsl:element name="resourceName">
@@ -169,4 +263,10 @@
 		</xsl:element>
 	</xsl:template>
+
+	<xsl:template match="computingResource" mode="addEnergyEstimationPlugin">
+		<xsl:element name="energyEstimationPlugin">
+			<xsl:value-of select="name"></xsl:value-of>
+		</xsl:element>
+	</xsl:template>
 	
 	<xsl:template match="resourceUnit | parameter | location">
@@ -177,4 +277,5 @@
 		<xsl:copy copy-namespaces="no">
 			<xsl:copy-of select="@*" />
+			
 			<xsl:apply-templates select="powerProfile" />
 		</xsl:copy>
@@ -221,4 +322,5 @@
 				</xsl:otherwise>
 			</xsl:choose>
+			
 			<!-- Copy all children of powerProfile -->
 			<xsl:copy-of select="@*|node()" />
