sysdeftools/validate/test-model.xsl
branchHighFidelityModel
changeset 202 19ce6071ceaa
parent 151 84b123918d3f
child 312 9527bd30de64
equal deleted inserted replaced
201:280dc2a9385b 202:19ce6071ceaa
    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(@version)]) &gt; 1 and @filter='s60'">
   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: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>
   207 		</xsl:when>
   216 		</xsl:when>
   208 		<xsl:when test="count(*[not(@version)]) &gt; 1">
   217 		<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>
   218 			<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>
   210 		</xsl:when>
   219 		</xsl:when>
   211 	</xsl:choose>
   220 	</xsl:choose>
   212 	<xsl:choose>
   221 	<xsl:choose>
   213 		<xsl:when test="unit"/>
   222 		<xsl:when test="unit"/>
   262 	</xsl:apply-templates>
   271 	</xsl:apply-templates>
   263 </xsl:if>
   272 </xsl:if>
   264 </xsl:template>
   273 </xsl:template>
   265 
   274 
   266 
   275 
       
   276 
       
   277 <xsl:template match="meta">	<xsl:param name="filename"/>
       
   278 	<xsl:apply-templates select="@*"/>
       
   279 </xsl:template>
       
   280 
       
   281 <xsl:template match="meta/@rel | meta/@type | meta/@href"/> <!-- anything is valid -->
       
   282 
       
   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>
       
   317 
       
   318 
   294 <xsl:template match="@bldFile|@mrp"><xsl:param name="filename"/>
   319 <xsl:template match="@bldFile|@mrp"><xsl:param name="filename"/>
   295 
   320 <xsl:if test="substring(.,string-length(.))='/'">
       
   321 		<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>
       
   322 </xsl:if>
       
   323 <xsl:if test="contains(.,'\')">
       
   324 		<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>
       
   325 </xsl:if>
       
   326 
       
   327 <!-- this is a realtive path, so just check that it's the expected number of dirs down -->
       
   328 	<xsl:variable name="fullpath"><xsl:call-template name="normpath">
       
   329 				<xsl:with-param name="path">
       
   330 					<xsl:if test="not(starts-with(.,'/'))">
       
   331 						<xsl:call-template name="before">
       
   332 							<xsl:with-param name="text" select="$filename"/>
       
   333 						</xsl:call-template>
       
   334 					</xsl:if>
       
   335 					<xsl:value-of select="."/>
       
   336 				 </xsl:with-param>
       
   337 			</xsl:call-template>
       
   338 		</xsl:variable>
       
   339 		<xsl:variable name="path">
       
   340 			<xsl:choose>
       
   341 				<xsl:when test="not(contains($filename,':'))">/<xsl:for-each select="ancestor::*/@id"><xsl:apply-templates mode="path" select="."/>/</xsl:for-each></xsl:when>
       
   342 				<xsl:otherwise><xsl:for-each select="../../../@id|../../@id"><xsl:apply-templates mode="path" select="."/>/</xsl:for-each></xsl:otherwise>
       
   343 			</xsl:choose>
       
   344 		</xsl:variable>
       
   345 		<xsl:variable name="segment"> <!-- the part relative to the fragment directory -->
       
   346 			<xsl:choose>
       
   347 				<xsl:when test="ancestor::layer">
       
   348 					<xsl:apply-templates select="ancestor::package" mode="localid"/>/<xsl:apply-templates select="ancestor::collection" mode="localid"/>
       
   349 				</xsl:when>
       
   350 				<xsl:when test="ancestor::package">
       
   351 				<xsl:apply-templates select="ancestor::collection" mode="localid"/>
       
   352 				</xsl:when>
       
   353 				<xsl:when test="ancestor::collection"/>
       
   354 			</xsl:choose>/<xsl:apply-templates select="ancestor::component" mode="localid"/>/</xsl:variable>
       
   355 		<xsl:choose>
       
   356 			<xsl:when test="not(starts-with(concat(.,'/'),$segment))">
       
   357 				<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>
       
   358 			</xsl:when>
       
   359 		</xsl:choose>
       
   360 </xsl:template>
       
   361 
       
   362 
       
   363 <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"/>
       
   364 <xsl:if test="substring(.,string-length(.))='/'">
       
   365 		<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>
       
   366 </xsl:if>
       
   367 <xsl:if test="contains(.,'\')">
       
   368 		<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>
       
   369 </xsl:if>
   296 	<xsl:variable name="fullpath"><xsl:call-template name="normpath">
   370 	<xsl:variable name="fullpath"><xsl:call-template name="normpath">
   297 				<xsl:with-param name="path">
   371 				<xsl:with-param name="path">
   298 					<xsl:if test="not(starts-with(.,'/'))">
   372 					<xsl:if test="not(starts-with(.,'/'))">
   299 						<xsl:call-template name="before">
   373 						<xsl:call-template name="before">
   300 							<xsl:with-param name="text" select="$filename"/>
   374 							<xsl:with-param name="text" select="$filename"/>
   328 		</xsl:variable>
   402 		</xsl:variable>
   329 <xsl:choose>
   403 <xsl:choose>
   330 	<xsl:when test="contains($filename,':')">
   404 	<xsl:when test="contains($filename,':')">
   331 		<xsl:choose>
   405 		<xsl:choose>
   332 			<xsl:when test="not(starts-with(.,$path) or concat(.,'/')=$path)">
   406 			<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>
   407 				<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>
   408 			</xsl:when>
   335 		</xsl:choose>
   409 		</xsl:choose>
   336 	</xsl:when>
   410 	</xsl:when>
   337 	<xsl:otherwise>
   411 	<xsl:otherwise>
   338 		<xsl:choose>
   412 		<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,':')))">
   413 			<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>
   414 				<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>
   415 			</xsl:when>
   342 			<xsl:when test="substring-before(substring($segment,2),'/') != substring-before(substring($path,2),'/')">
   416 			<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>
   417 				<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>
   418 			</xsl:when>
   345 			<xsl:when test="not(starts-with($segment,$path))">
   419 			<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>
   420 				<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>
   421 			</xsl:when>
   348 		</xsl:choose>
   422 		</xsl:choose>
   349 	</xsl:otherwise>
   423 	</xsl:otherwise>
   350 </xsl:choose>
   424 </xsl:choose>
   351 <xsl:if test="substring(.,string-length(.))='/'">
   425 </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 
   426 
   360 <xsl:template match="SystemDefinition" mode="check-matches">
   427 <xsl:template match="SystemDefinition" mode="check-matches">
   361 	<xsl:param name="which"/>
   428 	<xsl:param name="which"/>
   362 	<xsl:param name="other"/>
   429 	<xsl:param name="other"/>
   363 	<xsl:for-each select="//*[@mrp]">
   430 	<xsl:for-each select="//*[@mrp]">