sysmodelgen/core/joinsysdef-module.xsl
branchHighFidelityModel
changeset 165 ba562c1e2717
parent 152 5acf50bbb618
child 207 2fd8a273d6d6
equal deleted inserted replaced
164:8309dda95234 165:ba562c1e2717
    47 					<xsl:choose>
    47 					<xsl:choose>
    48 						<xsl:when test="$n='id'"/> <!-- never copy this, always set -->
    48 						<xsl:when test="$n='id'"/> <!-- never copy this, always set -->
    49 						<xsl:when test="$origin/@*[name()=$n]"> <!-- don't copy if already set -->
    49 						<xsl:when test="$origin/@*[name()=$n]"> <!-- don't copy if already set -->
    50 							<xsl:message>Cannot set "<xsl:value-of select="$n"/>", already set</xsl:message>
    50 							<xsl:message>Cannot set "<xsl:value-of select="$n"/>", already set</xsl:message>
    51 						</xsl:when>
    51 						</xsl:when>
    52 						<xsl:when test="$n='before'">
    52 						<xsl:when test="$n='before' or $n='replace'">
    53 							<!-- ensure ns is correct (if any future attribtues will ever use an ID, process it here too)-->
    53 							<!-- ensure ns is correct (if any future attribtues will ever use an ID, process it here too)-->
    54 							<xsl:apply-templates select="." mode="join">
    54 							<xsl:apply-templates select="." mode="join">
    55 								<xsl:with-param name="namespaces" select="$namespaces"/>
    55 								<xsl:with-param name="namespaces" select="$namespaces"/>
    56 							</xsl:apply-templates>
    56 							</xsl:apply-templates>
    57 						</xsl:when> 
    57 						</xsl:when> 
   317 		 <xsl:variable name="href">
   317 		 <xsl:variable name="href">
   318 		 	<xsl:apply-templates select="." mode="link">
   318 		 	<xsl:apply-templates select="." mode="link">
   319 				<xsl:with-param name="data" select="$data"/>
   319 				<xsl:with-param name="data" select="$data"/>
   320 			</xsl:apply-templates>
   320 			</xsl:apply-templates>
   321 		 </xsl:variable>
   321 		 </xsl:variable>
   322 	 		 
       
   323 		<xsl:element name="{name()}"> <!-- use this instead of <copy> so xalan doesn't add extra wrong namespaces -->
   322 		<xsl:element name="{name()}"> <!-- use this instead of <copy> so xalan doesn't add extra wrong namespaces -->
   324 			<xsl:apply-templates select="@*" mode="join">
   323 			<xsl:apply-templates select="@*" mode="join">
   325 				<xsl:with-param name="namespaces" select="$namespaces"/>
   324 				<xsl:with-param name="namespaces" select="$namespaces"/>
   326 			</xsl:apply-templates>
   325 			</xsl:apply-templates>
   327 			<xsl:if test="$display != '' ">
   326 			<xsl:if test="$display != '' ">
   438 	<xsl:apply-templates select=".." mode="err-path"/>/</xsl:if>
   437 	<xsl:apply-templates select=".." mode="err-path"/>/</xsl:if>
   439 <xsl:value-of select="@id"/>
   438 <xsl:value-of select="@id"/>
   440 </xsl:template>
   439 </xsl:template>
   441 
   440 
   442 
   441 
   443 <xsl:template match="@id|@before" mode="join">
   442 <xsl:template match="@id|@before|@replace" mode="join">
   444 	<xsl:param name="namespaces"/>
   443 	<xsl:param name="namespaces"/>
   445 	<!-- this will change the namespace prefixes for all IDs to match the root document -->
   444 	<!-- this will change the namespace prefixes for all IDs to match the root document -->
   446 	<xsl:variable name="ns">
   445 	<xsl:variable name="ns">
   447 		<xsl:apply-templates select="." mode="my-namespace"/>
   446 		<xsl:apply-templates select="." mode="my-namespace"/>
   448 	</xsl:variable>
   447 	</xsl:variable>
   449 	<xsl:if test="$ns=''">
   448 	<xsl:if test="$ns=''">
   450 		<xsl:message terminate="yes">ERROR: Could not find namespace for <xsl:value-of select="name()"/> "<xsl:value-of select="."/>" in <xsl:apply-templates select="../.." mode="err-path"/>
   449 		<xsl:message terminate="yes">ERROR: Could not find namespace for <xsl:value-of select="name()"/> "<xsl:value-of select="."/>" in <xsl:apply-templates select="../.." mode="err-path"/>
   451 		<xsl:text>&#xa;</xsl:text>
   450 		<xsl:text>&#xa;</xsl:text>
   452 		</xsl:message>
   451 		</xsl:message>
   453 	</xsl:if>
   452 	</xsl:if>
       
   453 
   454 	<xsl:variable name="prefix" select="name($namespaces[.=$ns])"/>
   454 	<xsl:variable name="prefix" select="name($namespaces[.=$ns])"/>
   455 	<xsl:attribute name="{name()}">
   455 	<xsl:attribute name="{name()}">
   456 	<xsl:choose>
   456 	<xsl:choose>
   457 		<xsl:when test="$prefix = 'id-namespace' or  (not($namespaces[name()='id-prefix']) and $ns=$defaultns)"/> <!-- it's the default namespace, no prefix -->
   457 
       
   458 		<xsl:when test="$prefix = 'id-namespace' or  (not($namespaces[name()='id-namespace']) and $ns=$defaultns)"/> <!-- it's the default namespace, no prefix -->
   458 		<xsl:when test="$prefix='' and contains(.,':')">
   459 		<xsl:when test="$prefix='' and contains(.,':')">
   459 			<!-- complex: copy id and copy namespace (namespace should be copied already)-->
   460 			<!-- complex: copy id and copy namespace (namespace should be copied already)-->
   460 			<xsl:value-of select="."/>
   461 			<xsl:value-of select="."/>
   461 		</xsl:when>
   462 		</xsl:when>
   462 		<xsl:when test="$prefix='' and $ns=$defaultns"/> <!-- no prefix and it's the default --> 
   463 		<xsl:when test="$prefix='' and $ns=$defaultns"/> <!-- no prefix and it's the default -->