More error msgs in joining and checklinks. Better support for 3.0.1 in merging and downgrading. HighFidelityModel
authorBob Rosenberg <bob.rosenberg@nokia.com>
Mon, 28 Jun 2010 10:19:24 +0100
branchHighFidelityModel
changeset 319 b085ba15cdaa
parent 316 079a06b9ec58
child 321 eb9d7e2366f2
More error msgs in joining and checklinks. Better support for 3.0.1 in merging and downgrading.
sysdeftools/joinsysdef-module.xsl
sysdeftools/mergesysdef-module.xsl
sysdeftools/sysdefdowngrade.xsl
sysdeftools/validate/checklinks.pl
--- a/sysdeftools/joinsysdef-module.xsl	Fri Jun 25 17:18:04 2010 +0100
+++ b/sysdeftools/joinsysdef-module.xsl	Mon Jun 28 10:19:24 2010 +0100
@@ -133,12 +133,16 @@
 <xsl:template match="*[@href and not(self::meta)]" mode="scan-for-namespaces">
 	<!-- produce a list of namespace-prefix namespace pairs separated by newlines, in reverse order found in documents 
 		reverse order so we can try to use the first namespace prefix defined if it's available-->
-	<xsl:for-each select="document(@href,.)/*">
+	<xsl:variable name="linked" select="document(@href,.)/*"/>
+	<xsl:for-each select="$linked">
 		<xsl:apply-templates select="//*[(self::component or self::collection or self::package or self::layer) and @href]" mode="scan-for-namespaces"/>
 		<xsl:for-each select="//namespace::* | @id-namespace">
 			<xsl:value-of select="concat(name(),' ',.,'&#xa;')"/>
 		</xsl:for-each>
-	</xsl:for-each>			
+	</xsl:for-each>
+	<xsl:if test="not($linked)">
+	<xsl:message>Note: The link to <xsl:value-of select="@href"/> from <xsl:value-of select="concat(name(),' ',@id)"/> could not be resolved. Perhaps there's an error in the XML?</xsl:message>
+	</xsl:if>
 </xsl:template>
 
 <xsl:template name="needed-namespaces">
--- a/sysdeftools/mergesysdef-module.xsl	Fri Jun 25 17:18:04 2010 +0100
+++ b/sysdeftools/mergesysdef-module.xsl	Mon Jun 28 10:19:24 2010 +0100
@@ -374,15 +374,16 @@
 
 	<xsl:choose>
 		<xsl:when test="$replaces[.=$this/@id] or (self::component and $match)">  <!-- replace the item instead of merge -->
-			<xsl:message>Note: <xsl:value-of select="name()"/> "<xsl:value-of select="@id"/>" <xsl:choose>
+			<xsl:message>Note: <xsl:value-of select="name()"/> "<xsl:value-of select="@id"/>" in "<xsl:value-of select="../@id"/>" <xsl:choose>
 				<xsl:when test="self::component and $match">overridden in downstream sysdef</xsl:when>
-				<xsl:otherwise><xsl:for-each select="$replaces[.=$this/@id]/..">replaced by <xsl:value-of select="name()"/> "<xsl:value-of select="@id"/>"</xsl:for-each></xsl:otherwise>
+				<xsl:otherwise><xsl:for-each select="$replaces[.=$this/@id]/..">replaced by <xsl:value-of select="name()"/> "<xsl:value-of select="@id"/>" in "<xsl:value-of select="../@id"/>"</xsl:for-each></xsl:otherwise>
 			</xsl:choose>
 			</xsl:message>
 			<!-- if the removed item is in the downstream doc, just copy that and ignore the upstream contents -->
 			<xsl:apply-templates mode="merge-copy-of" select="$match">
 				<xsl:with-param name="origin" select="$down"/>
 				<xsl:with-param name="root" select="$this/ancestor::systemModel"/>			
+				<xsl:with-param name="replaces" select="$replaces"/>
 			</xsl:apply-templates>		
 		</xsl:when>
 		<xsl:otherwise>
@@ -408,6 +409,7 @@
 		<xsl:apply-templates mode="merge-copy-of" select="$match/preceding-sibling::*[@id and not(@before)]">
 			<xsl:with-param name="origin" select="$down"/>
 			<xsl:with-param name="root" select="$this/ancestor::systemModel"/>	
+			<xsl:with-param name="replaces" select="$replaces"/>
 		</xsl:apply-templates>
 	</xsl:when>
 	</xsl:choose>
@@ -417,6 +419,7 @@
 		<xsl:with-param name="remove-before" select="1"/>
 		<xsl:with-param name="origin" select="$down"/>
 		<xsl:with-param name="root" select="$this/ancestor::systemModel"/>	
+		<xsl:with-param name="replaces" select="$replaces"/>
 	</xsl:apply-templates>
 
 	
@@ -475,6 +478,7 @@
 						<xsl:apply-templates mode="merge-copy-of" select=".">
 							<xsl:with-param name="origin" select="$down"/>
 							<xsl:with-param name="root" select="$this/ancestor::systemModel"/>			
+							<xsl:with-param name="replaces" select="$replaces"/>
 						</xsl:apply-templates>
 					</xsl:if>
 				</xsl:for-each>
@@ -490,6 +494,7 @@
 		<xsl:apply-templates mode="merge-copy-of" select="$other/layer[not(@before) and not(following-sibling::*[@id=$this/../layer/@id]) and not(@id=$this/../layer/@id)]">
 			<xsl:with-param name="origin" select="$down"/>
 			<xsl:with-param name="root" select="$this/ancestor::systemModel"/>			
+			<xsl:with-param name="replaces" select="$replaces"/>
 		</xsl:apply-templates>		
 	</xsl:if>
 </xsl:template>
@@ -500,10 +505,12 @@
 	<xsl:param name="remove-before" select="0"/> <!-- set to true if any before attribute is to be removed -->
 	<xsl:param name="origin"/>	<!--the element containing the @name to use the origin-model attribute  -->
 	<xsl:param name="root"/> 	<!--the systemModel element in the upstream doc  -->
+	<xsl:param name="replaces" select="ancestor::SystemDefinition/descendant::*[(self::component or self::collection or self::package or self::layer) and not(ancestor::meta)]/@replace"/> <!-- recalculate this is necessarfy, but should just pass down as a param -->
 
+	<xsl:variable name="moved" select="$root/descendant::*[name()=name(current()/..) and @id!=current()/../@id]/*[@id=current()/@id]"/>
 	<xsl:choose>
 		<!-- this might slow things down, consider making optional -->
-		<xsl:when test="not(self::layer) and count($root/descendant::*[name()=name(current()/..) and @id!=current()/../@id]/*[@id=current()/@id])">
+		<xsl:when test="not(self::layer) and (count($moved) and not($moved[ancestor-or-self::*/@id=$replaces]) )">
 			<xsl:message>Warning: <xsl:value-of select="name()"/> "<xsl:value-of select="@id"/>" moved in downstream model. Ignoring moved <xsl:value-of select="name()"/>
 				<xsl:text>&#xa;</xsl:text>
 			</xsl:message>
@@ -514,6 +521,7 @@
 				<xsl:apply-templates select="*|comment()" mode="merge-copy-of">
 					<xsl:with-param name="origin" select="$origin"/>
 					<xsl:with-param name="root" select="$root"/>
+					<xsl:with-param name="replaces" select="$replaces"/>
 				</xsl:apply-templates>
 			</xsl:variable>
 			<xsl:choose>
--- a/sysdeftools/sysdefdowngrade.xsl	Fri Jun 25 17:18:04 2010 +0100
+++ b/sysdeftools/sysdefdowngrade.xsl	Mon Jun 28 10:19:24 2010 +0100
@@ -19,6 +19,7 @@
 	<!-- $Path is the location of the root system definition XML file. Must not end in /
 		This is used to compute the absolute paths the 2.0 syntax needs-->
 	<xsl:param name="Root"/> <!-- space separated list of root variables in the form "VAR1=value1 VAR=value2" --> 
+	<xsl:param name="Strict" select="0"/> <!-- Strict processing on means namespaced extensions are stripped out --> 
 	<xsl:variable name="root" select="concat(' ',$Root,' ')"/> <!-- sort of hack to allow absolute paths in downgraded output -->
 	<xsl:variable name="srcroot" select="substring-before(substring-after($root,' SRCROOT='),' ')"/> <!-- the default path prefix -->
 
@@ -26,10 +27,10 @@
 	<xsl:message terminate="yes">ERROR: Cannot process this document</xsl:message>
 </xsl:template>
 
-<!-- can only handle 3.0.0 to 2.0.1 transforms
+<!-- can only handle 3.0.x to 2.0.1 transforms
 	Assumes only packages are using href
  -->
-<xsl:template match="/SystemDefinition[@schema='3.0.0']"> 
+<xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.')]"> 
 	<!-- process root system definition or package definition-->
 	<xsl:call-template name="DTD"/> <!-- insert 2.0.01 DTD -->
   <SystemDefinition name="{*/@name}" schema="2.0.1">
@@ -37,7 +38,7 @@
   </SystemDefinition>
 </xsl:template>
 
-<xsl:template match="/SystemDefinition[@schema='3.0.0' and systemModel]"> 
+<xsl:template match="/SystemDefinition[starts-with(@schema,'3.0.') and systemModel]"> 
 	<xsl:call-template name="DTD"/> <!-- insert 2.0.01 DTD -->
   <SystemDefinition name="{systemModel/@name}" schema="2.0.1">
   	<xsl:apply-templates select="*|comment()"/>
@@ -217,7 +218,7 @@
 			<xsl:with-param name="path" select="$path"/> 
 		</xsl:apply-templates>
 		<xsl:copy-of select="@filter|@root[not(contains($root,concat(' ',.,'=')))]|@version|@prebuilt|@priority"/>
-		<xsl:for-each select="@*[name()='qt:proFile' or name()='qt:qmakeArgs']">
+		<xsl:for-each select="@*[contains(name(),':') and not($Strict)]">
 			<xsl:attribute name="{local-name()}">
 				<xsl:value-of select="."/>
 			</xsl:attribute>
--- a/sysdeftools/validate/checklinks.pl	Fri Jun 25 17:18:04 2010 +0100
+++ b/sysdeftools/validate/checklinks.pl	Mon Jun 28 10:19:24 2010 +0100
@@ -70,7 +70,7 @@
 my @p2=reverse(split(/[\\\/]/,$realloc));
 
 shift(@p1);shift(@p2); # don't care abt file name
-while(lc($p1[0]) eq lc($p2[0])) {shift(@p1);shift(@p2)}
+while(lc($p1[0]) eq lc($p2[0]) && scalar(@p1)) {shift(@p1);shift(@p2)}
 
 $unitmap{join('/',reverse(@p1))} = join("/",reverse(@p2));