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