Ignore:
Timestamp:
03/13/13 09:27:32 (12 years ago)
Author:
gosiaw
Message:

Creating templates corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DCWoRMS/branches/coolemall/src/test/DEBBTranslator/xml/PLMXMLTranslator.xsl

    r946 r949  
    1717        <xsl:param name="resourceUnitClasses" select="resourceUnitClasses" /> 
    1818 
     19        <!-- Information from which level the translator should start moving information to templates --> 
     20        <xsl:variable name="templateStartLevel" select="'Node'" /> 
     21 
    1922        <!-- Specification of the output document --> 
    2023        <xsl:output method="xml" version="1.0" encoding="UTF-8" 
     
    3134        <xsl:template match="/"> 
    3235                <xsl:element name="environment"> 
    33                         <xsl:attribute name="xsi:noNamespaceSchemaLocation">DCWormsResSchema.xsd</xsl:attribute> 
     36                        <xsl:attribute name="xsi:noNamespaceSchemaLocation">../DCWormsResSchema.xsd</xsl:attribute> 
     37                         
    3438                        <xsl:element name="resources"> 
    3539                                <!-- Iterate the document, create hierarchy and "links" to templates --> 
     
    4044                        </xsl:element> 
    4145                         
    42                         <xsl:element name="templates"> 
    43                                 <!-- Iterate the document and createTemplates --> 
    44                                 <xsl:apply-templates select="//plm:InstanceGraph" mode="createTemplates"/> 
    45                         </xsl:element> 
     46                        <xsl:if test="fun:containsTemplates()"> 
     47                                <xsl:element name="templates"> 
     48                                        <!-- Iterate the document and createTemplates --> 
     49                                        <xsl:apply-templates select="//plm:InstanceGraph" mode="createTemplates"/> 
     50                                </xsl:element>                   
     51                        </xsl:if> 
    4652                         
    4753                </xsl:element> 
     
    5561 
    5662        <xsl:template match="plm:InstanceGraph" mode="createTemplates"> 
    57                 <xsl:apply-templates select="plm:ProductRevisionView" mode="createTemplates"/> 
     63                <xsl:apply-templates select="//plm:ProductRevisionView[plm:UserData/plm:UserValue/@title='DEBBLevel' and plm:UserData/plm:UserValue/@value=$templateStartLevel]" mode="createTemplates"/> 
    5864        </xsl:template> 
    5965 
     
    6874                                <xsl:attribute name="name"><xsl:value-of select="@name" /></xsl:attribute> 
    6975 
     76 
     77                                <!-- Find corresponding ProductRevisionView and let it translate itself --> 
     78<!--                            <xsl:apply-templates--> 
     79<!--                                    select="//plm:ProductRevisionView[@id=$productInstanceId]" />--> 
     80                                <xsl:apply-templates select="//plm:ProductRevisionView[@id=$productInstanceId]" mode="createHierarchy"/> 
    7081 
    7182                                <!-- Add hostnames, labels, locations, sequences, etc. --> 
     
    109120                                                </xsl:element> 
    110121                                        </xsl:element> 
    111                                 </xsl:if> 
    112                                  
    113                                 <!-- Find corresponding ProductRevisionView and let it translate itself --> 
    114 <!--                            <xsl:apply-templates--> 
    115 <!--                                    select="//plm:ProductRevisionView[@id=$productInstanceId]" />--> 
    116                                 <xsl:apply-templates select="//plm:ProductRevisionView[@id=$productInstanceId]" mode="createHierarchy"/> 
    117                                  
    118                                  
     122                                </xsl:if>                                
    119123                        </xsl:element> 
    120124                </xsl:if> 
     
    134138                        select="plm:UserData/plm:UserValue[@title='DEBBComponentId']/@value" /> 
    135139         
    136                 <xsl:element name="templateId"> 
     140                <xsl:attribute name="class"> 
    137141                        <xsl:value-of select="$debbLevel"/> 
    138                         <xsl:text>-</xsl:text> 
    139                         <xsl:value-of select="$debbComponentId"/> 
    140                 </xsl:element> 
    141  
    142                 <!-- Iterate children and ask them to translate themselves --> 
    143                 <xsl:for-each select="1 to count($tokenizedText)"> 
    144                         <xsl:variable name="index" select="." /> 
    145                         <xsl:apply-templates 
    146                                 select="$rootDoc//plm:ProductInstance[@id=$tokenizedText[$index]]" mode="createHierarchy"/> 
    147                 </xsl:for-each> 
    148                  
     142                </xsl:attribute> 
     143                 
     144                <xsl:choose> 
     145                        <xsl:when test="$debbLevel = $templateStartLevel"> 
     146                                <!-- Change into template. The rest of the hierarchy will be in template. --> 
     147                                <xsl:element name="templateId"> 
     148                                        <xsl:value-of select="$debbLevel"/> 
     149                                        <xsl:text>-</xsl:text> 
     150                                        <xsl:value-of select="$debbComponentId"/> 
     151                                </xsl:element>           
     152                        </xsl:when> 
     153                        <xsl:otherwise> 
     154                                <!-- Iterate children and ask them to translate themselves --> 
     155                                <xsl:for-each select="1 to count($tokenizedText)"> 
     156                                        <xsl:variable name="index" select="." /> 
     157                                        <xsl:apply-templates 
     158                                                select="$rootDoc//plm:ProductInstance[@id=$tokenizedText[$index]]" mode="createHierarchy"/> 
     159                                </xsl:for-each>                  
     160                        </xsl:otherwise> 
     161                </xsl:choose> 
    149162        </xsl:template> 
    150163         
     
    341354                 
    342355         
     356        <xsl:function name="fun:containsTemplates"> 
     357                <xsl:variable name="productRevisionViews" select="$rootDoc//plm:ProductRevisionView[UserData/UserValue/@DEBBLevel=$templateStartLevel]"/> 
     358                <xsl:value-of select="count($productRevisionViews) > 0"/> 
     359        </xsl:function>  
    343360         
    344361</xsl:stylesheet> 
Note: See TracChangeset for help on using the changeset viewer.