put_xml_param3 - update description of parameters in xml file
new_tt = put_xml_param3(txt_list,filen)
- txt_list : list
- list_txt() : integer. indentation level
- list_txt()(1) : integer. id of parameter
- list_txt()(2) : matrix of string of size(n,2)
- list_txt()(2)(,1) : string. name of parameter
- list_txt()(2)(,2) : string. description of parameter
- filen : string. target XML file (path+name)
- new_tt : vector of strings. the text of the new XML file
//put_xml_param3
//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_param3(txt_list,filen)
if fileinfo(filen)<>[] 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
//si les délimiteurs ont été trouvés
if a<>0&b<>0 then
//si la chaine txt n'es pas vide
if txt_list<>list() then
//trouve le nbre de paramètres
nb_para=0;
for i=1:size(txt_list)
for j=1:size(txt_list(i)(1),1)
nb_para=nb_para+1;
end
end
//initialise une nouvelle liste
n=list()
for i=1:nb_para
n(i)=list();
n(i)(1)=0;
n(i)(2)=""
n(i)(3)=""
end
//met la liste dans l'ordre des paragraphes
for i=1:size(txt_list)
for j=1:size(txt_list(i)(1),1)
n(txt_list(i)(1)(j,1))(1)=i;
n(txt_list(i)(1)(j,1))(2)=txt_list(i)(2)(j,1);
n(txt_list(i)(1)(j,1))(3)=txt_list(i)(2)(j,2);
end
end
//crée la liste des param au format xml
tt_param=[];
pre_i=0; //indentation précédente
for i=1:size(n)
dif_i=n(i)(1)-pre_i;
if dif_i<>0 then
if dif_i>0 then
for j=1:dif_i
tt_param=[tt_param;' <PARAM_INDENT>'];
end
elseif dif_i<0 then
for j=-1:-1:dif_i
tt_param=[tt_param;' </PARAM_INDENT>'];
end
end
end
pre_i=n(i)(1);
tt_param=[tt_param;' <PARAM_ITEM>';
' <PARAM_NAME>'+n(i)(2)+'</PARAM_NAME>';
' <PARAM_DESCRIPTION>';
' <SP>';
' '+n(i)(3);
' </SP>';
' </PARAM_DESCRIPTION>';
' </PARAM_ITEM>';];
end
dif_i=-pre_i;
if dif_i<0 then
for j=-1:-1:dif_i
tt_param=[tt_param;' </PARAM_INDENT>'];
end
end
else
tt_param=[];
end
//Ecrit la chaine de texte finale
new_tt=[tt_sav(1:a);tt_param;tt_sav(b:size(tt_sav,1))];
end
else
printf("File %s not found\n",filen);
new_tt=[];
end
endfunction
IRCOM Group
Alan Layec