From 30ec6e497c989be984d37495cfb6705c056169ce Mon Sep 17 00:00:00 2001 From: Andreas Neiser Date: Mon, 14 Jul 2014 12:09:52 +0200 Subject: [PATCH] =?utf8?q?xml-db:=20Adding=20=C2=A7HeadNode=20as=20special?= =?utf8?q?=20entry=20containing=20all=20top-level=20items=20as=20children?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- xml-db/xml-db.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/xml-db/xml-db.pl b/xml-db/xml-db.pl index c64c9f5..2e04ee4 100755 --- a/xml-db/xml-db.pl +++ b/xml-db/xml-db.pl @@ -159,6 +159,21 @@ sub WorkOnDoc { push(@{$dbitem->{'children'}}, $childname); } } + + + # add a HeadNode with its top-level children + my $headnode = {}; + my $hn_children = $doc->getDocumentElement->findnodes('group | register | memory | fifo'); + foreach my $childnode (@$hn_children) { + my $childname = $childnode->getAttribute('name'); + + if (not defined $db->{$childname}) { + PrintMessage($childnode, "Fatal Error: Child $childname of §HeadNode not found in database", 1) + } + push(@{$headnode->{'children'}}, $childname); + } + $db->{'§HeadNode'} = $headnode; + return $db; } -- 2.43.0