Orb/utils/sysdefupgrade.xsl
changeset 3 d8fccb2cd802
parent 1 82f11024044a
equal deleted inserted replaced
2:932c358ece3e 3:d8fccb2cd802
       
     1 <?xml version="1.0"?>
       
     2 <!--
       
     3 Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 All rights reserved.-->
       
     5  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       
     6 <xsl:key name="id" match="*[@name]" use="@name"/>
       
     7 	<xsl:param name="td"/>
       
     8 	
       
     9 <xsl:template match="/*">
       
    10 	<xsl:message>Cannot process this document</xsl:message>
       
    11 </xsl:template>
       
    12 
       
    13 <xsl:template match="/SystemDefinition[@schema='2.0.1']">
       
    14 <xsl:call-template name="DTD"/>
       
    15 <SystemDefinition schema="3.0.0">
       
    16 	<systemModel name="{@name}">
       
    17 		<xsl:apply-templates select="systemModel/layer"/>
       
    18 	</systemModel>
       
    19 </SystemDefinition>
       
    20 </xsl:template>
       
    21 
       
    22 <xsl:template match="@*"/>
       
    23 
       
    24 <xsl:template match="@name"> 
       
    25 	<!-- throw an error if there are duplicate IDs -->
       
    26 	<xsl:if test="count(key('id',.))!=1">
       
    27 		<xsl:message>Duplicate ID, cannot transform: <xsl:value-of select="."/></xsl:message>
       
    28 	</xsl:if>
       
    29 	<xsl:attribute name="id"><xsl:value-of select="."/></xsl:attribute>
       
    30 </xsl:template>
       
    31 
       
    32 <xsl:template match="@long-name">
       
    33 	<xsl:attribute name="name"><xsl:value-of select="."/></xsl:attribute>
       
    34 </xsl:template>
       
    35 
       
    36 
       
    37 
       
    38 <xsl:template match="layer|collection">
       
    39 	<xsl:copy>
       
    40 		<xsl:apply-templates select="@*"/>
       
    41 		<xsl:apply-templates select="*|comment()"/>
       
    42 	</xsl:copy>
       
    43 </xsl:template>
       
    44 
       
    45 
       
    46 <xsl:template match="block|subblock">
       
    47 	<package>
       
    48 		<xsl:apply-templates select="@name|@long-name|@level|@span|@levels|@tech_domain"/>
       
    49 		<xsl:if test="$td!=''">
       
    50 			<xsl:for-each select="document($td)//block[@name=current()/@name]">
       
    51 				<xsl:attribute name="tech-domain"><xsl:value-of select="@tech_domain"/></xsl:attribute>
       
    52 			</xsl:for-each>
       
    53 		</xsl:if>
       
    54 		<xsl:apply-templates select="*|comment()"/>
       
    55 	</package>
       
    56 </xsl:template>
       
    57 
       
    58 
       
    59 <xsl:template match="component">
       
    60 	<xsl:copy>
       
    61 		<xsl:apply-templates select="@name|@long-name|@deprecated|@introduced|@filter|@purpose"/>
       
    62 		<xsl:call-template name="class">
       
    63 			<xsl:with-param name="remove">placeholder PC test</xsl:with-param>
       
    64 			<xsl:with-param name="add">
       
    65 				<xsl:if test="@plugin='Y'">plugin</xsl:if>
       
    66 			</xsl:with-param>
       
    67 		</xsl:call-template>
       
    68 		<xsl:if test="contains(concat(' ',@class,' '),' PC ')">
       
    69 			<xsl:attribute name="target">desktop</xsl:attribute>
       
    70 		</xsl:if>
       
    71 		<xsl:apply-templates select="*|comment()"/>		
       
    72 	</xsl:copy>
       
    73 </xsl:template>
       
    74 
       
    75 <xsl:template match="unit">
       
    76 	<xsl:copy>
       
    77 		<xsl:apply-templates select="@*"/>
       
    78 	</xsl:copy>
       
    79 </xsl:template>
       
    80 
       
    81 <xsl:template match="@levels|@level|@span|@deprecated|@introduced|@filter|unit/@*|comment()|@purpose">
       
    82 	<xsl:copy-of select="."/>
       
    83 </xsl:template>
       
    84 
       
    85 <xsl:template match="unit/@mrp|unit/@bldFile">
       
    86 	<xsl:attribute name="{name()}"><xsl:if test="not(starts-with(.,'/'))">/</xsl:if><xsl:value-of select="."/></xsl:attribute>
       
    87 </xsl:template>
       
    88 
       
    89 <xsl:template name="class"><xsl:param name="remove"/><xsl:param name="add"/>
       
    90 	<xsl:param name="class" select="normalize-space(@class)"/>
       
    91 	<xsl:variable name="r">
       
    92 		<xsl:text> </xsl:text>
       
    93 		<xsl:choose>
       
    94 			<xsl:when test="contains($remove,' ')"><xsl:value-of select="substring-before($remove,' ')"/></xsl:when>
       
    95 			<xsl:otherwise><xsl:value-of select="$remove"/></xsl:otherwise>
       
    96 		</xsl:choose>
       
    97 		<xsl:text> </xsl:text>
       
    98 	</xsl:variable>
       
    99 	<xsl:variable name="c">
       
   100 		<xsl:choose>
       
   101 			<xsl:when test="contains(concat(' ',$class,' '),$r)">
       
   102 				<xsl:value-of select="substring-before(concat(' ',$class,' '),$r)"/>
       
   103 				<xsl:text> </xsl:text>
       
   104 				<xsl:value-of select="substring-after(concat(' ',$class,' '),$r)"/>
       
   105 			</xsl:when>
       
   106 			<xsl:otherwise><xsl:value-of select="$class"/></xsl:otherwise>
       
   107 		</xsl:choose>
       
   108 		<xsl:if test="normalize-space($add)!=''"><xsl:value-of select="concat(' ',normalize-space($add))"/></xsl:if>
       
   109 	</xsl:variable>
       
   110 	<xsl:choose>
       
   111 		<xsl:when test="contains($remove,' ')">
       
   112 			<xsl:call-template name="class">
       
   113 				<xsl:with-param name="remove" select="substring-after($remove,' ')"/>
       
   114 				<xsl:with-param name="class" select="$c"/>
       
   115 			</xsl:call-template>
       
   116 		</xsl:when>
       
   117 		<xsl:when test="normalize-space($c)!=''">
       
   118 			<xsl:attribute name="class">
       
   119 				<xsl:value-of select="normalize-space($c)"/>
       
   120 			</xsl:attribute>
       
   121 		</xsl:when>
       
   122 	</xsl:choose>
       
   123 </xsl:template>
       
   124 
       
   125 <xsl:template match="@tech_domain" priority="5">
       
   126 	<xsl:attribute name="tech-domain"><xsl:value-of select="."/></xsl:attribute>
       
   127 </xsl:template>
       
   128 
       
   129 <xsl:template name="DTD">
       
   130 <xsl:text disable-output-escaping="yes"><![CDATA[]]></xsl:text>
       
   131 </xsl:template>
       
   132 
       
   133 </xsl:stylesheet>