metatools/sysdeftools/lib/test-model.xsl
changeset 663 8e27d440923e
parent 661 199bb033aacf
equal deleted inserted replaced
662:60be34e1b006 663:8e27d440923e
     1  <!DOCTYPE XSLT  [
     1 <xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
     2       <!ENTITY AZ  "ABCDEFGHIJKLMNOPQRSTUVWXYZ">
       
     3       <!ENTITY az  "abcdefghijklmnopqrstuvwxyz">
       
     4  ]><xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
       
     5 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     2 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     6 	All rights reserved.
     3 	All rights reserved.
     7 	This component and the accompanying materials are made available
     4 	This component and the accompanying materials are made available
     8 	under the terms of the License "Eclipse Public License v1.0"
     5 	under the terms of the License "Eclipse Public License v1.0"
     9 	which accompanies this distribution, and is available
     6 	which accompanies this distribution, and is available
    21 
    18 
    22 	<xsl:variable name="all-ids">
    19 	<xsl:variable name="all-ids">
    23 		<xsl:apply-templates select="document(/model/sysdef/@href)| SystemDefinition" mode="ids"/>
    20 		<xsl:apply-templates select="document(/model/sysdef/@href)| SystemDefinition" mode="ids"/>
    24 	</xsl:variable>
    21 	</xsl:variable>
    25 
    22 
    26 	<xsl:variable name="sf-ns">http://www.symbian.org/system-definition</xsl:variable>
       
    27  
    23  
    28 <xsl:template match="/model" priority="-1">
    24 <xsl:template match="/model" priority="-1">
    29 	<xsl:apply-templates select="." mode="check"/>
    25 	<xsl:apply-templates select="." mode="check"/>
    30 </xsl:template>
    26 </xsl:template>
    31 
    27 
    63 
    59 
    64 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')and systemModel]" priority="2">
    60 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')and systemModel]" priority="2">
    65 	<xsl:param name="filename" select="$Filename"/>
    61 	<xsl:param name="filename" select="$Filename"/>
    66 <xsl:call-template name="Section">
    62 <xsl:call-template name="Section">
    67 	<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>
    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>
    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>
    69 </xsl:call-template>
    65 </xsl:call-template>
    70 	<xsl:apply-templates select="*">
    66 	<xsl:apply-templates select="*">
    71 		<xsl:with-param name="filename" select="$filename"/>
    67 		<xsl:with-param name="filename" select="$filename"/>
    72 	</xsl:apply-templates>
    68 	</xsl:apply-templates>
    73 </xsl:template>
    69 </xsl:template>
    74 
    70 
    75 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')] | systemModel">
    71 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')] | systemModel">
    76 	<xsl:param name="filename"  select="$Filename"/>
    72 	<xsl:param name="filename"  select="$Filename"/>
    77 		
    73 		
    78 <xsl:if test="descendant::unit and not(self::systemModel)">
    74 <xsl:if test="//unit">
    79 <xsl:call-template name="Section">
    75 <xsl:call-template name="Section">
    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>
    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>
    81 	<xsl:with-param name="id"><xsl:value-of select="*/@id"/></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>
    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>
    83 </xsl:call-template>
    78 </xsl:call-template>
    84 </xsl:if>
    79 </xsl:if>
    85 <xsl:if test="self::systemModel and not(@name)">
    80 <xsl:if test="self::systemModel and not(@name)">
    86 	<xsl:call-template name="Error"><xsl:with-param name="text">systemModel element should have a name</xsl:with-param></xsl:call-template>
    81 	<xsl:call-template name="Error"><xsl:with-param name="text">systemModel element should have a name</xsl:with-param></xsl:call-template>
    87 </xsl:if>
    82 </xsl:if>
    88 	<xsl:apply-templates select="*">
    83 	<xsl:apply-templates select="*">
    89 		<xsl:with-param name="filename" select="$filename"/>
    84 		<xsl:with-param name="filename" select="$filename"/>
    90 	</xsl:apply-templates>
    85 	</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>
       
    96 </xsl:template>
    86 </xsl:template>
    97 
    87 
    98 
    88 
    99 <xsl:template match="@*" mode="valid">
    89 <xsl:template match="@*" mode="valid">
   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>
    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>
   101 </xsl:template>
    91 </xsl:template>
   102 
    92 
   103 <xsl:template match="@before|package/@span|layer/@span|collection/@level|package/@level|package/@levels|layer/@levels" mode="valid"/> <!-- really should check syntax -->
    93 <xsl:template match="@before|@id|package/@span|layer/@span|collection/@level|package/@level|package/@levels|layer/@levels" mode="valid"/> <!-- really should check syntax -->
   104 
    94 
   105 <xsl:template match="@href|@id|@filter|package/@version|unit/@version|unit/@prebuilt" mode="valid"/> 
    95 <xsl:template match="@name|@href|@filter|package/@version|unit/@version|unit/@prebuilt" mode="valid"/> 
   106 
    96 
   107 <xsl:template match="component/@introduced" mode="valid"/>
    97 <xsl:template match="component/@introduced|component/@deprecated" 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 
       
   178 
    98 
   179 <xsl:template match="component/@origin-model" mode="valid"/>
    99 <xsl:template match="component/@origin-model" mode="valid"/>
   180 
   100 
   181 <xsl:template match="unit/@priority" mode="valid">
   101 <xsl:template match="unit/@priority" mode="valid">
   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>
   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>
   188 </xsl:template>
   108 </xsl:template>
   189 
   109 
   190 <xsl:template match="@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='proFile']" mode="valid"/> 
   110 <xsl:template match="@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='proFile']" mode="valid"/> 
   191 	
   111 	
   192 
   112 
   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 
       
   198 <xsl:template match="@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='qmakeArgs']" mode="valid"> 
   113 <xsl:template match="@*[namespace-uri()='http://www.nokia.com/qt' and local-name()='qmakeArgs']" mode="valid"> 
   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>
   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>
   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>
       
   204 </xsl:template>
   115 </xsl:template>
   205 
   116 
   206 
   117 
   207 <xsl:template match="@replace" mode="valid">
   118 <xsl:template match="@replace" mode="valid">
   208 	<xsl:if test="/SystemDefinition[@schema='3.0.0']">
   119 	<xsl:if test="/SystemDefinition[@schema='3.0.0']">
   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>
   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>
   210 	</xsl:if>
   121 	</xsl:if>
   211 </xsl:template>
   122 </xsl:template>
   212 
   123 
   213 
   124 
   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>
       
   229 
   125 
   230 <xsl:template name="validate-class">
   126 <xsl:template name="validate-class">
   231 	<ok>plugin</ok>
   127 	<ok>plugin</ok>
   232 	<ok>doc</ok>
   128 	<ok>doc</ok>
   233 	<ok>tool</ok>
   129 	<ok>tool</ok>
   300 </xsl:template> 
   196 </xsl:template> 
   301 
   197 
   302 
   198 
   303 <xsl:template match="package/@tech-domain|component/@purpose|component/@target" mode="valid">
   199 <xsl:template match="package/@tech-domain|component/@purpose|component/@target" mode="valid">
   304 	<xsl:variable name="v" select="document('')/*/xsl:template[@name=concat('validate-',name(current()))]/*[.=current()]"/>
   200 	<xsl:variable name="v" select="document('')/*/xsl:template[@name=concat('validate-',name(current()))]/*[.=current()]"/>
   305 	<xsl:variable name="ns"><xsl:apply-templates select="../@id" mode="namespace-for-id"/></xsl:variable>
   201 	<xsl:choose>
   306 	<xsl:choose>
   202 		<xsl:when test="not($v)">
   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>
   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>
   309 		</xsl:when> 
       
   310 		<xsl:when test="not($v)">
       
   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>
       
   312 		</xsl:when> 
   204 		</xsl:when> 
   313 		<xsl:when test="name($v)='ok'"/> 
   205 		<xsl:when test="name($v)='ok'"/> 
   314 		<xsl:when test="name($v)='w'">
   206 		<xsl:when test="name($v)='w'">
   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>
   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>
   316 		</xsl:when> 
   208 		</xsl:when> 
   320 
   212 
   321 
   213 
   322 
   214 
   323 
   215 
   324 <xsl:template match="*" priority="-2">
   216 <xsl:template match="*" priority="-2">
   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>
   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>
   326 </xsl:template>
   218 </xsl:template>
   327 
   219 
   328 <xsl:template match="component[not(parent::collection) or (parent::SystemDefinition and count(../*)=1)] | 
   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">
   329 	collection[not(parent::package) 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>
   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>
       
   333 </xsl:template>
   222 </xsl:template>
   334 
   223 
   335 <xsl:template match="layer | package | collection | component">
   224 <xsl:template match="layer | package | collection | component">
   336 	<xsl:param name="filename"/>
   225 	<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>
       
   345 
   226 
   346 <xsl:apply-templates select="@*" mode="valid"/>
   227 <xsl:apply-templates select="@*" mode="valid"/>
   347 <xsl:apply-templates select="@id"/>
   228 <xsl:apply-templates select="@id"/>
   348 <xsl:if test="self::component">
   229 <xsl:if test="self::component">
   349 	<xsl:choose>
   230 	<xsl:choose>
   350 		<xsl:when test="count(unit[not(@filter | @version)]) = 0 "/>
   231 		<xsl:when test="count(unit[not(@filter | @version)]) = 0 "/>
   351 		<xsl:when test="count(unit[not(@version)]) &gt; 1 and descendant-or-self::*[contains(@filter,'s60')]">
   232 		<xsl:when test="count(unit[not(@version)]) &gt; 1 and @filter='s60'">
   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>
   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>
   353 		</xsl:when>
   234 		</xsl:when>
   354 		<xsl:when test="count(unit[not(@version)]) &gt; 1">
   235 		<xsl:when test="count(unit[not(@version)]) &gt; 1">
   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>
   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>
   356 		</xsl:when>
   237 		</xsl:when>
   357 	</xsl:choose>
   238 	</xsl:choose>
   358 	<xsl:choose>
   239 	<xsl:choose>
   359 		<xsl:when test="unit"/>
   240 		<xsl:when test="unit"/>
   360 		<xsl:when test="contains(comment(),'PLACEHOLDER=')"/>
   241 		<xsl:when test="contains(comment(),'PLACEHOLDER=')"/>
   367 	</xsl:choose>
   248 	</xsl:choose>
   368 </xsl:if>
   249 </xsl:if>
   369 <xsl:if test="@href">
   250 <xsl:if test="@href">
   370 	<xsl:variable name="child" select="document(@href,.)/SystemDefinition"/>
   251 	<xsl:variable name="child" select="document(@href,.)/SystemDefinition"/>
   371 	<xsl:if test="@id!=$child/@id">
   252 	<xsl:if test="@id!=$child/@id">
   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>
   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>
   373 	</xsl:if>
   254 	</xsl:if>
   374 	<xsl:if test="$child/@href">
   255 	<xsl:if test="$child/@href">
   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>
   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>
   376 	</xsl:if>
   257 	</xsl:if>
   377 	<xsl:for-each select="@*[name()!='id']">
   258 	<xsl:for-each select="@*[name()!='id']">
   378 		<xsl:if test="$child/@*[name()=name(current())]">
   259 		<xsl:if test="$child/@*[name()=name(current())]">
   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>
   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>
   380 		</xsl:if>
   261 		</xsl:if>
   381 	</xsl:for-each>
   262 	</xsl:for-each>
   382 	<xsl:if test="*">
   263 	<xsl:if test="*">
   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>
   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>
   384 	</xsl:if>
   265 	</xsl:if>
   385 </xsl:if>
   266 </xsl:if>
   386 <xsl:if test="@href and name()!=name(document(@href,.)/SystemDefinition/*)">
   267 <xsl:if test="@href and name()!=name(document(@href,.)/SystemDefinition/*)">
   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>
   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>
   388 </xsl:if>
   269 </xsl:if>
   389 <xsl:if test="not(@href)">
   270 <xsl:if test="not(@href)">
   390 	<xsl:apply-templates select="*">
   271 	<xsl:apply-templates select="*">
   391 		<xsl:with-param name="filename" select="$filename"/>
   272 		<xsl:with-param name="filename" select="$filename"/>
   392 	</xsl:apply-templates>
   273 	</xsl:apply-templates>
   405 				 </xsl:with-param>
   286 				 </xsl:with-param>
   406 			</xsl:call-template>
   287 			</xsl:call-template>
   407 		 </xsl:with-param>
   288 		 </xsl:with-param>
   408 	</xsl:apply-templates>
   289 	</xsl:apply-templates>
   409 </xsl:if>
   290 </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>
       
   414 </xsl:template>
   291 </xsl:template>
   415 
   292 
   416 
   293 
   417 
   294 
   418 <xsl:template match="meta">	<xsl:param name="filename"/>
   295 <xsl:template match="meta">	<xsl:param name="filename"/>
   425 	<xsl:apply-templates select="@*">
   302 	<xsl:apply-templates select="@*">
   426 		<xsl:with-param name="filename" select="$filename"/>
   303 		<xsl:with-param name="filename" select="$filename"/>
   427 	</xsl:apply-templates>
   304 	</xsl:apply-templates>
   428 </xsl:template>
   305 </xsl:template>
   429 
   306 
   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 
       
   477 
   307 
   478 <xsl:template match="unit/@* | meta/@*" priority="-1">	
   308 <xsl:template match="unit/@* | meta/@*" priority="-1">	
   479 	<xsl:apply-templates select="." mode="valid"/>
   309 	<xsl:apply-templates select="." mode="valid"/>
   480 </xsl:template>
   310 </xsl:template>
   481 
   311 
   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 
       
   486 
   312 
   487 <xsl:template match="@id" mode="path">
   313 <xsl:template match="@id" mode="path">
   488 	<xsl:choose>
   314 	<xsl:choose>
   489 		<xsl:when test="contains(.,':')"><xsl:value-of  select="substring-after(.,':')"/></xsl:when>
   315 		<xsl:when test="contains(.,':')"><xsl:value-of  select="substring-after(.,':')"/></xsl:when>
   490 		<xsl:otherwise><xsl:value-of  select="."/></xsl:otherwise>
   316 		<xsl:otherwise><xsl:value-of  select="."/></xsl:otherwise>
   492 </xsl:template>
   318 </xsl:template>
   493 
   319 
   494 
   320 
   495 <xsl:template match="@id">
   321 <xsl:template match="@id">
   496 <xsl:if test="contains(concat(' ',substring-after($all-ids,concat(' ',.,' '))),concat(' ',.,' '))">
   322 <xsl:if test="contains(concat(' ',substring-after($all-ids,concat(' ',.,' '))),concat(' ',.,' '))">
   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>
   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>
   498 </xsl:if>
   324 </xsl:if>
   499 
   325 
   500 <xsl:if test="contains(.,':') and not(ancestor::*/namespace::*[name()=substring-before(current(),':')])">
   326 <xsl:if test="contains(.,':') and not(ancestor::*/namespace::*[name()=substring-before(current(),':')])">
   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>
   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>
   502 </xsl:if>
   328 </xsl:if>
   503 
   329 
   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>
       
   536 </xsl:template>
   330 </xsl:template>
   537 
   331 
   538 
   332 
   539 <xsl:template mode="localid" match="*">
   333 <xsl:template mode="localid" match="*">
   540 	<xsl:choose>
   334 	<xsl:choose>
   546 <xsl:if test="substring(.,string-length(.))='/'">
   340 <xsl:if test="substring(.,string-length(.))='/'">
   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>
   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>
   548 </xsl:if>
   342 </xsl:if>
   549 <xsl:if test="contains(.,'\')">
   343 <xsl:if test="contains(.,'\')">
   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>
   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>
   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>
       
   564 </xsl:if>
   345 </xsl:if>
   565 
   346 
   566 <!-- this is a realtive path, so just check that it's the expected number of dirs down -->
   347 <!-- this is a realtive path, so just check that it's the expected number of dirs down -->
   567 	<xsl:variable name="fullpath"><xsl:call-template name="normpath">
   348 	<xsl:variable name="fullpath"><xsl:call-template name="normpath">
   568 				<xsl:with-param name="path">
   349 				<xsl:with-param name="path">