1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common"> |
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 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 All rights reserved. |
3 All rights reserved. |
4 This component and the accompanying materials are made available |
4 This component and the accompanying materials are made available |
5 under the terms of the License "Eclipse Public License v1.0" |
5 under the terms of the License "Eclipse Public License v1.0" |
6 which accompanies this distribution, and is available |
6 which accompanies this distribution, and is available |
11 Contributors: |
11 Contributors: |
12 Description: |
12 Description: |
13 Merge two 3.x syntax system definitions |
13 Merge two 3.x syntax system definitions |
14 --> |
14 --> |
15 |
15 |
|
16 <!--Description:This merges two 3.x syntax system definitions. |
|
17 It can process two standalone sysdefs or two sysdef fragments which describe |
|
18 the same system model item. |
|
19 If the sysdefs are not the same schema, the output will use the highest schema |
|
20 value of the two. |
|
21 --> |
|
22 <!--Input:<sysdef> - (required) The system definition XML file to process in the 3.0 format, and can be a fragment or stand-alone. |
|
23 If a fragment, this must be the same rank as the Downstream sysdef--> |
|
24 <!--Output:<sysdef> - (optional) The system definition XML file to save the output as. If not present it will write to stdout.--> |
|
25 |
16 <xsl:output method="xml" indent="yes"/> |
26 <xsl:output method="xml" indent="yes"/> |
17 <xsl:param name="Downstream">mcl/System_Definition_Template.xml</xsl:param> |
27 <xsl:param name="Downstream">mcl/System_Definition_Template.xml</xsl:param> <!-- <sysdef> - (required) The path to the downstream systef relative to the upstream one (ie the -in sysdef). --> |
18 <xsl:key name="origin" match="component" use="@origin-model"/> |
28 <xsl:key name="origin" match="component" use="@origin-model"/> |
19 |
|
20 <!-- only supports 3.x syntax and only operates on stand-alone models --> |
|
21 |
29 |
22 <xsl:variable name="downstream" select="document($Downstream,.)/SystemDefinition"/> |
30 <xsl:variable name="downstream" select="document($Downstream,.)/SystemDefinition"/> |
23 <xsl:param name="upname"> |
31 <xsl:param name="upname"> |
24 <xsl:choose> |
32 <xsl:choose> |
25 <xsl:when test="$downstream[starts-with(@schema,'2.') or starts-with(@schema,'1.')]"> |
33 <xsl:when test="$downstream[starts-with(@schema,'2.') or starts-with(@schema,'1.')]"> |
37 </xsl:apply-templates> |
45 </xsl:apply-templates> |
38 </xsl:when> |
46 </xsl:when> |
39 <xsl:otherwise><xsl:value-of select="/SystemDefinition/systemModel/@name"/></xsl:otherwise> |
47 <xsl:otherwise><xsl:value-of select="/SystemDefinition/systemModel/@name"/></xsl:otherwise> |
40 </xsl:choose> |
48 </xsl:choose> |
41 </xsl:param> |
49 </xsl:param> |
|
50 <!-- [name] - (optional) The name used in the origin-model attribute of any component that comes from the upstream sysdef. Defaults to the name attribute on the systemModel element, or "Upstream"--> |
42 |
51 |
43 <xsl:param name="downname"> |
52 <xsl:param name="downname"> |
44 <xsl:choose> |
53 <xsl:choose> |
45 <xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name or not($downstream/systemModel/@name)"> |
54 <xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name or not($downstream/systemModel/@name)"> |
46 <xsl:apply-templates mode="origin-term" select="$downstream"> |
55 <xsl:apply-templates mode="origin-term" select="$downstream"> |
51 <xsl:message terminate="yes">Can only merge fragments of the same rank</xsl:message> |
60 <xsl:message terminate="yes">Can only merge fragments of the same rank</xsl:message> |
52 </xsl:when> |
61 </xsl:when> |
53 <xsl:otherwise><xsl:value-of select="$downstream/systemModel/@name"/></xsl:otherwise> |
62 <xsl:otherwise><xsl:value-of select="$downstream/systemModel/@name"/></xsl:otherwise> |
54 </xsl:choose> |
63 </xsl:choose> |
55 </xsl:param> |
64 </xsl:param> |
|
65 <!-- [name] - (optional) The name used in the origin-model attribute of any component that comes from the downstream sysdef. Defaults to the name attribute on the systemModel element, or "Downstream"--> |
56 |
66 |
57 <xsl:template mode="origin-term" match="*"> |
67 <xsl:template mode="origin-term" match="*"> |
58 <xsl:param name="root"/> |
68 <xsl:param name="root"/> |
59 <xsl:param name="index"/> |
69 <xsl:param name="index"/> |
60 <xsl:choose> |
70 <xsl:choose> |
75 </xsl:otherwise> |
85 </xsl:otherwise> |
76 </xsl:choose> |
86 </xsl:choose> |
77 </xsl:template> |
87 </xsl:template> |
78 |
88 |
79 |
89 |
80 <!-- this merge only two files according to the 3.0.0 rules. Old syntax not supported. Must be converetd before calling --> |
90 <!-- choose the greater of the two versions --> |
|
91 <xsl:template name="compare-versions"><xsl:param name="v1"/><xsl:param name="v2"/> |
|
92 <xsl:choose> |
|
93 <xsl:when test="$v1=$v2"><xsl:value-of select="$v1"/></xsl:when> |
|
94 <xsl:when test="substring-before($v1,'.') > substring-before($v2,'.')"><xsl:value-of select="$v1"/></xsl:when> |
|
95 <xsl:when test="substring-before($v1,'.') < substring-before($v2,'.')"><xsl:value-of select="$v2"/></xsl:when> |
|
96 <xsl:when test="substring-before(substring-after($v1,'.'),'.') > substring-before(substring-after($v2,'.'),'.')"><xsl:value-of select="$v1"/></xsl:when> |
|
97 <xsl:when test="substring-before(substring-after($v1,'.'),'.') < substring-before(substring-after($v2,'.'),'.')"><xsl:value-of select="$v2"/></xsl:when> |
|
98 <xsl:when test="substring-after(substring-after($v1,'.'),'.') > substring-after(substring-after($v2,'.'),'.')"><xsl:value-of select="$v1"/></xsl:when> |
|
99 <xsl:when test="substring-after(substring-after($v1,'.'),'.') < substring-after(substring-after($v2,'.'),'.')"><xsl:value-of select="$v2"/></xsl:when> |
|
100 <xsl:otherwise><xsl:value-of select="$v1"/></xsl:otherwise> |
|
101 </xsl:choose> |
|
102 </xsl:template> |
|
103 |
|
104 <!-- this merge only two files according to the 3.0.x rules. Old syntax not supported. Must be converetd before calling --> |
81 |
105 |
82 |
106 |
83 |
107 |
84 <xsl:template match="/*"> |
108 <xsl:template match="/*"> |
85 <xsl:variable name="upmodel"> |
109 <xsl:variable name="upmodel"> |
86 <sysdef name="{$upname}"/> |
110 <sysdef name="{$upname}"/> |
87 </xsl:variable> |
111 </xsl:variable> |
88 <xsl:variable name="downmodel"> |
112 <xsl:variable name="downmodel"> |
89 <sysdef name="{$downname}"/> |
113 <sysdef name="{$downname}" pathto="{$Downstream}"/> |
90 </xsl:variable> |
114 </xsl:variable> |
91 |
115 |
92 <xsl:choose> |
116 <xsl:choose> |
93 <xsl:when test="function-available('exslt:node-set')"> |
117 <xsl:when test="function-available('exslt:node-set')"> |
94 <xsl:apply-templates mode="merge-models" select="."> |
118 <xsl:apply-templates mode="merge-models" select="."> |
103 </xsl:apply-templates> |
127 </xsl:apply-templates> |
104 </xsl:otherwise> |
128 </xsl:otherwise> |
105 </xsl:choose> |
129 </xsl:choose> |
106 </xsl:template> |
130 </xsl:template> |
107 |
131 |
|
132 <xsl:include href="path-module.xsl"/> |
108 <xsl:include href="mergesysdef-module.xsl"/> |
133 <xsl:include href="mergesysdef-module.xsl"/> |
|
134 <xsl:template match="@*[local-name()='proFile' or local-name()='qmakeArgs' or namespace-uri()='qt']" mode="merge-copy-of"> |
|
135 <!-- this fixes a xalan-j bug where it changes the namespace in the merged model to just "qt"--> |
|
136 <xsl:attribute name="{local-name()}" namespace="http://www.nokia.com/qt"> |
|
137 <xsl:value-of select="."/> |
|
138 </xsl:attribute> |
|
139 </xsl:template> |
|
140 |
109 </xsl:stylesheet> |
141 </xsl:stylesheet> |