txt_list = return_xml_param3(fname)
Add here a paragraph of the function description. Other paragraph can be added
Add here a paragraph of the function description
Add here scilab instructions and comments
//return_xml_param3 //fonction qui retourne les paramères dun fichier xml //d'aide scilab //ex : return_xml_param2(MODNUM+'/man/xml/CAN_f.xml') //Entrée fname : chemin+nom du fichier xml //Sortie txt_list : une liste // txt_list()() // | | // | |------> 1 : numero paramètre // | 2 : tableau de chaines de caractères de taille n,2 // | colonne 1 : nom du paramètre // | colonne 2 : description du paramètre // | // |----> profondeur d'indentation function txt_list=return_xml_param3(fname) txt_temp=mgetl(fname); txt_list=[] a=[] b=[] c=[] if txt_temp<>[] then //Cherche les bornes <PARAM> et </PARAM> for i=1:size(txt_temp,'*') if strindex(txt_temp(i),'<PARAM>')<>[] then a=i; end; if strindex(txt_temp(i),'</PARAM>')<>[] then b=i; end end if a<>[]&b<>[] then nb_indent=0; nb_max_indent=0; //Cherche le nbre de <PARAM_INDENT> for i=a:b if strindex(txt_temp(i),'<PARAM_INDENT>')<>[] then nb_indent=nb_indent+1; elseif strindex(txt_temp(i),'</PARAM_INDENT>')<>[] then nb_indent=nb_indent-1; end if nb_indent>nb_max_indent then nb_max_indent=nb_indent, end end //initalise la liste txt_list=list(); for i=1:nb_max_indent+1 txt_list(i)=list(); txt_list(i)(1)=[]; //le numero param txt_list(i)(2)=""; //le texte end //Remplit la liste j=0; e=0; f=1; for i=a:b if strindex(txt_temp(i),'<PARAM_INDENT>')<>[] then j=j+1; elseif strindex(txt_temp(i),'</PARAM_INDENT>')<>[] then j=j-1; elseif strindex(txt_temp(i),'<PARAM_ITEM>')<>[] then e=e+1; txt_list(j+1)(1)=[txt_list(j+1)(1);e]; txt_list(j+1)(2)=[txt_list(j+1)(2);txt_temp(i)]; else txt_list(j+1)(2)=[txt_list(j+1)(2);txt_temp(i)]; end end for ij=1:nb_max_indent+1 a=[]; b=[]; j=1; txt=[]; //Cherche les bornes <PARAM_ITEM> et </PARAM_ITEM> for i=1:size(txt_list(ij)(2),'*') if strindex(txt_list(ij)(2)(i),'<PARAM_ITEM>')<>[] then a(j,1)=i; end; if strindex(txt_list(ij)(2)(i),'</PARAM_ITEM>')<>[] then a(j,2)=i; j=j+1; end end for i=1:size(a,'r') //pour chaque bloc for j=a(i,1):a(i,2) //Trouve les bornes du nom du paramètre if strindex(txt_list(ij)(2)(j),'<PARAM_NAME>')<>[] then b(i,1)=j; end if strindex(txt_list(ij)(2)(j),'</PARAM_NAME>')<>[] then b(i,2)=j; end //Trouve les bornes de la description du paramètre if strindex(txt_list(ij)(2)(j),'<PARAM_DESCRIPTION>')<>[] then c(i,1)=j; end if strindex(txt_list(ij)(2)(j),'</PARAM_DESCRIPTION>')<>[] then c(i,2)=j; end end end for i=1:size(b,'r') txt(i,1)=""; if b<>[] then for j=b(i,1):b(i,2) txt(i,1)=txt(i,1)+txt_list(ij)(2)(j); end //Enlève les délimiteurs <PARAM_NAME> et </PARAM_NAME> txt(i,1)=strsubst(txt(i,1),'<PARAM_NAME>',""); txt(i,1)=strsubst(txt(i,1),'</PARAM_NAME>',""); //Enlève les blancs du début txt(i,1)=stripblanks_begin(txt(i,1)); //Enlève les blancs placés à la fin txt(i,1)=stripblanks_end(txt(i,1)); end txt(i,2)=""; if c<>[] then for j=c(i,1):c(i,2) txt(i,2)=txt(i,2)+txt_list(ij)(2)(j); end //Enlève les délimiteurs <PARAM_DESCRIPTION> et </PARAM_DESCRIPTION> txt(i,2)=strsubst(txt(i,2),'<PARAM_DESCRIPTION>',""); txt(i,2)=strsubst(txt(i,2),'</PARAM_DESCRIPTION>',""); //Enlève les délimiteurs <SP> et </SP> if strindex(txt(i,2),'<SP>')<>[] then txt(i,2)=strsubst(txt(i,2),'<SP>',""); end if strindex(txt(i,2),'</SP>')<>[] then txt(i,2)=strsubst(txt(i,2),'</SP>',""); end //Enlève les blancs du début txt(i,2)=stripblanks_begin(txt(i,2)); //Enlève les blancs placés à la fin txt(i,2)=stripblanks_end(txt(i,2)); //Enlève les : du début if part(txt(i,2),1)==':' then txt(i,2)=part(txt(i,2),2:length(txt(i,2))); end //Enlève les blancs du début txt(i,2)=stripblanks_begin(txt(i,2)); txt(i,2)=retrieve_char(txt(i,2)) end end txt_list(ij)(2)=txt end //Enlève la première liste si vide if txt_list(1)(1)==[] then nb_indent=size(txt_list); if nb_indent<>1 then new_list=list(); for i=1:nb_indent-1 new_list(i)=list() new_list(i)=txt_list(i+1); end txt_list=new_list; else txt_list=[] end end end end endfunction