From: Michael Wiebusch
Date: Fri, 12 Jul 2013 12:57:57 +0000 (+0200)
Subject: cleaned up a lot of xml functions without breaking them
X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=028aa172e3bb90a86cc89271f93cf900a8c5f199;p=mvdsensorcontrol.git
cleaned up a lot of xml functions without breaking them
---
diff --git a/tools/jtageditor.pl b/tools/jtageditor.pl
index ddf7beb..c569aa6 100755
--- a/tools/jtageditor.pl
+++ b/tools/jtageditor.pl
@@ -43,8 +43,8 @@ my %cgiHash = &read_input;
if ( !keys %cgiHash )
{ # if script is called without arguments: initialize the html structure
- initPage();
- exit;
+ initPage();
+ exit;
}
@@ -70,81 +70,86 @@ our $specDir = '../specs';
# end of global variables
if ( $cgiHash{'print'} eq 'fileSelection' ) {
- print "
";
print "";
changeAncestor(""); # break the evil circle where it was closed!
+ writeConfigFile();
exit;
}
@@ -252,6 +254,7 @@ sub buildAncestry {
print
"";
changeAncestor(""); # break the evil circle where it was closed!
+ writeConfigFile();
exit;
#die "no circular includes please! $!";
@@ -275,6 +278,7 @@ sub buildAncestry {
print "
The faulty include directive was removed.
";
print "";
changeAncestor(""); # break the evil circle where it was closed!
+ writeConfigFile();
exit;
return;
}
@@ -307,6 +311,7 @@ sub buildAncestry {
print "
The faulty include directive was removed.
";
print "";
changeAncestor(""); # break the evil circle where it was closed!
+ writeConfigFile();
exit;
}
@@ -317,6 +322,7 @@ sub buildAncestry {
print "
The faulty include directive was removed.
";
print "";
changeAncestor(""); # break the evil circle where it was closed!
+ writeConfigFile();
exit;
}
unless ( $ancestorFileName eq "" ) {
@@ -370,6 +376,26 @@ sub integrateAncestry {
# description: this function extends $configTree to include all information that is held
# by its ancestor (and ancestor's ancestor ... and so on)
+sub changeAncestor {
+ my $ancestorFileName = $_[0];
+ my $xmltree = $configTree;
+ my $xmlfile = $configFile;
+ my $maps = $xmltree->findnodes("/MAPS")->shift();
+
+ $maps->setAttribute( "inheritSettingsFrom", $ancestorFileName );
+
+# open( SCHREIBEN, "> $xmlfile" )
+# or print "could not open file $xmlfile for writing: $!\n";
+#
+# print SCHREIBEN $xmltree->toString();
+# close SCHREIBEN;
+
+}
+# args: ancestorFileName
+# globs: $configTree,$configFile
+# description: change the "inheritSettingsFrom" tag in the current configTree to "ancestorFileName"
+# make change permanent by calling writeConfigFile() hereafter.
+
sub del {
my $registerName = $_[0];
@@ -402,15 +428,16 @@ sub del {
print "deleted register as well ";
}
}
- open( SCHREIBEN, "> $xmlfile" )
- or print "could not open file $xmlfile for writing: $!\n";
-
- print SCHREIBEN $xmltree->toString();
- close SCHREIBEN;
+# open( SCHREIBEN, "> $xmlfile" )
+# or print "could not open file $xmlfile for writing: $!\n";
+#
+# print SCHREIBEN $xmltree->toString();
+# close SCHREIBEN;
}
# args: registerName,fieldName,
# globs: $configFile,$configTree
-# description: deletes field "fieldName" in register "registerName" in $configFile
+# description: deletes field "fieldName" in register "registerName" in $configTree
+# make change permanent by calling writeConfigFile() hereafter.
sub save {
@@ -446,16 +473,17 @@ sub save {
$field->setAttribute( "value", $newValue );
print $field->findvalue("./\@value");
- open( SCHREIBEN, "> $xmlfile" )
- or print "could not open file $xmlfile for writing: $!\n";
-
- print SCHREIBEN $xmltree->toString();
- close SCHREIBEN;
+# open( SCHREIBEN, "> $xmlfile" )
+# or print "could not open file $xmlfile for writing: $!\n";
+#
+# print SCHREIBEN $xmltree->toString();
+# close SCHREIBEN;
}
# args: registerName,fieldName,newValue
# globs: $configFile,$configTree,
-# description: saves value "newValue" in field "fieldName" in register "registerName" (in the $configFile)
+# description: saves value "newValue" in field "fieldName" in register "registerName" (in the $configTree)
# if field or register does not exist yet, it is created.
+# make change permanent by calling writeConfigFile() hereafter.
sub copyDefaultRegister {
my $registerName = $_[0];
@@ -481,15 +509,23 @@ sub copyDefaultRegister {
$configField->setAttribute( "value", $fieldValue );
print $configField->findvalue("./\@value");
}
+
+ #writeConfigFile();
+}
+# args: registerName
+# globs: $configTree,$specTree,$configFile
+# description: copys register "registerName" from $specTree to $configTree
+# make change permanent by calling writeConfigFile() hereafter.
+
+sub writeConfigFile(){
open( SCHREIBEN, "> $configFile" )
or print "could not open file $configFile for writing: $!\n";
print SCHREIBEN $configTree->toString();
close SCHREIBEN;
}
-# args: registerName
-# globs: $config
-
+# globs: $configFile,$configTree
+# description: writes the current $configTree to $configFile
###############################
## subs generating html output
@@ -591,52 +627,7 @@ sub print_fileSelection {
print "