metatools/sysdeftools/lib/test-model.xsl
changeset 662 60be34e1b006
parent 661 199bb033aacf
child 663 8e27d440923e
equal deleted inserted replaced
654:7c11c3d8d025 662:60be34e1b006
     1 <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
     1  <!DOCTYPE XSLT  [
       
     2       <!ENTITY AZ  "ABCDEFGHIJKLMNOPQRSTUVWXYZ">
       
     3       <!ENTITY az  "abcdefghijklmnopqrstuvwxyz">
       
     4  ]><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).
     5 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 	All rights reserved.
     6 	All rights reserved.
     4 	This component and the accompanying materials are made available
     7 	This component and the accompanying materials are made available
     5 	under the terms of the License "Eclipse Public License v1.0"
     8 	under the terms of the License "Eclipse Public License v1.0"
     6 	which accompanies this distribution, and is available
     9 	which accompanies this distribution, and is available
    18 
    21 
    19 	<xsl:variable name="all-ids">
    22 	<xsl:variable name="all-ids">
    20 		<xsl:apply-templates select="document(/model/sysdef/@href)| SystemDefinition" mode="ids"/>
    23 		<xsl:apply-templates select="document(/model/sysdef/@href)| SystemDefinition" mode="ids"/>
    21 	</xsl:variable>
    24 	</xsl:variable>
    22 
    25 
       
    26 	<xsl:variable name="sf-ns">http://www.symbian.org/system-definition</xsl:variable>
    23  
    27  
    24 <xsl:template match="/model" priority="-1">
    28 <xsl:template match="/model" priority="-1">
    25 	<xsl:apply-templates select="." mode="check"/>
    29 	<xsl:apply-templates select="." mode="check"/>
    26 </xsl:template>
    30 </xsl:template>
    27 
    31 
    59 
    63 
    60 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')and systemModel]" priority="2">
    64 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')and systemModel]" priority="2">
    61 	<xsl:param name="filename" select="$Filename"/>
    65 	<xsl:param name="filename" select="$Filename"/>
    62 <xsl:call-template name="Section">
    66 <xsl:call-template name="Section">
    63 	<xsl:with-param name="text">System Definition: <xsl:value-of select="*/@name"/></xsl:with-param>
    67 	<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>
    68 	<xsl:with-param name="sub"><xsl:value-of select="(string-length($all-ids) - string-length(translate($all-ids,' ','')) - 1) div 2 "/> items</xsl:with-param>
    65 </xsl:call-template>
    69 </xsl:call-template>
    66 	<xsl:apply-templates select="*">
    70 	<xsl:apply-templates select="*">
    67 		<xsl:with-param name="filename" select="$filename"/>
    71 		<xsl:with-param name="filename" select="$filename"/>
    68 	</xsl:apply-templates>
    72 	</xsl:apply-templates>
    69 </xsl:template>
    73 </xsl:template>
    70 
    74 
    71 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')] | systemModel">
    75 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')] | systemModel">
    72 	<xsl:param name="filename"  select="$Filename"/>
    76 	<xsl:param name="filename"  select="$Filename"/>
    73 		
    77 		
    74 <xsl:if test="//unit">
    78 <xsl:if test="descendant::unit and not(self::systemModel)">
    75 <xsl:call-template name="Section">
    79 <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>
    80 	<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>
       
    81 	<xsl:with-param name="id"><xsl:value-of select="*/@id"/></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>
    82 	<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>
    83 </xsl:call-template>
    79 </xsl:if>
    84 </xsl:if>
    80 <xsl:if test="self::systemModel and not(@name)">
    85 <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>
    86 	<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>
    87 </xsl:if>
    83 	<xsl:apply-templates select="*">
    88 	<xsl:apply-templates select="*">
    84 		<xsl:with-param name="filename" select="$filename"/>
    89 		<xsl:with-param name="filename" select="$filename"/>
    85 	</xsl:apply-templates>
    90 	</xsl:apply-templates>
       
    91 	<xsl:for-each select="//text()[normalize-space(.)!='']">
       
    92 		<xsl:if test="not(ancestor::meta)">
       
    93 			<xsl:call-template name="Error"><xsl:with-param name="text">Text content not valid in <xsl:value-of select="name(..)"/> (<xsl:value-of select="normalize-space(.)"/>)</xsl:with-param></xsl:call-template>
       
    94 		</xsl:if>
       
    95 	</xsl:for-each>
    86 </xsl:template>
    96 </xsl:template>
    87 
    97 
    88 
    98 
    89 <xsl:template match="@*" mode="valid">
    99 <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>
   100 	<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>
   101 </xsl:template>
    92 
   102 
    93 <xsl:template match="@before|@id|package/@span|layer/@span|collection/@level|package/@level|package/@levels|layer/@levels" mode="valid"/> <!-- really should check syntax -->
   103 <xsl:template match="@before|package/@span|layer/@span|collection/@level|package/@level|package/@levels|layer/@levels" mode="valid"/> <!-- really should check syntax -->
    94 
   104 
    95 <xsl:template match="@name|@href|@filter|package/@version|unit/@version|unit/@prebuilt" mode="valid"/> 
   105 <xsl:template match="@href|@id|@filter|package/@version|unit/@version|unit/@prebuilt" mode="valid"/> 
    96 
   106 
    97 <xsl:template match="component/@introduced|component/@deprecated" mode="valid"/> 
   107 <xsl:template match="component/@introduced" mode="valid"/>
       
   108 <xsl:template match="component/@deprecated" mode="valid">
       
   109 	<xsl:if test="../@purpose='mandatory'">
       
   110 		<xsl:call-template name="Warning"><xsl:with-param name="text">Deprecated component <id><xsl:value-of select="../@id"/></id> should not be mandatory</xsl:with-param></xsl:call-template>
       
   111 	</xsl:if>
       
   112 </xsl:template>
       
   113 
       
   114 <xsl:template match="@name" mode="valid"> <!-- look for various naming troubles -->
       
   115 	<xsl:variable name="pre"><xsl:value-of select="name(..)"/> with name "<xsl:value-of select="."/>"</xsl:variable>
       
   116 	<xsl:if test="normalize-space(.)!=.">
       
   117 		<xsl:call-template name="Warning"><xsl:with-param name="text"><xsl:value-of select="$pre"/> has unexpected whitespace</xsl:with-param></xsl:call-template>
       
   118 	</xsl:if>
       
   119 
       
   120 	<xsl:choose> <!-- these are likely to all be the same error -->
       
   121 		<xsl:when test=".=../@id or .=substring-after(../@id,':')">
       
   122 			<xsl:call-template name="Error"><xsl:with-param name="text"><xsl:value-of select="$pre"/> is the same as the id</xsl:with-param></xsl:call-template>
       
   123 		</xsl:when>
       
   124 
       
   125 		<xsl:when test="contains(.,'_')">
       
   126 			<xsl:call-template name="Error"><xsl:with-param name="text">
       
   127 			<xsl:value-of select="$pre"/> must not contain the underscore character (_)</xsl:with-param></xsl:call-template>
       
   128 		</xsl:when>
       
   129 		<xsl:when test="translate(.,'&az;0123456789_ ','')=''">
       
   130 			<xsl:call-template name="Warning"><xsl:with-param name="text">The human-readable name for <xsl:value-of select="name(..)"/> "<xsl:value-of select="."/>" cannot be entirely lowercase</xsl:with-param></xsl:call-template>
       
   131 		</xsl:when>
       
   132 	</xsl:choose>
       
   133 
       
   134 	<xsl:variable name="spaced" select="concat(' ',.,' ')"/>
       
   135 	<xsl:variable name="this" select="."/>
       
   136 	<xsl:variable name="terms" select="document('')/*/xsl:template[@name='bad-names']/*"/>
       
   137 	<xsl:variable name="std" select="document('')/*/xsl:template[@name='std-names']/*"/>
       
   138 
       
   139 	<xsl:for-each select="$terms"> <!-- common errors in names -->
       
   140 		<xsl:if test="contains($spaced,concat(' ',.,' '))">
       
   141 			<xsl:choose>
       
   142 				<xsl:when test="name()='bad'">
       
   143 					<xsl:call-template name="Warning"><xsl:with-param name="text">
       
   144 						<xsl:value-of select="$pre"/> should use "<xsl:value-of select="@ok"/>"</xsl:with-param></xsl:call-template>
       
   145 				</xsl:when>
       
   146 				<xsl:when test="name()='pref'">
       
   147 					<xsl:call-template name="Note"><xsl:with-param name="text">
       
   148 						<xsl:value-of select="$pre"/> should use "<xsl:value-of select="@ok"/>" instead of "<xsl:value-of select="."/>"</xsl:with-param></xsl:call-template>
       
   149 				</xsl:when>
       
   150 			</xsl:choose>
       
   151 		</xsl:if>
       
   152 	</xsl:for-each>
       
   153 
       
   154 	<xsl:if test="../self::component and 
       
   155 		( (substring(.,string-length(.) - string-length(' Plugin') + 1) = ' Plugin') or
       
   156 		 (substring(.,string-length(.) - string-length(' Plugins') + 1) = ' Plugins') ) 
       
   157 		  and not(contains(../@class,'plugin'))">
       
   158 		<xsl:call-template name="Note"><xsl:with-param name="text">
       
   159 			<xsl:value-of select="$pre"/> should have class "plugin"</xsl:with-param></xsl:call-template>
       
   160 	</xsl:if>
       
   161 
       
   162 	<xsl:for-each select="$std"> <!-- standard naming schemes -->
       
   163 		<xsl:choose>
       
   164 			<xsl:when test="name()='suffix' and substring($this/../@id,string-length($this/../@id) - string-length(.) + 1)=. 
       
   165 				and not(substring($this,string-length($this) - string-length(@name) + 1) = @name or  substring($this,string-length($this) - string-length(@or) + 1) = @or)">
       
   166 				<xsl:call-template name="Note"><xsl:with-param name="text">
       
   167 					<xsl:value-of select="$pre"/> should end with "...<xsl:value-of select="@name"/>"<xsl:if test="@or"> or "...<xsl:value-of select="@or"/>"</xsl:if></xsl:with-param></xsl:call-template>
       
   168 			</xsl:when>
       
   169 			<xsl:when test="name()='prefix' and starts-with($this/../@id,.) and not(starts-with($this,@name))">
       
   170 				<xsl:call-template name="Note"><xsl:with-param name="text">
       
   171 					<xsl:value-of select="$pre"/> should start with "<xsl:value-of select="@name"/>..."</xsl:with-param></xsl:call-template>
       
   172 			</xsl:when>
       
   173 		</xsl:choose>
       
   174 	</xsl:for-each>
       
   175 
       
   176 </xsl:template>
       
   177 
    98 
   178 
    99 <xsl:template match="component/@origin-model" mode="valid"/>
   179 <xsl:template match="component/@origin-model" mode="valid"/>
   100 
   180 
   101 <xsl:template match="unit/@priority" mode="valid">
   181 <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>
   182 	<xsl:call-template name="Note"><xsl:with-param name="text">Attribute <xsl:value-of select="name()"/> is deprecated</xsl:with-param></xsl:call-template>
   108 </xsl:template>
   188 </xsl:template>
   109 
   189 
   110 <xsl:template match="@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='proFile']" mode="valid"/> 
   190 <xsl:template match="@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='proFile']" mode="valid"/> 
   111 	
   191 	
   112 
   192 
       
   193 <xsl:template match="@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='qmakeArgs' and not(../@*[local-name()='proFile'])]" mode="valid"> 
       
   194 	<xsl:call-template name="Error"><xsl:with-param name="text">Extension attribute <code><xsl:value-of select="local-name()"/>="<xsl:value-of select="."/>"</code> in namespace <xsl:value-of select="namespace-uri()"/> cannot be used without a proFile extention attribute</xsl:with-param></xsl:call-template>
       
   195 </xsl:template>
       
   196 
       
   197 
   113 <xsl:template match="@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='qmakeArgs']" mode="valid"> 
   198 <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>
   199 	<xsl:call-template name="Note"><xsl:with-param name="text">Use of extension attribute <code><xsl:value-of select="local-name()"/>="<xsl:value-of select="."/>"</code> in namespace <xsl:value-of select="namespace-uri()"/> is deprecated. Put contents in the "<code>symbian: { ... }</code>" section of <xsl:value-of select="../@bldFile"/>/<xsl:value-of select="../@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='proFile']"/></xsl:with-param></xsl:call-template>
       
   200 </xsl:template>
       
   201 
       
   202 <xsl:template match="@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='qmakeArgs' and .='-r']" mode="valid"> 
       
   203 	<xsl:call-template name="Warning"><xsl:with-param name="text">Extension attribute <code><xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</code> must be removed. The attribute is deprecated and that is the default behaviour</xsl:with-param></xsl:call-template>
   115 </xsl:template>
   204 </xsl:template>
   116 
   205 
   117 
   206 
   118 <xsl:template match="@replace" mode="valid">
   207 <xsl:template match="@replace" mode="valid">
   119 	<xsl:if test="/SystemDefinition[@schema='3.0.0']">
   208 	<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>
   209 		<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>
   210 	</xsl:if>
   122 </xsl:template>
   211 </xsl:template>
   123 
   212 
   124 
   213 
       
   214 <xsl:template name="bad-names">
       
   215 	<bad ok="SHAI">shai</bad>
       
   216 	<bad ok="API">api</bad>
       
   217 	<pref ok="A-GPS">AGPS</pref>
       
   218 	<pref ok="APIs">Headers</pref>
       
   219 </xsl:template>
       
   220 
       
   221 <xsl:template name="std-names">
       
   222 	<suffix name=" API">_api</suffix>
       
   223 	<suffix name=" SHAI">_shai</suffix>
       
   224 	<suffix name=" Info">_info</suffix>
       
   225 	<suffix name=" Public Interfaces">_pub</suffix>
       
   226 	<suffix name=" Platform Interfaces">_plat</suffix>
       
   227 	<suffix name=" Test" or="Tests">test</suffix>
       
   228 </xsl:template>
   125 
   229 
   126 <xsl:template name="validate-class">
   230 <xsl:template name="validate-class">
   127 	<ok>plugin</ok>
   231 	<ok>plugin</ok>
   128 	<ok>doc</ok>
   232 	<ok>doc</ok>
   129 	<ok>tool</ok>
   233 	<ok>tool</ok>
   196 </xsl:template> 
   300 </xsl:template> 
   197 
   301 
   198 
   302 
   199 <xsl:template match="package/@tech-domain|component/@purpose|component/@target" mode="valid">
   303 <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()]"/>
   304 	<xsl:variable name="v" select="document('')/*/xsl:template[@name=concat('validate-',name(current()))]/*[.=current()]"/>
   201 	<xsl:choose>
   305 	<xsl:variable name="ns"><xsl:apply-templates select="../@id" mode="namespace-for-id"/></xsl:variable>
       
   306 	<xsl:choose>
       
   307 		<xsl:when test="not($v) and $ns=$sf-ns">
       
   308 			<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>
       
   309 		</xsl:when> 
   202 		<xsl:when test="not($v)">
   310 		<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>
   311 			<xsl:call-template name="Note"><xsl:with-param name="text">Non-standard <xsl:value-of select="name()"/> value <xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</xsl:with-param></xsl:call-template>
   204 		</xsl:when> 
   312 		</xsl:when> 
   205 		<xsl:when test="name($v)='ok'"/> 
   313 		<xsl:when test="name($v)='ok'"/> 
   206 		<xsl:when test="name($v)='w'">
   314 		<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>
   315 			<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> 
   316 		</xsl:when> 
   212 
   320 
   213 
   321 
   214 
   322 
   215 
   323 
   216 <xsl:template match="*" priority="-2">
   324 <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>
   325 	<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:if test="ancestor::meta"> in <xsl:value-of select="ancestor::meta/@rel"/> metadata section</xsl:if></xsl:with-param></xsl:call-template>
   218 </xsl:template>
   326 </xsl:template>
   219 
   327 
   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">
   328 <xsl:template match="component[not(parent::collection) or (parent::SystemDefinition and count(../*)=1)] | 
   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>
   329 	collection[not(parent::package) or (parent::SystemDefinition and count(../*)=1)] | 
       
   330 	package[not(parent::package or parent::layer or (parent::SystemDefinition and count(../*)=1))] |
       
   331 	layer[not(parent::systemModel)] " priority="3">
       
   332 	<xsl:call-template name="Error"><xsl:with-param name="text"><xsl:value-of select="name()"/> "<id><xsl:value-of select="@id"/></id>" has invalid parent <xsl:value-of select="name(..)"/> "<id><xsl:value-of select="../@id"/></id>"</xsl:with-param></xsl:call-template>
   222 </xsl:template>
   333 </xsl:template>
   223 
   334 
   224 <xsl:template match="layer | package | collection | component">
   335 <xsl:template match="layer | package | collection | component">
   225 	<xsl:param name="filename"/>
   336 	<xsl:param name="filename"/>
       
   337 
       
   338 <xsl:if test="self::package[not(@href)] and not(parent::SystemDefinition)">
       
   339 <xsl:call-template name="Section">
       
   340 	<xsl:with-param name="id"><xsl:value-of select="@id"/></xsl:with-param>
       
   341 	<xsl:with-param name="text"><xsl:value-of select="translate(substring(name(),1,1),'clp','CLP')"/><xsl:value-of select="substring(name(),2)"/>: <xsl:value-of select="@name"/></xsl:with-param>
       
   342 	<xsl:with-param name="sub"><xsl:value-of select="count(descendant::unit)"/> unit<xsl:if test="count(descendant::unit)!=1">s</xsl:if></xsl:with-param>
       
   343 </xsl:call-template>
       
   344 </xsl:if>
   226 
   345 
   227 <xsl:apply-templates select="@*" mode="valid"/>
   346 <xsl:apply-templates select="@*" mode="valid"/>
   228 <xsl:apply-templates select="@id"/>
   347 <xsl:apply-templates select="@id"/>
   229 <xsl:if test="self::component">
   348 <xsl:if test="self::component">
   230 	<xsl:choose>
   349 	<xsl:choose>
   231 		<xsl:when test="count(unit[not(@filter | @version)]) = 0 "/>
   350 		<xsl:when test="count(unit[not(@filter | @version)]) = 0 "/>
   232 		<xsl:when test="count(unit[not(@version)]) &gt; 1 and @filter='s60'">
   351 		<xsl:when test="count(unit[not(@version)]) &gt; 1 and descendant-or-self::*[contains(@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>
   352 			<xsl:call-template name="Warning"><xsl:with-param name="text">S60 Component <id><xsl:value-of select="@id"/></id> has <xsl:value-of select="count(unit)"/> units.</xsl:with-param></xsl:call-template>
   234 		</xsl:when>
   353 		</xsl:when>
   235 		<xsl:when test="count(unit[not(@version)]) &gt; 1">
   354 		<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>
   355 			<xsl:call-template name="Error"><xsl:with-param name="text">Component "<id><xsl:value-of select="@id"/></id>" has <xsl:value-of select="count(unit)"/> units.</xsl:with-param></xsl:call-template>
   237 		</xsl:when>
   356 		</xsl:when>
   238 	</xsl:choose>
   357 	</xsl:choose>
   239 	<xsl:choose>
   358 	<xsl:choose>
   240 		<xsl:when test="unit"/>
   359 		<xsl:when test="unit"/>
   241 		<xsl:when test="contains(comment(),'PLACEHOLDER=')"/>
   360 		<xsl:when test="contains(comment(),'PLACEHOLDER=')"/>
   248 	</xsl:choose>
   367 	</xsl:choose>
   249 </xsl:if>
   368 </xsl:if>
   250 <xsl:if test="@href">
   369 <xsl:if test="@href">
   251 	<xsl:variable name="child" select="document(@href,.)/SystemDefinition"/>
   370 	<xsl:variable name="child" select="document(@href,.)/SystemDefinition"/>
   252 	<xsl:if test="@id!=$child/@id">
   371 	<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>
   372 		<xsl:call-template name="Error"><xsl:with-param name="text"><xsl:value-of select="name()"/> "<id><xsl:value-of select="@id"/></id>" must match ID in linked file "<xsl:value-of select="@href"/>"</xsl:with-param></xsl:call-template>
   254 	</xsl:if>
   373 	</xsl:if>
   255 	<xsl:if test="$child/@href">
   374 	<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>
   375 		<xsl:call-template name="Error"><xsl:with-param name="text">linked <xsl:value-of select="name()"/> "<id><xsl:value-of select="@id"/></id>" cannot be a link</xsl:with-param></xsl:call-template>
   257 	</xsl:if>
   376 	</xsl:if>
   258 	<xsl:for-each select="@*[name()!='id']">
   377 	<xsl:for-each select="@*[name()!='id']">
   259 		<xsl:if test="$child/@*[name()=name(current())]">
   378 		<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>
   379 			<xsl:call-template name="Warning"><xsl:with-param name="text">linked <xsl:value-of select="name()"/> "<id><xsl:value-of select="@id"/></id>" has duplicate attribute to linking document. Duplicate ignored.</xsl:with-param></xsl:call-template>
   261 		</xsl:if>
   380 		</xsl:if>
   262 	</xsl:for-each>
   381 	</xsl:for-each>
   263 	<xsl:if test="*">
   382 	<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>
   383 		<xsl:call-template name="Error"><xsl:with-param name="text"><xsl:value-of select="name()"/> "<id><xsl:value-of select="@id"/></id>" cannot have both link and content. Content ignored.</xsl:with-param></xsl:call-template>
   265 	</xsl:if>
   384 	</xsl:if>
   266 </xsl:if>
   385 </xsl:if>
   267 <xsl:if test="@href and name()!=name(document(@href,.)/SystemDefinition/*)">
   386 <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>
   387 		<xsl:call-template name="Error"><xsl:with-param name="text"><xsl:value-of select="name()"/> "<id><xsl:value-of select="@id"/></id>" must match item in linked file "<xsl:value-of select="@href"/>"</xsl:with-param></xsl:call-template>
   269 </xsl:if>
   388 </xsl:if>
   270 <xsl:if test="not(@href)">
   389 <xsl:if test="not(@href)">
   271 	<xsl:apply-templates select="*">
   390 	<xsl:apply-templates select="*">
   272 		<xsl:with-param name="filename" select="$filename"/>
   391 		<xsl:with-param name="filename" select="$filename"/>
   273 	</xsl:apply-templates>
   392 	</xsl:apply-templates>
   286 				 </xsl:with-param>
   405 				 </xsl:with-param>
   287 			</xsl:call-template>
   406 			</xsl:call-template>
   288 		 </xsl:with-param>
   407 		 </xsl:with-param>
   289 	</xsl:apply-templates>
   408 	</xsl:apply-templates>
   290 </xsl:if>
   409 </xsl:if>
       
   410 
       
   411 <xsl:if test="self::colleciton and not(@level) and ../@levels">
       
   412 	<xsl:call-template name="Error"><xsl:with-param name="text">Collection <id><xsl:value-of select="@id"/></id> has no level, despite levels "<xsl:value-of select="../@levels"/>" being defined in <xsl:value-of select="name(..)"/> "<id><xsl:value-of select="../@id"/></id>"</xsl:with-param></xsl:call-template>
       
   413 </xsl:if>
   291 </xsl:template>
   414 </xsl:template>
   292 
   415 
   293 
   416 
   294 
   417 
   295 <xsl:template match="meta">	<xsl:param name="filename"/>
   418 <xsl:template match="meta">	<xsl:param name="filename"/>
   302 	<xsl:apply-templates select="@*">
   425 	<xsl:apply-templates select="@*">
   303 		<xsl:with-param name="filename" select="$filename"/>
   426 		<xsl:with-param name="filename" select="$filename"/>
   304 	</xsl:apply-templates>
   427 	</xsl:apply-templates>
   305 </xsl:template>
   428 </xsl:template>
   306 
   429 
       
   430 <!-- config metadata -->
       
   431 
       
   432 <xsl:template match="meta[@rel='config']">	<xsl:param name="filename"/>
       
   433 	<xsl:if test="@type!='auto'">
       
   434 	<xsl:call-template name="Warning"><xsl:with-param name="text">Unrecognised configuration metadata type <xsl:value-of select="@type"/></xsl:with-param></xsl:call-template>		
       
   435 	</xsl:if>
       
   436 	<xsl:for-each select="descendant::text()[normalize-space(.)!='']">
       
   437 		<xsl:call-template name="Error"><xsl:with-param name="text">Text content not valid in <xsl:value-of select="name(..)"/> (<xsl:value-of select="normalize-space(.)"/>)</xsl:with-param></xsl:call-template>
       
   438 	</xsl:for-each>
       
   439 	<xsl:if test="pick">
       
   440 		<xsl:variable name="npicks" select="count(pick) +1"/>
       
   441 		<xsl:for-each select="../descendant-or-self::component">
       
   442 			<xsl:if test="count(unit) &gt; $npicks">
       
   443 				<xsl:call-template name="Warning"><xsl:with-param name="text">Configuration metadata should have at least one fewer pick elements (<xsl:value-of select="$npicks - 1"/>) than the number of units in <xsl:value-of select="name(..)"/> "<id><xsl:value-of select="../@id"/></id>" (<xsl:value-of select="count(unit)"/>)</xsl:with-param></xsl:call-template>				
       
   444 			</xsl:if>
       
   445 		</xsl:for-each>
       
   446 	</xsl:if>
       
   447 	<xsl:apply-templates select="@* | *"/>
       
   448 </xsl:template>
       
   449 
       
   450 
       
   451 <xsl:template match="meta[@rel='config']/defined | meta[@rel='config']/not-defined | meta[@rel='config']/pick/defined | meta[@rel='config']/pick/not-defined">
       
   452 	<xsl:if test="node()">
       
   453 		<xsl:call-template name="Error"><xsl:with-param name="text">Configuration metadata <xsl:value-of select="name()"/> must be empty</xsl:with-param></xsl:call-template>		
       
   454 	</xsl:if>
       
   455 	<xsl:if test="not(@condition)">
       
   456 		<xsl:call-template name="Error"><xsl:with-param name="text">Configuration metadata <xsl:value-of select="name()"/> must have a condition</xsl:with-param></xsl:call-template>		
       
   457 	</xsl:if>
       
   458 		<xsl:apply-templates select="@*[name()!='condition']" mode="valid"/>
       
   459 </xsl:template>
       
   460 
       
   461 <xsl:template match="meta[@rel='config']/pick">
       
   462 	<xsl:choose>
       
   463 		<xsl:when test="not(@version)">
       
   464 			<xsl:call-template name="Error"><xsl:with-param name="text">Configuration metadata <xsl:value-of select="name()"/> must have a version</xsl:with-param></xsl:call-template>		
       
   465 		</xsl:when>
       
   466 		<xsl:when test="not(../../descendant::unit[@version=current()/@version])">
       
   467 			<xsl:call-template name="Error"><xsl:with-param name="text">Configuration metadata <xsl:value-of select="name()"/> version="<xsl:value-of select="@version"/>" must match a unit within the containing <xsl:value-of select="name(../..)"/> "<xsl:value-of select="../../@id"/>"</xsl:with-param></xsl:call-template>				
       
   468 		</xsl:when>
       
   469 	</xsl:choose>
       
   470 	<xsl:apply-templates select="@*[name()!='version']" mode="valid"/>
       
   471 	<xsl:apply-templates select="*"/>
       
   472 </xsl:template>
       
   473 
       
   474 <!-- /config metadata -->
       
   475 
       
   476 
   307 
   477 
   308 <xsl:template match="unit/@* | meta/@*" priority="-1">	
   478 <xsl:template match="unit/@* | meta/@*" priority="-1">	
   309 	<xsl:apply-templates select="." mode="valid"/>
   479 	<xsl:apply-templates select="." mode="valid"/>
   310 </xsl:template>
   480 </xsl:template>
   311 
   481 
       
   482 <xsl:template match="@*[.='']" mode="valid">
       
   483 	<xsl:call-template name="Error"><xsl:with-param name="text">Empty attribute "<xsl:value-of select="name()"/>" on <xsl:value-of select="name(..)"/><xsl:if test="../@id[.!='']"> "<id><xsl:value-of select="../@id"/></id>"</xsl:if></xsl:with-param></xsl:call-template>
       
   484 </xsl:template>
       
   485 
   312 
   486 
   313 <xsl:template match="@id" mode="path">
   487 <xsl:template match="@id" mode="path">
   314 	<xsl:choose>
   488 	<xsl:choose>
   315 		<xsl:when test="contains(.,':')"><xsl:value-of  select="substring-after(.,':')"/></xsl:when>
   489 		<xsl:when test="contains(.,':')"><xsl:value-of  select="substring-after(.,':')"/></xsl:when>
   316 		<xsl:otherwise><xsl:value-of  select="."/></xsl:otherwise>
   490 		<xsl:otherwise><xsl:value-of  select="."/></xsl:otherwise>
   318 </xsl:template>
   492 </xsl:template>
   319 
   493 
   320 
   494 
   321 <xsl:template match="@id">
   495 <xsl:template match="@id">
   322 <xsl:if test="contains(concat(' ',substring-after($all-ids,concat(' ',.,' '))),concat(' ',.,' '))">
   496 <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>
   497 	<xsl:call-template name="Error"><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>
   498 </xsl:if>
   325 
   499 
   326 <xsl:if test="contains(.,':') and not(ancestor::*/namespace::*[name()=substring-before(current(),':')])">
   500 <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>
   501 	<xsl:call-template name="Error"><xsl:with-param name="text">Undefined namespace for ID "<id><xsl:value-of select="."/></id>"</xsl:with-param></xsl:call-template>
   328 </xsl:if>
   502 </xsl:if>
   329 
   503 
       
   504 <xsl:if test="translate(.,'-','')!=.">
       
   505 	<xsl:call-template name="Error"><xsl:with-param name="text">ID "<id><xsl:value-of select="."/></id>" contains reserved character "-" </xsl:with-param></xsl:call-template>
       
   506 </xsl:if>
       
   507 
       
   508 <xsl:if test="contains(.,'.') and not(parent::package) and not(contains(ancestor::package/@id,'.'))">
       
   509 	<xsl:call-template name="Error"><xsl:with-param name="text">ID "<xsl:value-of select="."/>" contains reserved character "<code>.</code>" </xsl:with-param></xsl:call-template>
       
   510 </xsl:if>
       
   511 
       
   512 <xsl:if test="translate(substring(.,1,1),'0123456789','')=''">
       
   513 	<xsl:call-template name="Error"><xsl:with-param name="text">ID "<id><xsl:value-of select="."/></id>" cannot begin with a digit</xsl:with-param></xsl:call-template>
       
   514 </xsl:if>
       
   515 
       
   516 
       
   517 <xsl:if test="translate(.,'&AZ;','')!=.">
       
   518 	<xsl:call-template name="Warning"><xsl:with-param name="text">IDs should be entirely in lowercase (<xsl:value-of select="."/>)</xsl:with-param></xsl:call-template>
       
   519 </xsl:if>
       
   520 
       
   521 
       
   522 <!-- should also test for outside the range of  Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
       
   523 	see http://www.w3.org/TR/2000/WD-xml-2e-20000814#NT-Name
       
   524  -->
       
   525 </xsl:template>
       
   526 
       
   527 
       
   528 <xsl:template match="@*" mode="namespace-for-id">
       
   529 <xsl:choose>
       
   530 	<xsl:when test="contains(.,':') and ancestor::*/namespace::*[name()=substring-before(current(),':')]">
       
   531 		<xsl:value-of select="ancestor::*/namespace::*[name()=substring-before(current(),':')]"/>
       
   532 	</xsl:when>
       
   533 	<xsl:when test="ancestor::SystemDefinition/@id-namespace"><xsl:value-of select="ancestor::SystemDefinition/@id-namespace"/></xsl:when>
       
   534 	<xsl:otherwise><xsl:value-of select="$sf-ns"/></xsl:otherwise>
       
   535 </xsl:choose>
   330 </xsl:template>
   536 </xsl:template>
   331 
   537 
   332 
   538 
   333 <xsl:template mode="localid" match="*">
   539 <xsl:template mode="localid" match="*">
   334 	<xsl:choose>
   540 	<xsl:choose>
   340 <xsl:if test="substring(.,string-length(.))='/'">
   546 <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>
   547 		<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>
   548 </xsl:if>
   343 <xsl:if test="contains(.,'\')">
   549 <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>
   550 		<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>
       
   551 </xsl:if>
       
   552 
       
   553 <xsl:if test="count(//unit[@bldFile=current()]/..) &gt; 1">
       
   554 		<xsl:call-template name="Error"><xsl:with-param name="text"><code><xsl:value-of select="name()"/></code> path "<xsl:value-of select="."/>" appears in components <xsl:for-each select="//unit[@bldFile=current()]/..">
       
   555 			<id><xsl:value-of select="@id"/></id>
       
   556 			<xsl:choose>
       
   557 			<xsl:when test="position()=last() - 1"> and </xsl:when>
       
   558 			<xsl:when test="position()!=last()">, </xsl:when>
       
   559 			</xsl:choose>
       
   560 			</xsl:for-each>
       
   561 		</xsl:with-param>
       
   562 		<xsl:with-param name="sub">Use filters or config metadata to control what kind of builds a component can appear in</xsl:with-param>
       
   563 		</xsl:call-template>
   345 </xsl:if>
   564 </xsl:if>
   346 
   565 
   347 <!-- this is a realtive path, so just check that it's the expected number of dirs down -->
   566 <!-- 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">
   567 	<xsl:variable name="fullpath"><xsl:call-template name="normpath">
   349 				<xsl:with-param name="path">
   568 				<xsl:with-param name="path">