metatools/sysdeftools/joinsysdef.pl
changeset 662 60be34e1b006
parent 660 66ff3e731c60
child 663 8e27d440923e
equal deleted inserted replaced
654:7c11c3d8d025 662:60be34e1b006
   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','proFile')
   279 		foreach my $atr ('bldFile','mrp','base')
   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 (keys %rootmap) {
   285 				foreach my $a (sort {length($b) - length($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;	
   290 				$node->setAttribute($atr,$link);
   292 				$node->setAttribute($atr,$link);
   291 				}
   293 				}
       
   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";
   292 			}
   298 			}
   293 		}
   299 		}
   294 	elsif($tag eq 'meta')
   300 	elsif($tag eq 'meta')
   295 		{
   301 		{
   296 		my $rel= $node->getAttribute('rel') || 'Generic';
   302 		my $rel= $node->getAttribute('rel') || 'Generic';
   486 
   492 
   487 sub fixIDs
   493 sub fixIDs
   488 	{
   494 	{
   489 	# translate the ID to use the root doc's namespaces 
   495 	# translate the ID to use the root doc's namespaces 
   490 	my $node = shift;
   496 	my $node = shift;
   491 	foreach my $id ('id','before')
   497 	foreach my $id ('id','before','replace')
   492 		{
   498 		{
   493 		&fixID($node,$id);
   499 		&fixID($node,$id);
   494 		}
   500 		}
   495 }
   501 }
   496 
   502