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

Revision 847, 4.4 KB checked in by gosiaw, 12 years ago (diff)
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="resources" />
40                </xsl:copy>
41        </xsl:template>
42
43        <xsl:template match="resources">
44                <xsl:copy copy-namespaces="no">
45                        <xsl:apply-templates select="//resources/computingResource" />
46                        <xsl:element name="scheduler">
47                                <xsl:attribute name="class">Cluster</xsl:attribute>
48                                <xsl:attribute name="name">cluster</xsl:attribute>
49                                <xsl:apply-templates select="$nestedDoc//schedulingPlugin" />
50                        </xsl:element>
51                </xsl:copy>
52        </xsl:template>
53
54        <xsl:template match="schedulingPlugin">
55                <xsl:element name="schedulingPlugin">
56                        <xsl:element name="name">
57                                <xsl:value-of select="name" />
58                        </xsl:element>
59                        <xsl:if test="frequency != ''">
60                                <xsl:element name="frequency">
61                                        <xsl:value-of select="frequency"/>
62                                </xsl:element>
63                        </xsl:if>
64                </xsl:element>
65                <xsl:element name="managedComputingResources">
66                        <!-- TODO: This parameter should be taken from somewhere. -->
67                        <xsl:attribute name="include">false</xsl:attribute>
68                        <!-- Find appropriate resources (identified by class, type and name(s)) and add their names here -->
69                        <xsl:variable name="resourceClass"><xsl:value-of select="resources/class"/></xsl:variable>
70<!--                    <xsl:value-of select="$resourceClass"/>-->
71                        <xsl:variable name="resourceType"><xsl:value-of select="resources/type"/></xsl:variable>
72<!--                    <xsl:value-of select="$resourceType"/>-->
73                        <xsl:variable name="resourceNames"><xsl:value-of select="resources/name"/></xsl:variable>
74                        <xsl:variable name="xpath">$rootDoc//computingResource[@class=<xsl:value-of select="$resourceClass"/> and @type=<xsl:value-of select="$resourceType"/>]</xsl:variable>
75<!--                    <xsl:value-of select="$xpath"></xsl:value-of>-->
76                        <xsl:choose>
77                                <xsl:when test="$resourceClass != '' and $resourceType != ''">
78<!--                                    <xsl:value-of select="$resourceClass"/>-->
79<!--                                    <xsl:value-of select="$resourceType"/>-->
80                                        <xsl:apply-templates select="$rootDoc//computingResource[@class=$resourceClass and @type=$resourceType]" mode="addResorceName"/>
81                                </xsl:when>
82                                <xsl:otherwise>
83<!--                                    <xsl:value-of select="$resourceClass"/>-->
84                                        <xsl:apply-templates select="$rootDoc//computingResource[@class=$resourceClass]" mode="addResorceName"/>
85                                </xsl:otherwise>
86                        </xsl:choose>
87                       
88                       
89                       
90                </xsl:element>
91        </xsl:template>
92
93        <xsl:template match="computingResource">
94                <xsl:copy copy-namespaces="no">
95                        <xsl:copy-of select="@*" />
96                        <!-- Find nested elements in appropriate order and copy them -->
97                        <!-- resourceUnit -->
98                        <xsl:apply-templates select="resourceUnit" />
99                        <!-- parameter -->
100                        <xsl:apply-templates select="parameter" />
101                        <!-- profile -->
102                        <xsl:apply-templates select="profile" />
103                        <!-- location -->
104                        <xsl:apply-templates select="location" />
105                        <!-- computingResource -->
106                        <xsl:apply-templates select="computingResource" />
107                </xsl:copy>
108        </xsl:template>
109
110        <xsl:template match="computingResource" mode="addResorceName">
111                <xsl:element name="resourceName">
112                        <xsl:value-of select="../@name"></xsl:value-of>
113                </xsl:element>
114        </xsl:template>
115       
116        <xsl:template match="resourceUnit | parameter | profile | location">
117                <xsl:copy-of select="." copy-namespaces="no" />
118        </xsl:template>
119
120        <!-- <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*"/>
121                <xsl:apply-templates/> </xsl:copy> </xsl:template> -->
122
123</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.