author | Shabe Razvi <shaber@symbian.org> |
Wed, 05 May 2010 12:02:47 +0100 | |
branch | HighFidelityModel |
changeset 194 | 965cc620394d |
parent 151 | 84b123918d3f |
child 201 | 280dc2a9385b |
permissions | -rw-r--r-- |
151
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
1 |
use strict; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
2 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
3 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
4 |
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
|
5 |
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
|
6 |
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
|
7 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
8 |
use Cwd; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
9 |
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
|
10 |
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
|
11 |
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
|
12 |
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
|
13 |
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
|
14 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
15 |
my $output; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
16 |
my $path; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
17 |
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
|
18 |
my @searchpaths; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
19 |
my @searchroots; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
20 |
my %additional; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
21 |
my %add; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
22 |
my %newNs; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
23 |
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
|
24 |
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
|
25 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
26 |
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
|
27 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
28 |
# need to add options for controlling which metas are filtered out and which are included inline |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
29 |
GetOptions |
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 |
'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
|
32 |
'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
|
33 |
'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
|
34 |
'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
|
35 |
'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
|
36 |
'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
|
37 |
); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
38 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
39 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
40 |
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
|
41 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
42 |
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
|
43 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
44 |
# 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
|
45 |
# 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
|
46 |
# 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
|
47 |
# 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
|
48 |
# 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
|
49 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
50 |
#rootsysdef.pl -root F:\dev\personal\sftest\sf\mcl -glob "\*\*\package_definition.xml" -output ..\..\..\deviceplatformrelease\nokia_system\system_definition.sf.xml ..\..\..\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
|
51 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
52 |
my %replacefile; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
53 |
my $dir; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
54 |
foreach(@searchpaths) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
55 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
56 |
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
|
57 |
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
|
58 |
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
|
59 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
60 |
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
|
61 |
$map=~tr/\\/\//; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
62 |
$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
|
63 |
$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
|
64 |
$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
|
65 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
66 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
67 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
68 |
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
|
69 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
70 |
# 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
|
71 |
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
|
72 |
my %nsmap; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
73 |
my %urimap; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
74 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
75 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
76 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
77 |
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
|
78 |
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
|
79 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
80 |
my $mapmeta; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
81 |
my $modpath; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
82 |
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
|
83 |
{ #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
|
84 |
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
|
85 |
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
|
86 |
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
|
87 |
pop(@smpath); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
88 |
pop(@fspath); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
89 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
90 |
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
|
91 |
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
|
92 |
$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
|
93 |
$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
|
94 |
$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
|
95 |
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
|
96 |
$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
|
97 |
$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
|
98 |
$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
|
99 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
100 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
101 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
102 |
$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
|
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 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
106 |
# find all the namespaces used in all trhe fragments and use that |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
107 |
# to set the namespaces ni the root element of the created doc |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
108 |
# 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
|
109 |
# 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
|
110 |
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
|
111 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
112 |
my %replacing; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
113 |
my %newContainer; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
114 |
my %foundDescendants; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
115 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
116 |
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
|
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 $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
|
119 |
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
|
120 |
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
|
121 |
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
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
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
|
126 |
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
|
127 |
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
|
128 |
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
|
129 |
@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
|
130 |
$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
|
131 |
$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
|
132 |
# 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
|
133 |
# 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
|
134 |
$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
|
135 |
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
|
136 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
137 |
$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
|
138 |
$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
|
139 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
140 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
141 |
|
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 |
while(@nslist) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
144 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
145 |
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
|
146 |
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
|
147 |
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
|
148 |
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
|
149 |
$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
|
150 |
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
|
151 |
{ # 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
|
152 |
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
|
153 |
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
|
154 |
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
|
155 |
{ # 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
|
156 |
$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
|
157 |
$i++; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
158 |
# 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
|
159 |
$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
|
160 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
161 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
162 |
$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
|
163 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
164 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
165 |
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
|
166 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
167 |
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
|
168 |
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
|
169 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
170 |
$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
|
171 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
172 |
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
|
173 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
174 |
$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
|
175 |
$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
|
176 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
177 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
178 |
&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
|
179 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
180 |
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
|
181 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
182 |
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
|
183 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
184 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
185 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
186 |
$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
|
187 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
188 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
189 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
190 |
sub abspath |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
191 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
192 |
# 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
|
193 |
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
|
194 |
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
|
195 |
$path=~tr,\\,/,; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
196 |
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
|
197 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
198 |
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
|
199 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
200 |
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
|
201 |
my @new; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
202 |
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
|
203 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
204 |
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
|
205 |
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
|
206 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
207 |
pop(@new); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
208 |
next; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
209 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
210 |
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
|
211 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
212 |
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
|
213 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
214 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
215 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
216 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
217 |
sub normpath |
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 |
# 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
|
220 |
my @norm; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
221 |
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
|
222 |
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
|
223 |
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
|
224 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
225 |
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
|
226 |
{ # 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
|
227 |
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
|
228 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
229 |
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
|
230 |
{ # 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
|
231 |
next |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
232 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
233 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
234 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
235 |
pop(@norm); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
236 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
237 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
238 |
else |
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 |
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
|
241 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
242 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
243 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
244 |
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
|
245 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
246 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
247 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
248 |
sub rootMap { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
249 |
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
|
250 |
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
|
251 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
252 |
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
|
253 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
254 |
pop(@rootdirs); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
255 |
pop(@pathdirs); |
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 |
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
|
258 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
259 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
260 |
sub replacedBy |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
261 |
{ # 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
|
262 |
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
|
263 |
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
|
264 |
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
|
265 |
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
|
266 |
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
|
267 |
return $repl; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
268 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
269 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
270 |
sub walk |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
271 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
272 |
#' 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
|
273 |
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
|
274 |
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
|
275 |
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
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
280 |
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
|
281 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
282 |
&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
|
283 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
284 |
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
|
285 |
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
|
286 |
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
|
287 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
288 |
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
|
289 |
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
|
290 |
{ # 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
|
291 |
if($link) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
292 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
293 |
$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
|
294 |
} |
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 |
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
|
297 |
{ # 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
|
298 |
$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
|
299 |
return; |
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 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
303 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
304 |
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
|
305 |
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
|
306 |
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
|
307 |
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
|
308 |
{ # 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
|
309 |
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
|
310 |
&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
|
311 |
return; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
312 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
313 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
314 |
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
|
315 |
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
|
316 |
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
|
317 |
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
|
318 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
319 |
if($link) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
320 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
321 |
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
|
322 |
&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
|
323 |
return; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
324 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
325 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
326 |
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
|
327 |
{ # 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
|
328 |
$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
|
329 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
330 |
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
|
331 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
332 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
333 |
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
|
334 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
335 |
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
|
336 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
337 |
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
|
338 |
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
|
339 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
340 |
if($mapmeta) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
341 |
{ # 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
|
342 |
$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
|
343 |
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
|
344 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
345 |
$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
|
346 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
347 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
348 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
349 |
{ # 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
|
350 |
$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
|
351 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
352 |
$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
|
353 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
354 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
355 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
356 |
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
|
357 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
358 |
&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
|
359 |
&processMeta($node); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
360 |
next; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
361 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
362 |
else {return} |
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 $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
|
364 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
365 |
#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
|
366 |
&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
|
367 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
368 |
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
|
369 |
{ # 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
|
370 |
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
|
371 |
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
|
372 |
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
|
373 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
374 |
&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
|
375 |
} |
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 |
} |
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 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
380 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
381 |
sub getNs |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
382 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
383 |
# 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
|
384 |
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
|
385 |
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
|
386 |
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
|
387 |
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
|
388 |
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
|
389 |
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
|
390 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
391 |
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
|
392 |
} |
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 |
|
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 |
sub fixIDs |
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 |
# 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
|
399 |
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
|
400 |
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
|
401 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
402 |
&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
|
403 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
404 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
405 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
406 |
sub idns |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
407 |
{ # 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
|
408 |
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
|
409 |
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
|
410 |
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
|
411 |
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
|
412 |
{ # 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
|
413 |
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
|
414 |
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
|
415 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
416 |
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
|
417 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
418 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
419 |
sub fixID |
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 |
# 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
|
422 |
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
|
423 |
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
|
424 |
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
|
425 |
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
|
426 |
my $ns; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
427 |
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
|
428 |
{ # 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
|
429 |
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
|
430 |
$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
|
431 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
432 |
else |
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 |
$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
|
435 |
$defaultns; |
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 |
$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
|
438 |
$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
|
439 |
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
|
440 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
441 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
442 |
sub firstElement { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
443 |
# 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
|
444 |
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
|
445 |
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
|
446 |
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
|
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 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
450 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
451 |
sub atts { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
452 |
# 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
|
453 |
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
|
454 |
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
|
455 |
my %list; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
456 |
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
|
457 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
458 |
if($a ne '') |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
459 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
460 |
$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
|
461 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
462 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
463 |
return %list; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
464 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
465 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
466 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
467 |
sub ns |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
468 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
469 |
# 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
|
470 |
my $node = shift; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
471 |
my %list; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
472 |
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
|
473 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
474 |
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
|
475 |
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
|
476 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
477 |
$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
|
478 |
} |
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 |
return %list; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
481 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
482 |
|
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 namespaces |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
486 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
487 |
# 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
|
488 |
# 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
|
489 |
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
|
490 |
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
|
491 |
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
|
492 |
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
|
493 |
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
|
494 |
my @res; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
495 |
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
|
496 |
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
|
497 |
{ # 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
|
498 |
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
|
499 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
500 |
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
|
501 |
{ # 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
|
502 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
503 |
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
|
504 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
505 |
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
|
506 |
if($default) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
507 |
{# 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
|
508 |
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
|
509 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
510 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
511 |
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
|
512 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
513 |
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
|
514 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
515 |
return @res; |
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 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
518 |
sub processMeta |
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 |
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
|
521 |
# 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
|
522 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
523 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
524 |
sub guessIdInPath |
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 |
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
|
527 |
my @path = reverse(split(/\//,shift)); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
528 |
while(@path) |
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 |
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
|
531 |
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
|
532 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
533 |
return ($id,@path); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
534 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
535 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
536 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
537 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
538 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
539 |
sub parentPath |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
540 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
541 |
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
|
542 |
my @path; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
543 |
while($node) |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
544 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
545 |
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
|
546 |
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
|
547 |
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
|
548 |
$id=~s/^.*://; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
549 |
@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
|
550 |
$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
|
551 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
552 |
return @path; |
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 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
555 |
sub childTag |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
556 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
557 |
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
|
558 |
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
|
559 |
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
|
560 |
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
|
561 |
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
|
562 |
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
|
563 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
564 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
565 |
sub appendNewItem |
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 |
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
|
568 |
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
|
569 |
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
|
570 |
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
|
571 |
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
|
572 |
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
|
573 |
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
|
574 |
if($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 |
$id=$1; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
577 |
$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
|
578 |
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
|
579 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
580 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
581 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
582 |
$contents = ''; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
583 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
584 |
$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
|
585 |
$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
|
586 |
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
|
587 |
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
|
588 |
{ # 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
|
589 |
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
|
590 |
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
|
591 |
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
|
592 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
593 |
&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
|
594 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
595 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
596 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
597 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
598 |
{ # 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
|
599 |
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
|
600 |
{ #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
|
601 |
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
|
602 |
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
|
603 |
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
|
604 |
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
|
605 |
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
|
606 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
607 |
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
|
608 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
609 |
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
|
610 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
611 |
&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
|
612 |
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
|
613 |
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
|
614 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
615 |
# 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
|
616 |
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
|
617 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
618 |
$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
|
619 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
620 |
else |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
621 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
622 |
$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
|
623 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
624 |
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
|
625 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
626 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
627 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
628 |
sub getNamespacePrefix |
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 |
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
|
631 |
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
|
632 |
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
|
633 |
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
|
634 |
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
|
635 |
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
|
636 |
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
|
637 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
638 |
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
|
639 |
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
|
640 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
641 |
if($node->getAttribute ($a) eq $ns) {return $pre} |
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 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
644 |
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
|
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 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
648 |
sub resolvePath |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
649 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
650 |
# 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
|
651 |
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
|
652 |
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
|
653 |
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
|
654 |
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
|
655 |
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
|
656 |
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
|
657 |
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
|
658 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
659 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
660 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
661 |
sub fixHref { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
662 |
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
|
663 |
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
|
664 |
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
|
665 |
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
|
666 |
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
|
667 |
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
|
668 |
{ # 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
|
669 |
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
|
670 |
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
|
671 |
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
|
672 |
$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
|
673 |
return; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
674 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
675 |
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
|
676 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
677 |
$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
|
678 |
$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
|
679 |
return; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
680 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
681 |
$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
|
682 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
683 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
684 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
685 |
sub setHref { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
686 |
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
|
687 |
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
|
688 |
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
|
689 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
690 |
$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
|
691 |
$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
|
692 |
$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
|
693 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
694 |
else |
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 |
$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
|
697 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
698 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
699 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
700 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
701 |
sub relativeTo { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
702 |
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
|
703 |
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
|
704 |
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
|
705 |
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
|
706 |
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
|
707 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
708 |
shift(@outfile); |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
709 |
shift(@infile); |
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 |
$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
|
712 |
if($asdir) { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
713 |
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
|
714 |
} 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
|
715 |
return $modpath; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
716 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
717 |
|
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
718 |
sub positionByTechDomain |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
719 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
720 |
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
|
721 |
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
|
722 |
my %before; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
723 |
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
|
724 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
725 |
$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
|
726 |
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
|
727 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
728 |
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
|
729 |
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
|
730 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
731 |
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
|
732 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
733 |
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
|
734 |
{ |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
735 |
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
|
736 |
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
|
737 |
if($next) { |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
738 |
$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
|
739 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
740 |
last; |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
741 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
742 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
743 |
} |
84b123918d3f
Added latest version of sysdeftools. See readme.txt for details on content.
Bob Rosenberg <bob.rosenberg@nokia.com>
parents:
diff
changeset
|
744 |
} |