source: DCWoRMS/trunk/src/test/DEBBTranslator/xml/DCWoRMSDEBBUpdater.xsl @ 881

Revision 881, 6.4 KB checked in by gosiaw, 12 years ago (diff)

Adding information about energyEstimationPlugin corrected

Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="2.0"
3        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dcworms="DCWormsResSchema.xsd"
4        xmlns:debb2dcworms="../../debb2dcworms.xsd">
5
6        <!-- Specification of the output document -->
7        <xsl:output method="xml" version="1.0" encoding="UTF-8"
8                indent="yes" />
9
10        <!-- Root of the DCWoRMS XML document -->
11        <xsl:variable name="rootDoc" select="/" />
12
13        <!-- Information about schedulers and estimators -->
14        <xsl:param name="additionalInformationFileName" select="additionalInformationFileName" />
15
16
17        <xsl:variable name="nestedDoc"
18                select="document($additionalInformationFileName)" />
19
20        <xsl:template match="/">
21                <xsl:comment>
22                        This is DEBB information (taken from PLM XML and DEBBComponent
23                        files), updated by schedulers and estimators. Moreover, all elements
24                        are sorted and appear in correct order, according to the schema.
25                </xsl:comment>
26                <xsl:comment>
27                        Schedulers and estimators information is loaded from
28                        <xsl:value-of select="$additionalInformationFileName" />
29                        file
30                </xsl:comment>
31
32                <xsl:apply-templates select="environment" />
33
34        </xsl:template>
35
36        <xsl:template match="environment">
37                <xsl:copy>
38                        <xsl:copy-of select="@*" />
39                        <xsl:apply-templates select="$nestedDoc//timeEstimationPlugin" />
40                        <xsl:apply-templates select="resources" />
41                </xsl:copy>
42        </xsl:template>
43
44        <xsl:template match="resources">
45                <xsl:copy copy-namespaces="no">
46                        <xsl:apply-templates select="//resources/computingResource" />
47                        <xsl:element name="scheduler">
48                                <xsl:attribute name="class">Cluster</xsl:attribute>
49                                <xsl:attribute name="name">cluster</xsl:attribute>
50                                <xsl:apply-templates select="$nestedDoc//schedulingPlugin" />
51                        </xsl:element>
52                </xsl:copy>
53        </xsl:template>
54       
55        <xsl:template match="timeEstimationPlugin">
56                <xsl:element name="timeEstimationPlugin">
57                        <xsl:element name="name">
58                                <xsl:value-of select="name" />
59                        </xsl:element>
60                </xsl:element>
61        </xsl:template>
62       
63
64        <xsl:template match="schedulingPlugin">
65                <xsl:element name="schedulingPlugin">
66                        <xsl:element name="name">
67                                <xsl:value-of select="name" />
68                        </xsl:element>
69                        <xsl:if test="frequency != ''">
70                                <xsl:element name="frequency">
71                                        <xsl:value-of select="frequency"/>
72                                </xsl:element>
73                        </xsl:if>
74                </xsl:element>
75                <xsl:element name="managedComputingResources">
76                        <!-- TODO: This parameter should be taken from somewhere. -->
77                        <xsl:attribute name="include">false</xsl:attribute>
78                       
79                        <!-- Find appropriate resources (identified by class, type and name(s)) and add their names here -->
80                        <xsl:variable name="resourceClass"><xsl:value-of select="resources/class"/></xsl:variable>
81<!--                    <xsl:value-of select="$resourceClass"/>-->
82                        <xsl:variable name="resourceType"><xsl:value-of select="resources/type"/></xsl:variable>
83<!--                    <xsl:value-of select="$resourceType"/>-->
84                        <xsl:variable name="resourceNames"><xsl:value-of select="resources/name"/></xsl:variable>
85                        <xsl:variable name="xpath">$rootDoc//computingResource[@class=<xsl:value-of select="$resourceClass"/> and @type=<xsl:value-of select="$resourceType"/>]</xsl:variable>
86<!--                    <xsl:value-of select="$xpath"></xsl:value-of>-->
87
88                        <!-- TODO: Names are ignored now, for simplicity. Should be changed! -->
89                        <xsl:choose>
90                                <xsl:when test="$resourceClass != '' and $resourceType != ''">
91<!--                                    <xsl:value-of select="$resourceClass"/>-->
92<!--                                    <xsl:value-of select="$resourceType"/>-->
93                                        <xsl:apply-templates select="$rootDoc//computingResource[@class=$resourceClass and @type=$resourceType]" mode="addResorceName"/>
94                                </xsl:when>
95                                <xsl:otherwise>
96<!--                                    <xsl:value-of select="$resourceClass"/>-->
97                                        <xsl:apply-templates select="$rootDoc//computingResource[@class=$resourceClass]" mode="addResorceName"/>
98                                </xsl:otherwise>
99                        </xsl:choose>
100                       
101                       
102                       
103                </xsl:element>
104        </xsl:template>
105
106        <xsl:template match="energyEstimationPlugin">
107                <xsl:element name="energyEstimationPlugin">
108                        <xsl:element name="name">
109                                <xsl:value-of select="name" />
110                        </xsl:element>
111                </xsl:element>
112        </xsl:template>
113       
114        <xsl:template match="computingResource">
115                <xsl:copy copy-namespaces="no">
116                        <xsl:copy-of select="@*" />
117                        <!-- Find nested elements in appropriate order and copy them -->
118                        <!-- resourceUnit -->
119                        <xsl:apply-templates select="resourceUnit" />
120                        <!-- parameter -->
121                        <xsl:apply-templates select="parameter" />
122                        <!-- profile -->
123                        <xsl:apply-templates select="profile" />               
124                        <!-- location -->
125                        <xsl:apply-templates select="location" />
126                        <!-- computingResource -->
127                        <xsl:apply-templates select="computingResource" />
128                </xsl:copy>
129        </xsl:template>
130
131        <xsl:template match="computingResource" mode="addResorceName">
132                <xsl:element name="resourceName">
133                        <xsl:value-of select="../@name"></xsl:value-of>
134                </xsl:element>
135        </xsl:template><!--
136       
137        <xsl:template match="powerProfile" mode="addEstimationPlugin">
138                <xsl:element name="energyEstimationPlugin">
139                        <xsl:element name="name">
140                                <xsl:value-of select="name" />
141                        </xsl:element>
142                </xsl:element> 
143        </xsl:template>
144       
145        --><xsl:template match="resourceUnit | parameter | location">
146                <xsl:copy-of select="." copy-namespaces="no" />
147        </xsl:template>
148
149        <xsl:template match="profile">
150                <xsl:copy copy-namespaces="no">
151                        <xsl:copy-of select="@*" />
152                        <xsl:apply-templates select="powerProfile" />
153                </xsl:copy>                                     
154        </xsl:template>
155
156        <xsl:template match="powerProfile">     
157                <xsl:copy copy-namespaces="no">
158                        <xsl:variable name="resourceClass" select="../../@class"></xsl:variable>
159                        <xsl:variable name="resourceType" select="../../@type"></xsl:variable>
160                        <xsl:variable name="resourceName" select="../../@name"></xsl:variable>
161                        <xsl:choose>
162                                <xsl:when test="$resourceType != ''">
163                                        <!-- resource class and type -->
164                                        <!-- Add information about energy estimation plugin -->
165                                        <xsl:apply-templates select="$nestedDoc//energyEstimationPlugin[resources/class = $resourceClass and resources/type = $resourceType]"/>                                 
166                                </xsl:when>
167                                <xsl:otherwise>
168                                        <!-- resource class only -->
169                                        <!-- Add information about energy estimation plugin -->
170                                        <xsl:apply-templates select="$nestedDoc//energyEstimationPlugin[resources/class = $resourceClass]"/>                                   
171                                </xsl:otherwise>
172                        </xsl:choose>
173                        <!-- Copy all children of powerProfile -->
174                        <xsl:copy-of select="@*|node()" />             
175                </xsl:copy>     
176               
177        </xsl:template> 
178       
179         <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*"/> 
180                <xsl:apply-templates/> </xsl:copy> </xsl:template> 
181
182</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.