--- a/sysdeftools/rootsysdef.pl Thu May 06 16:24:41 2010 +0100
+++ b/sysdeftools/rootsysdef.pl Thu May 06 16:31:38 2010 +0100
@@ -118,6 +118,10 @@
my $fragment = $parser->parsefile ($_);
my $fdoc = $fragment->getDocumentElement();
my $topmost =&firstElement($fdoc);
+ if(!$topmost) {
+ print STDERR "$warning: $_ has no content. Skipping\n";
+ next;
+ }
my $type = $topmost->getTagName;
my $id = $topmost->getAttribute('id');
my ($localid,$ns) = &idns($topmost,$id);
@@ -356,6 +360,7 @@
elsif($tag eq 'meta')
{
&fixHref($node,$file);
+ foreach my $child (@{$node->getChildNodes}) {$node->removeChild($child)} # can't have children
&processMeta($node);
next;
}
@@ -524,7 +529,7 @@
sub guessIdInPath
{
my $id = shift;
- my @path = reverse(split(/\//,shift));
+ my @path = reverse(split(/\//,$_[0]));
while(@path)
{
my $dir = shift(@path);
@@ -533,6 +538,12 @@
return ($id,@path);
}
}
+ print STDERR "$warning: Non-standard ID $id in $_[0]\n";
+ @path = reverse(split(/\//,$_[0]));
+ if($path[0] eq 'package_definition.xml')
+ {
+ return @path[1..$#path];
+ }
}
@@ -567,6 +578,7 @@
my $node = shift;
my $doc = $node->getOwnerDocument;
my $id = shift;
+ if($id eq '') {return}
my $fullid=$id;
my $contents = shift;
my $tag = &childTag($node->getTagName());
@@ -638,7 +650,7 @@
my $pre = $a;
if($pre=~s/^xmlns://)
{
- if($node->getAttribute ($a) eq $ns) {return $pre}
+ if($root->getAttribute ($a) eq $ns) {return $pre}
}
}
die "ERROR: no namespace prefix defined for $ns";
@@ -672,6 +684,7 @@
$node->getParentNode->removeChild($node);
return;
}
+ foreach my $child (@{$node->getChildNodes}) {$node->removeChild($child)} # can't have children
if($output eq '')
{
$path=~s,^/?,file:///,;
@@ -695,6 +708,7 @@
{
$node->setAttribute('href',&relativeTo(&abspath($output),$file,'file'));
}
+ while(my $child = $node->getFirstChild ) {$node->removeChild($child)}
}