11 Contributors: |
11 Contributors: |
12 Description: |
12 Description: |
13 Module containing the validation logic for system definition 3.0.0 syntax |
13 Module containing the validation logic for system definition 3.0.0 syntax |
14 --> |
14 --> |
15 <xsl:key name="named" match="*[ancestor::systemModel]" use="@name"/> |
15 <xsl:key name="named" match="*[ancestor::systemModel]" use="@name"/> |
|
16 <xsl:param name="path-errors" select="0"/> |
16 <xsl:param name="Filename"/> |
17 <xsl:param name="Filename"/> |
17 <xsl:variable name="info" select="document(/model//info[@type='extra']/@href,/model)//c"/> |
18 <xsl:variable name="info" select="document(/model//info[@type='extra']/@href,/model)//c"/> |
18 |
19 |
19 <xsl:variable name="all-ids"> |
20 <xsl:variable name="all-ids"> |
20 <xsl:apply-templates select="document(/model/sysdef/@href)| SystemDefinition" mode="ids"/> |
21 <xsl:apply-templates select="document(/model/sysdef/@href)| SystemDefinition" mode="ids"/> |
88 |
89 |
89 <xsl:template match="@*" mode="valid"> |
90 <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> |
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> |
91 </xsl:template> |
92 </xsl:template> |
92 |
93 |
93 <xsl:template match="@before|@id|package/@span|collection/@level|package/@level|package/@levels|layer/@levels" mode="valid"/> <!-- really should check syntax --> |
94 <xsl:template match="@before|@id|package/@span|layer/@span|collection/@level|package/@level|package/@levels|layer/@levels" mode="valid"/> <!-- really should check syntax --> |
94 |
95 |
95 <xsl:template match="@name|@href|@filter" mode="valid"/> |
96 <xsl:template match="@name|@href|@filter" mode="valid"/> |
96 |
97 |
97 <xsl:template match="component/@introduced|component/@deprecated" mode="valid"/> |
98 <xsl:template match="component/@introduced|component/@deprecated" mode="valid"/> |
98 |
99 |
209 |
210 |
210 <xsl:apply-templates select="@*" mode="valid"/> |
211 <xsl:apply-templates select="@*" mode="valid"/> |
211 <xsl:apply-templates select="@id"/> |
212 <xsl:apply-templates select="@id"/> |
212 <xsl:if test="self::component"> |
213 <xsl:if test="self::component"> |
213 <xsl:choose> |
214 <xsl:choose> |
|
215 <xsl:when test="count(unit[not(@filter | @version)]) = 0 "/> |
214 <xsl:when test="count(unit[not(@version)]) > 1 and @filter='s60'"> |
216 <xsl:when test="count(unit[not(@version)]) > 1 and @filter='s60'"> |
215 <xsl:call-template name="Warning"><xsl:with-param name="text">S60 Component "<xsl:value-of select="@id"/>" has <xsl:value-of select="count(*)"/> children.</xsl:with-param></xsl:call-template> |
217 <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> |
216 </xsl:when> |
218 </xsl:when> |
217 <xsl:when test="count(unit[not(@version)]) > 1"> |
219 <xsl:when test="count(unit[not(@version)]) > 1"> |
218 <xsl:call-template name="Error"><xsl:with-param name="text">Component "<xsl:value-of select="@id"/>" has <xsl:value-of select="count(*)"/> children.</xsl:with-param></xsl:call-template> |
220 <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> |
219 </xsl:when> |
221 </xsl:when> |
220 </xsl:choose> |
222 </xsl:choose> |
221 <xsl:choose> |
223 <xsl:choose> |
222 <xsl:when test="unit"/> |
224 <xsl:when test="unit"/> |
223 <xsl:when test="contains(comment(),'PLACEHOLDER=')"/> |
225 <xsl:when test="contains(comment(),'PLACEHOLDER=')"/> |
278 <xsl:apply-templates select="@*"/> |
280 <xsl:apply-templates select="@*"/> |
279 </xsl:template> |
281 </xsl:template> |
280 |
282 |
281 <xsl:template match="meta/@rel | meta/@type | meta/@href"/> <!-- anything is valid --> |
283 <xsl:template match="meta/@rel | meta/@type | meta/@href"/> <!-- anything is valid --> |
282 |
284 |
283 |
|
284 <xsl:template match="unit"> <xsl:param name="filename"/> |
285 <xsl:template match="unit"> <xsl:param name="filename"/> |
285 <xsl:apply-templates select="@mrp|@bldFile"> |
286 <xsl:apply-templates select="@mrp|@bldFile"> |
286 <xsl:with-param name="filename" select="$filename"/> |
287 <xsl:with-param name="filename" select="$filename"/> |
287 </xsl:apply-templates> |
288 </xsl:apply-templates> |
288 </xsl:template> |
289 </xsl:template> |
312 <xsl:choose> |
313 <xsl:choose> |
313 <xsl:when test="contains(@id,':')">/<xsl:value-of select="substring-after(@id,':')"/></xsl:when> |
314 <xsl:when test="contains(@id,':')">/<xsl:value-of select="substring-after(@id,':')"/></xsl:when> |
314 <xsl:otherwise><xsl:value-of select="@id"/></xsl:otherwise> |
315 <xsl:otherwise><xsl:value-of select="@id"/></xsl:otherwise> |
315 </xsl:choose> |
316 </xsl:choose> |
316 </xsl:template> |
317 </xsl:template> |
317 |
|
318 |
|
319 <xsl:template match="@bldFile|@mrp"><xsl:param name="filename"/> |
318 <xsl:template match="@bldFile|@mrp"><xsl:param name="filename"/> |
320 <xsl:if test="substring(.,string-length(.))='/'"> |
319 <xsl:if test="substring(.,string-length(.))='/'"> |
321 <xsl:call-template name="Warning"><xsl:with-param name="text"><code><xsl:value-of select="name()"/></code> path "<xsl:value-of select="."/>" should not end in /</xsl:with-param></xsl:call-template> |
320 <xsl:call-template name="Warning"><xsl:with-param name="text"><code><xsl:value-of select="name()"/></code> path "<xsl:value-of select="."/>" should not end in /</xsl:with-param></xsl:call-template> |
322 </xsl:if> |
321 </xsl:if> |
323 <xsl:if test="contains(.,'\')"> |
322 <xsl:if test="contains(.,'\')"> |
351 <xsl:apply-templates select="ancestor::collection" mode="localid"/> |
350 <xsl:apply-templates select="ancestor::collection" mode="localid"/> |
352 </xsl:when> |
351 </xsl:when> |
353 <xsl:when test="ancestor::collection"/> |
352 <xsl:when test="ancestor::collection"/> |
354 </xsl:choose>/<xsl:apply-templates select="ancestor::component" mode="localid"/>/</xsl:variable> |
353 </xsl:choose>/<xsl:apply-templates select="ancestor::component" mode="localid"/>/</xsl:variable> |
355 <xsl:choose> |
354 <xsl:choose> |
356 <xsl:when test="not(starts-with(concat(.,'/'),$segment))"> |
355 <xsl:when test="not(starts-with(concat(.,'/'),$segment)) and $path-errors"> |
357 <xsl:call-template name="Note"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -> <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="$fullpath"/>"</xsl:with-param></xsl:call-template> |
356 <xsl:call-template name="Note"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -> <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="$fullpath"/>"</xsl:with-param></xsl:call-template> |
358 </xsl:when> |
357 </xsl:when> |
359 </xsl:choose> |
358 </xsl:choose> |
360 </xsl:template> |
359 </xsl:template> |
361 |
360 |
401 </xsl:choose> |
400 </xsl:choose> |
402 </xsl:variable> |
401 </xsl:variable> |
403 <xsl:choose> |
402 <xsl:choose> |
404 <xsl:when test="contains($filename,':')"> |
403 <xsl:when test="contains($filename,':')"> |
405 <xsl:choose> |
404 <xsl:choose> |
406 <xsl:when test="not(starts-with(.,$path) or concat(.,'/')=$path)"> |
405 <xsl:when test="not(starts-with(.,$path) or concat(.,'/')=$path) and $path-errors"> |
407 <xsl:call-template name="Note"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -> <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="."/>"</xsl:with-param></xsl:call-template> |
406 <xsl:call-template name="Note"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -> <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="."/>"</xsl:with-param></xsl:call-template> |
408 </xsl:when> |
407 </xsl:when> |
409 </xsl:choose> |
408 </xsl:choose> |
410 </xsl:when> |
409 </xsl:when> |
411 <xsl:otherwise> |
410 <xsl:otherwise> |
412 <xsl:choose> |
411 <xsl:choose> |
|
412 <xsl:when test="not($path-errors)"/> |
413 <xsl:when test="substring-before(substring($segment,2),'/') != substring-before(substring($path,2),'/') and (ancestor::SystemDefinition/@id-namespace!='http://www.symbian.org/system-definition' and not(contains(../../@id,':')))"> |
413 <xsl:when test="substring-before(substring($segment,2),'/') != substring-before(substring($path,2),'/') and (ancestor::SystemDefinition/@id-namespace!='http://www.symbian.org/system-definition' and not(contains(../../@id,':')))"> |
414 <xsl:call-template name="Warning"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -> <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="$fullpath"/>"</xsl:with-param></xsl:call-template> |
414 <xsl:call-template name="Warning"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -> <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="$fullpath"/>"</xsl:with-param></xsl:call-template> |
415 </xsl:when> |
415 </xsl:when> |
416 <xsl:when test="substring-before(substring($segment,2),'/') != substring-before(substring($path,2),'/')"> |
416 <xsl:when test="substring-before(substring($segment,2),'/') != substring-before(substring($path,2),'/')"> |
417 <xsl:call-template name="Error"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -> <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="$fullpath"/>"</xsl:with-param></xsl:call-template> |
417 <xsl:call-template name="Error"><xsl:with-param name="text">Unexpected <code><xsl:value-of select="name()"/></code> path for <xsl:apply-templates mode="path" select="../../../@id"/> -> <strong><xsl:apply-templates mode="path" select="../../@id"/></strong>: "<xsl:value-of select="$fullpath"/>"</xsl:with-param></xsl:call-template> |