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

Revision 876, 4.8 KB checked in by gosiaw, 12 years ago (diff)

timeEstimationPlugin and energyEstimationPlugin templates added

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                        <!-- Find appropriate resources (identified by class, type and name(s)) and add their names here -->
79                        <xsl:variable name="resourceClass"><xsl:value-of select="resources/class"/></xsl:variable>
80<!--                    <xsl:value-of select="$resourceClass"/>-->
81                        <xsl:variable name="resourceType"><xsl:value-of select="resources/type"/></xsl:variable>
82<!--                    <xsl:value-of select="$resourceType"/>-->
83                        <xsl:variable name="resourceNames"><xsl:value-of select="resources/name"/></xsl:variable>
84                        <xsl:variable name="xpath">$rootDoc//computingResource[@class=<xsl:value-of select="$resourceClass"/> and @type=<xsl:value-of select="$resourceType"/>]</xsl:variable>
85<!--                    <xsl:value-of select="$xpath"></xsl:value-of>-->
86
87                        <!-- TODO: Names are ignored now, for simplicity. Should be changed! -->
88                        <xsl:choose>
89                                <xsl:when test="$resourceClass != '' and $resourceType != ''">
90<!--                                    <xsl:value-of select="$resourceClass"/>-->
91<!--                                    <xsl:value-of select="$resourceType"/>-->
92                                        <xsl:apply-templates select="$rootDoc//computingResource[@class=$resourceClass and @type=$resourceType]" mode="addResorceName"/>
93                                </xsl:when>
94                                <xsl:otherwise>
95<!--                                    <xsl:value-of select="$resourceClass"/>-->
96                                        <xsl:apply-templates select="$rootDoc//computingResource[@class=$resourceClass]" mode="addResorceName"/>
97                                </xsl:otherwise>
98                        </xsl:choose>
99                       
100                       
101                       
102                </xsl:element>
103        </xsl:template>
104
105        <xsl:template match="energyEstimationPlugin">
106        </xsl:template>
107       
108        <xsl:template match="computingResource">
109                <xsl:copy copy-namespaces="no">
110                        <xsl:copy-of select="@*" />
111                        <!-- Find nested elements in appropriate order and copy them -->
112                        <!-- resourceUnit -->
113                        <xsl:apply-templates select="resourceUnit" />
114                        <!-- parameter -->
115                        <xsl:apply-templates select="parameter" />
116                        <!-- profile -->
117                        <xsl:apply-templates select="profile" />
118                        <!-- location -->
119                        <xsl:apply-templates select="location" />
120                        <!-- computingResource -->
121                        <xsl:apply-templates select="computingResource" />
122                </xsl:copy>
123        </xsl:template>
124
125        <xsl:template match="computingResource" mode="addResorceName">
126                <xsl:element name="resourceName">
127                        <xsl:value-of select="../@name"></xsl:value-of>
128                </xsl:element>
129        </xsl:template>
130       
131        <xsl:template match="resourceUnit | parameter | profile | location">
132                <xsl:copy-of select="." copy-namespaces="no" />
133        </xsl:template>
134
135        <!-- <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*"/>
136                <xsl:apply-templates/> </xsl:copy> </xsl:template> -->
137
138</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.