179
|
1 |
<!--
|
|
2 |
============================================================================
|
|
3 |
Name : mergesysdef.xsl
|
|
4 |
Part of : Helium AntLib
|
|
5 |
|
|
6 |
Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
7 |
All rights reserved.
|
|
8 |
This component and the accompanying materials are made available
|
|
9 |
under the terms of the License "Eclipse Public License v1.0"
|
|
10 |
which accompanies this distribution, and is available
|
|
11 |
at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
12 |
|
|
13 |
Initial Contributors:
|
|
14 |
Nokia Corporation - initial contribution.
|
|
15 |
|
|
16 |
Contributors:
|
|
17 |
|
|
18 |
Description:
|
|
19 |
|
|
20 |
============================================================================
|
|
21 |
-->
|
|
22 |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common">
|
|
23 |
<xsl:output method="xml" indent="yes"/>
|
|
24 |
<xsl:param name="Downstream">mcl/System_Definition_Template.xml</xsl:param>
|
|
25 |
<xsl:key name="origin" match="component" use="@origin-model"/>
|
|
26 |
|
|
27 |
<!-- only supports 3.x syntax and only operates on stand-alone models -->
|
|
28 |
|
|
29 |
<xsl:variable name="downstream" select="document($Downstream,.)/SystemDefinition"/>
|
|
30 |
<xsl:param name="upname">
|
|
31 |
<xsl:choose>
|
|
32 |
<xsl:when test="$downstream[starts-with(@schema,'2.') or starts-with(@schema,'1.') or not(systemModel)]">
|
|
33 |
<xsl:message terminate="yes">Syntax <xsl:value-of select="@schema"/> not supported</xsl:message>
|
|
34 |
</xsl:when>
|
|
35 |
<xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name">
|
|
36 |
<xsl:apply-templates mode="origin-term" select="/*">
|
|
37 |
<xsl:with-param name="root">Upstream</xsl:with-param>
|
|
38 |
</xsl:apply-templates>
|
|
39 |
</xsl:when>
|
|
40 |
<xsl:otherwise><xsl:value-of select="/SystemDefinition/systemModel/@name"/></xsl:otherwise>
|
|
41 |
</xsl:choose>
|
|
42 |
</xsl:param>
|
|
43 |
|
|
44 |
<xsl:param name="downname">
|
|
45 |
<xsl:choose>
|
|
46 |
<xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name">
|
|
47 |
<xsl:apply-templates mode="origin-term" select="$downstream">
|
|
48 |
<xsl:with-param name="root">Downstream</xsl:with-param>
|
|
49 |
</xsl:apply-templates>
|
|
50 |
</xsl:when>
|
|
51 |
<xsl:otherwise><xsl:value-of select="$downstream/systemModel/@name"/></xsl:otherwise>
|
|
52 |
</xsl:choose>
|
|
53 |
</xsl:param>
|
|
54 |
|
|
55 |
<xsl:template mode="origin-term" match="*">
|
|
56 |
<xsl:param name="root"/>
|
|
57 |
<xsl:param name="index"/>
|
|
58 |
<xsl:choose>
|
|
59 |
<xsl:when test="not(key('origin',concat($root,$index)))">
|
|
60 |
<xsl:value-of select="concat($root,$index)"/>
|
|
61 |
</xsl:when>
|
|
62 |
<xsl:when test="$index=''">
|
|
63 |
<xsl:apply-templates mode="origin-term" select=".">
|
|
64 |
<xsl:with-param name="root" select="$root"/>
|
|
65 |
<xsl:with-param name="index" select="1"/>
|
|
66 |
</xsl:apply-templates>
|
|
67 |
</xsl:when>
|
|
68 |
<xsl:otherwise>
|
|
69 |
<xsl:apply-templates mode="origin-term" select=".">
|
|
70 |
<xsl:with-param name="root" select="$root"/>
|
|
71 |
<xsl:with-param name="index" select="$index + 1"/>
|
|
72 |
</xsl:apply-templates>
|
|
73 |
</xsl:otherwise>
|
|
74 |
</xsl:choose>
|
|
75 |
</xsl:template>
|
|
76 |
|
|
77 |
|
|
78 |
<!-- this merge only two files according to the 3.0.0 rules. Old syntax not supported. Must be converetd before calling -->
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
<xsl:template match="/*">
|
|
83 |
<xsl:variable name="upmodel">
|
|
84 |
<sysdef name="{$upname}"/>
|
|
85 |
</xsl:variable>
|
|
86 |
<xsl:variable name="downmodel">
|
|
87 |
<sysdef name="{$downname}"/>
|
|
88 |
</xsl:variable>
|
|
89 |
|
|
90 |
<xsl:choose>
|
|
91 |
<xsl:when test="function-available('exslt:node-set')">
|
|
92 |
<xsl:apply-templates mode="merge-models" select=".">
|
|
93 |
<xsl:with-param name="other" select="$downstream"/>
|
|
94 |
<xsl:with-param name="up" select="exslt:node-set($upmodel)/sysdef"/>
|
|
95 |
<xsl:with-param name="down" select="exslt:node-set($downmodel)/sysdef"/>
|
|
96 |
</xsl:apply-templates>
|
|
97 |
</xsl:when>
|
|
98 |
<xsl:otherwise> <!-- no node set funcion, so don't bother setting the names -->
|
|
99 |
<xsl:apply-templates mode="merge-models" select=".">
|
|
100 |
<xsl:with-param name="other" select="$downstream"/>
|
|
101 |
</xsl:apply-templates>
|
|
102 |
</xsl:otherwise>
|
|
103 |
</xsl:choose>
|
|
104 |
</xsl:template>
|
|
105 |
|
|
106 |
<xsl:include href="mergesysdef-module.xsl"/>
|
|
107 |
</xsl:stylesheet>
|