1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" exclude-result-prefixes="exslt"> |
1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common" exclude-result-prefixes="exslt"> |
2 |
2 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 <!-- this merge only two files according to the 3.0.0 rules. Old syntax not supported. Must be converetd before calling --> |
3 All rights reserved. |
|
4 This component and the accompanying materials are made available |
|
5 under the terms of the License "Eclipse Public License v1.0" |
|
6 which accompanies this distribution, and is available |
|
7 at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
|
9 Initial Contributors: |
|
10 Nokia Corporation - initial contribution. |
|
11 Contributors: |
|
12 Description: |
|
13 XSLT module for merging only two sysdef files according to the 3.0.0 rules. Old syntax not supported and must be converetd before calling. |
|
14 --> |
|
15 |
4 <xsl:variable name="defaultnamespace">http://www.symbian.org/system-definition</xsl:variable> |
16 <xsl:variable name="defaultnamespace">http://www.symbian.org/system-definition</xsl:variable> |
5 |
17 |
6 <xsl:template match="/SystemDefinition[starts-with(@schema,'2.') or starts-with(@schema,'1.')]" priority="2" mode="merge-models"> |
18 <xsl:template match="/SystemDefinition[starts-with(@schema,'2.') or starts-with(@schema,'1.')]" priority="2" mode="merge-models"> |
7 <xsl:message terminate="yes">Syntax <xsl:value-of select="@schema"/> not supported</xsl:message> |
19 <xsl:message terminate="yes">ERROR: Syntax <xsl:value-of select="@schema"/> not supported</xsl:message> |
8 </xsl:template> |
20 </xsl:template> |
9 <xsl:template match="/SystemDefinition[not(systemModel)]" priority="2" mode="merge-models"> |
21 <!--<xsl:template match="/SystemDefinition[not(systemModel)]" priority="2" mode="merge-models"> |
10 <xsl:message terminate="yes">Can only merge stand-alone system models</xsl:message> |
22 <xsl:message terminate="yes">ERROR: Can only merge stand-alone system models</xsl:message> |
11 </xsl:template> |
23 </xsl:template>--> |
12 |
24 |
13 <!-- stuff for dealing with namespaces --> |
25 <!-- stuff for dealing with namespaces --> |
14 |
26 |
15 |
27 |
16 <xsl:template match="node()|@*" mode="translate-namespaces"><xsl:copy-of select="."/></xsl:template> |
28 <xsl:template match="node()|@*" mode="translate-namespaces"><xsl:copy-of select="."/></xsl:template> |
72 </xsl:apply-templates> |
84 </xsl:apply-templates> |
73 </xsl:variable> |
85 </xsl:variable> |
74 <xsl:value-of select="concat($myns,':',$id)"/> |
86 <xsl:value-of select="concat($myns,':',$id)"/> |
75 </xsl:when> |
87 </xsl:when> |
76 <xsl:otherwise> <!-- some namespace that needed to be defined --> |
88 <xsl:otherwise> <!-- some namespace that needed to be defined --> |
77 <xsl:message>"<xsl:value-of select="$ns"/>" for <xsl:value-of select="$id"/></xsl:message> |
89 <xsl:message>Warning: need definition for namespace "<xsl:value-of select="$ns"/>" for <xsl:value-of select="$id"/></xsl:message> |
78 <xsl:value-of select="."/> |
90 <xsl:value-of select="."/> |
79 </xsl:otherwise> |
91 </xsl:otherwise> |
80 </xsl:choose> |
92 </xsl:choose> |
81 </xsl:attribute> |
93 </xsl:attribute> |
82 </xsl:template> |
94 </xsl:template> |
90 <xsl:choose> |
102 <xsl:choose> |
91 <xsl:when test="$pre!='' and $pre!='id-namespace' and not(//namespace::*[name()=$pre]) and not(contains($dontuse,concat(' ',$pre,' ')))"> |
103 <xsl:when test="$pre!='' and $pre!='id-namespace' and not(//namespace::*[name()=$pre]) and not(contains($dontuse,concat(' ',$pre,' ')))"> |
92 <xsl:value-of select="$pre"/> |
104 <xsl:value-of select="$pre"/> |
93 </xsl:when> |
105 </xsl:when> |
94 <xsl:when test="$ns='' and $chars=''"> |
106 <xsl:when test="$ns='' and $chars=''"> |
95 <xsl:message terminate="yes">Cannot create namespace prefix for downstream default namespace</xsl:message> |
107 <xsl:message terminate="yes">ERROR: Cannot create namespace prefix for downstream default namespace in <xsl:value-of select="*/@id"/></xsl:message> |
96 </xsl:when> |
108 </xsl:when> |
97 <xsl:when test="$name!='' and not(contains($dontuse,concat(' ',$name,' ')))"><xsl:value-of select="$name"/></xsl:when> |
109 <xsl:when test="$name!='' and not(contains($dontuse,concat(' ',$name,' ')))"><xsl:value-of select="$name"/></xsl:when> |
98 <xsl:when test="namespace::*[name()=substring($chars,1,1)] or contains($dontuse,concat(' ',substring($chars,1,1),' '))"> |
110 <xsl:when test="namespace::*[name()=substring($chars,1,1)] or contains($dontuse,concat(' ',substring($chars,1,1),' '))"> |
99 <xsl:apply-templates mode="ns-prefix"> |
111 <xsl:apply-templates mode="ns-prefix"> |
100 <xsl:with-param name="chars" select="substring($chars,2)"/> |
112 <xsl:with-param name="chars" select="substring($chars,2)"/> |
114 <xsl:param name="up" select="systemModel"/> <!-- the element containing the origin @name used for any component from "this" model. --> |
126 <xsl:param name="up" select="systemModel"/> <!-- the element containing the origin @name used for any component from "this" model. --> |
115 <xsl:param name="down" select="$other/systemModel"/> <!-- the element containing origin @name used for any component from $other model. --> |
127 <xsl:param name="down" select="$other/systemModel"/> <!-- the element containing origin @name used for any component from $other model. --> |
116 |
128 |
117 <!-- do some testing --> |
129 <!-- do some testing --> |
118 <xsl:if test="$other[starts-with(@schema,'2.') or starts-with(@schema,'1.')]"> |
130 <xsl:if test="$other[starts-with(@schema,'2.') or starts-with(@schema,'1.')]"> |
119 <xsl:message terminate="yes">Syntax <xsl:value-of select="$other/@schema"/> not supported</xsl:message> |
131 <xsl:message terminate="yes">ERROR: Syntax <xsl:value-of select="$other/@schema"/> not supported</xsl:message> |
120 </xsl:if> |
132 </xsl:if> |
121 <xsl:if test="not($other/systemModel)"> |
133 <xsl:if test="name(*) != name($other/*)"> |
122 <xsl:message terminate="yes">Can only merge stand-alone system models</xsl:message> |
134 <xsl:message terminate="yes">ERROR: Can only merge system models of the same rank</xsl:message> |
123 </xsl:if> |
135 </xsl:if> |
124 |
136 |
125 <xsl:copy> |
137 <xsl:copy> |
126 <xsl:copy-of select="@*"/> <!-- use attributes from origin model --> |
138 <xsl:copy-of select="@*"/> <!-- use attributes from origin model --> |
127 <xsl:variable name="namespaces"> |
139 <xsl:variable name="namespaces"> |