bldsystemtools/sysdeftools/mergesysdef.xsl
changeset 63 d706e2bc01db
parent 25 85578ba0aa08
equal deleted inserted replaced
51:858432135449 63:d706e2bc01db
    20 <!-- only supports 3.x syntax and only operates on stand-alone models -->
    20 <!-- only supports 3.x syntax and only operates on stand-alone models -->
    21 
    21 
    22 <xsl:variable name="downstream" select="document($Downstream,.)/SystemDefinition"/>
    22 <xsl:variable name="downstream" select="document($Downstream,.)/SystemDefinition"/>
    23 <xsl:param name="upname">
    23 <xsl:param name="upname">
    24 	<xsl:choose>
    24 	<xsl:choose>
    25 		<xsl:when test="$downstream[starts-with(@schema,'2.') or starts-with(@schema,'1.')  or not(systemModel)]">
    25 		<xsl:when test="$downstream[starts-with(@schema,'2.') or starts-with(@schema,'1.')]">
    26 			<xsl:message terminate="yes">Syntax <xsl:value-of select="@schema"/> not supported</xsl:message>
    26 			<xsl:message terminate="yes">Syntax <xsl:value-of select="@schema"/> not supported</xsl:message>
    27 		</xsl:when>
    27 		</xsl:when>
    28 		<xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name">
    28 		<xsl:when test="name($downstream/*)!=name(/SystemDefinition/*)">
       
    29 			<xsl:message terminate="yes">Can only merge fragments of the same rank</xsl:message>
       
    30 		</xsl:when>
       
    31 <!--		<xsl:when test="$downstream[not(systemModel)]">
       
    32 			<xsl:message terminate="yes">Needs to be a standalone system definition</xsl:message>
       
    33 		</xsl:when>-->
       
    34 		<xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name or not(/SystemDefinition/systemModel/@name)">
    29 			<xsl:apply-templates mode="origin-term" select="/*">
    35 			<xsl:apply-templates mode="origin-term" select="/*">
    30 				<xsl:with-param name="root">Upstream</xsl:with-param>
    36 				<xsl:with-param name="root">Upstream</xsl:with-param>
    31 			</xsl:apply-templates>
    37 			</xsl:apply-templates>
    32 			</xsl:when>
    38 			</xsl:when>
    33 		<xsl:otherwise><xsl:value-of select="/SystemDefinition/systemModel/@name"/></xsl:otherwise>
    39 		<xsl:otherwise><xsl:value-of select="/SystemDefinition/systemModel/@name"/></xsl:otherwise>
    34 	</xsl:choose>
    40 	</xsl:choose>
    35 </xsl:param>
    41 </xsl:param>
    36 
    42 
    37 <xsl:param name="downname">
    43 <xsl:param name="downname">
    38 	<xsl:choose>
    44 	<xsl:choose>
    39 		<xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name">
    45 		<xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name or not($downstream/systemModel/@name)">
    40 			<xsl:apply-templates mode="origin-term" select="$downstream">	
    46 			<xsl:apply-templates mode="origin-term" select="$downstream">	
    41 				<xsl:with-param name="root">Downstream</xsl:with-param>
    47 				<xsl:with-param name="root">Downstream</xsl:with-param>
    42 			</xsl:apply-templates>
    48 			</xsl:apply-templates>
    43 			</xsl:when>
    49 			</xsl:when>
       
    50 		<xsl:when test="name($downstream/*)!=name(/SystemDefinition/*)">
       
    51 			<xsl:message terminate="yes">Can only merge fragments of the same rank</xsl:message>
       
    52 		</xsl:when>
    44 		<xsl:otherwise><xsl:value-of select="$downstream/systemModel/@name"/></xsl:otherwise>
    53 		<xsl:otherwise><xsl:value-of select="$downstream/systemModel/@name"/></xsl:otherwise>
    45 	</xsl:choose>
    54 	</xsl:choose>
    46 </xsl:param>
    55 </xsl:param>
    47 
    56 
    48 <xsl:template mode="origin-term" match="*">
    57 <xsl:template mode="origin-term" match="*">
    66 		</xsl:otherwise>
    75 		</xsl:otherwise>
    67 	</xsl:choose>
    76 	</xsl:choose>
    68 </xsl:template>
    77 </xsl:template>
    69 
    78 
    70 
    79 
    71 <!--  this merge only two files according to the 3.0.0 rules. Old syntax not supported. Must be converetd before calling -->
    80 <!-- choose the greater of the two versions -->
       
    81 <xsl:template name="compare-versions"><xsl:param name="v1"/><xsl:param name="v2"/>
       
    82 			<xsl:choose>
       
    83 				<xsl:when test="$v1=$v2"><xsl:value-of select="$v1"/></xsl:when>
       
    84 				<xsl:when test="substring-before($v1,'.') &gt; substring-before($v2,'.')"><xsl:value-of select="$v1"/></xsl:when>
       
    85 				<xsl:when test="substring-before($v1,'.') &lt; substring-before($v2,'.')"><xsl:value-of select="$v2"/></xsl:when>
       
    86 				<xsl:when test="substring-before(substring-after($v1,'.'),'.') &gt; substring-before(substring-after($v2,'.'),'.')"><xsl:value-of select="$v1"/></xsl:when>
       
    87 				<xsl:when test="substring-before(substring-after($v1,'.'),'.') &lt; substring-before(substring-after($v2,'.'),'.')"><xsl:value-of select="$v2"/></xsl:when>
       
    88 				<xsl:when test="substring-after(substring-after($v1,'.'),'.') &gt; substring-after(substring-after($v2,'.'),'.')"><xsl:value-of select="$v1"/></xsl:when>
       
    89 				<xsl:when test="substring-after(substring-after($v1,'.'),'.') &lt; substring-after(substring-after($v2,'.'),'.')"><xsl:value-of select="$v2"/></xsl:when>
       
    90 				<xsl:otherwise><xsl:value-of select="$v1"/></xsl:otherwise>
       
    91 			</xsl:choose>
       
    92 </xsl:template>
       
    93 
       
    94 <!--  this merge only two files according to the 3.0.x rules. Old syntax not supported. Must be converetd before calling -->
    72 
    95 
    73 
    96 
    74 
    97 
    75 <xsl:template match="/*">
    98 <xsl:template match="/*">
    76 	<xsl:variable name="upmodel">
    99 	<xsl:variable name="upmodel">