More detailed error messages when joining sysdef fragments HighFidelityModel
authorBob Rosenberg <bob.rosenberg@nokia.com>
Tue, 01 Jun 2010 13:15:51 +0100
branchHighFidelityModel
changeset 259 fbf606da2044
parent 258 137189f7ec29
child 261 d0d7f897a313
child 264 1742dcffa186
More detailed error messages when joining sysdef fragments
sysdeftools/joinsysdef-module.xsl
sysdeftools/joinsysdef.pl
--- a/sysdeftools/joinsysdef-module.xsl	Tue Jun 01 11:42:12 2010 +0100
+++ b/sysdeftools/joinsysdef-module.xsl	Tue Jun 01 13:15:51 2010 +0100
@@ -20,7 +20,14 @@
 <!-- create a stand-alone sysdef from a linked set of fragments -->
 
 <xsl:template match="/*" mode="join">
-	<xsl:message terminate="yes">ERROR: Cannot process this document</xsl:message>
+	<xsl:param name="filename"/>
+	<xsl:message terminate="yes">ERROR: Cannot process this document<xsl:if test="$filename !=''"> (<xsl:value-of select="$filename)</xsl:if>
+		<xsl:choose>
+			<xsl:when test="self::SystemDefinition/@schema">. Unrecognised syntax schema="<xsl:value-of select="@schema"/>"</xsl:when>
+			<xsl:when test="self::SystemDefinition">. Missing schema</xsl:when>
+			<xsl:otherwise>. Invalid file type: <xsl:value-of select="name()"/></xsl:otherwise>
+		<xsl:choose>
+	</xsl:message>
 </xsl:template>
 
 <!-- anything in schemas 3.0.x won't add new functional attributes that need processing here, just blindly copy them-->
@@ -47,7 +54,7 @@
 					<xsl:choose>
 						<xsl:when test="$n='id'"/> <!-- never copy this, always set -->
 						<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:message>Note: Cannot set "<xsl:value-of select="$n"/>", already set. Ignoring linked value</xsl:message>
 						</xsl:when>
 						<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)-->
--- a/sysdeftools/joinsysdef.pl	Tue Jun 01 11:42:12 2010 +0100
+++ b/sysdeftools/joinsysdef.pl	Tue Jun 01 13:15:51 2010 +0100
@@ -610,12 +610,19 @@
 			$link=&resolvePath($file,$link);
 			if(-e $link)
 				{
-				my  $doc = $parser->parsefile ($link);
-				&checkSyntaxVersion($doc->getDocumentElement->getAttribute('schema'));	# ensure we track we highest syntax number
-				my @docns = &namespaces($link,$doc->getDocumentElement);
-				undef $doc;
-				return (@res,@docns);
-				#ignore any children nodes if this is a link
+				my  $doc;
+				eval {
+					$doc = $parser->parsefile ($link);
+				};
+				if($doc)
+					{
+					&checkSyntaxVersion($doc->getDocumentElement->getAttribute('schema'));	# ensure we track we highest syntax number
+					my @docns = &namespaces($link,$doc->getDocumentElement);
+					undef $doc;
+					return (@res,@docns);
+					#ignore any children nodes if this is a link
+					}
+				print STDERR "Error: Malformed XML. Could not process $link\n";
 				}
 			# print STDERR "Note: $link not found\n";  -- no need to warm now. Do so later when trying to join
 			}