bldsystemtools/sysdeftools/validate/test-model.xsl
changeset 63 d706e2bc01db
parent 25 85578ba0aa08
equal deleted inserted replaced
51:858432135449 63:d706e2bc01db
     1 <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
     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).
     2 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 	All rights reserved.
     3 	All rights reserved.
     4 	This component and the accompanying materials are made available
     4 	This component and the accompanying materials are made available
     5 	under the terms of "Eclipse Public License v1.0"
     5 	under the terms of the License "Eclipse Public License v1.0"
     6 	which accompanies this distribution, and is available
     6 	which accompanies this distribution, and is available
     7 	at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 	at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 
     8 
     9 	Initial Contributors:
     9 	Initial Contributors:
    10 	Nokia Corporation - initial contribution.
    10 	Nokia Corporation - initial contribution.
    50 <xsl:apply-templates mode="x-check" select="document (//info[@type='build']/@href)/*">
    50 <xsl:apply-templates mode="x-check" select="document (//info[@type='build']/@href)/*">
    51 	<xsl:with-param name="sysdef" select="document (sysdef/@href)/*"/>
    51 	<xsl:with-param name="sysdef" select="document (sysdef/@href)/*"/>
    52 </xsl:apply-templates>
    52 </xsl:apply-templates>
    53 </xsl:template>
    53 </xsl:template>
    54 
    54 
    55 <xsl:template match="/SystemDefinition[@schema='3.0.0']" mode="ids">
    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>
    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"/>
    57 	<xsl:apply-templates select="document(//layer/@href | //package/@href | //collection/@href | //component/@href,.)/*" mode="ids"/>
    58 </xsl:template>
    58 </xsl:template>
    59 
    59 
    60 <xsl:template match="/SystemDefinition[@schema='3.0.0' and systemModel]" priority="2">
    60 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')and systemModel]" priority="2">
    61 	<xsl:param name="filename" select="$Filename"/>
    61 	<xsl:param name="filename" select="$Filename"/>
    62 <xsl:call-template name="Section">
    62 <xsl:call-template name="Section">
    63 	<xsl:with-param name="text">System Definition: <xsl:value-of select="*/@name"/></xsl:with-param>
    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>
    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>
    65 </xsl:call-template>
    66 	<xsl:apply-templates select="*">
    66 	<xsl:apply-templates select="*">
    67 		<xsl:with-param name="filename" select="$filename"/>
    67 		<xsl:with-param name="filename" select="$filename"/>
    68 	</xsl:apply-templates>
    68 	</xsl:apply-templates>
    69 </xsl:template>
    69 </xsl:template>
    70 
    70 
    71 <xsl:template match="/SystemDefinition[@schema='3.0.0'] | systemModel">
    71 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')] | systemModel">
    72 	<xsl:param name="filename"  select="$Filename"/>
    72 	<xsl:param name="filename"  select="$Filename"/>
    73 		
    73 		
    74 <xsl:if test="//unit">
    74 <xsl:if test="//unit">
    75 <xsl:call-template name="Section">
    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>
    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>
    93 <xsl:template match="@before|@id|package/@span|collection/@level|package/@level|package/@levels|layer/@levels" mode="valid"/> <!-- really should check syntax -->
    93 <xsl:template match="@before|@id|package/@span|collection/@level|package/@level|package/@levels|layer/@levels" mode="valid"/> <!-- really should check syntax -->
    94 
    94 
    95 <xsl:template match="@name|@href|@filter" mode="valid"/> 
    95 <xsl:template match="@name|@href|@filter" mode="valid"/> 
    96 
    96 
    97 <xsl:template match="component/@introduced|component/@deprecated" mode="valid"/> 
    97 <xsl:template match="component/@introduced|component/@deprecated" mode="valid"/> 
       
    98 
       
    99 
       
   100 
       
   101 <xsl:template match="@replace" mode="valid">
       
   102 	<xsl:if test="/SystemDefinition[@schema='3.0.0']">
       
   103 		<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>
       
   104 	</xsl:if>
       
   105 </xsl:template>
       
   106 
    98 
   107 
    99 
   108 
   100 <xsl:template name="validate-class">
   109 <xsl:template name="validate-class">
   101 	<ok>plugin</ok>
   110 	<ok>plugin</ok>
   102 	<ok>doc</ok>
   111 	<ok>doc</ok>
   200 
   209 
   201 <xsl:apply-templates select="@*" mode="valid"/>
   210 <xsl:apply-templates select="@*" mode="valid"/>
   202 <xsl:apply-templates select="@id"/>
   211 <xsl:apply-templates select="@id"/>
   203 <xsl:if test="self::component">
   212 <xsl:if test="self::component">
   204 	<xsl:choose>
   213 	<xsl:choose>
   205 		<xsl:when test="count(*[not(@version)]) &gt; 1 and @filter='s60'">
   214 		<xsl:when test="count(unit[not(@filter | @version)]) = 0 "/>
   206 			<xsl:call-template name="Warning"><xsl:with-param name="text">S60 Component "<xsl:value-of select="@id"/>" has <xsl:value-of select="count(*)"/> children.</xsl:with-param></xsl:call-template>
   215 		<xsl:when test="count(unit[not(@version)]) &gt; 1 and @filter='s60'">
       
   216 			<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>
   207 		</xsl:when>
   217 		</xsl:when>
   208 		<xsl:when test="count(*[not(@version)]) &gt; 1">
   218 		<xsl:when test="count(unit[not(@version)]) &gt; 1">
   209 			<xsl:call-template name="Error"><xsl:with-param name="text">Component "<xsl:value-of select="@id"/>" has <xsl:value-of select="count(*)"/> children.</xsl:with-param></xsl:call-template>
   219 			<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>
   210 		</xsl:when>
   220 		</xsl:when>
   211 	</xsl:choose>
   221 	</xsl:choose>
   212 	<xsl:choose>
   222 	<xsl:choose>
   213 		<xsl:when test="unit"/>
   223 		<xsl:when test="unit"/>
   214 		<xsl:when test="contains(comment(),'PLACEHOLDER=')"/>
   224 		<xsl:when test="contains(comment(),'PLACEHOLDER=')"/>
   262 	</xsl:apply-templates>
   272 	</xsl:apply-templates>
   263 </xsl:if>
   273 </xsl:if>
   264 </xsl:template>
   274 </xsl:template>
   265 
   275 
   266 
   276 
       
   277 
       
   278 <xsl:template match="meta">	<xsl:param name="filename"/>
       
   279 	<xsl:apply-templates select="@*"/>
       
   280 </xsl:template>
       
   281 
       
   282 <xsl:template match="meta/@rel | meta/@type | meta/@href"/> <!-- anything is valid -->
       
   283 
   267 <xsl:template match="unit">	<xsl:param name="filename"/>
   284 <xsl:template match="unit">	<xsl:param name="filename"/>
   268 	<xsl:apply-templates select="@mrp|@bldFile">
   285 	<xsl:apply-templates select="@mrp|@bldFile">
   269 		<xsl:with-param name="filename" select="$filename"/>
   286 		<xsl:with-param name="filename" select="$filename"/>
   270 	</xsl:apply-templates>
   287 	</xsl:apply-templates>
   271 </xsl:template>
   288 </xsl:template>
   289 </xsl:if>
   306 </xsl:if>
   290 
   307 
   291 </xsl:template>
   308 </xsl:template>
   292 
   309 
   293 
   310 
       
   311 <xsl:template mode="localid" match="*">
       
   312 	<xsl:choose>
       
   313 		<xsl:when test="contains(@id,':')">/<xsl:value-of select="substring-after(@id,':')"/></xsl:when>
       
   314 		<xsl:otherwise><xsl:value-of select="@id"/></xsl:otherwise>
       
   315 	</xsl:choose>
       
   316 </xsl:template>
   294 <xsl:template match="@bldFile|@mrp"><xsl:param name="filename"/>
   317 <xsl:template match="@bldFile|@mrp"><xsl:param name="filename"/>
   295 
   318 <xsl:if test="substring(.,string-length(.))='/'">
       
   319 		<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>
       
   320 </xsl:if>
       
   321 <xsl:if test="contains(.,'\')">
       
   322 		<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>
       
   323 </xsl:if>
       
   324 
       
   325 <!-- this is a realtive path, so just check that it's the expected number of dirs down -->
       
   326 	<xsl:variable name="fullpath"><xsl:call-template name="normpath">
       
   327 				<xsl:with-param name="path">
       
   328 					<xsl:if test="not(starts-with(.,'/'))">
       
   329 						<xsl:call-template name="before">
       
   330 							<xsl:with-param name="text" select="$filename"/>
       
   331 						</xsl:call-template>
       
   332 					</xsl:if>
       
   333 					<xsl:value-of select="."/>
       
   334 				 </xsl:with-param>
       
   335 			</xsl:call-template>
       
   336 		</xsl:variable>
       
   337 		<xsl:variable name="path">
       
   338 			<xsl:choose>
       
   339 				<xsl:when test="not(contains($filename,':'))">/<xsl:for-each select="ancestor::*/@id"><xsl:apply-templates mode="path" select="."/>/</xsl:for-each></xsl:when>
       
   340 				<xsl:otherwise><xsl:for-each select="../../../@id|../../@id"><xsl:apply-templates mode="path" select="."/>/</xsl:for-each></xsl:otherwise>
       
   341 			</xsl:choose>
       
   342 		</xsl:variable>
       
   343 		<xsl:variable name="segment"> <!-- the part relative to the fragment directory -->
       
   344 			<xsl:choose>
       
   345 				<xsl:when test="ancestor::layer">
       
   346 					<xsl:apply-templates select="ancestor::package" mode="localid"/>/<xsl:apply-templates select="ancestor::collection" mode="localid"/>
       
   347 				</xsl:when>
       
   348 				<xsl:when test="ancestor::package">
       
   349 				<xsl:apply-templates select="ancestor::collection" mode="localid"/>
       
   350 				</xsl:when>
       
   351 				<xsl:when test="ancestor::collection"/>
       
   352 			</xsl:choose>/<xsl:apply-templates select="ancestor::component" mode="localid"/>/</xsl:variable>
       
   353 		<xsl:choose>
       
   354 			<xsl:when test="not(starts-with(concat(.,'/'),$segment))">
       
   355 				<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>
       
   356 			</xsl:when>
       
   357 		</xsl:choose>
       
   358 </xsl:template>
       
   359 
       
   360 
       
   361 <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"/>
       
   362 <xsl:if test="substring(.,string-length(.))='/'">
       
   363 		<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>
       
   364 </xsl:if>
       
   365 <xsl:if test="contains(.,'\')">
       
   366 		<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>
       
   367 </xsl:if>
   296 	<xsl:variable name="fullpath"><xsl:call-template name="normpath">
   368 	<xsl:variable name="fullpath"><xsl:call-template name="normpath">
   297 				<xsl:with-param name="path">
   369 				<xsl:with-param name="path">
   298 					<xsl:if test="not(starts-with(.,'/'))">
   370 					<xsl:if test="not(starts-with(.,'/'))">
   299 						<xsl:call-template name="before">
   371 						<xsl:call-template name="before">
   300 							<xsl:with-param name="text" select="$filename"/>
   372 							<xsl:with-param name="text" select="$filename"/>
   328 		</xsl:variable>
   400 		</xsl:variable>
   329 <xsl:choose>
   401 <xsl:choose>
   330 	<xsl:when test="contains($filename,':')">
   402 	<xsl:when test="contains($filename,':')">
   331 		<xsl:choose>
   403 		<xsl:choose>
   332 			<xsl:when test="not(starts-with(.,$path) or concat(.,'/')=$path)">
   404 			<xsl:when test="not(starts-with(.,$path) or concat(.,'/')=$path)">
   333 				<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>
   405 				<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>
   334 			</xsl:when>
   406 			</xsl:when>
   335 		</xsl:choose>
   407 		</xsl:choose>
   336 	</xsl:when>
   408 	</xsl:when>
   337 	<xsl:otherwise>
   409 	<xsl:otherwise>
   338 		<xsl:choose>
   410 		<xsl:choose>
   339 			<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,':')))">
   411 			<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,':')))">
   340 				<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>
   412 				<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>
   341 			</xsl:when>
   413 			</xsl:when>
   342 			<xsl:when test="substring-before(substring($segment,2),'/') != substring-before(substring($path,2),'/')">
   414 			<xsl:when test="substring-before(substring($segment,2),'/') != substring-before(substring($path,2),'/')">
   343 				<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>
   415 				<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>
   344 			</xsl:when>
   416 			</xsl:when>
   345 			<xsl:when test="not(starts-with($segment,$path))">
   417 			<xsl:when test="not(starts-with($segment,$path))">
   346 				<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>
   418 				<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>
   347 			</xsl:when>
   419 			</xsl:when>
   348 		</xsl:choose>
   420 		</xsl:choose>
   349 	</xsl:otherwise>
   421 	</xsl:otherwise>
   350 </xsl:choose>
   422 </xsl:choose>
   351 <xsl:if test="substring(.,string-length(.))='/'">
   423 </xsl:template>
   352 		<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>
       
   353 </xsl:if>
       
   354 <xsl:if test="contains(.,'\')">
       
   355 		<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>
       
   356 </xsl:if>
       
   357 </xsl:template>
       
   358 
       
   359 
   424 
   360 <xsl:template match="SystemDefinition" mode="check-matches">
   425 <xsl:template match="SystemDefinition" mode="check-matches">
   361 	<xsl:param name="which"/>
   426 	<xsl:param name="which"/>
   362 	<xsl:param name="other"/>
   427 	<xsl:param name="other"/>
   363 	<xsl:for-each select="//*[@mrp]">
   428 	<xsl:for-each select="//*[@mrp]">