Fonction Scilab
eng - fr


return_xml_param2 - retourne les paramètres d'un fichier xml

Librairie

Séquence d'appel

txt = return_xml_param2(fname)

Paramètres

Description

Add here a paragraph of the function description. Other paragraph can be added

Add here a paragraph of the function description

Exemple

Add here scilab instructions and comments

Contenu du fichier


//return_xml_param2
//fonction qui retourne les paramères dun fichier
//d'aide scilab construit avec help_skeleton
//ex : return_xml_param2(MODNUM+'/man/xml/CAN_f.xml')
//Entrée fname : chemin+nom du fichier xml
//Sortie txt : tableau de chaines de caractères de taille n,2
//             colonne 1 : nom du paramètre
//             colonne 2 : description du paramètre
function txt=return_xml_param2(fname)
txt_temp=mgetl(fname);
txt=[]
j=1;
a=[]
b=[]
c=[]

//Cherche les bornes <PARAM_ITEM> et </PARAM_ITEM>
if txt_temp<>[] then
 for i=1:size(txt_temp,'*')
  if strindex(txt_temp(i),'<PARAM_ITEM>')<>[] then
   a(j,1)=i;
  end;
  if strindex(txt_temp(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_temp(j),'<PARAM_NAME>')<>[] then
           b(i,1)=j;
        end
        if strindex(txt_temp(j),'</PARAM_NAME>')<>[] then
           b(i,2)=j;
        end

        //Trouve les bornes de la description du paramètre
        if strindex(txt_temp(j),'<PARAM_DESCRIPTION>')<>[] then
           c(i,1)=j;
        end
        if strindex(txt_temp(j),'</PARAM_DESCRIPTION>')<>[] then
           c(i,2)=j;
        end
     end
 end

 for i=1:size(a,'r')
   txt(i,1)="";
   if b<>[] then  
     for j=b(i,1):b(i,2)
       txt(i,1)=txt(i,1)+txt_temp(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_temp(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

else
 txt=[]
end
endfunction 

Fonction(s) utilisée(s)

Add here the used function name and references

Auteurs

enter here the author name Add here the author references