metatools/sysdeftools/lib/test-model.xsl
changeset 624 f70b728ea30c
child 656 88e01c8f013e
equal deleted inserted replaced
621:96fee2635b19 624:f70b728ea30c
       
     1 <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
       
     2 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 	All rights reserved.
       
     4 	This component and the accompanying materials are made available
       
     5 	under the terms of the License "Eclipse Public License v1.0"
       
     6 	which accompanies this distribution, and is available
       
     7 	at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 
       
     9 	Initial Contributors:
       
    10 	Nokia Corporation - initial contribution.
       
    11 	Contributors:
       
    12 	Description:
       
    13 	Module containing the validation logic for system definition 3.0.0 syntax
       
    14 -->
       
    15 	<xsl:key name="named" match="*[ancestor::systemModel]" use="@name"/>
       
    16 	<xsl:param name="Filename"/> <!--<Filename> - (optional) the full system model path to the current sysdef file. This is needed to determine non-standard path errors -->
       
    17 	<xsl:variable name="info" select="document(/model//info[@type='extra']/@href,/model)//c"/>
       
    18 
       
    19 	<xsl:variable name="all-ids">
       
    20 		<xsl:apply-templates select="document(/model/sysdef/@href)| SystemDefinition" mode="ids"/>
       
    21 	</xsl:variable>
       
    22 
       
    23  
       
    24 <xsl:template match="/model" priority="-1">
       
    25 	<xsl:apply-templates select="." mode="check"/>
       
    26 </xsl:template>
       
    27 
       
    28 <xsl:template match="/model" mode="check">
       
    29 	<xsl:for-each select="sysdef">
       
    30 		<xsl:apply-templates select="document (@href,. )/*">
       
    31 			<xsl:with-param name="filename">
       
    32 				<xsl:choose>
       
    33 					<xsl:when test="starts-with(current()/@href,current()/@rootpath)">
       
    34 						<xsl:value-of select="substring-after(current()/@href,current()/@rootpath)"/>
       
    35 					</xsl:when>
       
    36 					<xsl:otherwise>
       
    37 						<xsl:value-of select="@href"/>
       
    38 					</xsl:otherwise>
       
    39 				</xsl:choose>
       
    40 			 </xsl:with-param>
       
    41 		</xsl:apply-templates>
       
    42 	</xsl:for-each>
       
    43 
       
    44 
       
    45 
       
    46 <xsl:apply-templates mode="x-check" select="document (//info[@type='vp']/@href)/*">
       
    47 	<xsl:with-param name="sysdef" select="document (sysdef/@href)/*"/>
       
    48 </xsl:apply-templates>
       
    49 
       
    50 <xsl:apply-templates mode="x-check" select="document (//info[@type='build']/@href)/*">
       
    51 	<xsl:with-param name="sysdef" select="document (sysdef/@href)/*"/>
       
    52 </xsl:apply-templates>
       
    53 </xsl:template>
       
    54 
       
    55 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')]" mode="ids">
       
    56 	<xsl:for-each select="//*[@id and not(@href)]"><xsl:value-of select="concat(' ',@id,' ')"/></xsl:for-each>
       
    57 	<xsl:apply-templates select="document(//layer/@href | //package/@href | //collection/@href | //component/@href,.)/*" mode="ids"/>
       
    58 </xsl:template>
       
    59 
       
    60 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')and systemModel]" priority="2">
       
    61 	<xsl:param name="filename" select="$Filename"/>
       
    62 <xsl:call-template name="Section">
       
    63 	<xsl:with-param name="text">System Definition: <xsl:value-of select="*/@name"/></xsl:with-param>
       
    64 	<xsl:with-param name="sub"><xsl:value-of select="(string-length($all-ids) - string-length(translate($all-ids,' ',''))) div 2 "/> items</xsl:with-param>
       
    65 </xsl:call-template>
       
    66 	<xsl:apply-templates select="*">
       
    67 		<xsl:with-param name="filename" select="$filename"/>
       
    68 	</xsl:apply-templates>
       
    69 </xsl:template>
       
    70 
       
    71 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')] | systemModel">
       
    72 	<xsl:param name="filename"  select="$Filename"/>
       
    73 		
       
    74 <xsl:if test="//unit">
       
    75 <xsl:call-template name="Section">
       
    76 	<xsl:with-param name="text"><xsl:value-of select="translate(substring(name(*),1,1),'clp','CLP')"/><xsl:value-of select="substring(name(*),2)"/> Definition: <xsl:value-of select="*/@name"/></xsl:with-param>
       
    77 	<xsl:with-param name="sub"><xsl:value-of select="count(//unit)"/> unit<xsl:if test="count(//unit)!=1">s</xsl:if></xsl:with-param>
       
    78 </xsl:call-template>
       
    79 </xsl:if>
       
    80 <xsl:if test="self::systemModel and not(@name)">
       
    81 	<xsl:call-template name="Error"><xsl:with-param name="text">systemModel element should have a name</xsl:with-param></xsl:call-template>
       
    82 </xsl:if>
       
    83 	<xsl:apply-templates select="*">
       
    84 		<xsl:with-param name="filename" select="$filename"/>
       
    85 	</xsl:apply-templates>
       
    86 </xsl:template>
       
    87 
       
    88 
       
    89 <xsl:template match="@*" mode="valid">
       
    90 	<xsl:call-template name="Error"><xsl:with-param name="text">Attribute <xsl:value-of select="name()"/>="<xsl:value-of select="."/>" is not valid for <xsl:value-of select="name(..)"/></xsl:with-param></xsl:call-template>
       
    91 </xsl:template>
       
    92 
       
    93 <xsl:template match="@before|@id|package/@span|layer/@span|collection/@level|package/@level|package/@levels|layer/@levels" mode="valid"/> <!-- really should check syntax -->
       
    94 
       
    95 <xsl:template match="@name|@href|@filter|package/@version|unit/@version|unit/@prebuilt" mode="valid"/> 
       
    96 
       
    97 <xsl:template match="component/@introduced|component/@deprecated" mode="valid"/> 
       
    98 
       
    99 <xsl:template match="component/@origin-model" mode="valid"/>
       
   100 
       
   101 <xsl:template match="unit/@priority" mode="valid">
       
   102 	<xsl:call-template name="Note"><xsl:with-param name="text">Attribute <xsl:value-of select="name()"/> is deprecated</xsl:with-param></xsl:call-template>
       
   103 </xsl:template>
       
   104 
       
   105 
       
   106 <xsl:template match="@*[namespace-uri()!='']" mode="valid"> 
       
   107 	<xsl:call-template name="Note"><xsl:with-param name="text">Extension attribute <xsl:value-of select="local-name()"/>="<xsl:value-of select="."/>" in namespace <xsl:value-of select="namespace-uri()"/></xsl:with-param></xsl:call-template>
       
   108 </xsl:template>
       
   109 
       
   110 <xsl:template match="@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='proFile']" mode="valid"/> 
       
   111 	
       
   112 
       
   113 <xsl:template match="@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='qmakeArgs']" mode="valid"> 
       
   114 	<xsl:call-template name="Note"><xsl:with-param name="text">Should avoid using extension attribute <xsl:value-of select="local-name()"/>="<xsl:value-of select="."/>" in namespace <xsl:value-of select="namespace-uri()"/></xsl:with-param></xsl:call-template>
       
   115 </xsl:template>
       
   116 
       
   117 
       
   118 <xsl:template match="@replace" mode="valid">
       
   119 	<xsl:if test="/SystemDefinition[@schema='3.0.0']">
       
   120 		<xsl:call-template name="Error"><xsl:with-param name="text">Attribute <b><xsl:value-of select="name()"/></b>="<xsl:value-of select="."/>" not valid in schema <xsl:value-of select="/SystemDefinition/@schema"/>. Must use schema 3.0.1 or higher</xsl:with-param></xsl:call-template>
       
   121 	</xsl:if>
       
   122 </xsl:template>
       
   123 
       
   124 
       
   125 
       
   126 <xsl:template name="validate-class">
       
   127 	<ok>plugin</ok>
       
   128 	<ok>doc</ok>
       
   129 	<ok>tool</ok>
       
   130 	<ok>config</ok>
       
   131 	<ok>api</ok>
       
   132 	<w d="deprecated">test</w>
       
   133 </xsl:template>
       
   134 
       
   135 <xsl:template name="validate-purpose">
       
   136 	<ok>mandatory</ok>
       
   137 	<ok>optional</ok>
       
   138 	<ok>development</ok>
       
   139 </xsl:template>
       
   140 <xsl:template name="validate-target">
       
   141 	<ok>other</ok>
       
   142 	<ok>desktop</ok>
       
   143 	<ok>device</ok>
       
   144 </xsl:template>
       
   145 
       
   146 
       
   147 <xsl:template name="validate-tech-domain">
       
   148 	<ok>lo</ok>
       
   149 	<ok>hb</ok>
       
   150 	<ok>mm</ok>
       
   151 	<ok>ma</ok>
       
   152 	<ok>pr</ok>
       
   153 	<ok>vc</ok>
       
   154 	<ok>se</ok>
       
   155 	<ok>ui</ok>
       
   156 	<ok>dc</ok>
       
   157 	<ok>de</ok>
       
   158 	<ok>dm</ok>
       
   159 	<ok>rt</ok>
       
   160 	<ok>to</ok>
       
   161 	<w d="Non-standard">ocp</w>
       
   162 </xsl:template>
       
   163 
       
   164 <xsl:template match="component/@class" mode="valid">
       
   165 	<xsl:call-template name="checklist">
       
   166 		<xsl:with-param name="list" select="normalize-space(.)"/>
       
   167 		<xsl:with-param name="values" select="document('')/*/xsl:template[@name=concat('validate-',name(current()))]/*"/>
       
   168 	</xsl:call-template>
       
   169 </xsl:template> 
       
   170 
       
   171 <xsl:template name="checklist">
       
   172 	<xsl:param name="list" select="."/><xsl:param name="values"/><xsl:param name="sep" select="' '"/>
       
   173 	<xsl:variable name="item">
       
   174 		<xsl:choose>
       
   175 			<xsl:when test="contains($list,$sep)"><xsl:value-of select="substring-before($list,$sep)"/></xsl:when>
       
   176 			<xsl:otherwise><xsl:value-of select="$list"/></xsl:otherwise>
       
   177 		</xsl:choose>
       
   178 	</xsl:variable>
       
   179 	<xsl:variable name="v" select="$values[.=$item]"/>
       
   180 	<xsl:choose>
       
   181 		<xsl:when test="not($v)">
       
   182 			<xsl:call-template name="Error"><xsl:with-param name="text">Illegal <xsl:value-of select="name()"/> value <xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</xsl:with-param></xsl:call-template>
       
   183 		</xsl:when> 
       
   184 		<xsl:when test="name($v)='ok'"/> 
       
   185 		<xsl:when test="name($v)='w'">
       
   186 			<xsl:call-template name="Warning"><xsl:with-param name="text"><xsl:value-of select="$v/@d"/> value in <xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</xsl:with-param></xsl:call-template>
       
   187 		</xsl:when> 
       
   188 	</xsl:choose>	
       
   189 	<xsl:if test="contains($list,$sep)">
       
   190 		<xsl:call-template name="checklist">
       
   191 			<xsl:with-param name="list" select="substring-after($list,$sep)"/>
       
   192 			<xsl:with-param name="values" select="$values"/>
       
   193 			<xsl:with-param name="sep" select="$sep"/>			
       
   194 		</xsl:call-template>
       
   195 	</xsl:if>
       
   196 </xsl:template> 
       
   197 
       
   198 
       
   199 <xsl:template match="package/@tech-domain|component/@purpose|component/@target" mode="valid">
       
   200 	<xsl:variable name="v" select="document('')/*/xsl:template[@name=concat('validate-',name(current()))]/*[.=current()]"/>
       
   201 	<xsl:choose>
       
   202 		<xsl:when test="not($v)">
       
   203 			<xsl:call-template name="Error"><xsl:with-param name="text">Illegal <xsl:value-of select="name()"/> value <xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</xsl:with-param></xsl:call-template>
       
   204 		</xsl:when> 
       
   205 		<xsl:when test="name($v)='ok'"/> 
       
   206 		<xsl:when test="name($v)='w'">
       
   207 			<xsl:call-template name="Warning"><xsl:with-param name="text"><xsl:value-of select="$v/@d"/> value in <xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</xsl:with-param></xsl:call-template>
       
   208 		</xsl:when> 
       
   209 	</xsl:choose>
       
   210 </xsl:template> 
       
   211 
       
   212 
       
   213 
       
   214 
       
   215 
       
   216 <xsl:template match="*" priority="-2">
       
   217 	<xsl:call-template name="Error"><xsl:with-param name="text">Element "<xsl:value-of select="name()"/>" is not valid in the context of "<xsl:value-of select="name(..)"/>"</xsl:with-param></xsl:call-template>
       
   218 </xsl:template>
       
   219 
       
   220 <xsl:template match="component[not(parent::collection)] | collection[not(parent::package)] | package[not(parent::package or parent::layer or (parent::SystemDefinition and count(../*)=1))] | layer[not(parent::systemModel)] " priority="3">
       
   221 	<xsl:call-template name="Error"><xsl:with-param name="text"><xsl:value-of select="name()"/> "<xsl:value-of select="@id"/>" has invalid parent <xsl:value-of select="name(..)"/> "<xsl:value-of select="../@id"/>"</xsl:with-param></xsl:call-template>
       
   222 </xsl:template>
       
   223 
       
   224 <xsl:template match="layer | package | collection | component">
       
   225 	<xsl:param name="filename"/>
       
   226 
       
   227 <xsl:apply-templates select="@*" mode="valid"/>
       
   228 <xsl:apply-templates select="@id"/>
       
   229 <xsl:if test="self::component">
       
   230 	<xsl:choose>
       
   231 		<xsl:when test="count(unit[not(@filter | @version)]) = 0 "/>
       
   232 		<xsl:when test="count(unit[not(@version)]) &gt; 1 and @filter='s60'">
       
   233 			<xsl:call-template name="Warning"><xsl:with-param name="text">S60 Component "<xsl:value-of select="@id"/>" has <xsl:value-of select="count(unit)"/> units.</xsl:with-param></xsl:call-template>
       
   234 		</xsl:when>
       
   235 		<xsl:when test="count(unit[not(@version)]) &gt; 1">
       
   236 			<xsl:call-template name="Error"><xsl:with-param name="text">Component "<xsl:value-of select="@id"/>" has <xsl:value-of select="count(unit)"/> units.</xsl:with-param></xsl:call-template>
       
   237 		</xsl:when>
       
   238 	</xsl:choose>
       
   239 	<xsl:choose>
       
   240 		<xsl:when test="unit"/>
       
   241 		<xsl:when test="contains(comment(),'PLACEHOLDER=')"/>
       
   242 		<xsl:when test="comment()">
       
   243 			<xsl:call-template name="Note"><xsl:with-param name="text">Component "<xsl:value-of select="@name"/>" is empty.</xsl:with-param></xsl:call-template>
       
   244 		</xsl:when>
       
   245 		<xsl:when test="not(comment())">
       
   246 			<xsl:call-template name="Warning"><xsl:with-param name="text">Component "<xsl:value-of select="@name"/>" is empty and has no comment</xsl:with-param></xsl:call-template>
       
   247 		</xsl:when>
       
   248 	</xsl:choose>
       
   249 </xsl:if>
       
   250 <xsl:if test="@href">
       
   251 	<xsl:variable name="child" select="document(@href,.)/SystemDefinition"/>
       
   252 	<xsl:if test="@id!=$child/@id">
       
   253 		<xsl:call-template name="Error"><xsl:with-param name="text"><xsl:value-of select="name()"/> "<xsl:value-of select="@id"/>" must match ID in linked file "<xsl:value-of select="@href"/>"</xsl:with-param></xsl:call-template>
       
   254 	</xsl:if>
       
   255 	<xsl:if test="$child/@href">
       
   256 		<xsl:call-template name="Error"><xsl:with-param name="text">linked <xsl:value-of select="name()"/> "<xsl:value-of select="@id"/>" cannot be a link</xsl:with-param></xsl:call-template>
       
   257 	</xsl:if>
       
   258 	<xsl:for-each select="@*[name()!='id']">
       
   259 		<xsl:if test="$child/@*[name()=name(current())]">
       
   260 			<xsl:call-template name="Warning"><xsl:with-param name="text">linked <xsl:value-of select="name()"/> "<xsl:value-of select="@id"/>" has duplicate attribute to linking document. Duplicate ignored.</xsl:with-param></xsl:call-template>
       
   261 		</xsl:if>
       
   262 	</xsl:for-each>
       
   263 	<xsl:if test="*">
       
   264 		<xsl:call-template name="Error"><xsl:with-param name="text"><xsl:value-of select="name()"/> "<xsl:value-of select="@id"/>" cannot have both link and content. Content ignored.</xsl:with-param></xsl:call-template>
       
   265 	</xsl:if>
       
   266 </xsl:if>
       
   267 <xsl:if test="@href and name()!=name(document(@href,.)/SystemDefinition/*)">
       
   268 		<xsl:call-template name="Error"><xsl:with-param name="text"><xsl:value-of select="name()"/> "<xsl:value-of select="@id"/>" must match item in linked file "<xsl:value-of select="@href"/>"</xsl:with-param></xsl:call-template>
       
   269 </xsl:if>
       
   270 <xsl:if test="not(@href)">
       
   271 	<xsl:apply-templates select="*">
       
   272 		<xsl:with-param name="filename" select="$filename"/>
       
   273 	</xsl:apply-templates>
       
   274 </xsl:if>
       
   275 <xsl:if test="@href">
       
   276 	<xsl:apply-templates select="document(@href,.)/*">
       
   277 		<xsl:with-param name="filename">
       
   278 			<xsl:call-template name="normpath">
       
   279 				<xsl:with-param name="path">
       
   280 					<xsl:if test="not(starts-with(current()/@href,'/'))">
       
   281 						<xsl:call-template name="before">
       
   282 							<xsl:with-param name="text" select="$filename"/>
       
   283 						</xsl:call-template>
       
   284 					</xsl:if>
       
   285 					<xsl:value-of select="current()/@href"/>
       
   286 				 </xsl:with-param>
       
   287 			</xsl:call-template>
       
   288 		 </xsl:with-param>
       
   289 	</xsl:apply-templates>
       
   290 </xsl:if>
       
   291 </xsl:template>
       
   292 
       
   293 
       
   294 
       
   295 <xsl:template match="meta">	<xsl:param name="filename"/>
       
   296 	<xsl:apply-templates select="@*"/>
       
   297 </xsl:template>
       
   298 
       
   299 <xsl:template match="meta/@rel | meta/@type | meta/@href"/> <!-- anything is valid -->
       
   300 
       
   301 <xsl:template match="unit">	<xsl:param name="filename"/>
       
   302 	<xsl:apply-templates select="@*">
       
   303 		<xsl:with-param name="filename" select="$filename"/>
       
   304 	</xsl:apply-templates>
       
   305 </xsl:template>
       
   306 
       
   307 
       
   308 <xsl:template match="unit/@* | meta/@*" priority="-1">	
       
   309 	<xsl:apply-templates select="." mode="valid"/>
       
   310 </xsl:template>
       
   311 
       
   312 
       
   313 <xsl:template match="@id" mode="path">
       
   314 	<xsl:choose>
       
   315 		<xsl:when test="contains(.,':')"><xsl:value-of  select="substring-after(.,':')"/></xsl:when>
       
   316 		<xsl:otherwise><xsl:value-of  select="."/></xsl:otherwise>
       
   317 	</xsl:choose>
       
   318 </xsl:template>
       
   319 
       
   320 
       
   321 <xsl:template match="@id">
       
   322 <xsl:if test="contains(concat(' ',substring-after($all-ids,concat(' ',.,' '))),concat(' ',.,' '))">
       
   323 	<xsl:call-template name="Warning"><xsl:with-param name="text">Duplicate ID: <xsl:value-of select="name(..)"/> "<xsl:value-of select="."/>"</xsl:with-param></xsl:call-template>
       
   324 </xsl:if>
       
   325 
       
   326 <xsl:if test="contains(.,':') and not(ancestor::*/namespace::*[name()=substring-before(current(),':')])">
       
   327 	<xsl:call-template name="Error"><xsl:with-param name="text">Undefined namespace for ID "<xsl:value-of select="."/>"</xsl:with-param></xsl:call-template>
       
   328 </xsl:if>
       
   329 
       
   330 </xsl:template>
       
   331 
       
   332 
       
   333 <xsl:template mode="localid" match="*">
       
   334 	<xsl:choose>
       
   335 		<xsl:when test="contains(@id,':')">/<xsl:value-of select="substring-after(@id,':')"/></xsl:when>
       
   336 		<xsl:otherwise><xsl:value-of select="@id"/></xsl:otherwise>
       
   337 	</xsl:choose>
       
   338 </xsl:template>
       
   339 <xsl:template match="@bldFile|@mrp|@base"><xsl:param name="filename"/>
       
   340 <xsl:if test="substring(.,string-length(.))='/'">
       
   341 		<xsl:call-template name="Warning"><xsl:with-param name="text"><code><xsl:value-of select="name()"/></code> path "<xsl:value-of select="."/>" should not end in /</xsl:with-param></xsl:call-template>
       
   342 </xsl:if>
       
   343 <xsl:if test="contains(.,'\')">
       
   344 		<xsl:call-template name="Error"><xsl:with-param name="text"><code><xsl:value-of select="name()"/></code> path "<xsl:value-of select="."/>" must use only forward slashes</xsl:with-param></xsl:call-template>
       
   345 </xsl:if>
       
   346 
       
   347 <!-- this is a realtive path, so just check that it's the expected number of dirs down -->
       
   348 	<xsl:variable name="fullpath"><xsl:call-template name="normpath">
       
   349 				<xsl:with-param name="path">
       
   350 					<xsl:if test="not(starts-with(.,'/'))">
       
   351 						<xsl:call-template name="before">
       
   352 							<xsl:with-param name="text" select="$filename"/>
       
   353 						</xsl:call-template>
       
   354 					</xsl:if>
       
   355 					<xsl:value-of select="."/>
       
   356 				 </xsl:with-param>
       
   357 			</xsl:call-template>
       
   358 		</xsl:variable>
       
   359 		<xsl:variable name="path">
       
   360 			<xsl:choose>
       
   361 				<xsl:when test="not(contains($filename,':'))">/<xsl:for-each select="ancestor::*/@id"><xsl:apply-templates mode="path" select="."/>/</xsl:for-each></xsl:when>
       
   362 				<xsl:otherwise><xsl:for-each select="../../../@id|../../@id"><xsl:apply-templates mode="path" select="."/>/</xsl:for-each></xsl:otherwise>
       
   363 			</xsl:choose>
       
   364 		</xsl:variable>
       
   365 		<xsl:variable name="segment"> <!-- the part relative to the fragment directory -->
       
   366 			<xsl:choose>
       
   367 				<xsl:when test="ancestor::layer">
       
   368 					<xsl:apply-templates select="ancestor::package" mode="localid"/>/<xsl:apply-templates select="ancestor::collection" mode="localid"/>
       
   369 				</xsl:when>
       
   370 				<xsl:when test="ancestor::package">
       
   371 				<xsl:apply-templates select="ancestor::collection" mode="localid"/>
       
   372 				</xsl:when>
       
   373 				<xsl:when test="ancestor::collection"/>
       
   374 			</xsl:choose>/<xsl:apply-templates select="ancestor::component" mode="localid"/>/</xsl:variable>
       
   375 		<xsl:choose>
       
   376 			<xsl:when test="not(starts-with(concat(.,'/'),$segment) or starts-with(concat('/',.,'/'),$segment)) and $path-errors">
       
   377 				<xsl:call-template name="Note"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -&gt; <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="$fullpath"/>"</xsl:with-param></xsl:call-template>
       
   378 			</xsl:when>
       
   379 		</xsl:choose>
       
   380 </xsl:template>
       
   381 
       
   382 
       
   383 <xsl:template match="@bldFile[starts-with(.,'/') or contains(.,'../') or contains(.,':')] | @mrp[starts-with(.,'/') or contains(.,'../') or contains(.,':')] |@base[starts-with(.,'/') or contains(.,'../') or contains(.,':')]"><xsl:param name="filename"/>
       
   384 <xsl:if test="substring(.,string-length(.))='/'">
       
   385 		<xsl:call-template name="Warning"><xsl:with-param name="text"><code><xsl:value-of select="name()"/></code> path "<xsl:value-of select="."/>" should not end in /</xsl:with-param></xsl:call-template>
       
   386 </xsl:if>
       
   387 <xsl:if test="contains(.,'\')">
       
   388 		<xsl:call-template name="Error"><xsl:with-param name="text"><code><xsl:value-of select="name()"/></code> path "<xsl:value-of select="."/>" must use only forward slashes</xsl:with-param></xsl:call-template>
       
   389 </xsl:if>
       
   390 	<xsl:variable name="fullpath"><xsl:call-template name="normpath">
       
   391 				<xsl:with-param name="path">
       
   392 					<xsl:if test="not(starts-with(.,'/'))">
       
   393 						<xsl:call-template name="before">
       
   394 							<xsl:with-param name="text" select="$filename"/>
       
   395 						</xsl:call-template>
       
   396 					</xsl:if>
       
   397 					<xsl:value-of select="."/>
       
   398 				 </xsl:with-param>
       
   399 			</xsl:call-template>
       
   400 		</xsl:variable>
       
   401 		<xsl:variable name="path">
       
   402 			<xsl:choose>
       
   403 				<xsl:when test="not(contains($filename,':'))">/<xsl:for-each select="ancestor::*/@id"><xsl:apply-templates mode="path" select="."/>/</xsl:for-each></xsl:when>
       
   404 				<xsl:otherwise><xsl:for-each select="../../../@id|../../@id"><xsl:apply-templates mode="path" select="."/>/</xsl:for-each></xsl:otherwise>
       
   405 			</xsl:choose>
       
   406 		</xsl:variable>
       
   407 		<xsl:variable name="segment">
       
   408 			<xsl:choose>
       
   409 				<xsl:when test="ancestor::layer">
       
   410 					<xsl:value-of select="concat($fullpath,'/')"/>
       
   411 				</xsl:when>
       
   412 				<xsl:when test="ancestor::package">
       
   413 					<xsl:value-of select="concat('/',substring-after(substring-after($fullpath,'/'),'/'),'/')"/>
       
   414 				</xsl:when>
       
   415 				<xsl:when test="ancestor::collection">
       
   416 					<xsl:value-of select="concat('/',substring-after(substring-after(substring-after($fullpath,'/'),'/'),'/'),'/')"/>
       
   417 				</xsl:when>
       
   418 				<xsl:otherwise>
       
   419 					<xsl:value-of select="concat('/',substring-after(substring-after(substring-after(substring-after($fullpath,'/'),'/'),'/'),'/'),'/')"/>
       
   420 				</xsl:otherwise>
       
   421 			</xsl:choose>
       
   422 		</xsl:variable>
       
   423 <xsl:choose>
       
   424 	<xsl:when test="contains($filename,':')">
       
   425 		<xsl:choose>
       
   426 			<xsl:when test="not(starts-with(.,$path) or concat(.,'/')=$path) and $path-errors">
       
   427 				<xsl:call-template name="Note"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -&gt; <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="."/>"</xsl:with-param></xsl:call-template>
       
   428 			</xsl:when>
       
   429 		</xsl:choose>
       
   430 	</xsl:when>
       
   431 	<xsl:otherwise>
       
   432 		<xsl:choose>
       
   433 			<xsl:when test="not($path-errors)"/>
       
   434 			<xsl:when test="substring-before(substring($segment,2),'/') != substring-before(substring($path,2),'/') and (ancestor::SystemDefinition/@id-namespace!='http://www.symbian.org/system-definition' and not(contains(../../@id,':')))">
       
   435 				<xsl:call-template name="Warning"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -&gt; <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="$fullpath"/>"</xsl:with-param></xsl:call-template>
       
   436 			</xsl:when>
       
   437 			<xsl:when test="substring-before(substring($segment,2),'/') != substring-before(substring($path,2),'/')">
       
   438 				<xsl:call-template name="Error"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -&gt; <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="$fullpath"/>"</xsl:with-param></xsl:call-template>
       
   439 			</xsl:when>
       
   440 			<xsl:when test="not(starts-with($segment,$path))">
       
   441 				<xsl:call-template name="Note"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -&gt; <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="$fullpath"/>"</xsl:with-param></xsl:call-template>
       
   442 			</xsl:when>
       
   443 		</xsl:choose>
       
   444 	</xsl:otherwise>
       
   445 </xsl:choose>
       
   446 </xsl:template>
       
   447 
       
   448 <xsl:template match="SystemDefinition" mode="check-matches">
       
   449 	<xsl:param name="which"/>
       
   450 	<xsl:param name="other"/>
       
   451 	<xsl:for-each select="//*[@mrp]">
       
   452 		<xsl:variable name="mrp" select="@mrp"/>
       
   453 		<xsl:if test="not($other//*[@mrp=$mrp])">
       
   454 			<xsl:call-template name="Error"><xsl:with-param name="text"><xsl:value-of select="$mrp"/> has no match in <xsl:value-of select="$which"/>.</xsl:with-param></xsl:call-template>
       
   455 		</xsl:if>
       
   456 	</xsl:for-each>
       
   457 </xsl:template>
       
   458 
       
   459 <xsl:template match="*" mode="value">
       
   460 	<xsl:call-template name="Error"><xsl:with-param name="text">
       
   461 		<xsl:value-of select="name()"/>:<xsl:for-each select="@*"><xsl:value-of select="concat(name(),'=',.)"/></xsl:for-each>
       
   462 	</xsl:with-param></xsl:call-template>
       
   463 </xsl:template>
       
   464 
       
   465 <xsl:template match="*" mode="compare"><xsl:param name="base"/>
       
   466 <xsl:variable name="n" select="@id"/>
       
   467 <xsl:variable name="tag" select="name()"/>
       
   468 <xsl:variable name="v"><xsl:apply-templates select="." mode="value"/></xsl:variable>
       
   469 <xsl:variable name="v2"><xsl:apply-templates mode="value" select="$base//*[name()=$tag and @id=$n]"/></xsl:variable>
       
   470 <xsl:if  test="$v != $v2">
       
   471 	<xsl:call-template name="Error"><xsl:with-param name="text">
       
   472 		<xsl:value-of select="concat(name(),' ',@name)"/> not identical. [<xsl:value-of select="$v"/>|<xsl:value-of select="$v2"/>]</xsl:with-param></xsl:call-template>
       
   473 </xsl:if>	
       
   474 </xsl:template>
       
   475 
       
   476 
       
   477 
       
   478 <xsl:template match="unit" mode="compare" priority="1"><xsl:param name="base"/>
       
   479 <xsl:variable name="n" select="concat(@version,':',@mrp,'.',@prebuilt)"/>
       
   480 <xsl:variable name="v"><xsl:apply-templates select="." mode="value"/></xsl:variable>
       
   481 <xsl:variable name="v2"><xsl:apply-templates mode="value" select="$base//unit[concat(@version,':',@mrp,'.',@prebuilt)=$n]"/></xsl:variable>
       
   482 <xsl:if  test="$v != $v2">
       
   483 	<xsl:call-template name="Error"><xsl:with-param name="text">
       
   484 		<xsl:value-of select="concat('&#xa;',name(),' ',../@name,' v',@version)"/> not identical. [<xsl:value-of select="$v"/>|<xsl:value-of select="$v2"/>]</xsl:with-param></xsl:call-template>
       
   485 </xsl:if>
       
   486 </xsl:template>
       
   487 
       
   488 <xsl:template match="/variations/@module"> (<xsl:value-of select="."/>)</xsl:template>
       
   489 
       
   490 <xsl:template match="/variations" mode="x-check"><xsl:param name="sysdef"/>
       
   491 <xsl:call-template name="Section"><xsl:with-param name="text">vp cross-check <xsl:apply-templates select="@module"/></xsl:with-param></xsl:call-template>
       
   492 <xsl:for-each select="//component">
       
   493 	<xsl:variable name="found">
       
   494 		<xsl:apply-templates select="$sysdef" mode="lookfor">
       
   495 			<xsl:with-param name="id" select="@name"/>
       
   496 			<xsl:with-param name="version" select="@version"/>
       
   497 		</xsl:apply-templates>
       
   498 	</xsl:variable>
       
   499 	<xsl:if test="$found=''">
       
   500 		<xsl:call-template name="Error"><xsl:with-param name="text">VP component "<xsl:value-of select="@name"/>"<xsl:if test="@version"> v<xsl:value-of select="@version"/></xsl:if> not in SysDef</xsl:with-param></xsl:call-template>
       
   501 	</xsl:if>
       
   502 </xsl:for-each>
       
   503 </xsl:template>
       
   504 
       
   505 <xsl:template match="*" mode="lookfor"><xsl:param name="id"/><xsl:param name="version"/>
       
   506 	<xsl:choose>
       
   507 		<xsl:when test="string-length($version) and //component[@id=$id and unit[@version=$version]]">Found</xsl:when>
       
   508 		<xsl:when test="string-length($version)=0 and //*[@id=$id]">Found</xsl:when>
       
   509 		<xsl:otherwise>
       
   510 			<xsl:apply-templates select="document(//layer/@href | //package/@href | //collection/@href | //component/@href,.)/*/*" mode="lookfor">
       
   511 				<xsl:with-param name="version" select="$version"/>
       
   512 				<xsl:with-param name="id" select="$id"/>
       
   513 			</xsl:apply-templates>
       
   514 		</xsl:otherwise>
       
   515 	</xsl:choose>
       
   516 </xsl:template>
       
   517 
       
   518 
       
   519 
       
   520 <xsl:template match="SystemBuild" mode="x-check"><xsl:param name="sysdef"/>
       
   521 
       
   522 <xsl:call-template name="Section"><xsl:with-param name="text">System Build cross-check</xsl:with-param></xsl:call-template>
       
   523 <xsl:for-each select="//ref">
       
   524 	<xsl:variable name="found">
       
   525 		<xsl:apply-templates select="$sysdef" mode="lookfor">
       
   526 		<xsl:with-param name="id" select="current()/@item"/>
       
   527 	</xsl:apply-templates>
       
   528 </xsl:variable>
       
   529 	<xsl:if test="$found=''">
       
   530 		<xsl:call-template name="Error"><xsl:with-param name="text">Build item "<xsl:value-of select="@item"/>" not in SysDef</xsl:with-param></xsl:call-template>
       
   531 </xsl:if>
       
   532 </xsl:for-each>
       
   533 
       
   534 <xsl:for-each select="//listRef">
       
   535 	<xsl:if test="not(//list[@name=current()/@list])">
       
   536 		<xsl:call-template name="Error"><xsl:with-param name="text">Build list "<xsl:value-of select="@name"/>" not defined</xsl:with-param></xsl:call-template>
       
   537 </xsl:if>	
       
   538 </xsl:for-each>
       
   539 </xsl:template>
       
   540 
       
   541 
       
   542 <xsl:template name="my-release">
       
   543 	<xsl:variable name="n" select="@name"/>
       
   544 	<xsl:variable name="new" select="@introduced"/>
       
   545 	<xsl:variable name="end" select="@deprecated"/>
       
   546 	<xsl:choose>
       
   547 		<xsl:when test="$new!='' and $end!=''">(<xsl:value-of select="concat($new,' - ',$end)"/>)</xsl:when>
       
   548 		<xsl:when test="$new!='' ">(<xsl:value-of select="$new"/>)</xsl:when>
       
   549 		<xsl:when test="$end!=''">(? - <xsl:value-of select="$end"/>)</xsl:when>
       
   550 	</xsl:choose>
       
   551 </xsl:template>
       
   552 
       
   553 <xsl:template name="normpath"><xsl:param name="path"/>
       
   554 <!-- normalize out any ".." in the path in $path  -->
       
   555 <xsl:choose>
       
   556 	<xsl:when test="contains($path,'/../')">
       
   557 	<xsl:call-template name="normpath">
       
   558 		<xsl:with-param name="path">
       
   559 		<xsl:call-template name="before">
       
   560 			<xsl:with-param name="text" select="substring-before($path,'/../')"/>
       
   561 		</xsl:call-template>
       
   562 		<xsl:value-of select="substring-after($path,'/../')"/>
       
   563 		</xsl:with-param>
       
   564 		</xsl:call-template>
       
   565 	</xsl:when>
       
   566 	<xsl:otherwise><xsl:value-of select="$path"/></xsl:otherwise>
       
   567 </xsl:choose>
       
   568 </xsl:template>
       
   569 
       
   570 <!-- return all text before the last / -->
       
   571 <xsl:template name="before"><xsl:param name="text"/>
       
   572 <xsl:if test="contains($text,'/')">
       
   573 	<xsl:value-of select="substring-before($text,'/')"/>/<xsl:call-template name="before"><xsl:with-param name="text" select="substring-after($text,'/')"/></xsl:call-template>
       
   574 	</xsl:if>
       
   575 </xsl:template>
       
   576 
       
   577 
       
   578 </xsl:stylesheet>