author | Bob Rosenberg <bob.rosenberg@nokia.com> |
Tue, 20 Apr 2010 15:23:40 +0100 | |
branch | HighFidelityModel |
changeset 175 | d0f0c2098b73 |
parent 164 | 8309dda95234 |
child 201 | 280dc2a9385b |
permissions | -rw-r--r-- |
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; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
33 |
my $config; |
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 |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
38 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
39 |
my @newarg; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
40 |
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
|
41 |
{ #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
|
42 |
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
|
43 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
44 |
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
|
45 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
46 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
47 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
48 |
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
|
49 |
} |
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 |
@ARGV=@newarg; |
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 |
# 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
|
54 |
GetOptions |
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 |
'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
|
57 |
'output=s' => \$output, |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
58 |
'config=s' => \$config |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
59 |
); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
60 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
61 |
# -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
|
62 |
# 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
|
63 |
# 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
|
64 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
65 |
# -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
|
66 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
67 |
# -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
|
68 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
69 |
# -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
|
70 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
71 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
72 |
# 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
|
73 |
# 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
|
74 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
75 |
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
|
76 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
77 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
78 |
my $sysdef = &abspath(shift); # resolve the location of the root sysdef |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
79 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
80 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
81 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
82 |
# 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
|
83 |
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
|
84 |
my %nsmap; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
85 |
my %urimap; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
86 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
87 |
if($config ne '') |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
88 |
{ # run cpp to get all #defines |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
89 |
&getDefines($config); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
90 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
91 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
92 |
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
|
93 |
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
|
94 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
95 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
96 |
# 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
|
97 |
# 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
|
98 |
# 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
|
99 |
# 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
|
100 |
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
|
101 |
|
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 |
while(@nslist) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
104 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
105 |
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
|
106 |
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
|
107 |
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
|
108 |
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
|
109 |
$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
|
110 |
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
|
111 |
{ # 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
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
{ # 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
|
116 |
$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
|
117 |
$i++; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
118 |
# 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
|
119 |
$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
|
120 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
121 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
122 |
$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
|
123 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
124 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
125 |
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
|
126 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
127 |
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
|
128 |
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
|
129 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
130 |
$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
|
131 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
132 |
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
|
133 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
134 |
$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
|
135 |
$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
|
136 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
137 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
138 |
&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
|
139 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
140 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
141 |
# 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
|
142 |
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
|
143 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
144 |
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
|
145 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
146 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
147 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
148 |
$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
|
149 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
150 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
151 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
152 |
sub abspath |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
153 |
{ # 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
|
154 |
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
|
155 |
$path=~tr,\\,/,; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
156 |
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
|
157 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
158 |
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
|
159 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
160 |
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
|
161 |
my @new; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
162 |
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
|
163 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
164 |
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
|
165 |
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
|
166 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
167 |
pop(@new); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
168 |
next; |
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 |
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
|
171 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
172 |
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
|
173 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
174 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
175 |
sub rootMap { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
176 |
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
|
177 |
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
|
178 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
179 |
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
|
180 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
181 |
pop(@rootdirs); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
182 |
pop(@pathdirs); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
183 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
184 |
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
|
185 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
186 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
187 |
sub rootMapMeta { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
188 |
# 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
|
189 |
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
|
190 |
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
|
191 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
192 |
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
|
193 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
194 |
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
|
195 |
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
|
196 |
$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
|
197 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
198 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
199 |
# 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
|
200 |
$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
|
201 |
} |
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 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
204 |
sub walk |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
205 |
{ # 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
|
206 |
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
|
207 |
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
|
208 |
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
|
209 |
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
|
210 |
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
|
211 |
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
|
212 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
213 |
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
|
214 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
215 |
&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
|
216 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
217 |
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
|
218 |
if($link) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
219 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
220 |
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
|
221 |
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
|
222 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
223 |
&combineLink($node,&resolveURI($file,$link)); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
224 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
225 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
226 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
227 |
print STDERR "Note: $file not found\n"; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
228 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
229 |
return; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
230 |
} |
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 |
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
|
233 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
234 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
235 |
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
|
236 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
237 |
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
|
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 $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
|
240 |
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
|
241 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
242 |
$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
|
243 |
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
|
244 |
$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
|
245 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
246 |
# 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
|
247 |
$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
|
248 |
$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
|
249 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
250 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
251 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
252 |
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
|
253 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
254 |
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
|
255 |
$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
|
256 |
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
|
257 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
258 |
if($link=~/^[\/]+:/) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
259 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
260 |
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
|
261 |
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
|
262 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
263 |
if(! ($link=~/^\//)) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
264 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
265 |
$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
|
266 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
267 |
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
|
268 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
269 |
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
|
270 |
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
|
271 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
272 |
# 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
|
273 |
# no processing logic is done! It's just embedded blindly |
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
|
274 |
my $metadoc = $parser->parsefile ($link); |
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
|
275 |
my $item = $metadoc->getDocumentElement; |
151
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
276 |
if(!$item) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
277 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
278 |
print STDERR "Warning: Could not process metadata file: $link\n"; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
279 |
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
|
280 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
281 |
$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
|
282 |
&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
|
283 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
284 |
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
|
285 |
{# 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
|
286 |
&rootMapMeta($node); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
287 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
288 |
return; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
289 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
290 |
else {return} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
291 |
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
|
292 |
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
|
293 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
294 |
#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
|
295 |
&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
|
296 |
$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
|
297 |
} |
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($checkversion && $config ne '') |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
300 |
{ # 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
|
301 |
&doCmpConfig($node); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
302 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
303 |
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
|
304 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
305 |
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
|
306 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
307 |
&processMeta($item); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
308 |
} |
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 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
311 |
|
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 |
sub combineLink |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
314 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
315 |
# 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
|
316 |
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
|
317 |
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
|
318 |
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
|
319 |
$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
|
320 |
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
|
321 |
my $item =&firstElement($doc->getDocumentElement); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
322 |
$item || die "badly formatted $file"; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
323 |
&fixIDs($item); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
324 |
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
|
325 |
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
|
326 |
$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
|
327 |
$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
|
328 |
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
|
329 |
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
|
330 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
331 |
$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
|
332 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
333 |
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
|
334 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
335 |
©Into($node,$child); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
336 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
337 |
&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
|
338 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
339 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
340 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
341 |
sub blindCopyInto |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
342 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
343 |
# 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
|
344 |
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
|
345 |
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
|
346 |
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
|
347 |
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
|
348 |
my $new; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
349 |
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
|
350 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
351 |
$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
|
352 |
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
|
353 |
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
|
354 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
355 |
$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
|
356 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
357 |
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
|
358 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
359 |
&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
|
360 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
361 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
362 |
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
|
363 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
364 |
$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
|
365 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
366 |
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
|
367 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
368 |
$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
|
369 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
370 |
if($new) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
371 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
372 |
$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
|
373 |
} |
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 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
376 |
sub copyInto |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
377 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
378 |
# 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
|
379 |
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
|
380 |
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
|
381 |
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
|
382 |
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
|
383 |
my $new; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
384 |
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
|
385 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
386 |
&fixIDs($item); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
387 |
$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
|
388 |
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
|
389 |
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
|
390 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
391 |
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
|
392 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
393 |
$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
|
394 |
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
|
395 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
396 |
} |
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 |
©Into($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 getNs |
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 |
# 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
|
423 |
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
|
424 |
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
|
425 |
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
|
426 |
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
|
427 |
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
|
428 |
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
|
429 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
430 |
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
|
431 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
432 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
433 |
|
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 |
sub fixIDs |
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 |
# 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
|
438 |
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
|
439 |
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
|
440 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
441 |
&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
|
442 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
443 |
} |
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 |
sub fixID |
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 |
# 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
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
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
|
452 |
my $ns; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
453 |
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
|
454 |
{ # 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
|
455 |
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
|
456 |
$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
|
457 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
458 |
else |
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 |
$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
|
461 |
$defaultns; |
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 |
$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
|
464 |
$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
|
465 |
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
|
466 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
467 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
468 |
sub firstElement { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
469 |
# 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
|
470 |
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
|
471 |
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
|
472 |
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
|
473 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
474 |
} |
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 |
sub atts { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
478 |
# 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
|
479 |
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
|
480 |
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
|
481 |
my %list; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
482 |
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
|
483 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
484 |
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
|
485 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
486 |
$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
|
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 |
return %list; |
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 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
492 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
493 |
sub ns |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
494 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
495 |
# 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
|
496 |
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
|
497 |
my %list; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
498 |
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
|
499 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
500 |
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
|
501 |
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
|
502 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
503 |
$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
|
504 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
505 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
506 |
return %list; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
507 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
508 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
509 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
510 |
sub resolvePath |
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 |
# 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
|
513 |
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
|
514 |
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
|
515 |
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
|
516 |
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
|
517 |
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
|
518 |
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
|
519 |
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
|
520 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
521 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
522 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
523 |
sub resolveURI |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
524 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
525 |
# 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
|
526 |
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
|
527 |
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
|
528 |
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
|
529 |
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
|
530 |
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
|
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 |
sub localfile |
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 |
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
|
536 |
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
|
537 |
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
|
538 |
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
|
539 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
540 |
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
|
541 |
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
|
542 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
543 |
return $file |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
544 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
545 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
546 |
sub namespaces |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
547 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
548 |
# 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
|
549 |
# 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
|
550 |
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
|
551 |
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
|
552 |
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
|
553 |
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
|
554 |
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
|
555 |
my @res; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
556 |
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
|
557 |
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
|
558 |
{ # 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
|
559 |
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
|
560 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
561 |
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
|
562 |
{ # 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
|
563 |
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
|
564 |
if($link) |
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 |
$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
|
567 |
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
|
568 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
569 |
my $doc = $parser->parsefile ($link); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
570 |
my @docns = &namespaces($link,$doc->getDocumentElement); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
571 |
undef $doc; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
572 |
return (@res,@docns); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
573 |
#ignore any children nodes if this is a link |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
574 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
575 |
print STDERR "Note: $link not found\n"; |
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 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
578 |
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
|
579 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
580 |
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
|
581 |
if($default) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
582 |
{# 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
|
583 |
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
|
584 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
585 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
586 |
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
|
587 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
588 |
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
|
589 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
590 |
return @res; |
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 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
593 |
sub processMeta |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
594 |
{ # 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
|
595 |
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
|
596 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
597 |
my $rel = $metanode->getAttribute('rel') || 'Generic'; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
598 |
if($rel eq 'config' && $config ne '') |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
599 |
{ # 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
|
600 |
&doconfig($metanode); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
601 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
602 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
603 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
604 |
# 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
|
605 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
606 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
607 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
608 |
sub doCmpConfig |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
609 |
{ # 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
|
610 |
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
|
611 |
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
|
612 |
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
|
613 |
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
|
614 |
{ # 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
|
615 |
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
|
616 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
617 |
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
|
618 |
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
|
619 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
620 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
621 |
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
|
622 |
$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
|
623 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
624 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
625 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
626 |
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
|
627 |
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
|
628 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
629 |
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
|
630 |
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
|
631 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
632 |
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
|
633 |
return; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
634 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
635 |
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
|
636 |
{ # 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
|
637 |
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
|
638 |
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
|
639 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
640 |
$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
|
641 |
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
|
642 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
643 |
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
|
644 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
645 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
646 |
{ # 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
|
647 |
$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
|
648 |
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
|
649 |
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
|
650 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
651 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
652 |
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
|
653 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
654 |
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
|
655 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
656 |
} |
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 |
sub getMetaConfigPick |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
660 |
{ # 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
|
661 |
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
|
662 |
my @pick; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
663 |
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
|
664 |
{ |
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 (@{$node->getChildNodes}) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
666 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
667 |
my @picks; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
668 |
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
|
669 |
{ # 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
|
670 |
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
|
671 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
672 |
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
|
673 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
674 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
675 |
@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
|
676 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
677 |
$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
|
678 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
679 |
return @pick; |
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 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
682 |
sub definedMatches |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
683 |
{ # 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
|
684 |
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
|
685 |
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
|
686 |
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
|
687 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
688 |
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
|
689 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
690 |
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
|
691 |
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
|
692 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
693 |
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
|
694 |
$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
|
695 |
$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
|
696 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
697 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
698 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
699 |
return $match; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
700 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
701 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
702 |
sub doconfig |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
703 |
{ # 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
|
704 |
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
|
705 |
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
|
706 |
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
|
707 |
if(!$keep) |
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 |
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
|
710 |
$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
|
711 |
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
|
712 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
713 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
714 |
$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
|
715 |
} |
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 |
sub getDefines |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
718 |
{ # 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
|
719 |
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
|
720 |
my $inc; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
721 |
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
|
722 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
723 |
$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
|
724 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
725 |
open(CPP,"cpp -dD$inc \"$file\"|"); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
726 |
while(<CPP>) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
727 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
728 |
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
|
729 |
if(/^# [0-9]+ /) {next} # don't care about these |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
730 |
s/\s+$//; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
731 |
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
|
732 |
{ #parametered define |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
733 |
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
|
734 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
735 |
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
|
736 |
{ # normal define |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
737 |
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
|
738 |
s/^\s+//; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
739 |
$defines{$1}=$_; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
740 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
741 |
else {die "cannot process $_";} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
742 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
743 |
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
|
744 |
$? && 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
|
745 |
} |