Using a dictionary no longer looks in meta sections. New argument -ignore-meta to ignore specific meta types. New xslt-param pkgAuxWidth to leave extra space on the right of packages. Fix for spanned layer height bug. Fix for namespace bug when joining. Support for drawing multiple sysdef fragments of the same rank. HighFidelityModel
authorBob Rosenberg <bob.rosenberg@nokia.com>
Mon, 19 Apr 2010 18:36:20 +0100
branchHighFidelityModel
changeset 165 ba562c1e2717
parent 164 8309dda95234
child 167 5d80ffb79e21
Using a dictionary no longer looks in meta sections. New argument -ignore-meta to ignore specific meta types. New xslt-param pkgAuxWidth to leave extra space on the right of packages. Fix for spanned layer height bug. Fix for namespace bug when joining. Support for drawing multiple sysdef fragments of the same rank.
sysmodelgen/core/draw-model.xsl
sysmodelgen/core/filtersysdef-module.xsl
sysmodelgen/core/joinsysdef-module.xsl
sysmodelgen/core/mergesysdef-module.xsl
sysmodelgen/core/mergesysdef.xsl
sysmodelgen/extra/makeabbrev.xsl
sysmodelgen/src/SysModelGen.pm
--- a/sysmodelgen/core/draw-model.xsl	Mon Apr 19 18:29:46 2010 +0100
+++ b/sysmodelgen/core/draw-model.xsl	Mon Apr 19 18:36:20 2010 +0100
@@ -33,6 +33,7 @@
 <xsl:param name="pkgMinWidth" select="$cSize * 3"/><!-- small pkg, use min width of 2 * smallest possible collection -->
 <xsl:param name="subpkgMinWidth" select="$cSize * 3"/> <!-- small nested pkg, use min width of  3 components -->
 <xsl:param name="pkgFixedWidth" select="$mMinWidth * 5"/><!-- fixed width of a  pacakge (mm) -->
+<xsl:param name="pkgAuxWidth" select="0"/><!-- Additional width on the right side of each package (mm) -->
 <xsl:param name="subpkgFixedWidth" select="$mMinWidth * 3"/> <!-- fixed width nested pkg (mm) -->
 <xsl:variable name="inlineLabel" select="3 * $cSize"/> <!-- the max width of an inline label. 3 times the width of a collection by default 
 	I don't like this. Should compute somehow and make local variable. -->
@@ -334,7 +335,7 @@
 	<xsl:param name="layers"/>
 	<xsl:param name="span"/>
 
-	<xsl:variable name="spanning" select="$span/preceding-sibling::layer[position() &lt;= $span/@span]"/>
+	<xsl:variable name="spanning" select="$span/preceding-sibling::layer[not(@span) and position() &lt;= $span/@span]"/>
 	
 	<xsl:variable name="h" select="sum($spanning/@height) + (count($spanning) - 1) * $groupDy"/>
 	<xsl:variable name="even" select="($span/@height - $h) div count($spanning)"/>
@@ -945,12 +946,12 @@
 			<xsl:attribute name="width">
 				<xsl:choose>
 					<xsl:when test="parent::package and $w + $expand-width &lt; $subpkgMinWidth">	<!-- small nested pkg, use width of  3 components -->
-						<xsl:value-of select="$subpkgMinWidth + $ext-w"/>
+						<xsl:value-of select="$subpkgMinWidth + $ext-w + pkgAuxWidth"/>
 					</xsl:when>
 					<xsl:when test="$w + $expand-width  &lt; $pkgMinWidth">	<!-- small pkg, use width of twice smallest possible collection -->
-						<xsl:value-of select="$pkgMinWidth + $ext-w"/>
+						<xsl:value-of select="$pkgMinWidth + $ext-w + $pkgAuxWidth "/>
 					</xsl:when>
-					<xsl:otherwise><xsl:value-of select="$w + $expand-width + $ext-w"/></xsl:otherwise>
+					<xsl:otherwise><xsl:value-of select="$w + $expand-width + $ext-w + $pkgAuxWidth"/></xsl:otherwise>
 				</xsl:choose>
 			</xsl:attribute>
 			<xsl:attribute name="height"><xsl:value-of select="$h"/></xsl:attribute>
--- a/sysmodelgen/core/filtersysdef-module.xsl	Mon Apr 19 18:29:46 2010 +0100
+++ b/sysmodelgen/core/filtersysdef-module.xsl	Mon Apr 19 18:36:20 2010 +0100
@@ -8,7 +8,9 @@
 	<xsl:variable name="result">		<!-- the ordered list of all ignores and filters, the last value is the one to note --> 
 		<xsl:choose>
 			<xsl:when test="$item[self::meta]">
-				<!-- TODO -->
+				<xsl:apply-templates select="ignore|../ignore" mode="filter">
+					<xsl:with-param name="item" select="$item"/>
+				</xsl:apply-templates>
 			</xsl:when>
 			<xsl:when test="$item[self::unit]">	
 				<!-- only filter to determine if it's shown -->
@@ -21,7 +23,7 @@
 				<xsl:variable name="id"><xsl:apply-templates select="$item/@id" mode="my-id"/></xsl:variable>			<!-- namespaceless ID of this here -->
 				<xsl:variable name="ns"><xsl:apply-templates select="$item/@id" mode="my-namespace"/></xsl:variable>	<!-- ID's namespace -->
 				<!-- use ignore and filter to determine if it's shown-->
-				<xsl:apply-templates select="ignore|filter|../ignore|../filter" mode="filter">
+				<xsl:apply-templates select="ignore[not(@meta or @meta-type)]|filter|../ignore[not(@meta or @meta-type)]|../filter" mode="filter">
 					<xsl:with-param name="id" select="$id"/>
 					<xsl:with-param name="ns" select="$ns"/>
 					<xsl:with-param name="item" select="$item"/>
@@ -65,6 +67,19 @@
 	<!-- old way of doing this -->
 	<xsl:if test="$item/@name=@name and name($item)= @type"> ignore </xsl:if>
 </xsl:template>
+
+
+<xsl:template match="ignore[@meta]" mode="filter" priority="2"><xsl:param name="item"/>
+	<!-- ignore certain metadata rel values -->
+	<xsl:if test="$item[self::meta] and (@meta='*' or $item/@rel=@meta  or (not($item/@rel) and @meta='Generic'))
+		and
+		(not(@meta-type) or  $item/@type=@meta-type or  (@meta-type='auto' and not($item/@type)))"> ignore </xsl:if>
+</xsl:template>
+
+<xsl:template match="ignore[@meta-type]" mode="filter" priority="1"><xsl:param name="item"/>
+	<!-- ignore certain metadata types, no rel values specified -->
+	<xsl:if test="$item[self::meta] and $item/@type=@meta-type or (not($item/@type) and @meta-type='Generic')"> ignore </xsl:if>
+</xsl:template>
  
 <xsl:template match="filter" mode="filter"  priority="1"><xsl:param name="item"/>
 	<xsl:variable name="att" select="@select"/>
--- a/sysmodelgen/core/joinsysdef-module.xsl	Mon Apr 19 18:29:46 2010 +0100
+++ b/sysmodelgen/core/joinsysdef-module.xsl	Mon Apr 19 18:36:20 2010 +0100
@@ -49,7 +49,7 @@
 						<xsl:when test="$origin/@*[name()=$n]"> <!-- don't copy if already set -->
 							<xsl:message>Cannot set "<xsl:value-of select="$n"/>", already set</xsl:message>
 						</xsl:when>
-						<xsl:when test="$n='before'">
+						<xsl:when test="$n='before' or $n='replace'">
 							<!-- ensure ns is correct (if any future attribtues will ever use an ID, process it here too)-->
 							<xsl:apply-templates select="." mode="join">
 								<xsl:with-param name="namespaces" select="$namespaces"/>
@@ -319,7 +319,6 @@
 				<xsl:with-param name="data" select="$data"/>
 			</xsl:apply-templates>
 		 </xsl:variable>
-	 		 
 		<xsl:element name="{name()}"> <!-- use this instead of <copy> so xalan doesn't add extra wrong namespaces -->
 			<xsl:apply-templates select="@*" mode="join">
 				<xsl:with-param name="namespaces" select="$namespaces"/>
@@ -440,7 +439,7 @@
 </xsl:template>
 
 
-<xsl:template match="@id|@before" mode="join">
+<xsl:template match="@id|@before|@replace" mode="join">
 	<xsl:param name="namespaces"/>
 	<!-- this will change the namespace prefixes for all IDs to match the root document -->
 	<xsl:variable name="ns">
@@ -451,10 +450,12 @@
 		<xsl:text>&#xa;</xsl:text>
 		</xsl:message>
 	</xsl:if>
+
 	<xsl:variable name="prefix" select="name($namespaces[.=$ns])"/>
 	<xsl:attribute name="{name()}">
 	<xsl:choose>
-		<xsl:when test="$prefix = 'id-namespace' or  (not($namespaces[name()='id-prefix']) and $ns=$defaultns)"/> <!-- it's the default namespace, no prefix -->
+
+		<xsl:when test="$prefix = 'id-namespace' or  (not($namespaces[name()='id-namespace']) and $ns=$defaultns)"/> <!-- it's the default namespace, no prefix -->
 		<xsl:when test="$prefix='' and contains(.,':')">
 			<!-- complex: copy id and copy namespace (namespace should be copied already)-->
 			<xsl:value-of select="."/>
--- a/sysmodelgen/core/mergesysdef-module.xsl	Mon Apr 19 18:29:46 2010 +0100
+++ b/sysmodelgen/core/mergesysdef-module.xsl	Mon Apr 19 18:36:20 2010 +0100
@@ -1,14 +1,26 @@
 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exslt="http://exslt.org/common"  exclude-result-prefixes="exslt">
+<!--Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+	All rights reserved.
+	This component and the accompanying materials are made available
+	under the terms of the License "Eclipse Public License v1.0"
+	which accompanies this distribution, and is available
+	at the URL "http://www.eclipse.org/legal/epl-v10.html".
+
+	Initial Contributors:
+	Nokia Corporation - initial contribution.
+	Contributors:
+	Description:
+	XSLT module for merging only two sysdef files according to the 3.0.0 rules. Old syntax not supported and must be converetd before calling.
+-->
 	
-<!--  this merge only two files according to the 3.0.0 rules. Old syntax not supported. Must be converetd before calling -->
 <xsl:variable name="defaultnamespace">http://www.symbian.org/system-definition</xsl:variable>
 
 <xsl:template match="/SystemDefinition[starts-with(@schema,'2.') or starts-with(@schema,'1.')]" priority="2" mode="merge-models">
-	<xsl:message terminate="yes">Syntax <xsl:value-of select="@schema"/> not supported</xsl:message>
+	<xsl:message terminate="yes">ERROR: Syntax <xsl:value-of select="@schema"/> not supported</xsl:message>
 </xsl:template>
-<xsl:template match="/SystemDefinition[not(systemModel)]" priority="2" mode="merge-models">
-	<xsl:message terminate="yes">Can only merge stand-alone system models</xsl:message>
-</xsl:template>
+<!--<xsl:template match="/SystemDefinition[not(systemModel)]" priority="2" mode="merge-models">
+	<xsl:message terminate="yes">ERROR: Can only merge stand-alone system models</xsl:message>
+</xsl:template>-->
 
 <!-- stuff for dealing with namespaces -->
 
@@ -74,7 +86,7 @@
 				<xsl:value-of select="concat($myns,':',$id)"/>
 			</xsl:when>
 			<xsl:otherwise> <!-- some namespace that needed to be defined --> 
-			<xsl:message>"<xsl:value-of select="$ns"/>" for <xsl:value-of select="$id"/></xsl:message>
+			<xsl:message>Warning: need definition for namespace "<xsl:value-of select="$ns"/>" for <xsl:value-of select="$id"/></xsl:message>
 				<xsl:value-of select="."/>					
 			</xsl:otherwise>
 		</xsl:choose>		
@@ -92,7 +104,7 @@
 			<xsl:value-of select="$pre"/>
 		</xsl:when>
 		<xsl:when test="$ns='' and $chars=''">
-			<xsl:message terminate="yes">Cannot create namespace prefix for downstream default namespace</xsl:message>
+			<xsl:message terminate="yes">ERROR: Cannot create namespace prefix for downstream default namespace in <xsl:value-of select="*/@id"/></xsl:message>
 		</xsl:when>
 		<xsl:when test="$name!='' and not(contains($dontuse,concat(' ',$name,' ')))"><xsl:value-of select="$name"/></xsl:when>
 		<xsl:when test="namespace::*[name()=substring($chars,1,1)] or contains($dontuse,concat(' ',substring($chars,1,1),' '))">
@@ -116,10 +128,10 @@
 	
 	<!-- do some testing -->
  	<xsl:if test="$other[starts-with(@schema,'2.') or starts-with(@schema,'1.')]">
-		<xsl:message terminate="yes">Syntax <xsl:value-of select="$other/@schema"/> not supported</xsl:message>
+		<xsl:message terminate="yes">ERROR: Syntax <xsl:value-of select="$other/@schema"/> not supported</xsl:message>
 	</xsl:if>
-	<xsl:if test="not($other/systemModel)">
-		<xsl:message terminate="yes">Can only merge stand-alone system models</xsl:message>
+	<xsl:if test="name(*) != name($other/*)">
+		<xsl:message terminate="yes">ERROR: Can only merge system models of the same rank</xsl:message>
 	</xsl:if>
 	 
 	<xsl:copy>
--- a/sysmodelgen/core/mergesysdef.xsl	Mon Apr 19 18:29:46 2010 +0100
+++ b/sysmodelgen/core/mergesysdef.xsl	Mon Apr 19 18:36:20 2010 +0100
@@ -22,10 +22,16 @@
 <xsl:variable name="downstream" select="document($Downstream,.)/SystemDefinition"/>
 <xsl:param name="upname">
 	<xsl:choose>
-		<xsl:when test="$downstream[starts-with(@schema,'2.') or starts-with(@schema,'1.')  or not(systemModel)]">
+		<xsl:when test="$downstream[starts-with(@schema,'2.') or starts-with(@schema,'1.')]">
 			<xsl:message terminate="yes">Syntax <xsl:value-of select="@schema"/> not supported</xsl:message>
 		</xsl:when>
-		<xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name">
+		<xsl:when test="name($downstream/*)!=name(/SystemDefinition/*)">
+			<xsl:message terminate="yes">Can only merge fragments of the same rank</xsl:message>
+		</xsl:when>
+<!--		<xsl:when test="$downstream[not(systemModel)]">
+			<xsl:message terminate="yes">Needs to be a standalone system definition</xsl:message>
+		</xsl:when>-->
+		<xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name or not(/SystemDefinition/systemModel/@name)">
 			<xsl:apply-templates mode="origin-term" select="/*">
 				<xsl:with-param name="root">Upstream</xsl:with-param>
 			</xsl:apply-templates>
@@ -36,11 +42,14 @@
 
 <xsl:param name="downname">
 	<xsl:choose>
-		<xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name">
+		<xsl:when test="/SystemDefinition/systemModel/@name=$downstream/systemModel/@name or not($downstream/systemModel/@name)">
 			<xsl:apply-templates mode="origin-term" select="$downstream">	
 				<xsl:with-param name="root">Downstream</xsl:with-param>
 			</xsl:apply-templates>
 			</xsl:when>
+		<xsl:when test="name($downstream/*)!=name(/SystemDefinition/*)">
+			<xsl:message terminate="yes">Can only merge fragments of the same rank</xsl:message>
+		</xsl:when>
 		<xsl:otherwise><xsl:value-of select="$downstream/systemModel/@name"/></xsl:otherwise>
 	</xsl:choose>
 </xsl:param>
--- a/sysmodelgen/extra/makeabbrev.xsl	Mon Apr 19 18:29:46 2010 +0100
+++ b/sysmodelgen/extra/makeabbrev.xsl	Mon Apr 19 18:36:20 2010 +0100
@@ -14,6 +14,8 @@
 	<xsl:apply-templates select="document(.,.)/SystemDefinition/*"/>
 </xsl:template>
 
+<xsl:template match="meta/@href"/>
+
 <xsl:template match="/*" priority="1">
 <display-names><xsl:apply-templates select="*"/>
 </display-names>
@@ -104,7 +106,7 @@
 </xsl:template>
 
 
-<xsl:template match="layer" priority="2"><!-- don't abbreviate layer names -->
+<xsl:template match="layer[string-length(@id) &lt; 10]" priority="2"><!-- don't abbreviate short layer names -->
 	<xsl:apply-templates select="*"/>
 </xsl:template>
 
--- a/sysmodelgen/src/SysModelGen.pm	Mon Apr 19 18:29:46 2010 +0100
+++ b/sysmodelgen/src/SysModelGen.pm	Mon Apr 19 18:36:20 2010 +0100
@@ -147,7 +147,9 @@
 	'iHide'			=> { 'type' =>  'attr[=val]', 'ordered' => 1,'param' => "hide-attr=s",
 		 'class' =>'Model Control', 'desc' => 'A mechanism of filtering which allows filtering based on component attribute values. If a value is set for that attribute, the component will not be shown on the model. Use in conjunction with -show-attr for fine contol of what is shown. "class" and "filter" attribtues are handled specially -- see the documentation for details'},
 	'iIgnore'				=> { 'type' => 'item', 'multi' => 1, 'param' => "ignore=s", 'xpath' => '/model/ignore',
-		 'class' =>'Model Control', 'desc' => 'A model entity to not draw, in the  form "[item-type]:[item-name]". Any number of these can be used. Defaults to "layer:Tools and Utils and SDKENG" ,"layer:MISC", "block:Techview"'},
+		 'class' =>'Model Control', 'desc' => 'The ID of a model entity to not draw. Any number of these can be used'},
+	'iIgnoreMeta'				=> { 'type' => 'item', 'multi' => 1, 'param' => "ignore-meta=s", 'xpath' => '/model/ignore',
+		 'class' =>'Model Control', 'desc' => 'The "rel" meta value to ignore. Takes the form of [relvalue] or [relvalue]:[type]. Any number of these can be used'},
 
 	'iNavCtrl'				=>{'param' => "navctrl=s" , 'type'=>'boolean' , 'xpath' => '/model/layout/@navctrl',
 		'class' =>'Model Control', 'desc' => 'If set, a navigation control widget will appear in the upper left corner of the model. The control might not work on some SVG viewers.'},
@@ -188,7 +190,7 @@
 	'iXsltParam'			=>{  'multi' => 2, 'param' => "xslt-param=s",
 		 'class' =>'Build Control', 'desc' => 'Advanced: Parameters to feed directly to the XSLT transforms'},
 	'iLegendNote'			=>{  'multi' => 1, 'param' => "note=s", 'xpath' => '/model/layout/legend/note',
-		 'class' => 'Labels', 'desc' => 'Free text to appear inside the legend box, on the rightmost side. If multiple ones are provided, they will appear as separate boxes from left to right. Newlines and other special characters can be entity-encoded (e.g. &#xa;)'}
+		 'class' => 'Labels', 'desc' => 'Free text to appear inside the legend box, on the rightmost side. If multiple ones are provided, they will appear as separate boxes from left to right. Newlines and other special characters can be entity-encoded (e.g. &#xa;). When using entities in an INI file, you *must* quote the value, otherwise the # will be treated as a comment delimiter.',}
 				);
 
 	$self->{iArgs} = \%Args;
@@ -668,7 +670,7 @@
 					} elsif(!$cur->{'multi'}){
 						$info{$match}.="\t<info xmlns='' type='$t'  href='",$self->{$param},"'/>\n";
 					}
-				} elsif($param eq 'iIgnore' or $param eq 'iLinkExpr' or $param eq 'iSysDefFile') {
+				} elsif($param eq 'iIgnore' or $param eq 'iIgnoreMeta' or $param eq 'iLinkExpr' or $param eq 'iSysDefFile') {
 					print XSLT "<template match='",$cur->{'xpath'},"'/>\n"	# ignore any already present if set
 				}		
 			} elsif($param eq 'iModel') {
@@ -718,6 +720,11 @@
 		if($ig=~/^(.*):(.*)$/) {print XSLT "type='$1' name='$2'/>\n"}
 		else {print XSLT "ref='$ig'/>\n"}
 	}
+	foreach my $ig (@{$self->{'iIgnoreMeta'}}) {
+		print XSLT "\t<ignore xmlns='' ";
+		if($ig=~/^(.*):(.*)$/) {print XSLT "meta-type='$2' meta='$1'/>\n"}
+		else {print XSLT "meta='$ig'/>\n"}
+	}
 	print XSLT join("\n\t",@{$self->{'iFiltering'}}),
 		"</template>\n";