sysdeftools/joinsysdef.pl
author William Roberts <williamr@symbian.org>
Wed, 29 Sep 2010 19:50:59 +0100
branchHighFidelityModel
changeset 435 4067ae46bbeb
parent 414 f503e8553dd5
permissions -rw-r--r--
Add naviengine.nec to Symbian^3 and Symbian^4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     1
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     2
# All rights reserved.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     3
# This component and the accompanying materials are made available
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     4
# under the terms of "Eclipse Public License v1.0"
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     5
# which accompanies this distribution, and is available
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     7
#
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     8
# Initial Contributors:
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
     9
# Nokia Corporation - initial contribution.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    10
#
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    11
# Contributors:
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    12
#
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    13
# Description:
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    14
#
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    15
#!/usr/bin/perl
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    16
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    17
use strict;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    18
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    19
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    20
use FindBin;		# for FindBin::Bin
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    21
use lib $FindBin::Bin;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    22
use lib "$FindBin::Bin/lib";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    23
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    24
use Cwd;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    25
use Cwd 'abs_path';
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    26
use Getopt::Long;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    27
use File::Basename;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    28
use File::Spec;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    29
use XML::DOM;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    30
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    31
my $output;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    32
my $path;
276
d9662ec4599f Allow multiple config files in joinsysdef.pl. Support ignoring items by namespace on the command line in sysmodelgen
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 259
diff changeset
    33
my @config;
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    34
my @includes;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    35
my %defineParams;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    36
my %defines;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    37
my $defaultns = 'http://www.symbian.org/system-definition';	# needed if no DTD
209
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
    38
my @excludeMetaList;
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
    39
my @cannotExclude= ('link-mapping', 'config');
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
    40
my %ID;	# list of all IDs
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    41
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    42
my @newarg;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    43
foreach my $a (@ARGV)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    44
	{ #extract all -I parameters from the parameter list 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    45
	if($a=~s/^-I//)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    46
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    47
		push(@includes,$a);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    48
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    49
	else
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    50
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    51
		push(@newarg,$a);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    52
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    53
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    54
@ARGV=@newarg;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    55
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    56
# need to add options for controlling which metas are filtered out and which are included inline
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    57
GetOptions
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    58
	(
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    59
	 'path=s' => \$path,
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    60
	'output=s' => \$output,
276
d9662ec4599f Allow multiple config files in joinsysdef.pl. Support ignoring items by namespace on the command line in sysmodelgen
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 259
diff changeset
    61
	'config=s' => \@config,
209
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
    62
	'exclude-meta=s' => \@excludeMetaList
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    63
	);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    64
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    65
# -path specifies the full system-model path to the file which is being processed. 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    66
#	This must be an absolute path if you're processing a root sysdef.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    67
#	If processing a pkgdef file, you can use "./package_definition.xml" to leave all links relative. Though I can't really see the use case for this.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    68
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    69
# -output specifies the file to save the output to. If not specified this will write to stdout
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    70
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    71
# -config specifies the name of an .hrh file in which the configuration data is acquired from. If not set, no confguration will be done.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    72
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    73
# -I[path] specifies the include paths to use when resolving #includes in the .hrh file. Same syntax as cpp command uses. Any number of these can be provided.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    74
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    75
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    76
# if config is not set, no confguration will be done.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    77
# If it is set, all configuration metadata will be processed and stripped from the output, even if the confguration data is empty
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    78
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    79
 if($path eq '') {$path = '/os/deviceplatformrelease/foundation_system/system_model/system_definition.xml'}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    80
201
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
    81
($#ARGV == -1 ) && &help();
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
    82
my $sysdef = &abspath(shift);	# resolve the location of the root sysdef
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    83
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    84
209
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
    85
my %excludeMeta;
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
    86
foreach (@excludeMetaList) {$excludeMeta{$_}=1}	# make list a hash table
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
    87
foreach (@cannotExclude)
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
    88
	{
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
    89
	$excludeMeta{$_} && print STDERR "Error: Cannot exclude meta rel=\"$_\"\n";
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
    90
	$excludeMeta{$_}=0
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
    91
	}	# cannot exclude any of these rel types
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    92
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    93
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    94
# rootmap is a mapping from the filesystem to the paths in the doc
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    95
my %rootmap = &rootMap($path,$sysdef);	
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    96
my %nsmap;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    97
my %urimap;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
    98
276
d9662ec4599f Allow multiple config files in joinsysdef.pl. Support ignoring items by namespace on the command line in sysmodelgen
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 259
diff changeset
    99
foreach my $conf (@config) 
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   100
	{ # run cpp to get all #defines
276
d9662ec4599f Allow multiple config files in joinsysdef.pl. Support ignoring items by namespace on the command line in sysmodelgen
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 259
diff changeset
   101
	&getDefines($conf);
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   102
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   103
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   104
my $parser = new XML::DOM::Parser;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   105
my   $sysdefdoc = $parser->parsefile ($sysdef);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   106
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   107
201
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   108
my $maxschema = $sysdefdoc->getDocumentElement()->getAttribute('schema');	# don't check value, just store it.
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   109
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   110
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   111
# find all the namespaces used in all trhe fragments and use that 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   112
# to set the namespaces ni the root element of the created doc
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   113
#   should be able to optimise by only parsing each doc once and 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   114
#	maybe skipping the contends of <meta>
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   115
my @nslist = &namespaces($sysdef,$sysdefdoc->getDocumentElement());
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   116
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   117
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   118
while(@nslist)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   119
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   120
	my $uri = shift(@nslist);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   121
	my $prefix =shift(@nslist);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   122
	if($prefix eq 'id namespace'){$prefix=''}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   123
	if(defined $urimap{$uri}) {next} # already done this uri
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   124
	$urimap{$uri} = $prefix;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   125
	if($nsmap{$prefix})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   126
		{ # need a new prefix for this, guess from the URI (for readability)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   127
		if($uri=~/http:\/\/(www\.)?([^.\/]+)\./) {$prefix = $2}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   128
		my $i=0;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   129
		while($nsmap{$prefix})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   130
			{ # still no prefix, just make up 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   131
			$prefix="ns$i";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   132
			$i++;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   133
			# next line not really necessary, but it's a good safety to stop infinite loops
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   134
			$i eq 1000 && die "cannot create namespace prefix for $uri";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   135
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   136
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   137
	$nsmap{$prefix}=$uri;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   138
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   139
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   140
my $docroot =  $sysdefdoc->getDocumentElement;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   141
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   142
my $ns = $docroot->getAttribute('id-namespace');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   143
if(!$ns && $nsmap{''})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   144
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   145
	$docroot->setAttribute('id-namespace',$nsmap{''});
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   146
	}
201
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   147
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   148
$docroot->setAttribute('schema',$maxschema);	# output has the largest syntax version of all includes
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   149
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   150
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   151
while(my($pre,$uri) = each(%nsmap))
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   152
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   153
	$pre ne '' || next ;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   154
	$docroot->setAttribute("xmlns:$pre",$uri);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   155
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   156
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   157
&walk($sysdef,$docroot);	# process the XML
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   158
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   159
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   160
# print to file or stdout
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   161
if($output eq '') 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   162
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   163
	print $sysdefdoc->toString;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   164
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   165
else
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   166
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   167
	$sysdefdoc->printToFile($output);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   168
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   169
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   170
 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   171
sub abspath
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   172
	{ 	# normalize the path into an absolute one
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   173
	my  ($name,$path) = fileparse($_[0]);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   174
	$path=~tr,\\,/,;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   175
	if( -e $path)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   176
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   177
		return abs_path($path)."/$name";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   178
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   179
	my @dir = split('/',$_[0]);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   180
	my @new;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   181
	foreach my $d (@dir)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   182
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   183
		if($d eq '.') {next}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   184
		if($d eq '..')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   185
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   186
			pop(@new);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   187
			next;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   188
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   189
		push(@new,$d)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   190
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   191
	return join('/',@new);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   192
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   193
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   194
sub rootMap {
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   195
	my @pathdirs = split(/\//,$_[0]);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   196
	my @rootdirs = split(/\//,$_[1]);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   197
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   198
	while(lc($rootdirs[$#rootdirs])  eq lc($pathdirs[$#pathdirs])  )
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   199
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   200
		pop(@rootdirs);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   201
		pop(@pathdirs);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   202
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   203
	return (join('/',@rootdirs)  => join('/',@pathdirs) );
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   204
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   205
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   206
sub rootMapMeta {
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   207
	# find all the explict path mapping from the link-mapping metadata
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   208
	my $node = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   209
	foreach my $child (@{$node->getChildNodes})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   210
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   211
			if ($child->getNodeType==1 && $child->getTagName eq 'map-prefix')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   212
				{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   213
				my $from = $child->getAttribute('link');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   214
				my $to = $child->getAttribute('to');		# optional, but blank if not set
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   215
				$rootmap{$from} = $to;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   216
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   217
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   218
	# once this is processed we have no more need for it. Remove from output
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   219
	$node->getParentNode->removeChild($node);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   220
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   221
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   222
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   223
sub walk
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   224
	{ 	# walk through the doc, resolving all links
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   225
	my $file = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   226
	my $node = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   227
	my $type = $node->getNodeType;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   228
	if($type!=1) {return}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   229
	my $tag = $node->getTagName;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   230
	if($tag=~/^(layer|package|collection|component)$/ )
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   231
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   232
		if($file eq $sysdef)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   233
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   234
			&fixIDs($node);	# normalise all IDs in the root doc. Child docs are handled elsewhere.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   235
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   236
		my $link= $node->getAttribute('href');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   237
		if($link)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   238
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   239
			my $file = &resolvePath($file,$link); 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   240
			if(-e $file)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   241
				{
201
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   242
				&combineLink($node,$file);
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   243
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   244
			else
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   245
				{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   246
				print STDERR "Note: $file not found\n";
209
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   247
				$node->removeAttribute('href');
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   248
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   249
			return;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   250
			}
209
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   251
		else 
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   252
			{ # only check for duplicate IDs on the implementation
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   253
			my $id= $node->getAttribute('id');
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   254
			my $p = $node->getParentNode();
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   255
			my $ptext = $p->getTagName()." \"".$p->getAttribute('id')."\"";
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   256
			if(defined $ID{$id})
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   257
				{
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   258
				print STDERR "Error: duplicate ID: $tag \"$id\" in $ptext matches $ID{$id}\n";
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   259
				}
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   260
			else 
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   261
				{
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   262
				my $p = $node->getParentNode();
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   263
				$ID{$id}="$tag in $ptext";
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   264
				}
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   265
			}
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   266
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   267
	elsif($tag=~/^(SystemDefinition|systemModel)$/ )
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   268
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   269
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   270
	elsif($tag eq 'unit')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   271
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   272
		foreach my $atr ('bldFile','mrp','base','proFile')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   273
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   274
			my $link= $node->getAttribute($atr);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   275
			if($link && !($link=~/^\//))
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   276
				{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   277
				$link= &abspath(File::Basename::dirname($file)."/$link");
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   278
				foreach my $a (keys %rootmap) {
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   279
					$link=~s,^$a,$rootmap{$a},ie;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   280
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   281
				# remove leading ./  which is used to indicate that paths should remain relative
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   282
				$link=~s,^\./([^/]),$1,; 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   283
				$node->setAttribute($atr,$link);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   284
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   285
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   286
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   287
	elsif($tag eq 'meta')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   288
		{
209
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   289
		my $rel= $node->getAttribute('rel') || 'Generic';
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   290
		if($excludeMeta{$rel})
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   291
			{
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   292
			$node->getParentNode->removeChild($node);
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   293
			return;
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   294
			}
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   295
		my $link= $node->getAttribute('href');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   296
		$link=~s,^file://(/([a-z]:/))?,$2,; # convert file URI to absolute path
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   297
		if ($link ne '' ) 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   298
			{ 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   299
			if($link=~/^[\/]+:/)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   300
				{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   301
				print STDERR "Note: Remote URL $link not embedded\n";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   302
				next; # do not alter children
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   303
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   304
			if(! ($link=~/^\//))
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   305
				{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   306
				$link= &abspath(File::Basename::dirname($file)."/$link");
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   307
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   308
			if(! -e $link) 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   309
				{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   310
				print STDERR "Warning: Local metadata file not found: $link\n";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   311
				next; # do not alter children
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   312
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   313
			# if we're here we can just embed the file
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   314
			# no processing logic is done! It's just embedded blindly
201
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   315
			my $item;
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   316
			eval {
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   317
				my  $metadoc = $parser->parsefile ($link);
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   318
				$item = $metadoc->getDocumentElement;
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   319
			};
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   320
			if(!$item)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   321
				{
201
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   322
				print STDERR "Error: Could not process metadata file: $link\n";
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   323
				next; # do not alter children
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   324
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   325
			$node->removeAttribute('href');
164
8309dda95234 Fixed namespace problem when joining non-SF namespace files. Merge can now process fragement sysdefs of the same rank.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 151
diff changeset
   326
			&blindCopyInto($node,$item);
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   327
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   328
		if($node->getAttribute('rel') eq 'link-mapping')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   329
			{# need to process this now
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   330
			&rootMapMeta($node);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   331
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   332
		return;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   333
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   334
	else {return}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   335
	my $checkversion=0;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   336
	foreach my $item (@{$node->getChildNodes})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   337
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   338
		#print $item->getNodeType,"\n";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   339
		&walk($file,$item);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   340
		$checkversion = $checkversion  || ($tag eq 'component' &&  $item->getNodeType==1 && $item->getAttribute('version') ne '');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   341
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   342
276
d9662ec4599f Allow multiple config files in joinsysdef.pl. Support ignoring items by namespace on the command line in sysmodelgen
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 259
diff changeset
   343
	if($checkversion && scalar(@config))
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   344
		{ # need to check the conf metadata on the units in this component
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   345
		&doCmpConfig($node);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   346
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   347
	foreach my $item (@{$node->getChildNodes})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   348
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   349
		if ($item->getNodeType==1 && $item->getTagName eq 'meta')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   350
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   351
			&processMeta($item);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   352
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   353
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   354
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   355
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   356
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   357
sub combineLink
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   358
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   359
	# combine data from linked sysdef fragment w/ equivalent element in parent document
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   360
	my $node = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   361
	my $file = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   362
	my $getfromfile = &localfile($file);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   363
	$getfromfile eq '' && return;  # already raised warning, no need to repeat
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   364
	my  $doc = $parser->parsefile ($getfromfile);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   365
	my $item =&firstElement($doc->getDocumentElement);
201
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   366
	$item || die "badly formatted $file";	
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   367
	&fixIDs($item);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   368
	my %up = &atts($node);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   369
	my %down = &atts($item);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   370
	$up{'id'} eq $down{'id'}  || die "$up{id} differs from $down{id}";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   371
	$node->removeAttribute('href');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   372
	foreach my $v (keys %up) {delete $down{$v}}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   373
	foreach my $v (keys %down)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   374
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   375
		$node->setAttribute($v,$down{$v})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   376
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   377
	foreach my $child (@{$item->getChildNodes})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   378
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   379
		&copyInto($node,$child);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   380
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   381
	&walk($file,$node);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   382
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   383
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   384
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   385
sub blindCopyInto
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   386
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   387
	# make a deep copy the node (2nd arg) into the element (1st arg)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   388
	my $parent=shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   389
	my $item = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   390
	my $doc = $parent->getOwnerDocument;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   391
	my $type = $item->getNodeType;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   392
	my $new;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   393
	if($type==1) 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   394
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   395
		$new = $doc->createElement($item->getTagName);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   396
		my %down = &atts($item);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   397
		while(my($a,$b) = each(%down))
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   398
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   399
			$new->setAttribute($a,$b);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   400
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   401
		foreach my $child (@{$item->getChildNodes})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   402
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   403
			&blindCopyInto($new,$child);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   404
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   405
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   406
	elsif($type==3) 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   407
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   408
		$new = $doc->createTextNode ($item->getData);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   409
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   410
	elsif($type==8) 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   411
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   412
		$new = $doc->createComment  ($item->getData);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   413
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   414
	if($new)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   415
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   416
		$parent->appendChild($new);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   417
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   418
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   419
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   420
sub copyInto
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   421
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   422
	# make a deep copy the node (2nd arg) into the element (1st arg)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   423
	my $parent=shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   424
	my $item = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   425
	my $doc = $parent->getOwnerDocument;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   426
	my $type = $item->getNodeType;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   427
	my $new;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   428
	if($type==1) 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   429
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   430
		&fixIDs($item);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   431
		$new = $doc->createElement($item->getTagName);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   432
		my %down = &atts($item);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   433
		foreach my $ordered ('id','name','bldFile','mrp','level','levels','introduced','deprecated','filter')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   434
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   435
			if($down{$ordered})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   436
				{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   437
				$new->setAttribute($ordered,$down{$ordered});
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   438
				delete $down{$ordered}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   439
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   440
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   441
		while(my($a,$b) = each(%down))
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   442
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   443
			$new->setAttribute($a,$b);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   444
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   445
		foreach my $child (@{$item->getChildNodes})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   446
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   447
			&copyInto($new,$child);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   448
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   449
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   450
	elsif($type==3) 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   451
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   452
		$new = $doc->createTextNode ($item->getData);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   453
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   454
	elsif($type==8) 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   455
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   456
		$new = $doc->createComment  ($item->getData);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   457
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   458
	if($new)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   459
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   460
		$parent->appendChild($new);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   461
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   462
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   463
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   464
sub getNs
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   465
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   466
	# find the namespace URI that applies to the specified prefix.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   467
	my $node = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   468
	my $pre = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   469
	my $uri = $node->getAttribute("xmlns:$pre");
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   470
	if($uri) {return $uri}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   471
	my $parent = $node->getParentNode;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   472
	if($parent && $parent->getNodeType==1)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   473
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   474
		return getNs($parent,$pre);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   475
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   476
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   477
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   478
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   479
sub fixIDs
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   480
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   481
	# translate the ID to use the root doc's namespaces 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   482
	my $node = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   483
	foreach my $id ('id','before')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   484
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   485
		&fixID($node,$id);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   486
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   487
}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   488
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   489
sub fixID
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   490
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   491
	# translate the ID to use the root doc's namespaces 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   492
	my $node = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   493
	my $attr = shift || 'id';
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   494
	my $id = $node->getAttribute($attr);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   495
	if($id eq '') {return}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   496
	my $ns;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   497
	if($id=~s/^(.*)://)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   498
		{ # it's got a ns, find out what it is
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   499
		my $pre = $1;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   500
		$ns=&getNs($node,$pre);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   501
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   502
	else
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   503
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   504
		$ns = $node->getOwnerDocument->getDocumentElement->getAttribute("id-namespace") ||
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   505
			$defaultns;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   506
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   507
	$ns = $urimap{$ns};
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   508
	$id = ($ns eq '') ? $id : "$ns:$id";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   509
	return $node->setAttribute($attr,$id);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   510
}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   511
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   512
sub firstElement {
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   513
	# return the first element in this node
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   514
	my $node = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   515
	foreach my $item (@{$node->getChildNodes}) {
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   516
		if($item->getNodeType==1) {return $item}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   517
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   518
}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   519
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   520
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   521
sub atts {
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   522
	# return a hash of all attribtues defined for this element
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   523
	my $node = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   524
	my %at = $node->getAttributes;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   525
	my %list;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   526
	foreach my $a (keys %{$node->getAttributes}) 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   527
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   528
		if($a ne '')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   529
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   530
			$list{$a} = $node->getAttribute ($a);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   531
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   532
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   533
	return %list;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   534
}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   535
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   536
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   537
sub ns 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   538
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   539
	# return a hash of ns prefix and uri -- the xmlns: part is stripped off
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   540
	my $node = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   541
	my %list;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   542
	foreach my $a (keys %{$node->getAttributes}) 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   543
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   544
		my $pre = $a;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   545
		if($pre=~s/^xmlns://)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   546
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   547
			$list{$pre} = $node->getAttribute ($a);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   548
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   549
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   550
	return %list;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   551
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   552
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   553
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   554
sub resolvePath
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   555
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   556
	# return full path to 2nd arg relative to first (path or absolute URI)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   557
	my $base = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   558
	my $path = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   559
	if($path=~m,^/,) {return $path } # path is absolute, but has no drive. Let OS deal with it.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   560
	if($path=~s,^file:///([a-zA-Z]:/),$1,) {return $path } # file URI with drive letter
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   561
	if($path=~m,^file://,) {return $path } # file URI with no drive letter (unit-style). Just pass on as is with leading / and let OS deal with it
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   562
	if($path=~m,^[a-z0-9][a-z0-9]+:,i) {return $path } # absolute URI -- no idea how to handle, so just return
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   563
	return &abspath(File::Basename::dirname($base)."/$path");
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   564
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   565
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   566
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   567
sub resolveURI
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   568
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   569
	# return full path to 2nd arg relative to first (path or absolute URI)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   570
	my $base = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   571
	my $path = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   572
	if($path=~m,[a-z0-9][a-z0-9]+:,i) {return $path } # absolute URI -- just return
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   573
	if($path=~m,^/,) {return $path } # path is absolute, but has no drive. Let OS deal with it.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   574
	return &abspath(File::Basename::dirname($base)."/$path");
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   575
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   576
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   577
sub localfile
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   578
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   579
	my $file = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   580
	if($file=~s,file:///([a-zA-Z]:/),$1,) {return $file } # file URI with drive letter
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   581
	if($file=~m,file://,) {return $file } # file URI with no drive letter (unit-style). Just pass on as is with leading / and let OS deal with it
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   582
	if($file=~m,^([a-z0-9][a-z0-9]+):,i)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   583
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   584
		print STDERR "ERROR: $1 scheme not supported\n";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   585
		return;  # return empty string if not supported.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   586
		} 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   587
	return $file
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   588
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   589
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   590
sub namespaces
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   591
	{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   592
	# return a list of namespace URI / prefix pairs, in the order they're defined
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   593
	# these need to be used to define namespaces in the root element
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   594
	my $file = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   595
	my $node = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   596
	my $type = $node->getNodeType;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   597
	if($type!=1) {return}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   598
	my $tag = $node->getTagName;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   599
	my @res;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   600
	my %nslist = &ns($node);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   601
	while(my($pre,$uri)=each(%nslist))
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   602
		{ # push all namespaces defined here onto the list
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   603
		push(@res,$uri,$pre);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   604
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   605
	if($tag=~/^(layer|package|collection|component)$/ )
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   606
		{ # these have the potential of linking, so check for that
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   607
		my $link= $node->getAttribute('href');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   608
		if($link)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   609
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   610
			$link=&resolvePath($file,$link);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   611
			if(-e $link)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   612
				{
259
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   613
				my  $doc;
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   614
				eval {
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   615
					$doc = $parser->parsefile ($link);
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   616
				};
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   617
				if($doc)
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   618
					{
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   619
					&checkSyntaxVersion($doc->getDocumentElement->getAttribute('schema'));	# ensure we track we highest syntax number
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   620
					my @docns = &namespaces($link,$doc->getDocumentElement);
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   621
					undef $doc;
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   622
					return (@res,@docns);
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   623
					#ignore any children nodes if this is a link
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   624
					}
fbf606da2044 More detailed error messages when joining sysdef fragments
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 209
diff changeset
   625
				print STDERR "Error: Malformed XML. Could not process $link\n";
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   626
				}
209
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   627
			# print STDERR "Note: $link not found\n";  -- no need to warm now. Do so later when trying to join
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   628
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   629
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   630
	elsif($tag eq 'SystemDefinition' )
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   631
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   632
		my $default = $node->getAttribute('id-namespace');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   633
		if($default)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   634
			{# mangle with a space so it's clear it's not a qname
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   635
			push(@res,$default,'id namespace');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   636
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   637
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   638
	foreach my $item (@{$node->getChildNodes})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   639
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   640
		push(@res,&namespaces($file,$item));
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   641
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   642
	return @res;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   643
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   644
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   645
sub processMeta
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   646
	{ # acts upon any known <meta> and strips it from the output if it's used
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   647
	my $metanode = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   648
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   649
	my $rel = $metanode->getAttribute('rel') || 'Generic';
276
d9662ec4599f Allow multiple config files in joinsysdef.pl. Support ignoring items by namespace on the command line in sysmodelgen
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 259
diff changeset
   650
	if($rel eq 'config' && scalar(@config))
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   651
		{ # only process if there is something to configure
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   652
		&doconfig($metanode);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   653
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   654
	else 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   655
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   656
		# do nothing. Not supported yet
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   657
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   658
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   659
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   660
sub doCmpConfig
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   661
	{ # configure in or out the units in a component
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   662
	my $cmp = shift;	# the component node
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   663
	my @unversioned;	# list of all units with no version attribute (if more than one, they should all have filters defined)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   664
	my %versioned;		# hash table of all units with a specified version, it's a fatal error to hav the same verison twice in one component
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   665
	foreach my $item (@{$cmp->getChildNodes})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   666
		{ # populate %versioned and @unversioned to save processsing later
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   667
		if($item->getNodeType==1 && $item->getTagName eq 'unit')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   668
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   669
			my $ver = $item->getAttribute('version');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   670
			if($ver eq '') {push(@unversioned,$item)}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   671
			else
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   672
				{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   673
				defined $versioned{$ver}  && die "Cannot have more than one unit with version $ver in the same component ".$cmp->getAttribute('id');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   674
				$versioned{$ver}=$item;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   675
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   676
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   677
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   678
	my @picks = &getMetaConfigPick($cmp); # the list, in order, of all <pick> elements that affect this component
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   679
	foreach my $pick (@picks)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   680
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   681
		my $ver = $pick->getAttribute('version');
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   682
		if(!$versioned{$ver})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   683
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   684
			print STDERR "ERROR: Reference to invalid unit version $ver in component ",$cmp->getAttribute('id'),". Ignoring.\n";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   685
			return;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   686
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   687
		if(&definedMatches($pick))
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   688
			{ # remove all other units;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   689
			delete $versioned{$ver}; # to avoid removing in loop
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   690
			foreach my $unit (@unversioned, values(%versioned))
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   691
				{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   692
				$cmp->removeChild($unit);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   693
				print STDERR "Note: unit ",$unit->getAttribute('version')," in component " ,$cmp->getAttribute('id')," configured out\n";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   694
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   695
			last; # done. No more processing after first match
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   696
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   697
		else
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   698
			{ # remove this unit and continue
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   699
			$cmp->removeChild($versioned{$ver});
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   700
			print STDERR "Note: unit $ver in component " ,$cmp->getAttribute('id')," configured out\n";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   701
			delete $versioned{$ver}; # gone, don't process anymore;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   702
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   703
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   704
	if (scalar(@unversioned, values(%versioned)) > 1)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   705
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   706
		print STDERR "Warning: component ",$cmp->getAttribute('id')," has more than one unit after configuration\n";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   707
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   708
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   709
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   710
	
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   711
sub getMetaConfigPick
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   712
	{	# return an array of all <pick> elements that affect the specified element
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   713
	my $node = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   714
	my @pick;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   715
	while($node->getParentNode->getNodeType==1)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   716
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   717
		foreach my $item (@{$node->getChildNodes})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   718
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   719
			my @picks;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   720
			if($item->getNodeType==1 &&  $item->getAttribute('rel') eq 'config') 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   721
				{ # it's conf metadata
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   722
				foreach my $p (@{$item->getChildNodes})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   723
					{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   724
					if($p->getNodeType==1 &&  $p->getTagName eq 'pick') {push(@picks,$p)}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   725
					}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   726
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   727
			@pick=(@picks,@pick); # prepend this to the start;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   728
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   729
		$node=$node->getParentNode;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   730
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   731
	return @pick;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   732
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   733
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   734
sub definedMatches
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   735
	{ # process all <defined> and <not-defined> the specified element and return true or false if the combination matches
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   736
	my $node  = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   737
	my $match = 1;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   738
	foreach my $def (@{$node->getChildNodes})
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   739
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   740
		if($def->getNodeType == 1) 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   741
			{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   742
			my $tag = $def->getTagName;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   743
			if($tag eq 'defined' or $tag eq 'not-defined')
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   744
				{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   745
				my $var = $def->getAttribute('condition') || die "Must have condition set on all $tag elements";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   746
				$defineParams{$var} && die "Cannot use a macro with parameters as a feature flag: $var(".$defineParams{$var}->[0].")"; 
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   747
				$match = $match &&  (($tag eq 'defined') ? defined($defines{$var}) : ! defined($defines{$var}));
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   748
				}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   749
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   750
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   751
		return $match;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   752
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   753
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   754
sub doconfig
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   755
	{ # confgure in or out a system model item that owns the specified <meta>, remove the <meta> when done.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   756
	my $meta  = shift;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   757
	my $keep = definedMatches($meta);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   758
	my $parent = $meta->getParentNode;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   759
	if(!$keep)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   760
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   761
		print STDERR "Note: ",$parent->getTagName," " ,$parent->getAttribute('id')," configured out\n";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   762
		$parent->getParentNode->removeChild($parent);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   763
		return; # it's removed, so there's nothing else we can possibly do
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   764
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   765
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   766
	$parent->removeChild($meta);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   767
	}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   768
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   769
sub getDefines
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   770
	{ # populate the list of #defines from a specified .hrh file.
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   771
	my $file = shift;
413
9bcf6c827202 Refined filtering of config files.
Johan Groth <johang@symbian.org>
parents: 276
diff changeset
   772
	my $inc = '';
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   773
	foreach my $i (@includes)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   774
		{
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   775
		$inc.=" -I$i";
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   776
		}
414
f503e8553dd5 Script now uses cpp from the installed PDT.
Johan Groth <johang@symbian.org>
parents: 413
diff changeset
   777
	my $CPP = $ENV{"SBS_HOME"} . "/win32/mingw/bin/cpp.exe";
f503e8553dd5 Script now uses cpp from the installed PDT.
Johan Groth <johang@symbian.org>
parents: 413
diff changeset
   778
f503e8553dd5 Script now uses cpp from the installed PDT.
Johan Groth <johang@symbian.org>
parents: 413
diff changeset
   779
	$CPP =~ s/\\/\//g;
f503e8553dd5 Script now uses cpp from the installed PDT.
Johan Groth <johang@symbian.org>
parents: 413
diff changeset
   780
f503e8553dd5 Script now uses cpp from the installed PDT.
Johan Groth <johang@symbian.org>
parents: 413
diff changeset
   781
	open(CPP,"$CPP -dD$inc \"$file\" 2>&1 |");
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   782
	while(<CPP>)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   783
		{
413
9bcf6c827202 Refined filtering of config files.
Johan Groth <johang@symbian.org>
parents: 276
diff changeset
   784
		s/\s+$//;
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   785
		if(!/\S/){next} # skip blank lines
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   786
		if(/^# [0-9]+ /) {next} # don't care about these
413
9bcf6c827202 Refined filtering of config files.
Johan Groth <johang@symbian.org>
parents: 276
diff changeset
   787
		if(/#undef/) { next } # don't care about these
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   788
		if(s/^#define\s+(\S+)\((.*?)\)\s+//)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   789
			{ #parametered define
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   790
			push(@{$defineParams{$1}},@2,$_);
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   791
			}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   792
		elsif(s/^#define\s+(\S+)//)
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   793
			{ # normal define
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   794
			my $def = $1;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   795
			s/^\s+//;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   796
			$defines{$1}=$_;
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   797
			}
414
f503e8553dd5 Script now uses cpp from the installed PDT.
Johan Groth <johang@symbian.org>
parents: 413
diff changeset
   798
		else
f503e8553dd5 Script now uses cpp from the installed PDT.
Johan Groth <johang@symbian.org>
parents: 413
diff changeset
   799
			{
f503e8553dd5 Script now uses cpp from the installed PDT.
Johan Groth <johang@symbian.org>
parents: 413
diff changeset
   800
			die "cannot process $_";
f503e8553dd5 Script now uses cpp from the installed PDT.
Johan Groth <johang@symbian.org>
parents: 413
diff changeset
   801
			}
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   802
		}
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   803
	close CPP;
164
8309dda95234 Fixed namespace problem when joining non-SF namespace files. Merge can now process fragement sysdefs of the same rank.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 151
diff changeset
   804
	$? && die "Call to cpp produced an error";
151
84b123918d3f Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff changeset
   805
	}
201
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   806
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   807
sub  checkSyntaxVersion
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   808
	{ # check if supplied version number is greater than $maxschema
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   809
	my $schema = shift;
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   810
	my @max=split(/\./,$maxschema);
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   811
	my @cur=split(/\./,$schema);
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   812
	while(@max) 
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   813
		{
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   814
		($max[0] > $cur[0])  && return;		# max is bigger, do nothing
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   815
		if($cur[0] > $max[0])
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   816
			{
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   817
			$maxschema=$schema;
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   818
			return;
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   819
			}
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   820
		shift @max;
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   821
		shift @cur;
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   822
		}
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   823
	# they are equal - do nothing
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   824
	}
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   825
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   826
sub help
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   827
	{
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   828
	my $name= $0; $name=~s,^.*[\\/],,;
209
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   829
my $text;
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   830
format STDERR =
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   831
 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   832
  $text,
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   833
     ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   834
    $text
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   835
.
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   836
print STDERR "usage: $name  [options...] sysdef\n  valid options are:\n\n";
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   837
	foreach (
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   838
		"-path\tspecifies the full system-model path to the file which is being processed. By default this is  \"/os/deviceplatformrelease/foundation_system/system_model/system_definition.xml\"",
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   839
			"   This must be an absolute path if you're processing a root sysdef.",
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   840
			"   If processing a pkgdef file, you can use \"./package_definition.xml\" to leave all links relative.",
201
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   841
209
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   842
		"-output\tspecifies the file to save the output to. If not specified this will write to stdout",
201
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   843
209
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   844
		"-config\tspecifies the name of an .hrh file in which the configuration data is acquired from. If not set, no confguration will be done.",
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   845
			"   If it is set, all configuration metadata will be processed and stripped from the output, even if the confguration data is empty",
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   846
		"-I[path]\tspecifies the include paths to use when resolving #includes in the .hrh file. This uses the same syntax as cpp command uses: a captial \"I\" followed by the path with no space in between. Any number of these can be provided.",
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   847
		"-exclude-meta [rel]\tspecifies the 'rel' value of <meta> elements to exclude from the output. Any number of these can be provided. The following meta rel values affect the processing of the system definition and cannot be excluded: ".join(', ',@cannotExclude)
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   848
		) {
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   849
		$text = $_;
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   850
		write STDERR;
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   851
		print STDERR "\n";
af20ebf91ca6 sysmodelgen bugfix when drawing collections next to nested packages. Major revision to validation script checklinks.pl (it's now reliable). joinsysdef.pl now reports errors on duplicate IDs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 201
diff changeset
   852
	}
201
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   853
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   854
	exit(1);
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   855
	}
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   856
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   857
280dc2a9385b Extra warnings, help and bug fixes in sysdeftools perl scripts. Support for 3.0.1 sysdef syntax (replacing when merging)
Bob Rosenberg <bob.rosenberg@nokia.com>
parents: 164
diff changeset
   858