|
1 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common"> |
|
2 <!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
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 Merge two 3.x syntax system definitions |
|
14 --> |
|
15 |
|
16 <xsl:output method="xml" indent="yes"/> |
|
17 <xsl:param name="Downstream">mcl/System_Definition_Template.xml</xsl:param> |
|
18 <xsl:key name="origin" match="component" use="@origin-model"/> |
|
19 |
|
20 <!-- only supports 3.x syntax and only operates on stand-alone models --> |
|
21 |
|
22 <xsl:variable name="downstream" select="document($Downstream,.)/SystemDefinition"/> |
|
23 <xsl:param name="upname"> |
|
24 <xsl:choose> |
|
25 <xsl:when test="$downstream[starts-with(@schema,'2.') or starts-with(@schema,'1.') or not(systemModel)]"> |
|
26 <xsl:message terminate="yes">Syntax <xsl:value-of select="@schema"/> not supported</xsl:message> |
|
27 </xsl:when> |
|
28 <xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name"> |
|
29 <xsl:apply-templates mode="origin-term" select="/*"> |
|
30 <xsl:with-param name="root">Upstream</xsl:with-param> |
|
31 </xsl:apply-templates> |
|
32 </xsl:when> |
|
33 <xsl:otherwise><xsl:value-of select="/SystemDefinition/systemModel/@name"/></xsl:otherwise> |
|
34 </xsl:choose> |
|
35 </xsl:param> |
|
36 |
|
37 <xsl:param name="downname"> |
|
38 <xsl:choose> |
|
39 <xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name"> |
|
40 <xsl:apply-templates mode="origin-term" select="$downstream"> |
|
41 <xsl:with-param name="root">Downstream</xsl:with-param> |
|
42 </xsl:apply-templates> |
|
43 </xsl:when> |
|
44 <xsl:otherwise><xsl:value-of select="$downstream/systemModel/@name"/></xsl:otherwise> |
|
45 </xsl:choose> |
|
46 </xsl:param> |
|
47 |
|
48 <xsl:template mode="origin-term" match="*"> |
|
49 <xsl:param name="root"/> |
|
50 <xsl:param name="index"/> |
|
51 <xsl:choose> |
|
52 <xsl:when test="not(key('origin',concat($root,$index)))"> |
|
53 <xsl:value-of select="concat($root,$index)"/> |
|
54 </xsl:when> |
|
55 <xsl:when test="$index=''"> |
|
56 <xsl:apply-templates mode="origin-term" select="."> |
|
57 <xsl:with-param name="root" select="$root"/> |
|
58 <xsl:with-param name="index" select="1"/> |
|
59 </xsl:apply-templates> |
|
60 </xsl:when> |
|
61 <xsl:otherwise> |
|
62 <xsl:apply-templates mode="origin-term" select="."> |
|
63 <xsl:with-param name="root" select="$root"/> |
|
64 <xsl:with-param name="index" select="$index + 1"/> |
|
65 </xsl:apply-templates> |
|
66 </xsl:otherwise> |
|
67 </xsl:choose> |
|
68 </xsl:template> |
|
69 |
|
70 |
|
71 <!-- this merge only two files according to the 3.0.0 rules. Old syntax not supported. Must be converetd before calling --> |
|
72 |
|
73 |
|
74 |
|
75 <xsl:template match="/*"> |
|
76 <xsl:variable name="upmodel"> |
|
77 <sysdef name="{$upname}"/> |
|
78 </xsl:variable> |
|
79 <xsl:variable name="downmodel"> |
|
80 <sysdef name="{$downname}"/> |
|
81 </xsl:variable> |
|
82 |
|
83 <xsl:choose> |
|
84 <xsl:when test="function-available('exslt:node-set')"> |
|
85 <xsl:apply-templates mode="merge-models" select="."> |
|
86 <xsl:with-param name="other" select="$downstream"/> |
|
87 <xsl:with-param name="up" select="exslt:node-set($upmodel)/sysdef"/> |
|
88 <xsl:with-param name="down" select="exslt:node-set($downmodel)/sysdef"/> |
|
89 </xsl:apply-templates> |
|
90 </xsl:when> |
|
91 <xsl:otherwise> <!-- no node set funcion, so don't bother setting the names --> |
|
92 <xsl:apply-templates mode="merge-models" select="."> |
|
93 <xsl:with-param name="other" select="$downstream"/> |
|
94 </xsl:apply-templates> |
|
95 </xsl:otherwise> |
|
96 </xsl:choose> |
|
97 </xsl:template> |
|
98 |
|
99 <xsl:include href="mergesysdef-module.xsl"/> |
|
100 </xsl:stylesheet> |