metatools/sysdeftools/joinsysdef.pl
changeset 663 8e27d440923e
parent 660 66ff3e731c60
equal deleted inserted replaced
662:60be34e1b006 663:8e27d440923e
   274 	elsif($tag=~/^(SystemDefinition|systemModel)$/ )
   274 	elsif($tag=~/^(SystemDefinition|systemModel)$/ )
   275 		{
   275 		{
   276 		}
   276 		}
   277 	elsif($tag eq 'unit')
   277 	elsif($tag eq 'unit')
   278 		{
   278 		{
   279 		foreach my $atr ('bldFile','mrp','base')
   279 		foreach my $atr ('bldFile','mrp','base','proFile')
   280 			{
   280 			{
   281 			my $link= $node->getAttribute($atr);
   281 			my $link= $node->getAttribute($atr);
   282 			if($link && !($link=~/^\//))
   282 			if($link && !($link=~/^\//))
   283 				{
   283 				{
   284 				$link= &abspath(File::Basename::dirname($file)."/$link");
   284 				$link= &abspath(File::Basename::dirname($file)."/$link");
   285 				foreach my $a (sort {length($b) - length($a)} keys(%rootmap)) {
   285 				foreach my $a (keys %rootmap) {
   286 					$link=~s,^$a,$rootmap{$a},ie;
   286 					$link=~s,^$a,$rootmap{$a},ie;
   287 				}
   287 				}
   288 				# remove leading ./  which is used to indicate that paths should remain relative
   288 				# remove leading ./  which is used to indicate that paths should remain relative
   289 				$link=~s,^\./([^/]),$1,; 
   289 				$link=~s,^\./([^/]),$1,; 
   290 				# remove windows drive letter -- only allow paths on the same drive. Use root attribuite to build across drives / filesystems
       
   291 				$link=~s,^[a-z]:/,/,i;	
       
   292 				$node->setAttribute($atr,$link);
   290 				$node->setAttribute($atr,$link);
   293 				}
   291 				}
   294 			}
       
   295 		if(scalar @{$node->getChildNodes()} && $maxschema=~/^3\.0/)
       
   296 			{
       
   297 			die "Error: Fatal syntax error in $file. Unit elements must be empty in schema $maxschema.\n";
       
   298 			}
   292 			}
   299 		}
   293 		}
   300 	elsif($tag eq 'meta')
   294 	elsif($tag eq 'meta')
   301 		{
   295 		{
   302 		my $rel= $node->getAttribute('rel') || 'Generic';
   296 		my $rel= $node->getAttribute('rel') || 'Generic';
   492 
   486 
   493 sub fixIDs
   487 sub fixIDs
   494 	{
   488 	{
   495 	# translate the ID to use the root doc's namespaces 
   489 	# translate the ID to use the root doc's namespaces 
   496 	my $node = shift;
   490 	my $node = shift;
   497 	foreach my $id ('id','before','replace')
   491 	foreach my $id ('id','before')
   498 		{
   492 		{
   499 		&fixID($node,$id);
   493 		&fixID($node,$id);
   500 		}
   494 		}
   501 }
   495 }
   502 
   496