metatools/sysdeftools/lib/test-model.xsl
changeset 660 66ff3e731c60
parent 656 88e01c8f013e
child 661 199bb033aacf
equal deleted inserted replaced
659:7afa5fba0903 660:66ff3e731c60
     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
    60 
    63 
    61 <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">
    62 	<xsl:param name="filename" select="$Filename"/>
    65 	<xsl:param name="filename" select="$Filename"/>
    63 <xsl:call-template name="Section">
    66 <xsl:call-template name="Section">
    64 	<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>
    65 	<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>
    66 </xsl:call-template>
    69 </xsl:call-template>
    67 	<xsl:apply-templates select="*">
    70 	<xsl:apply-templates select="*">
    68 		<xsl:with-param name="filename" select="$filename"/>
    71 		<xsl:with-param name="filename" select="$filename"/>
    69 	</xsl:apply-templates>
    72 	</xsl:apply-templates>
    70 </xsl:template>
    73 </xsl:template>
    71 
    74 
    72 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')] | systemModel">
    75 <xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')] | systemModel">
    73 	<xsl:param name="filename"  select="$Filename"/>
    76 	<xsl:param name="filename"  select="$Filename"/>
    74 		
    77 		
    75 <xsl:if test="//unit">
    78 <xsl:if test="//unit and not(self::systemModel)">
    76 <xsl:call-template name="Section">
    79 <xsl:call-template name="Section">
    77 	<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>
    78 	<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>
    79 </xsl:call-template>
    83 </xsl:call-template>
    80 </xsl:if>
    84 </xsl:if>
    81 <xsl:if test="self::systemModel and not(@name)">
    85 <xsl:if test="self::systemModel and not(@name)">
    82 	<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>
    83 </xsl:if>
    87 </xsl:if>
    84 	<xsl:apply-templates select="*">
    88 	<xsl:apply-templates select="*">
    85 		<xsl:with-param name="filename" select="$filename"/>
    89 		<xsl:with-param name="filename" select="$filename"/>
    86 	</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>
    87 </xsl:template>
    96 </xsl:template>
    88 
    97 
    89 
    98 
    90 <xsl:template match="@*" mode="valid">
    99 <xsl:template match="@*" mode="valid">
    91 	<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>
    92 </xsl:template>
   101 </xsl:template>
    93 
   102 
    94 <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 -->
    95 
   104 
    96 <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"/> 
    97 
   106 
    98 <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 
    99 
   178 
   100 <xsl:template match="component/@origin-model" mode="valid"/>
   179 <xsl:template match="component/@origin-model" mode="valid"/>
   101 
   180 
   102 <xsl:template match="unit/@priority" mode="valid">
   181 <xsl:template match="unit/@priority" mode="valid">
   103 	<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>
   109 </xsl:template>
   188 </xsl:template>
   110 
   189 
   111 <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"/> 
   112 	
   191 	
   113 
   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 
   114 <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"> 
   115 	<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>
   116 </xsl:template>
   204 </xsl:template>
   117 
   205 
   118 
   206 
   119 <xsl:template match="@replace" mode="valid">
   207 <xsl:template match="@replace" mode="valid">
   120 	<xsl:if test="/SystemDefinition[@schema='3.0.0']">
   208 	<xsl:if test="/SystemDefinition[@schema='3.0.0']">
   121 		<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>
   122 	</xsl:if>
   210 	</xsl:if>
   123 </xsl:template>
   211 </xsl:template>
   124 
   212 
   125 
   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>
   126 
   229 
   127 <xsl:template name="validate-class">
   230 <xsl:template name="validate-class">
   128 	<ok>plugin</ok>
   231 	<ok>plugin</ok>
   129 	<ok>doc</ok>
   232 	<ok>doc</ok>
   130 	<ok>tool</ok>
   233 	<ok>tool</ok>
   217 
   320 
   218 
   321 
   219 
   322 
   220 
   323 
   221 <xsl:template match="*" priority="-2">
   324 <xsl:template match="*" priority="-2">
   222 	<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>
   223 </xsl:template>
   326 </xsl:template>
   224 
   327 
   225 <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)] | 
   226 	<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>
   227 </xsl:template>
   333 </xsl:template>
   228 
   334 
   229 <xsl:template match="layer | package | collection | component">
   335 <xsl:template match="layer | package | collection | component">
   230 	<xsl:param name="filename"/>
   336 	<xsl:param name="filename"/>
       
   337 
       
   338 <xsl:if test="self::package 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>
   231 
   345 
   232 <xsl:apply-templates select="@*" mode="valid"/>
   346 <xsl:apply-templates select="@*" mode="valid"/>
   233 <xsl:apply-templates select="@id"/>
   347 <xsl:apply-templates select="@id"/>
   234 <xsl:if test="self::component">
   348 <xsl:if test="self::component">
   235 	<xsl:choose>
   349 	<xsl:choose>
   236 		<xsl:when test="count(unit[not(@filter | @version)]) = 0 "/>
   350 		<xsl:when test="count(unit[not(@filter | @version)]) = 0 "/>
   237 		<xsl:when test="count(unit[not(@version)]) &gt; 1 and @filter='s60'">
   351 		<xsl:when test="count(unit[not(@version)]) &gt; 1 and @filter='s60'">
   238 			<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>
   239 		</xsl:when>
   353 		</xsl:when>
   240 		<xsl:when test="count(unit[not(@version)]) &gt; 1">
   354 		<xsl:when test="count(unit[not(@version)]) &gt; 1">
   241 			<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>
   242 		</xsl:when>
   356 		</xsl:when>
   243 	</xsl:choose>
   357 	</xsl:choose>
   244 	<xsl:choose>
   358 	<xsl:choose>
   245 		<xsl:when test="unit"/>
   359 		<xsl:when test="unit"/>
   246 		<xsl:when test="contains(comment(),'PLACEHOLDER=')"/>
   360 		<xsl:when test="contains(comment(),'PLACEHOLDER=')"/>
   253 	</xsl:choose>
   367 	</xsl:choose>
   254 </xsl:if>
   368 </xsl:if>
   255 <xsl:if test="@href">
   369 <xsl:if test="@href">
   256 	<xsl:variable name="child" select="document(@href,.)/SystemDefinition"/>
   370 	<xsl:variable name="child" select="document(@href,.)/SystemDefinition"/>
   257 	<xsl:if test="@id!=$child/@id">
   371 	<xsl:if test="@id!=$child/@id">
   258 		<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>
   259 	</xsl:if>
   373 	</xsl:if>
   260 	<xsl:if test="$child/@href">
   374 	<xsl:if test="$child/@href">
   261 		<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>
   262 	</xsl:if>
   376 	</xsl:if>
   263 	<xsl:for-each select="@*[name()!='id']">
   377 	<xsl:for-each select="@*[name()!='id']">
   264 		<xsl:if test="$child/@*[name()=name(current())]">
   378 		<xsl:if test="$child/@*[name()=name(current())]">
   265 			<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>
   266 		</xsl:if>
   380 		</xsl:if>
   267 	</xsl:for-each>
   381 	</xsl:for-each>
   268 	<xsl:if test="*">
   382 	<xsl:if test="*">
   269 		<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>
   270 	</xsl:if>
   384 	</xsl:if>
   271 </xsl:if>
   385 </xsl:if>
   272 <xsl:if test="@href and name()!=name(document(@href,.)/SystemDefinition/*)">
   386 <xsl:if test="@href and name()!=name(document(@href,.)/SystemDefinition/*)">
   273 		<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>
   274 </xsl:if>
   388 </xsl:if>
   275 <xsl:if test="not(@href)">
   389 <xsl:if test="not(@href)">
   276 	<xsl:apply-templates select="*">
   390 	<xsl:apply-templates select="*">
   277 		<xsl:with-param name="filename" select="$filename"/>
   391 		<xsl:with-param name="filename" select="$filename"/>
   278 	</xsl:apply-templates>
   392 	</xsl:apply-templates>
   291 				 </xsl:with-param>
   405 				 </xsl:with-param>
   292 			</xsl:call-template>
   406 			</xsl:call-template>
   293 		 </xsl:with-param>
   407 		 </xsl:with-param>
   294 	</xsl:apply-templates>
   408 	</xsl:apply-templates>
   295 </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>
   296 </xsl:template>
   414 </xsl:template>
   297 
   415 
   298 
   416 
   299 
   417 
   300 <xsl:template match="meta">	<xsl:param name="filename"/>
   418 <xsl:template match="meta">	<xsl:param name="filename"/>
   307 	<xsl:apply-templates select="@*">
   425 	<xsl:apply-templates select="@*">
   308 		<xsl:with-param name="filename" select="$filename"/>
   426 		<xsl:with-param name="filename" select="$filename"/>
   309 	</xsl:apply-templates>
   427 	</xsl:apply-templates>
   310 </xsl:template>
   428 </xsl:template>
   311 
   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 
   312 
   477 
   313 <xsl:template match="unit/@* | meta/@*" priority="-1">	
   478 <xsl:template match="unit/@* | meta/@*" priority="-1">	
   314 	<xsl:apply-templates select="." mode="valid"/>
   479 	<xsl:apply-templates select="." mode="valid"/>
   315 </xsl:template>
   480 </xsl:template>
   316 
   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 
   317 
   486 
   318 <xsl:template match="@id" mode="path">
   487 <xsl:template match="@id" mode="path">
   319 	<xsl:choose>
   488 	<xsl:choose>
   320 		<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>
   321 		<xsl:otherwise><xsl:value-of  select="."/></xsl:otherwise>
   490 		<xsl:otherwise><xsl:value-of  select="."/></xsl:otherwise>
   323 </xsl:template>
   492 </xsl:template>
   324 
   493 
   325 
   494 
   326 <xsl:template match="@id">
   495 <xsl:template match="@id">
   327 <xsl:if test="contains(concat(' ',substring-after($all-ids,concat(' ',.,' '))),concat(' ',.,' '))">
   496 <xsl:if test="contains(concat(' ',substring-after($all-ids,concat(' ',.,' '))),concat(' ',.,' '))">
   328 	<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>
   329 </xsl:if>
   498 </xsl:if>
   330 
   499 
   331 <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(),':')])">
   332 	<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>
   333 </xsl:if>
   502 </xsl:if>
   334 
   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::pacakge/@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  -->
   335 </xsl:template>
   525 </xsl:template>
   336 
   526 
   337 
   527 
   338 <xsl:template match="@*" mode="namespace-for-id">
   528 <xsl:template match="@*" mode="namespace-for-id">
   339 <xsl:choose>
   529 <xsl:choose>