author | Ross Qin <ross.qin@nokia.com> |
Tue, 30 Nov 2010 13:59:58 +0800 | |
changeset 712 | df89378e9223 |
parent 660 | 66ff3e731c60 |
child 663 | 8e27d440923e |
permissions | -rw-r--r-- |
624
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
1 |
# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
2 |
# All rights reserved. |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
3 |
# This component and the accompanying materials are made available |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
4 |
# under the terms of "Eclipse Public License v1.0" |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
5 |
# which accompanies this distribution, and is available |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
6 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
7 |
# |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
8 |
# Initial Contributors: |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
9 |
# Nokia Corporation - initial contribution. |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
10 |
# |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
11 |
# Contributors: |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
12 |
# |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
13 |
# Description: |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
14 |
# This will create a new root system definition file based on the provided template |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
15 |
#!/usr/bin/perl |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
16 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
17 |
use strict; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
18 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
19 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
20 |
use FindBin; # for FindBin::Bin |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
21 |
use lib $FindBin::Bin; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
22 |
use lib "$FindBin::Bin/lib"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
23 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
24 |
use Cwd; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
25 |
use Cwd 'abs_path'; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
26 |
use Getopt::Long; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
27 |
use File::Basename; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
28 |
use File::Spec; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
29 |
use XML::DOM; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
30 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
31 |
my $output; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
32 |
my $path; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
33 |
my $defaultns = 'http://www.symbian.org/system-definition'; # needed if no DTD |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
34 |
my @searchpaths; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
35 |
my @searchroots; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
36 |
my %additional; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
37 |
my %add; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
38 |
my %newNs; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
39 |
my $warning = "Error"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
40 |
my $placeholders=0; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
41 |
my $sysmodelname; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
42 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
43 |
my @tdOrder =("hb","se", "lo","dc", "vc" , "pr", "dm", "de", "mm", "ma" , "ui", "rt", "to" ); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
44 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
45 |
sub help |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
46 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
47 |
my $name= $0; $name=~s,^.*[\\/],,; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
48 |
print STDERR "usage: $name [options...] template\n\nThis will create a new root system definition file based on the provided template by globbing for pkgdefs in the filesystem. Any found pkgdef files are added to the end of their layer or at the end of their tech domain section, if one is defined", |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
49 |
"\nvalid options are:\n", |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
50 |
" -path [dir]\tspecifies the full system-model path to the file which is being processed. By default this is \"/os/deviceplatformrelease/foundation_system/system_model/system_definition.xml\"\n", |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
51 |
"\t\tThis is only needed when creating a stand-alone sysdef as the output", |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
52 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
53 |
" -output [file]\tspecifies the file to save the output to. If set, all hrefs will set to be relative to this location. If not specified all href will be absolute file URIs and this will write to stdout\n\n", |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
54 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
55 |
" -w [Note|Warning|Error]\tspecifies prefix text for any notifications. Defautls to Error\n\n", |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
56 |
" -root [dir]\tspecifies the root directory of the filesystem. All globbing will be done relative to this path\n\n", |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
57 |
|
636
29e6a24e9521
More extensive error reporting in sysdef perl tools. Allow sysdef merging with an empty upstream model.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
624
diff
changeset
|
58 |
" -glob [wildcard path]\tThe wildcard search to look for pkgdef files. eg \"\\*\\*\\package_definition.xml\". Can specify any number of these.\n", |
624
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
59 |
" -placeholders [bool]\tif set, all packages not found in the template will be left in as empty placeholders\n"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
60 |
" -name [text]\tthe name in <systemModel> to use for the generated root sysdef. If not present, this will use the name from the templat\n"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
61 |
exit(1); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
62 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
63 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
64 |
GetOptions |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
65 |
( |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
66 |
'path=s' => \$path, |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
67 |
'name=s' => \$sysmodelname, |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
68 |
'output=s' => \$output, |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
69 |
'w=s' => \$warning, |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
70 |
'root=s' => \@searchroots, |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
71 |
'glob=s' => \@searchpaths, |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
72 |
'placeholders=s' => \$placeholders |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
73 |
); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
74 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
75 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
76 |
if($path eq '') {$path = '/os/deviceplatformrelease/foundation_system/system_model/system_definition.xml'} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
77 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
78 |
if(!($warning =~/^(Note|Warning|Error)$/)) {$warning="Error"} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
79 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
80 |
# path is the system model path of the processed sysdef file. This is only used when creating a stand-alone sysdef as the output |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
81 |
# output specifies the file this is saved in. If specified, all (relative) paths will be modified to be relative to it. If not, all paths will be absolute |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
82 |
# w is the warning level: Note, Warning or Error. |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
83 |
# root = -root g:\sf |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
84 |
# glob = -glob "\*\*\package_definition.xml" |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
85 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
86 |
#Example command lines: |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
87 |
#rootsysdef.pl -root F:\sftest\mcl\sf -glob "\*\*\package_definition.xml" -output F:\sftest\mcl\build\system_definition.sf.xml F:\sftest\mcl\sf\os\deviceplatformrelease\foundation_system\system_model\system_definition.xml |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
88 |
#rootsysdef.pl -root F:\sftest\mcl\sf -glob "\*\*\*\*\package_definition.xml" -output F:\sftest\mcl\build\system_definition.mine.xml F:\sftest\mcl\sf\os\deviceplatformrelease\foundation_system\system_model\system_definition.xml |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
89 |
if(!scalar @ARGV && !scalar @searchpaths) {&help()}; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
90 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
91 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
92 |
my %replacefile; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
93 |
my $dir; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
94 |
foreach(@searchpaths) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
95 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
96 |
my $ndir = shift(@searchroots); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
97 |
if($ndir ne '') {$dir=$ndir} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
98 |
foreach my $file (glob "$dir$_") |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
99 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
100 |
my $map =substr($file,length($dir)); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
101 |
$map=~tr/\\/\//; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
102 |
$additional{$map}=$file; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
103 |
$replacefile{&abspath($file)}=$map; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
104 |
$add{&abspath($file)}=1; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
105 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
106 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
107 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
108 |
my $parser = new XML::DOM::Parser; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
109 |
my $sysdef; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
110 |
my %rootmap; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
111 |
my $sysdefdoc; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
112 |
if(scalar @ARGV) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
113 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
114 |
$sysdef = &abspath(shift); # resolve the location of the root sysdef |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
115 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
116 |
# rootmap is a mapping from the filesystem to the paths in the doc |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
117 |
%rootmap = &rootMap($path,$sysdef); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
118 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
119 |
$sysdefdoc = $parser->parsefile ($sysdef); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
120 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
121 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
122 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
123 |
$sysdefdoc = $parser->parse('<SystemDefinition schema="3.0.1"><systemModel name="System Model"/></SystemDefinition>'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
124 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
125 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
126 |
my %nsmap; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
127 |
my %urimap; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
128 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
129 |
my $mapmeta; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
130 |
my $modpath; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
131 |
if($output eq '') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
132 |
{ #figure out mapping path |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
133 |
my @fspath = split(/[\\\/]/,$sysdef); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
134 |
my @smpath = split(/[\\\/]/,$path); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
135 |
while(lc($smpath[$#smpath]) eq lc($fspath[$#fspath] )) { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
136 |
pop(@smpath); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
137 |
pop(@fspath); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
138 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
139 |
my $mappath = join('/',@fspath); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
140 |
my $topath = join('/',@smpath); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
141 |
$mappath=~s,^/?,file:///,; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
142 |
$mapmeta = $sysdefdoc->createElement('meta'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
143 |
$mapmeta->setAttribute('rel','link-mapping'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
144 |
my $node = $sysdefdoc->createElement('map-prefix'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
145 |
$node->setAttribute('link',$mappath); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
146 |
$topath ne '' && $node->setAttribute('to',$topath); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
147 |
$mapmeta->appendChild($node); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
148 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
149 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
150 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
151 |
$modpath = &relativeTo(&abspath($output), $sysdef); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
152 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
153 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
154 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
155 |
# find all the namespaces used in all the fragments and use that |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
156 |
# to set the namespaces in the root element of the created doc |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
157 |
# should be able to optimise by only parsing each doc once and |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
158 |
# maybe skipping the contends of <meta> |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
159 |
my @nslist = &namespaces($sysdef,$sysdefdoc->getDocumentElement()); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
160 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
161 |
my %replacing; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
162 |
my %newContainer; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
163 |
my %foundDescendants; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
164 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
165 |
foreach(keys %add) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
166 |
{ |
636
29e6a24e9521
More extensive error reporting in sysdef perl tools. Allow sysdef merging with an empty upstream model.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
624
diff
changeset
|
167 |
|
29e6a24e9521
More extensive error reporting in sysdef perl tools. Allow sysdef merging with an empty upstream model.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
624
diff
changeset
|
168 |
my $fragment; |
29e6a24e9521
More extensive error reporting in sysdef perl tools. Allow sysdef merging with an empty upstream model.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
624
diff
changeset
|
169 |
|
29e6a24e9521
More extensive error reporting in sysdef perl tools. Allow sysdef merging with an empty upstream model.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
624
diff
changeset
|
170 |
eval { |
29e6a24e9521
More extensive error reporting in sysdef perl tools. Allow sysdef merging with an empty upstream model.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
624
diff
changeset
|
171 |
$fragment = $parser->parsefile ($_); |
29e6a24e9521
More extensive error reporting in sysdef perl tools. Allow sysdef merging with an empty upstream model.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
624
diff
changeset
|
172 |
}; |
29e6a24e9521
More extensive error reporting in sysdef perl tools. Allow sysdef merging with an empty upstream model.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
624
diff
changeset
|
173 |
$fragment || die "could not parse $_"; |
624
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
174 |
my $fdoc = $fragment->getDocumentElement(); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
175 |
my $topmost =&firstElement($fdoc); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
176 |
if(!$topmost) { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
177 |
print STDERR "$warning: $_ has no content. Skipping\n"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
178 |
next; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
179 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
180 |
my $type = $topmost->getTagName; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
181 |
my $id = $topmost->getAttribute('id'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
182 |
my ($localid,$ns) = &idns($topmost,$id); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
183 |
my @path = &guessIdInPath($localid,$_); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
184 |
if($type eq 'layer') {@path=@path[0]} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
185 |
elsif($type eq 'package') {@path=@path[0..1]} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
186 |
elsif($type eq 'collection') {@path=@path[0..2]} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
187 |
elsif($type eq 'component') {@path=@path[0..3]} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
188 |
@path = reverse(@path); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
189 |
$add{$_}=join('/',@path)." $localid $ns"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
190 |
$replacing{$type}->{"$localid $ns"} = $_; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
191 |
# keys with a space are namespaced and fully identified, and contain the filename as the content. |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
192 |
# keys with no space have unknown namespace and contain a hash of the content |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
193 |
$newContainer{join('/',@path[0..$#path-1])}->{"$localid $ns"} = $_; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
194 |
for(my $i=-1;$i<$#path-1;$i++) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
195 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
196 |
$foundDescendants{$path[$i+1]}=1; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
197 |
$newContainer{join('/',@path[0..$i])}->{$path[$i+1]}=1; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
198 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
199 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
200 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
201 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
202 |
while(@nslist) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
203 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
204 |
my $uri = shift(@nslist); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
205 |
my $prefix =shift(@nslist); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
206 |
if($prefix eq 'id namespace'){$prefix=''} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
207 |
if(defined $urimap{$uri}) {next} # already done this uri |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
208 |
$urimap{$uri} = $prefix; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
209 |
if($nsmap{$prefix}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
210 |
{ # need a new prefix for this, guess from the URI (for readability) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
211 |
if($uri=~/http:\/\/(www\.)?([^.\/]+)\./) {$prefix = $2} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
212 |
my $i=0; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
213 |
while($nsmap{$prefix}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
214 |
{ # still no prefix, just make up |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
215 |
$prefix="ns$i"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
216 |
$i++; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
217 |
# next line not really necessary, but it's a good safety to stop infinite loops |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
218 |
$i eq 1000 && die "ERROR: cannot create namespace prefix for $uri"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
219 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
220 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
221 |
$nsmap{$prefix}=$uri; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
222 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
223 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
224 |
my $docroot = $sysdefdoc->getDocumentElement; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
225 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
226 |
my $ns = $docroot->getAttribute('id-namespace'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
227 |
if(!$ns && $nsmap{''}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
228 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
229 |
$docroot->setAttribute('id-namespace',$nsmap{''}); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
230 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
231 |
while(my($pre,$uri) = each(%nsmap)) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
232 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
233 |
$pre ne '' || next ; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
234 |
$docroot->setAttribute("xmlns:$pre",$uri); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
235 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
236 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
237 |
&walk($sysdef,$docroot); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
238 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
239 |
if($output eq '') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
240 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
241 |
print $sysdefdoc->toString; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
242 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
243 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
244 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
245 |
$sysdefdoc->printToFile($output); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
246 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
247 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
248 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
249 |
sub abspath |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
250 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
251 |
# normalize the path into an absolute one |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
252 |
my ($name,$path) = fileparse($_[0]); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
253 |
if($path eq '' && $name eq '') {return}; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
254 |
$path=~tr,\\,/,; |
660
66ff3e731c60
Sysdeftools additional support for merging misordered system definitions. More extensive validation. Minor bug fixes. Bash wrappers for perl scripts for unix installs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
639
diff
changeset
|
255 |
if ($path eq './') |
66ff3e731c60
Sysdeftools additional support for merging misordered system definitions. More extensive validation. Minor bug fixes. Bash wrappers for perl scripts for unix installs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
639
diff
changeset
|
256 |
{ |
66ff3e731c60
Sysdeftools additional support for merging misordered system definitions. More extensive validation. Minor bug fixes. Bash wrappers for perl scripts for unix installs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
639
diff
changeset
|
257 |
return abs_path('.').$name; |
66ff3e731c60
Sysdeftools additional support for merging misordered system definitions. More extensive validation. Minor bug fixes. Bash wrappers for perl scripts for unix installs.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
639
diff
changeset
|
258 |
} |
624
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
259 |
if( -e $path) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
260 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
261 |
return abs_path($path)."/$name"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
262 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
263 |
my @dir = split('/',$_[0]); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
264 |
my @new; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
265 |
foreach my $d (@dir) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
266 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
267 |
if($d eq '.') {next} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
268 |
if($d eq '..') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
269 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
270 |
pop(@new); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
271 |
next; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
272 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
273 |
push(@new,$d) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
274 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
275 |
return join('/',@new); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
276 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
277 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
278 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
279 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
280 |
sub normpath |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
281 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
282 |
# normalize the path |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
283 |
my @norm; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
284 |
foreach my $dir(split(/[\\\/]/,shift)) { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
285 |
if($dir eq '.') {next} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
286 |
if($dir eq '..') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
287 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
288 |
if($#norm == -1 || $norm[$#norm] eq '..') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
289 |
{ # keep as is |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
290 |
push(@norm,$dir); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
291 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
292 |
elsif($#norm == 0 && $norm[0] eq '') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
293 |
{ # path begins with /, interpret /.. as just / -- ie toss out |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
294 |
next |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
295 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
296 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
297 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
298 |
pop(@norm); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
299 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
300 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
301 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
302 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
303 |
push(@norm,$dir); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
304 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
305 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
306 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
307 |
return join('/',@norm) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
308 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
309 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
310 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
311 |
sub rootMap { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
312 |
my @pathdirs = split(/\//,$_[0]); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
313 |
my @rootdirs = split(/\//,$_[1]); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
314 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
315 |
while(lc($rootdirs[$#rootdirs]) eq lc($pathdirs[$#pathdirs]) ) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
316 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
317 |
pop(@rootdirs); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
318 |
pop(@pathdirs); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
319 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
320 |
return (join('/',@rootdirs) => join('/',@pathdirs) ); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
321 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
322 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
323 |
sub replacedBy |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
324 |
{ # can only check once. Destroys data |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
325 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
326 |
my $fullid= join(' ',&idns($node)); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
327 |
my $type = $node->getTagName; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
328 |
my $repl = $replacing{$type}->{$fullid}; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
329 |
delete $replacing{$type}->{$fullid}; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
330 |
return $repl; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
331 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
332 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
333 |
sub walk |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
334 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
335 |
#' walk through the doc, resolving all links |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
336 |
my $file = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
337 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
338 |
my $type = $node->getNodeType; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
339 |
if($type!=1) {return} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
340 |
my $tag = $node->getTagName; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
341 |
if($tag=~/^(layer|package|collection|component)$/ ) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
342 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
343 |
if($file eq $sysdef) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
344 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
345 |
&fixIDs($node); # normalise all IDs in the root doc. |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
346 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
347 |
my $override = &replacedBy($node); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
348 |
my $link= $node->getAttribute('href'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
349 |
if($override eq '' ) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
350 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
351 |
my ($id,$ns)=&idns($node); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
352 |
if($foundDescendants{$id}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
353 |
{ # keep this node, it'll be populated by what we found |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
354 |
if($link) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
355 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
356 |
$node->removeAttribute('href'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
357 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
358 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
359 |
elsif($link || !$placeholders) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
360 |
{ # not going to be used, remove |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
361 |
$node->getParentNode->removeChild($node) ; # not present, remove |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
362 |
return; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
363 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
364 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
365 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
366 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
367 |
my $href = $node->getAttribute('href'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
368 |
my $ppath = join('/',&parentPath($node->getParentNode)); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
369 |
delete $newContainer{$ppath}->{join(' ',&idns($node))}; # remove this from list of things which need to be added |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
370 |
if(&resolvePath($file,$href) ne $override) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
371 |
{ # file has changed, update |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
372 |
print STDERR "$warning: Replacing $tag ",$node->getAttribute('id')," with $override\n"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
373 |
&setHref($node,$override); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
374 |
return; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
375 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
376 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
377 |
my @curpath = &parentPath($node); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
378 |
my $curitem = $curpath[$#curpath]; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
379 |
my $curp = join('/',@curpath[0..$#curpath-1]); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
380 |
delete $newContainer{$curp}->{$curitem}; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
381 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
382 |
if($link) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
383 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
384 |
foreach my $child (@{$node->getChildNodes}) {$node->removeChild($child)} # can't have children |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
385 |
&fixHref($node,$file); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
386 |
return; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
387 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
388 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
389 |
elsif($tag eq 'systemModel' && $mapmeta) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
390 |
{ # need absolute paths for all links |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
391 |
$node->insertBefore ($mapmeta,$node->getFirstChild); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
392 |
$sysmodelname eq '' || $node->setAttribute('name',$sysmodelname); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
393 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
394 |
elsif($tag=~/^(SystemDefinition|systemModel)$/ ) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
395 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
396 |
($sysmodelname ne '' && $tag eq 'systemModel') && $node->setAttribute('name',$sysmodelname); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
397 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
398 |
elsif($tag eq 'unit') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
399 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
400 |
foreach my $atr ('bldFile','mrp','base','proFile') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
401 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
402 |
my $link= $node->getAttribute($atr); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
403 |
if($link && !($link=~/^\//)) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
404 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
405 |
if($mapmeta) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
406 |
{ # use absolute paths |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
407 |
$link= &abspath(File::Basename::dirname($file)."/$link"); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
408 |
foreach my $a (keys %rootmap) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
409 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
410 |
$link=~s,^$a,$rootmap{$a},ie; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
411 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
412 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
413 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
414 |
{ # modified relative path |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
415 |
$link = &normpath($modpath.$link); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
416 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
417 |
$node->setAttribute($atr,$link); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
418 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
419 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
420 |
} |
639
0e65f93be3cb
Joinsysdef schema calculation handles missing files. rootsystef generation does not modify embedded metatdata.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
636
diff
changeset
|
421 |
elsif($tag eq 'meta' && $node->getAttribute('href')) |
624
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
422 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
423 |
&fixHref($node,$file); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
424 |
foreach my $child (@{$node->getChildNodes}) {$node->removeChild($child)} # can't have children |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
425 |
&processMeta($node); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
426 |
next; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
427 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
428 |
else {return} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
429 |
foreach my $item (@{$node->getChildNodes}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
430 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
431 |
#print $item->getNodeType,"\n"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
432 |
&walk($file,$item); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
433 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
434 |
if($tag=~/^(systemModel|layer|package|collection|component)$/ ) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
435 |
{ # check for appending |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
436 |
my $ppath = join('/',&parentPath($node)); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
437 |
if($newContainer{$ppath}) { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
438 |
foreach my $item (sort keys %{$newContainer{$ppath}}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
439 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
440 |
&appendNewItem($node,$item,$newContainer{$ppath}->{$item}); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
441 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
442 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
443 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
444 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
445 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
446 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
447 |
sub getNs |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
448 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
449 |
# find the ns URI that applies to the specified prefix. |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
450 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
451 |
my $pre = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
452 |
my $uri = $node->getAttribute("xmlns:$pre"); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
453 |
if($uri) {return $uri} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
454 |
my $parent = $node->getParentNode; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
455 |
if($parent && $parent->getNodeType==1) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
456 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
457 |
return getNs($parent,$pre); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
458 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
459 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
460 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
461 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
462 |
sub fixIDs |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
463 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
464 |
# translate the ID to use the root doc's namespaces |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
465 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
466 |
foreach my $id ('id','before') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
467 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
468 |
&fixID($node,$id); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
469 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
470 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
471 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
472 |
sub idns |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
473 |
{ # return the namespace of an ID |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
474 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
475 |
my $id = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
476 |
if($id eq '' ) {$id = $node->getAttribute('id'); } |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
477 |
if($id=~s/^(.*)://) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
478 |
{ # it's got a ns, find out what it is |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
479 |
my $pre = $1; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
480 |
return ($id,&getNs($node,$pre)); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
481 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
482 |
return ($id,$node->getOwnerDocument->getDocumentElement->getAttribute("id-namespace") || $defaultns); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
483 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
484 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
485 |
sub fixID |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
486 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
487 |
# translate the ID to use the root doc's namespaces |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
488 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
489 |
my $attr = shift || 'id'; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
490 |
my $id = $node->getAttribute($attr); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
491 |
if($id eq '') {return} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
492 |
my $ns; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
493 |
if($id=~s/^(.*)://) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
494 |
{ # it's got a ns, find out what it is |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
495 |
my $pre = $1; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
496 |
$ns=&getNs($node,$pre); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
497 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
498 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
499 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
500 |
$ns = $node->getOwnerDocument->getDocumentElement->getAttribute("id-namespace") || |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
501 |
$defaultns; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
502 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
503 |
$ns = $urimap{$ns}; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
504 |
$id = ($ns eq '') ? $id : "$ns:$id"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
505 |
return $node->setAttribute($attr,$id); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
506 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
507 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
508 |
sub firstElement { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
509 |
# return the first element in this node |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
510 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
511 |
foreach my $item (@{$node->getChildNodes}) { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
512 |
if($item->getNodeType==1) {return $item} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
513 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
514 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
515 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
516 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
517 |
sub atts { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
518 |
# return a hash of all attribtues defined for this element |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
519 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
520 |
my %at = $node->getAttributes; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
521 |
my %list; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
522 |
foreach my $a (keys %{$node->getAttributes}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
523 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
524 |
if($a ne '') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
525 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
526 |
$list{$a} = $node->getAttribute ($a); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
527 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
528 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
529 |
return %list; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
530 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
531 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
532 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
533 |
sub ns |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
534 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
535 |
# return a hash of ns prefix and uri -- the xmlns: part is stripped off |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
536 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
537 |
my %list; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
538 |
foreach my $a (keys %{$node->getAttributes}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
539 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
540 |
my $pre = $a; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
541 |
if($pre=~s/^xmlns://) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
542 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
543 |
$list{$pre} = $node->getAttribute ($a); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
544 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
545 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
546 |
return %list; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
547 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
548 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
549 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
550 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
551 |
sub namespaces |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
552 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
553 |
# return a list of namespace URI / prefix pairs, in the order they're defined |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
554 |
# these need to be used to define namespaces in the root element |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
555 |
my $file = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
556 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
557 |
my $type = $node->getNodeType; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
558 |
if($type!=1) {return} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
559 |
my $tag = $node->getTagName; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
560 |
my @res; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
561 |
my %nslist = &ns($node); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
562 |
while(my($pre,$uri)=each(%nslist)) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
563 |
{ # push all namespaces defined here onto the list |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
564 |
push(@res,$uri,$pre); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
565 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
566 |
if($tag=~/^(layer|package|collection|component)$/ ) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
567 |
{ # these have the potential of linking, so check for that |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
568 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
569 |
elsif($tag eq 'SystemDefinition' ) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
570 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
571 |
my $default = $node->getAttribute('id-namespace'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
572 |
if($default) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
573 |
{# mangle with a space so it's clear it's not a qname |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
574 |
push(@res,$default,'id namespace'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
575 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
576 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
577 |
foreach my $item (@{$node->getChildNodes}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
578 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
579 |
push(@res,&namespaces($file,$item)); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
580 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
581 |
return @res; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
582 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
583 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
584 |
sub processMeta |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
585 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
586 |
my $metanode = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
587 |
# do nothing. Not supported yet |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
588 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
589 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
590 |
sub guessIdInPath |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
591 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
592 |
my $id = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
593 |
my @path = reverse(split(/\//,$_[0])); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
594 |
while(@path) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
595 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
596 |
my $dir = shift(@path); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
597 |
if($dir eq $id) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
598 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
599 |
return ($id,@path); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
600 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
601 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
602 |
print STDERR "$warning: Non-standard ID $id in $_[0]\n"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
603 |
@path = reverse(split(/\//,$_[0])); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
604 |
if($path[0] eq 'package_definition.xml') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
605 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
606 |
return @path[1..$#path]; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
607 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
608 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
609 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
610 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
611 |
sub parentPath |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
612 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
613 |
my $node=shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
614 |
my @path; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
615 |
while($node) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
616 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
617 |
if(!$node) {return @path} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
618 |
my $id=$node->getAttribute('id'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
619 |
if($id eq '') {return @path} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
620 |
$id=~s/^.*://; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
621 |
@path = ($id,@path); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
622 |
$node = $node->getParentNode(); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
623 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
624 |
return @path; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
625 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
626 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
627 |
sub childTag |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
628 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
629 |
my $tag = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
630 |
if($tag eq 'systemModel') {return 'layer'} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
631 |
if($tag eq 'layer') {return 'package'} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
632 |
if($tag eq 'package') {return 'collection'} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
633 |
if($tag eq 'collection') {return 'component'} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
634 |
die "ERROR: no child for $tag"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
635 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
636 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
637 |
sub appendNewItem |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
638 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
639 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
640 |
my $doc = $node->getOwnerDocument; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
641 |
my $id = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
642 |
if($id eq '') {return} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
643 |
my $fullid=$id; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
644 |
my $contents = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
645 |
my $tag = &childTag($node->getTagName()); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
646 |
my $new = $doc->createElement($tag); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
647 |
if($id=~/^(.*) (.*)/) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
648 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
649 |
$id=$1; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
650 |
$ns = getNamespacePrefix($node,$2); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
651 |
if($ns ne '') {$id="$ns:$id"} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
652 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
653 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
654 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
655 |
$contents = ''; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
656 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
657 |
$new->setAttribute('id',$id); # default namespace |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
658 |
$node->appendChild($new); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
659 |
my $ppath = join('/',&parentPath($new)); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
660 |
if($contents eq '') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
661 |
{ # look for additions |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
662 |
print STDERR "$warning: Adding new $tag: $id\n"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
663 |
if($newContainer{$ppath}) { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
664 |
foreach my $item (sort keys %{$newContainer{$ppath}}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
665 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
666 |
&appendNewItem($new,$item,$newContainer{$ppath}->{$item}); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
667 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
668 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
669 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
670 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
671 |
{ # this one item is defined in the specified file |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
672 |
if($tag eq 'package') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
673 |
{ #include some package data in root |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
674 |
my $fragment = $parser->parsefile ($contents); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
675 |
my $fdoc = $fragment->getDocumentElement(); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
676 |
my $topmost =&firstElement($fdoc); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
677 |
my %at = &atts($topmost); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
678 |
foreach my $arg ('tech-domain','level','span') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
679 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
680 |
if($at{$arg}) { $new->setAttribute($arg,$at{$arg})} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
681 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
682 |
if($at{'tech-domain'}) {&positionByTechDomain($new)} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
683 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
684 |
&setHref($new,$contents); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
685 |
print STDERR "$warning: Adding found $tag $id from $contents\n"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
686 |
delete $replacing{$tag}->{$fullid}; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
687 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
688 |
# newline after each new tag so output's not ugly |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
689 |
if($new->getNextSibling) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
690 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
691 |
$node->insertBefore($doc->createTextNode ("\n"),$new->getNextSibling); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
692 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
693 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
694 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
695 |
$node->appendChild($doc->createTextNode ("\n")); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
696 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
697 |
delete $newContainer{$ppath}; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
698 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
699 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
700 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
701 |
sub getNamespacePrefix |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
702 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
703 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
704 |
my $ns = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
705 |
my $root = $node->getOwnerDocument->getDocumentElement; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
706 |
my $idns = $root->getAttribute("id-namespace"); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
707 |
if($idns && $idns eq $ns) {return} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
708 |
if(!$idns && $defaultns eq $ns) {return} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
709 |
foreach my $a (keys %{$root->getAttributes}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
710 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
711 |
my $pre = $a; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
712 |
if($pre=~s/^xmlns://) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
713 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
714 |
if($root->getAttribute ($a) eq $ns) {return $pre} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
715 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
716 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
717 |
die "ERROR: no namespace prefix defined for $ns"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
718 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
719 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
720 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
721 |
sub resolvePath |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
722 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
723 |
# return full path to 2nd arg relative to first (path or absolute URI) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
724 |
my $base = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
725 |
my $path = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
726 |
if($path=~m,^/,) {return $path } # path is absolute, but has no drive. Let OS deal with it. |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
727 |
if($path=~s,^file:///([a-zA-Z]:/),$1,) {return $path } # file URI with drive letter |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
728 |
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 |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
729 |
if($path=~m,^[a-z0-9][a-z0-9]+:,i) {return $path } # absolute URI -- no idea how to handle, so just return |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
730 |
return &abspath(File::Basename::dirname($base)."/$path"); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
731 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
732 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
733 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
734 |
sub fixHref { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
735 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
736 |
my $base = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
737 |
my $link= $node->getAttribute('href'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
738 |
if($link=~/^(ftp|http)s:\/\//) {return} # remote link, do nothing |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
739 |
my $path = &resolvePath($base,$link); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
740 |
if(!-e $path) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
741 |
{ # no such file, delete |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
742 |
my $tag =$node->getTagName; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
743 |
my $id = $node->getAttribute('id'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
744 |
print STDERR "$warning: $tag $id not found at $link\n"; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
745 |
$node->getParentNode->removeChild($node); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
746 |
return; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
747 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
748 |
foreach my $child (@{$node->getChildNodes}) {$node->removeChild($child)} # can't have children |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
749 |
if($output eq '') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
750 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
751 |
$path=~s,^/?,file:///,; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
752 |
$node->setAttribute('href',$path); # replace with absolute URI |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
753 |
return; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
754 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
755 |
$node->setAttribute('href',&normpath($modpath.$link)); # make relative path to output file |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
756 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
757 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
758 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
759 |
sub setHref { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
760 |
my $node = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
761 |
my $file = shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
762 |
if($output eq '') |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
763 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
764 |
$path = &abspath($file); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
765 |
$path=~s,^/?,file:///,; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
766 |
$node->setAttribute('href',$path); # replace with absolute URI |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
767 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
768 |
else |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
769 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
770 |
$node->setAttribute('href',&relativeTo(&abspath($output),$file,'file')); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
771 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
772 |
while(my $child = $node->getFirstChild ) {$node->removeChild($child)} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
773 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
774 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
775 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
776 |
sub relativeTo { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
777 |
if($_[0] eq '') {return &abspath($_[1])} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
778 |
my @outfile = split(/[\\\/]/,lc(shift)); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
779 |
my @infile = split(/[\\\/]/,lc(shift)); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
780 |
my $asdir = shift ne 'file'; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
781 |
while($outfile[0] eq $infile[0]) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
782 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
783 |
shift(@outfile); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
784 |
shift(@infile); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
785 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
786 |
$modpath = '../' x (scalar(@outfile) - 1); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
787 |
if($asdir) { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
788 |
if(scalar @infile > 1) {$modpath .= join('/',@infile[0..$#infile - 1]).'/'} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
789 |
} else {$modpath .= join('/',@infile)} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
790 |
return $modpath; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
791 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
792 |
|
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
793 |
sub positionByTechDomain |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
794 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
795 |
my $node=shift; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
796 |
my $td = $node->getAttribute('tech-domain'); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
797 |
my %before; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
798 |
foreach my $t (@tdOrder) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
799 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
800 |
$before{$t}=1; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
801 |
if($t eq $td) {last} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
802 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
803 |
my $prev = $node->getPreviousSibling; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
804 |
foreach my $child (reverse @{$node->getParentNode->getChildNodes}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
805 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
806 |
if($child->getNodeType==1 && $child->getTagName eq 'package' && $child!=$node) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
807 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
808 |
if($before{$child->getAttribute('tech-domain')}) |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
809 |
{ |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
810 |
my $next = $child->getNextSibling; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
811 |
while($next && $next->getNodeType!=1) {$next = $next->getNextSibling} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
812 |
if($next) { |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
813 |
$node->getParentNode->insertBefore ($node,$next); |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
814 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
815 |
last; |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
816 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
817 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
818 |
} |
f70b728ea30c
Move sysdeftools from buildtools package into build package
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
819 |
} |