put_xml_desc - update long description in xml file
new_tt = put_xml_desc(list_txt,filen)
- list_txt : list
- list_txt() : integer. id of paragraph
- list_txt()(1) : integer. indentation level
- list_txt()(2) : string. title of paragraph
- list_txt()(3) : vector of strings. text of paragraph
- filen : string. target XML file (path+name)
- new_tt : vector of strings. the text of the new XML file
//put_xml_desc
//Fonction qui insère une section description
//dans un fichier xml contenant des délimiteurs
//<DESCRIPTION> et </DESCRIPTION>
//Entrée : list_txt()() : une liste
// | |
// | |
// | |----> 1 : profondeur d'indentation
// | 2 : le titre du paragraphe
// | 3 : le texte du paragraphe
// |---> n° du paragraphe
// filen : nom du fichier xml (ex:filen=xml_path+'CAN_f.xml')
function new_tt=put_xml_desc(list_txt,filen)
if fileinfo(filen)<>[] then
del1='<DESCRIPTION>'
del2='</DESCRIPTION>'
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 size(list_txt(1))==3 then
if a<>0&b<>0 then
n=1; //profondeur d'indentation
tt_long=[];
for i=1:size(list_txt)
if list_txt(i)(1)>n then
for j=1:list_txt(i)(1)-n
tt_long=[tt_long;'<DESCRIPTION_INDENT>'}
end
n=list_txt(i)(1);
end
if i>1 & list_txt(i)(1)<n then
for j=1:n-list_txt(i)(1)
tt_long=[tt_long;'</DESCRIPTION_INDENT>'}
end
n=list_txt(i)(1);
end
if list_txt(i)(2)<>"" then
tt_long=[tt_long;'<DESCRIPTION_ITEM label='+list_txt(i)(2)+'>';
'<P>';list_txt(i)(3);'</P>';'</DESCRIPTION_ITEM>']
else
tt_long=[tt_long;'<DESCRIPTION_ITEM>';
'<P>';list_txt(i)(3);'</P>';'</DESCRIPTION_ITEM>']
end
end
if n>1 then
for j=1:(n-1)
tt_long=[tt_long;'</DESCRIPTION_INDENT>'}
end
end
tt_long=" "+tt_long;
//Ecrit la chaine de texte finale
new_tt=[tt_sav(1:a);tt_long;tt_sav(b:size(tt_sav,1))]
end
elseif size(list_txt(1))==0 then
if a<>0&b<>0 then
tt_long=[];
new_tt=[tt_sav(1:a);tt_long;tt_sav(b:size(tt_sav,1))]
end
//pause
else
printf("Incompatible rsh variable\n");
new_tt=[];
end
else
printf("File %s not found\n",filen);
new_tt=[];
end
endfunction
IRCOM Group
Alan Layec