Ignore:
Timestamp:
02/27/13 13:07:49 (12 years ago)
Author:
gosiaw
Message:

Handling resource names added.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/trunk/src/test/DEBBTranslator/xml/DCWoRMSDEBBUpdater.xsl

    r889 r890  
    4848                                <xsl:attribute name="class">Cluster</xsl:attribute> 
    4949                                <xsl:attribute name="name">cluster</xsl:attribute> 
    50                                 <!-- In first version, for simplicity, we assume we have only 
    51                                  one scheduler and one scheduling plugin. If $additionalInformationFileName 
    52                                  contains more than one, the rest is ignored --> 
     50                                <!-- In first version, for simplicity, we assume we have only one scheduler  
     51                                        and one scheduling plugin. If $additionalInformationFileName contains more  
     52                                        than one, the rest is ignored --> 
    5353                                <xsl:apply-templates select="$nestedDoc//schedulingPlugin[1]" /> 
    5454                        </xsl:element> 
    5555                </xsl:copy> 
    5656        </xsl:template> 
    57          
     57 
    5858        <xsl:template match="timeEstimationPlugin"> 
    5959                <xsl:element name="timeEstimationPlugin"> 
     
    6363                </xsl:element> 
    6464        </xsl:template> 
    65          
     65 
    6666 
    6767        <xsl:template match="schedulingPlugin"> 
     68                <xsl:variable name="pluginName" select="name" /> 
    6869                <xsl:element name="schedulingPlugin"> 
    6970                        <xsl:element name="name"> 
    70                                 <xsl:value-of select="name" /> 
     71                                <xsl:value-of select="$pluginName" /> 
    7172                        </xsl:element> 
    7273                        <xsl:if test="frequency != ''"> 
    7374                                <xsl:element name="frequency"> 
    74                                         <xsl:value-of select="frequency"/> 
     75                                        <xsl:value-of select="frequency" /> 
    7576                                </xsl:element> 
    7677                        </xsl:if> 
     
    7980                        <!-- TODO: This parameter should be taken from somewhere. --> 
    8081                        <xsl:attribute name="include">false</xsl:attribute> 
     82 
     83                        <!-- Find appropriate resources (identified by class, type and name(s))  
     84                                and add their names here --> 
     85                        <xsl:variable name="resourceClass"> 
     86                                <xsl:value-of select="resources/class" /> 
     87                        </xsl:variable> 
     88                        <!-- <xsl:value-of select="$resourceClass"/> --> 
     89                        <xsl:variable name="resourceType"> 
     90                                <xsl:value-of select="resources/type" /> 
     91                        </xsl:variable> 
     92                        <!-- <xsl:value-of select="$resourceType"/> --> 
    8193                         
    82                         <!-- Find appropriate resources (identified by class, type and name(s)) and add their names here --> 
    83                         <xsl:variable name="resourceClass"><xsl:value-of select="resources/class"/></xsl:variable> 
    84 <!--                    <xsl:value-of select="$resourceClass"/>--> 
    85                         <xsl:variable name="resourceType"><xsl:value-of select="resources/type"/></xsl:variable> 
    86 <!--                    <xsl:value-of select="$resourceType"/>--> 
    87                         <xsl:variable name="resourceNames"><xsl:value-of select="resources/name"/></xsl:variable> 
    88                         <xsl:variable name="xpath">$rootDoc//computingResource[@class=<xsl:value-of select="$resourceClass"/> and @type=<xsl:value-of select="$resourceType"/>]</xsl:variable> 
    89 <!--                    <xsl:value-of select="$xpath"></xsl:value-of>--> 
    90  
    91                         <!-- TODO: Names are ignored now, for simplicity. Should be changed! --> 
     94                        <!-- Not clear why it does not work this way :/ --> 
     95                        <!-- <xsl:variable name="resourceNames"><xsl:value-of select="resources/name"/></xsl:variable> --> 
     96                        <xsl:variable name="resourceNames" 
     97                                select="$nestedDoc//schedulingPlugin[name=$pluginName]/resources/name" /> 
     98 
    9299                        <xsl:choose> 
    93                                 <xsl:when test="$resourceClass != '' and $resourceType != ''"> 
    94 <!--                                    <xsl:value-of select="$resourceClass"/>--> 
    95 <!--                                    <xsl:value-of select="$resourceType"/>--> 
    96                                         <xsl:apply-templates select="$rootDoc//computingResource[@class=$resourceClass and @type=$resourceType]" mode="addResorceName"/> 
     100                                <!-- Resource names are present --> 
     101                                <xsl:when test="count($resourceNames) > 0"> 
     102                                        <xsl:for-each select="$resourceNames"> 
     103                                                <xsl:variable name="index" select="position()" /> 
     104                                                <xsl:variable name="resourceName" select="." /> 
     105                                                <xsl:choose> 
     106                                                        <!-- Resource type is present --> 
     107                                                        <xsl:when test="$resourceType != ''"> 
     108                                                                <xsl:apply-templates 
     109                                                                        select="$rootDoc//computingResource[@class=$resourceClass and @type=$resourceType and @name=$resourceName]" 
     110                                                                        mode="addResorceName" /> 
     111                                                        </xsl:when> 
     112                                                        <xsl:otherwise> 
     113                                                                <xsl:apply-templates 
     114                                                                        select="$rootDoc//computingResource[@class=$resourceClass and @name=$resourceName]" 
     115                                                                        mode="addResorceName" /> 
     116                                                        </xsl:otherwise> 
     117                                                </xsl:choose> 
     118                                        </xsl:for-each> 
    97119                                </xsl:when> 
     120                                <!-- No resource names --> 
    98121                                <xsl:otherwise> 
    99 <!--                                    <xsl:value-of select="$resourceClass"/>--> 
    100                                         <xsl:apply-templates select="$rootDoc//computingResource[@class=$resourceClass]" mode="addResorceName"/> 
     122                                        <xsl:choose> 
     123                                                <!-- Resource type is present --> 
     124                                                <xsl:when test="$resourceType != ''"> 
     125                                                        <xsl:apply-templates 
     126                                                                select="$rootDoc//computingResource[@class=$resourceClass and @type=$resourceType]" 
     127                                                                mode="addResorceName" /> 
     128                                                </xsl:when> 
     129                                                <xsl:otherwise> 
     130                                                        <xsl:apply-templates 
     131                                                                select="$rootDoc//computingResource[@class=$resourceClass]" 
     132                                                                mode="addResorceName" /> 
     133                                                </xsl:otherwise> 
     134                                        </xsl:choose> 
    101135                                </xsl:otherwise> 
    102136                        </xsl:choose> 
    103                          
    104                          
    105                          
    106137                </xsl:element> 
    107138        </xsl:template> 
     
    114145                </xsl:element> 
    115146        </xsl:template> 
    116          
     147 
    117148        <xsl:template match="computingResource"> 
    118149                <xsl:copy copy-namespaces="no"> 
     
    124155                        <xsl:apply-templates select="parameter" /> 
    125156                        <!-- profile --> 
    126                         <xsl:apply-templates select="profile" />                 
     157                        <xsl:apply-templates select="profile" /> 
    127158                        <!-- location --> 
    128159                        <xsl:apply-templates select="location" /> 
     
    134165        <xsl:template match="computingResource" mode="addResorceName"> 
    135166                <xsl:element name="resourceName"> 
    136                         <xsl:value-of select="../@name"></xsl:value-of> 
    137                 </xsl:element> 
    138         </xsl:template><!-- 
    139          
    140         <xsl:template match="powerProfile" mode="addEstimationPlugin"> 
    141                 <xsl:element name="energyEstimationPlugin"> 
    142                         <xsl:element name="name"> 
    143                                 <xsl:value-of select="name" /> 
    144                         </xsl:element> 
    145                 </xsl:element>   
    146         </xsl:template>  
    147          
    148         --><xsl:template match="resourceUnit | parameter | location"> 
     167                        <!-- <xsl:value-of select="../@name"></xsl:value-of> --> 
     168                        <xsl:value-of select="@name"></xsl:value-of> 
     169                </xsl:element> 
     170        </xsl:template><!-- <xsl:template match="powerProfile" mode="addEstimationPlugin">  
     171                <xsl:element name="energyEstimationPlugin"> <xsl:element name="name"> <xsl:value-of  
     172                select="name" /> </xsl:element> </xsl:element> </xsl:template> --> 
     173        <xsl:template match="resourceUnit | parameter | location"> 
    149174                <xsl:copy-of select="." copy-namespaces="no" /> 
    150175        </xsl:template> 
     
    154179                        <xsl:copy-of select="@*" /> 
    155180                        <xsl:apply-templates select="powerProfile" /> 
    156                 </xsl:copy>                                      
    157         </xsl:template> 
    158  
    159         <xsl:template match="powerProfile">      
     181                </xsl:copy> 
     182        </xsl:template> 
     183 
     184        <xsl:template match="powerProfile"> 
    160185                <xsl:copy copy-namespaces="no"> 
    161186                        <xsl:variable name="resourceClass" select="../../@class"></xsl:variable> 
    162187                        <xsl:variable name="resourceType" select="../../@type"></xsl:variable> 
    163188                        <xsl:variable name="resourceName" select="../../@name"></xsl:variable> 
    164                          
     189 
    165190                        <xsl:choose> 
    166191                                <xsl:when test="$resourceType != ''"> 
    167192                                        <!-- resource class and type --> 
    168193                                        <!-- Add information about energy estimation plugin --> 
    169                                         <xsl:apply-templates select="$nestedDoc//energyEstimationPlugin[resources/class = $resourceClass and resources/type = $resourceType]"/>                                  
     194                                        <xsl:apply-templates 
     195                                                select="$nestedDoc//energyEstimationPlugin[resources/class = $resourceClass and resources/type = $resourceType]" /> 
    170196                                </xsl:when> 
    171197                                <xsl:otherwise> 
    172198                                        <!-- resource class only --> 
    173199                                        <!-- Add information about energy estimation plugin --> 
    174                                         <xsl:apply-templates select="$nestedDoc//energyEstimationPlugin[resources/class = $resourceClass]"/>                                     
     200                                        <xsl:apply-templates 
     201                                                select="$nestedDoc//energyEstimationPlugin[resources/class = $resourceClass]" /> 
    175202                                </xsl:otherwise> 
    176203                        </xsl:choose> 
    177204                        <!-- Copy all children of powerProfile --> 
    178                         <xsl:copy-of select="@*|node()" />               
    179                 </xsl:copy>      
    180                  
    181         </xsl:template>  
    182          
    183          <xsl:template match="@*|node()"> <xsl:copy> <xsl:apply-templates select="@*"/>  
    184                 <xsl:apply-templates/> </xsl:copy> </xsl:template>  
     205                        <xsl:copy-of select="@*|node()" /> 
     206                </xsl:copy> 
     207 
     208        </xsl:template> 
     209 
     210        <xsl:template match="@*|node()"> 
     211                <xsl:copy> 
     212                        <xsl:apply-templates select="@*" /> 
     213                        <xsl:apply-templates /> 
     214                </xsl:copy> 
     215        </xsl:template> 
    185216 
    186217</xsl:stylesheet> 
Note: See TracChangeset for help on using the changeset viewer.