put_xml_param - update description of parameters in xml file
new_tt = put_xml_param(txt,filen)
- txt : matrix of strings of size (n,2)
- txt(,1) : name of parameter
- txt(,2) : description of parameter
- filen : string. target XML file (path+name)
- new_tt : vector of strings. the text of the new XML file
//put_xml_param
//Fonction qui insère une liste de paramètres
//dans un fichier xml contenant des délimiteurs
//<PARAM> et </PARAM>
//Entrée : txt : matrice de chaînes de caractères de taille n,2
// txt(,1) : le nom du paramètre
// txt(,2) : la description du paramètre
// filen : nom du fichier xml (ex:filen=xml_path+'CAN_f.xml')
//Sortie : new_tt : texte du fichier xml de sortie
function new_tt=put_xml_param(txt,filen)
if fileinfo(filen)<>[] then
if size(txt,2)==2 then
del1='<PARAM>'
del2='</PARAM>'
tt_sav=mgetl(filen);
a=0;b=0;new_tt=tt_sav;
//trouve la position des délimiteurs
for i=1:size(tt_sav,1)
if strindex(tt_sav(i),del1)<>[] then a=i, end;
if strindex(tt_sav(i),del2)<>[] then b=i, end;
end
if a<>0&b<>0 then
//crée la nouvelle liste des paramètres
tt_param=['<PARAM_INDENT>';'']
for i=1:size(txt,1)
tt_param=[tt_param;'<PARAM_ITEM>';'<PARAM_NAME>'+txt(i,1)+'</PARAM_NAME>';
'<PARAM_DESCRIPTION>';'<SP>';
': '+txt(i,2);
'</SP>';'</PARAM_DESCRIPTION>';'</PARAM_ITEM>';'']
end
tt_param=[tt_param;'</PARAM_INDENT>']
//Ecrit la chaine de texte finale
new_tt=[tt_sav(1:a);tt_param;tt_sav(b:size(tt_sav,1))];
end
else
printf("Incompatible rsh variable\n");
end
else
printf("File %s not found\n",filen);
new_tt=[];
end
endfunction
IRCOM Group
Alan Layec