1 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2 // Copyright (C) 2008 INRIA - Pierre MARECHAL <pierre.marechal@inria.fr>
3 // Copyright (C) 2008-2010 DIGITEO - Pierre MARECHAL <pierre.marechal@scilab.org>
4 // Copyright (C) 2009 DIGITEO - Vincent COUVERT <vincent.couvert@scilab.org>
5 // Copyright (C) 2010 - 2011 DIGITEO - Allan CORNET
7 // This file must be used under the terms of the CeCILL.
8 // This source file is licensed as described in the file COPYING, which
9 // you should have received as part of this distribution. The terms
10 // are also available at
11 // http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
13 function generated_files = xmltoformat(output_format,dirs,titles,directory_language,default_language)
15 // =========================================================================
16 // + output_format : "javaHelp", "pdf", "chm", "ps"
18 // + dirs : A set of directories for which help files (jar, pdf, chm, ...) are
21 // + titles : associated title strings (optional or [])
23 // + directory_language : language in which the help is written
25 // + default_language : The directory we compiling is completed with help files
26 // from the default_language
28 // if dirs is not specified or [] then standard scilab man are assumed and
29 // titles are searched in %helps
30 // =========================================================================
32 my_wanted_language = getlanguage(); // This variable is only need when
33 // build all scilab help
36 global %helps_modules;
38 if %helps_modules == [] then
39 x2f_reset_help_mod_var(my_wanted_language);
42 %HELPS = [%helps_modules; %helps];
44 SCI_long = pathconvert(getlongpathname(SCI),%F,%F);
46 //--------------------------------------------------------------------------
47 // Save the current environment
48 //--------------------------------------------------------------------------
50 current_directory = pwd();
53 %helps_modules_save = %helps_modules;
61 // Too much parameters
62 // ---------------------------------------------------------------------
64 if rhs > 5 | rhs < 1 then
65 error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"),"xmltoformat",1,5));
68 // Transformation du %helps_modules jar => help/language
70 // Default case : construction de l'aide en ligne de Scilab
71 // ---------------------------------------------------------------------
74 | ((rhs == 2) & (dirs == [])) ..
75 | ((rhs == 3) & (dirs == []) & (titles == [])) ..
76 | ((rhs == 4) & (dirs == []) & (titles == [])) ) then
80 // "directory_language" input argument is defined !
82 my_wanted_language = directory_language;
83 x2f_reset_help_mod_var(my_wanted_language);
84 %HELPS = [%helps_modules; %helps];
87 dirs_to_build = %HELPS;
88 dirs_to_build_m = %helps_modules;
89 dirs_to_build_c = %helps;
91 dirs = x2f_get_xml_path(dirs_to_build(:,1),my_wanted_language);
92 dirs_m = x2f_get_xml_path(dirs_to_build_m(:,1),my_wanted_language);
93 dirs_c = x2f_get_xml_path(dirs_to_build_c(:,1),my_wanted_language);
95 titles = dirs_to_build(:,2);
96 titles_m = dirs_to_build_m(:,2);
97 titles_c = dirs_to_build_c(:,2);
99 dirs( find(dirs == "")) = [];
100 dirs_m( find(dirs_m == "")) = [];
101 dirs_c( find(dirs_c == "")) = [];
102 titles( find(dirs == "")) = [];
103 titles_m( find(dirs_m == "")) = [];
104 titles_c( find(dirs_c == "")) = [];
106 directory_language = [];
107 directory_language_m = [];
108 directory_language_c = [];
110 default_language = [];
111 default_language_m = [];
112 default_language_c = [];
114 language_system = []; // language_system is equal to %T when
115 language_system_m = []; // a help directory needs to be completed
116 language_system_c = []; // with the default language
118 if my_wanted_language == getdefaultlanguage() then
119 for k=1:size(dirs,"*")
120 directory_language = [directory_language;my_wanted_language];
121 language_system = [language_system;%F];
123 for k=1:size(dirs_m,"*")
124 directory_language_m = [directory_language_m;my_wanted_language];
125 language_system_m = [language_system_m;%F];
127 for k=1:size(dirs_c,"*")
128 directory_language_c = [directory_language_c;my_wanted_language];
129 language_system_c = [language_system_c;%F];
132 for k=1:size(dirs,"*")
133 directory_language = [directory_language;my_wanted_language];
134 default_language = [default_language;getdefaultlanguage()];
135 language_system = [language_system;%T]; // Enable the language system
137 for k=1:size(dirs_m,"*")
138 directory_language_m = [directory_language_m;my_wanted_language];
139 default_language_m = [default_language_m;getdefaultlanguage()];
140 language_system_m = [language_system_m;%T]; // Enable the language system
142 for k=1:size(dirs_c,"*")
143 directory_language_c = [directory_language_c;my_wanted_language];
144 default_language_c = [default_language_c;getdefaultlanguage()];
145 language_system_c = [language_system_c;%T]; // Enable the language system
149 // Only directories are precised
150 // ---------------------------------------------------------------------
152 elseif (rhs == 2) & (dirs <> []) then
154 language_system = [];
156 directory_language = [];
157 default_language = [];
159 for k=1:size(dirs,"*")
160 directory_language = [directory_language ; x2f_guess_lang(dirs(k)) ]; // Language detection
161 default_language = [default_language ; getdefaultlanguage()]; // Default Language
162 titles = [titles;gettext("Help chapter")+" "+string(k)];
164 if directory_language(k) == default_language(k) then
165 language_system = [language_system;%F]; // Enable the language system
167 language_system = [language_system;%T]; // Enable the language system
171 // Only directories and title are precised
172 // ---------------------------------------------------------------------
176 language_system = [];
177 directory_language = [];
178 default_language = [];
180 for k=1:size(dirs,"*")
181 directory_language = [directory_language ; x2f_guess_lang(dirs(k)) ]; // Language detection
182 default_language = [default_language ; getdefaultlanguage()]; // Default Language
184 if directory_language(k) == default_language(k) then
185 language_system = [language_system;%F]; // Enable the language system
187 language_system = [language_system;%T]; // Enable the language system
191 // Directories, title and languages are specified
192 // ---------------------------------------------------------------------
196 language_system = [];
197 default_language = [];
199 for k=1:size(dirs,"*")
200 default_language = [default_language ; getdefaultlanguage()]; // Default Language
202 if directory_language(k) == default_language(k) then
203 language_system = [language_system;%F]; // Enable the language system
205 language_system = [language_system;%T]; // Enable the language system
210 // ---------------------------------------------------------------------
214 language_system = [];
216 for k=1:size(dirs,"*")
217 if isdir(pathconvert(dirs(k)+"/../"+default_language(k),%f,%f)) then
218 if directory_language(k) == default_language(k) then
219 language_system = [language_system;%F]; // Enable the language system
221 language_system = [language_system;%T]; // Enable the language system
228 // Convert paths into absolute paths
229 // ---------------------------------------------------------------------
230 function dir_modified = checkAndConvertDir(dirs_path)
232 if (dirs_path <> []) then
233 if ~and(isdir(dirs_path)) then
234 notDirIdx = find(isdir(dirs_path) == %F);
235 error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat", dirs_path(notDirIdx(1))));
237 dir_modified = fullpath(dirs_path);
241 dirs = checkAndConvertDir(dirs);
243 if all_scilab_help then
244 dirs_m = checkAndConvertDir(dirs_m);
245 dirs_c = checkAndConvertDir(dirs_c);
248 // =========================================================================
250 // =========================================================================
252 if all_scilab_help then
254 // ast_tree : "Modules" Tree
256 if directory_language_m(1) == "fr_FR" then
257 scilab_manual = "Aide Scilab"
258 elseif directory_language_m(1) == "pt_BR" then
259 scilab_manual = "Ajuda Scilab"
261 scilab_manual = "Scilab help"
264 modules_tree = struct();
265 modules_tree("level") = 0; // It's a book
266 modules_tree("title") = scilab_manual;
267 modules_tree("book_title") = scilab_manual;
268 modules_tree("language") = directory_language_m(1);
269 modules_tree("path") = SCI;
270 modules_tree("master.xml") = %F;
271 modules_tree("xml_number") = 0;
272 modules_tree("xml_list") = [];
278 for k=1:size(dirs_m,"*")
280 this_tree = x2f_dir_to_tree(dirs_m(k),1);
281 this_tree("title_addchapter") = titles_m(k);
282 this_tree("language") = directory_language_m(k);
284 if language_system_m(k) then
285 default_language_path = pathconvert(part(dirs_m(k),1:length(dirs_m(k))-5)+default_language_m(k));
286 if isdir(default_language_path) then
287 this_tree_dl = x2f_dir_to_tree(default_language_path,1);
288 this_tree = x2f_merge_trees(this_tree_dl,this_tree);
292 modules_tree("dir_"+getmd5(dirs_m(k),"string")) = this_tree;
300 contrib_tree = struct();
302 for k=1:size(dirs_c,"*")
304 this_tree = x2f_dir_to_tree(dirs_c(k),0);
305 this_tree("title_addchapter") = titles_c(k);
306 this_tree("language") = directory_language_c(k);
308 if language_system_c(k) then
309 default_language_path = pathconvert(part(dirs_c(k),1:length(dirs_c(k))-5)+default_language_c(k));
310 if isdir(default_language_path) then
311 this_tree_dl = x2f_dir_to_tree(default_language_path,0);
312 this_tree = x2f_merge_trees(this_tree_dl,this_tree);
316 contrib_tree(dirs_c(k)) = this_tree;
325 contrib_tree = struct();
327 for k=1:size(dirs,"*")
329 this_tree = x2f_dir_to_tree(dirs(k),0);
330 this_tree("title_addchapter") = titles(k);
331 this_tree("language") = directory_language(k);
333 if language_system(k) then
334 default_language_path = pathconvert(part(dirs(k),1:length(dirs(k))-5)+default_language(k));
335 if isdir(default_language_path) then
336 this_tree_dl = x2f_dir_to_tree(default_language_path,0);
337 this_tree = x2f_merge_trees(this_tree_dl,this_tree);
341 contrib_tree(dirs(k)) = this_tree;
346 // =========================================================================
347 // Build the master documents
348 // =========================================================================
350 if all_scilab_help then
356 mprintf(_("\nBuilding the Scilab manual master document for %s.\n"),my_wanted_language);
358 master_doc = pathconvert(SCI+"/modules/helptools/master_"+my_wanted_language+"_help.xml",%F);
359 modules_tree("master_document") = master_doc;
360 master_str = x2f_tree_to_master(modules_tree);
361 mputl(master_str,master_doc);
367 nb_dir = size(dirs_c,"*");
373 if displaydone == 0 then
374 mprintf(_("\nBuilding master documents:\n"));
378 mprintf(_("\nBuilding the master document:\n"));
381 mprintf(_("\t%s\n"),strsubst(dirs_c(k),SCI_long,"SCI"));
383 this_tree = contrib_tree(dirs_c(k));
384 master_doc = pathconvert(dirs_c(k)+"/master_help.xml",%F);
385 this_tree("master_document") = master_doc;
386 master_str = x2f_tree_to_master(this_tree);
387 mputl(master_str,master_doc);
388 contrib_tree(dirs_c(k)) = this_tree;
394 nb_dir = size(dirs,"*");
400 if displaydone == 0 then
401 mprintf(_("\nBuilding master documents:\n"));
405 mprintf(_("\nBuilding the master document:\n"));
408 mprintf(_("\t%s\n"),strsubst(dirs(k),SCI_long,"SCI"));
410 this_tree = contrib_tree(dirs(k));
412 if isfield(this_tree,"master.xml") & this_tree("master.xml") then
413 this_tree("master_document") = pathconvert(dirs(k)+"/master.xml",%F);
414 contrib_tree(dirs(k)) = this_tree;
418 master_doc = pathconvert(dirs(k)+"/master_help.xml",%F);
419 this_tree("master_document") = master_doc;
420 master_str = x2f_tree_to_master(this_tree);
421 mputl(master_str,master_doc);
422 contrib_tree(dirs(k)) = this_tree;
428 // =========================================================================
429 // Perform the help generation
430 // scilab help files generation
433 // -- scilab internal toolbox (example: scicos)
434 // =========================================================================
438 output_format_ext = "jar";
440 output_format_ext = "html";
442 output_format_ext = output_format;
445 is_html = (output_format == "html" | output_format == "web");
446 is_chm = (output_format == "chm");
448 if all_scilab_help then
450 mprintf(_("Building the scilab manual file ["+output_format+"]\n"));
452 // Define and create the final output directory if does not exist
453 if output_format == "web" then
454 final_output_dir = pathconvert(SCI+"/modules/helptools/web",%f,%f);
456 // Define and create the final output directory if does not exist
457 final_output_dir = pathconvert(SCI+"/modules/helptools/"+output_format_ext,%f,%f);
460 if ~isdir(final_output_dir) then
461 mkdir(final_output_dir);
467 final_output_dir = pathconvert(final_output_dir+"/"+my_wanted_language,%f,%f);
468 if ~isdir(final_output_dir) then
469 mkdir(final_output_dir);
473 // Define and create the path of buildDoc working directory
474 buildDoc_dir = pathconvert(SCI+"/modules/helptools/"+ output_format + "/scilab_" + my_wanted_language + "_help",%t,%f);
476 if ~isdir(pathconvert(SCI+"/modules/helptools/"+output_format,%f,%f)) then
477 mkdir(pathconvert(SCI+"/modules/helptools/"+output_format,%f,%f));
480 if ~isdir(buildDoc_dir) then
484 // Define the final location of the generated file
486 final_help_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f);
488 final_help_file = pathconvert(final_output_dir+"/index.html",%f,%f);
490 final_help_file = pathconvert(final_output_dir+"/scilab_" + my_wanted_language + "_help." + output_format_ext,%f,%f);
493 // Define the path of the generated file created by buildDoc
495 buildDoc_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f);
497 buildDoc_file = pathconvert(buildDoc_dir + "index.html",%f,%f);
499 buildDoc_file = pathconvert(buildDoc_dir + "scilab_" + my_wanted_language + "_help." + output_format_ext,%f,%f);
502 // Save the current directory
505 // Change Scilab current directory so that Java Indexer works
506 if ~chdir(buildDoc_dir) then
507 error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",buildDoc_dir));
511 fileToExec = buildDocv2(output_format,modules_tree("master_document"), my_wanted_language);
512 if fileToExec ~= [] then
513 exec(fileToExec, -1);
514 if output_format == "javaHelp" then
515 // We don't create the jar when building the online help
517 buildDocv2("jar-only",modules_tree("master_document"), my_wanted_language);
521 // Check if the help file has been generated
522 if fileinfo(buildDoc_file)==[] then
524 error(msprintf(gettext("%s: %s has not been generated."),"xmltoformat",buildDoc_file));
527 // move the generated file(s)
531 my_html_files = listfiles(buildDoc_dir);
532 for k=1:size(my_html_files,"*")
533 if ~copyfile(my_html_files(k),pathconvert(final_output_dir+"/"+my_html_files(k),%f,%f)) then
535 error(msprintf(gettext("%s: %s file hasn''t been moved in the %s directory."),"xmltoformat",my_html_files(k),final_output_dir));
537 mdelete(my_html_files(k));
540 copyfile(buildDoc_file,final_help_file);
541 mdelete(buildDoc_file);
544 // Move into the initial directory
545 if ~chdir(cur_dir) then
546 error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",cur_dir));
549 // Now we can add the help file to the list of all generated files
550 generated_files = [ generated_files ; final_help_file ];
554 // Now, build toolboxes help (if any)
556 for k=1:size(dirs_c,"*");
558 this_tree = contrib_tree(dirs_c(k));
560 mprintf(_("\nBuilding the manual file [%s] in %s.\n"),output_format,strsubst(dirs_c(k),SCI_long,"SCI"));
562 // Define and create the final output directory if does not exist
563 final_output_dir = pathconvert(dirs_c(k)+"/../../"+output_format_ext,%f,%f);
565 if ~isdir(final_output_dir) then
566 mkdir(final_output_dir);
569 // To improve the final_output_dir path
570 final_output_dir = pathconvert(fullpath(final_output_dir),%f,%f);
573 final_output_dir = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f);
575 final_output_dir = pathconvert(final_output_dir+"/"+directory_language_c(k),%f,%f);
576 if ~isdir(final_output_dir) then
577 mkdir(final_output_dir);
581 // Define and create the path of buildDoc working directory
582 buildDoc_dir = pathconvert(dirs_c(k) + "/scilab_" + directory_language_c(k) + "_help",%t,%f);
583 if ~isdir(buildDoc_dir) then
587 // Define the final location of the generated file
589 final_help_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f);
591 final_help_file = pathconvert(final_output_dir+"/index.html",%f,%f);
593 final_help_file = pathconvert(final_output_dir+"/scilab_" + directory_language_c(k) + "_help." + output_format_ext,%f,%f);
597 // Define the path of the generated file created by buildDoc
599 buildDoc_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f);
601 buildDoc_file = pathconvert(buildDoc_dir + "index.html",%f,%f);
603 buildDoc_file = pathconvert(buildDoc_dir + "scilab_" + directory_language_c(k) + "_help." + output_format_ext,%f,%f);
606 // Save the current directory
609 // Change Scilab current directory so that Java Indexer works
610 if ~chdir(buildDoc_dir) then
612 error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",buildDoc_dir));
616 fileToExec = buildDocv2(output_format,this_tree("master_document"),directory_language_c(k),dirs_c(k));
617 if fileToExec ~= [] then
618 exec(fileToExec, -1);
619 buildDocv2("jar-only",this_tree("master_document"),directory_language_c(k),dirs_c(k));
622 // Check if the help file has been generated
623 if fileinfo(buildDoc_file)==[] then
625 error(msprintf(gettext("%s: %s has not been generated."),"xmltoformat",buildDoc_file));
628 // move the generated file(s)
632 my_html_files = listfiles(buildDoc_dir);
633 for k=1:size(my_html_files,"*")
634 if ~copyfile(my_html_files(k),pathconvert(final_output_dir+"/"+my_html_files(k),%f,%f)) then
636 error(msprintf(gettext("%s: %s file hasn''t been moved in the %s directory."),"xmltoformat",my_html_files(k),final_output_dir));
638 mdelete(my_html_files(k));
641 copyfile(buildDoc_file,final_help_file);
642 mdelete(buildDoc_file);
645 // Move into the initial directory
646 if ~chdir(cur_dir) then
647 error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",oldDir));
650 // Now we can add the help file to the list of all generated files
651 generated_files = [ generated_files ; final_help_file ];
656 // ------------------------------
657 // external (Toolboxes)
658 // ------------------------------
661 // Dirs are precised in the input arguments
663 nb_dir = size(dirs,"*");
668 // Save the current directory
671 this_tree = contrib_tree(dirs(k));
674 if displaydone == 0 then
675 mprintf(_("\nBuilding the manual file [%s].\n"),output_format);
678 mprintf(_("\t%s\n"),strsubst(dirs(k),SCI_long,"SCI"));
680 mprintf(_("\nBuilding the manual file [%s] in %s.\n"),output_format,strsubst(dirs(k),SCI_long,"SCI"));
683 // Define and create the final output directory if does not exist
684 final_output_dir = pathconvert(dirs(k)+"/../../"+output_format_ext,%f,%f);
686 if ~isdir(final_output_dir) then
687 mkdir(final_output_dir);
690 // To improve the final_output_dir path
692 if ~chdir(final_output_dir) then
693 error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",final_output_dir));
696 final_output_dir = pathconvert(pwd(),%f,%f);
702 final_output_dir = pathconvert(final_output_dir+"/"+directory_language(k),%f,%f);
703 if ~isdir(final_output_dir) then
704 mkdir(final_output_dir);
709 // Define and create the path of buildDoc working directory
710 buildDoc_dir = pathconvert(dirs(k) + "/scilab_" + directory_language(k) + "_help",%t,%f);
711 if ~isdir(buildDoc_dir) then
715 // Define the final location of the generated file
717 final_help_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f);
720 final_help_file = pathconvert(final_output_dir+"/index.html",%f,%f);
722 final_help_file = pathconvert(final_output_dir+"/scilab_" + directory_language(k) + "_help." + output_format_ext,%f,%f);
726 // Define the path of the generated file created by buildDoc
728 buildDoc_file = pathconvert(buildDoc_dir + "htmlhelp.hhp",%f,%f);
730 buildDoc_file = pathconvert(buildDoc_dir + "index.html",%f,%f);
732 buildDoc_file = pathconvert(buildDoc_dir + "scilab_" + directory_language(k) + "_help." + output_format_ext,%f,%f);
735 // Change Scilab current directory so that Java Indexer works
736 if ~chdir(buildDoc_dir) then
737 error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",buildDoc_dir));
741 fileToExec = buildDocv2(output_format,this_tree("master_document"),directory_language(k),dirs(k));
742 if fileToExec ~= [] then
743 exec(fileToExec, -1);
744 buildDocv2("jar-only",this_tree("master_document"),directory_language(k),dirs(k));
747 // Check if the help file has been generated
748 if fileinfo(buildDoc_file)==[] then
750 error(msprintf(gettext("%s: %s has not been generated."),"xmltoformat",buildDoc_file));
753 // move the generated file(s)
757 my_html_files = listfiles(buildDoc_dir);
758 for k=1:size(my_html_files,"*")
759 if ~copyfile(my_html_files(k),pathconvert(final_output_dir+"/"+my_html_files(k),%f,%f)) then
761 error(msprintf(gettext("%s: %s file hasn''t been moved in the %s directory."),"xmltoformat",my_html_files(k),final_output_dir));
763 mdelete(my_html_files(k));
766 copyfile(buildDoc_file,final_help_file);
767 mdelete(buildDoc_file);
770 // Move into the initial directory
771 if ~chdir(cur_dir) then
772 error(msprintf(gettext("%s: Directory %s does not exist or read access denied."),"xmltoformat",oldDir));
775 // Now we can add the help file to the list of all generated files
776 generated_files = [ generated_files ; final_help_file ];
781 // Restore the original environment
782 //--------------------------------------------------------------------------
784 chdir(current_directory);
785 %helps = %helps_save;
786 %helps_modules = %helps_modules_save;
787 %HELPS = saved_helps;
792 // =============================================================================
793 // dirs_out = x2f_get_xml_path(dirs_in,my_wanted_language)
794 // =============================================================================
796 function dirs_out = x2f_get_xml_path(dirs_in,my_wanted_language)
800 for k=1:size(dirs_in,"*")
802 if basename(dirs_in(k)) == "jar" then
804 help_basepath = part(dirs_in(k),1:length(dirs_in(k))-4) + filesep() + "help";
806 if isdir(help_basepath + filesep() +my_wanted_language) then
807 dirs_out(k) = help_basepath + filesep() + my_wanted_language;
808 elseif isdir(help_basepath+filesep()+getdefaultlanguage()) then
809 dirs_out(k) = help_basepath+filesep()+getdefaultlanguage();
815 dirs_out(k) = dirs_in(k);
822 // =============================================================================
823 // language_out = x2f_guess_lang(dir_in)
824 // =============================================================================
826 function language_out = x2f_guess_lang(dir_in)
828 language_out = getlanguage();
830 [my_start,my_end,my_match] = regexp(basename(dir_in),"/([a-z][a-z]_[A-Z][A-Z])$/");
832 if my_start <> [] then
833 language_out = part(my_match,1:5);
838 // =============================================================================
839 // x2f_reset_help_mod_var(language)
840 // =============================================================================
842 function x2f_reset_help_mod_var(language)
844 global %helps_modules;
846 // Reset the variable in hand
849 modules_ordered_list = mgetl(SCI + "/modules/helptools/etc/MAIN_CHAPTERS");
850 // remove empty lines in MAIN_CHAPTERS
851 modules_ordered_list(modules_ordered_list == "") = [];
853 // get current modules used by scilab
854 current_modules_list = getmodules();
856 size_current_modules = size(current_modules_list, "*");
857 size_modules_ordered = size(modules_ordered_list, "*");
859 if size_current_modules > size_modules_ordered then
860 error(msprintf(gettext("%s: Please check %s, number of modules is invalid.\n"), "xmltoformat", SCI + "/modules/helptools/etc/MAIN_CHAPTERS"));
863 // Remove modules not present
865 cleaned_ordered_modules = [];
866 for i = 1:size_modules_ordered
867 for j = 1:size_current_modules
868 if (current_modules_list(j) == modules_ordered_list(i)) then
869 cleaned_ordered_modules(k) = modules_ordered_list(i);
875 // We force to add windows_tools module in help
877 if getos() <> "Windows" then
878 cleaned_ordered_modules(k) = "windows_tools";
881 size_cleaned_modules = size(cleaned_ordered_modules, "*");
883 // Loop on modules available ordered
884 for k = 1:size_cleaned_modules;
885 addchapter_path = SCI + "/modules/" + cleaned_ordered_modules(k) + "/help/" + language + "/addchapter.sce";
886 if isfile(addchapter_path) then
887 exec(addchapter_path, -1);
893 // =============================================================================
894 // tree = x2f_dir_to_tree(directory,level)
907 // =============================================================================
909 function tree = x2f_dir_to_tree(directory,level)
914 // Check number of input arguments
915 // =========================================================================
918 error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_dir_to_tree",2));
921 // Check input argument type
922 // =========================================================================
924 if type(directory) <> 10 then
925 error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"x2f_dir_to_tree",1));
928 if type(level) <> 1 then
929 error(msprintf(gettext("%s: Wrong type for input argument #%d: An integer expected.\n"),"x2f_dir_to_tree",2));
932 // Check input argument dimension
933 // =========================================================================
935 if size(directory,"*") <> 1 then
936 error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"x2f_dir_to_tree",1));
939 if size(level,"*") <> 1 then
940 error(msprintf(gettext("%s: Wrong size for input argument #%d: An integer expected.\n"),"x2f_dir_to_tree",1));
943 // Check the directory existence
944 // =========================================================================
946 if ~isdir(directory) then
947 error(msprintf(gettext("%s: Wrong value for input argument #%d: A valid existing directory is expected.\n"),"x2f_dir_to_tree",1));
950 // ... and now, Action
951 // =========================================================================
953 // Normalize the directory path
954 directory = pathconvert(directory);
957 // init the structure
959 tree("path") = directory;
960 tree("level") = level;
962 // If a master.xml file exists, don't go past
963 if fileinfo(directory+"master.xml")<>[] then
964 tree("master.xml") = %T;
967 tree("master.xml") = %F;
974 // Parse the CHAPTER file to get the directory title if this file is present
975 if fileinfo(directory+"CHAPTER")<>[] then
976 tree = x2f_cat(tree,x2f_read_CHAPTER(directory+"CHAPTER"));
979 // Check if the addchapter.sce is present
980 if fileinfo(directory+"addchapter.sce")<>[] then
981 tree("title_addchapter") = basename(directory);
984 // Check if the last_successful_build is present
985 if fileinfo(directory+".last_successful_build")<>[] then
986 tree = x2f_cat(tree , x2f_read_lsb(directory+".last_successful_build"));
989 // Get the default title
991 if getos() == "Windows" then
992 tmpdirectory = strsubst(directory,"/\\$/","","r");
994 tmpdirectory = strsubst(directory,"/\/$/","","r");
997 tree("title_default") = basename(tmpdirectory);
1000 // XML list management
1004 xmlfiles = x2f_get_xml_files(directory);
1006 // Allocate the xml list
1007 tree("xml_list") = xmlfiles;
1008 tree("xml_number") = size(xmlfiles(:,1),"*");
1011 // Sub Trees management
1014 // get the directory list
1015 directories = x2f_get_directories(directory);
1017 for i=1:size(directories,"*")
1018 this_dir_tree = x2f_dir_to_tree(directory+directories(i),tree("level") + 1);
1019 if this_dir_tree("xml_number") > 0 then
1020 tree("dir_"+getmd5(directories(i),"string")) = this_dir_tree;
1021 tree("xml_number") = tree("xml_number") + this_dir_tree("xml_number");
1027 // =============================================================================
1028 // xmlfiles = x2f_get_xml_files(directory)
1029 // return an n X 3 matrix
1031 // xmlfiles(:,1) : basename of each XML file
1032 // xmlfiles(:,2) : full path of each XML file
1033 // xmlfiles(:,3) : Last modification time of each XML file
1035 // Date : 24/04/2009
1036 // =============================================================================
1038 function xmlfiles = x2f_get_xml_files(directory)
1042 // Check number of input arguments
1043 // =========================================================================
1046 error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"x2f_get_xml_files",1));
1049 // Check input argument type
1050 // =========================================================================
1052 if type(directory) <> 10 then
1053 error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"x2f_get_xml_files",1));
1056 // Check input argument dimension
1057 // =========================================================================
1059 if size(directory,"*") <> 1 then
1060 error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"x2f_get_xml_files",1));
1063 // Check the directory existence
1064 // =========================================================================
1066 if ~isdir(directory) then
1067 error(msprintf(gettext("%s: Wrong value for input argument #%d: A valid existing directory is expected.\n"),"x2f_get_xml_files",1));
1070 // ... and now, Action
1071 // =========================================================================
1073 directory = pathconvert(directory);
1075 // remove duplicated names in current directory (example: case ".xml~")
1076 xmlfiles = unique(basename(findfiles(directory, "*.xml")));
1078 xmlfiles = gsort(xmlfiles, "lr", "i");
1079 xmlfiles(grep(xmlfiles,"master_help")) = [];
1080 xmlfiles(grep(xmlfiles,"master")) = [];
1082 // Loop on all xml files to get their full path
1083 // =========================================================================
1085 if xmlfiles <> [] then
1086 xmlpaths = directory + xmlfiles + ".xml";
1091 // Get XML modification time
1092 // =========================================================================
1094 if xmlpaths<>[] then
1095 infos = fileinfo(xmlpaths);
1098 lmt = string(infos(:,7));
1099 format(ft(2),ft(1));
1104 // xmlfiles => md5sum
1105 // =========================================================================
1107 if xmlfiles <> [] then
1108 xmlmd5 = "a" + getmd5(xmlpaths,"string");
1113 // Build the final matrix
1114 // =========================================================================
1115 xmlfiles = [ xmlmd5 xmlpaths lmt xmlfiles];
1119 // =============================================================================
1120 // directories = x2f_get_directories(directory)
1122 // Returns a colum vector that contain the list of subdirectories of <directory>
1124 // Date : 24/04/2009
1125 // =============================================================================
1127 function directories = x2f_get_directories(directory)
1131 // Check number of input arguments
1132 // =========================================================================
1135 error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"x2f_get_directories",1));
1138 // Check input argument type
1139 // =========================================================================
1141 if type(directory) <> 10 then
1142 error(msprintf(gettext("%s: Wrong type for input argument #%d: Single string expected.\n"),"x2f_get_directories",1));
1145 // Check input argument dimension
1146 // =========================================================================
1148 if size(directory,"*") <> 1 then
1149 error(msprintf(gettext("%s: Wrong size for input argument #%d: Single string expected.\n"),"x2f_get_directories",1));
1152 // Check the directory existence
1153 // =========================================================================
1155 if ~isdir(directory) then
1156 error(msprintf(gettext("%s: Wrong value for input argument #%d: A valid existing directory is expected.\n"),"x2f_get_directories",1));
1159 // ... and now, Action
1160 // =========================================================================
1162 // Normalize the directory path
1163 directory = pathconvert(directory);
1165 items = listfiles(directory);
1168 for i=1:size(items,"*")
1169 if isdir(directory+items(i)) then
1170 directories = [ directories ; items(i) ];
1175 directories = gsort(basename(directories),"lr","i");
1177 // Remove directories that start with a dot from the list
1178 directories(grep(directories,"/^\./","r")) = [];
1180 // Remove blank strings from the list
1181 directories(find(directories == "")) = [];
1183 // Remove all scilab_xx_XX_help directories from the list
1184 directories( grep(directories,"/^scilab_[a-z][a-z]_[A-Z][A-Z]_help$/","r") ) = []
1188 // =============================================================================
1189 // desc_out = x2f_read_CHAPTER(file_in)
1190 // Parse a CHAPTER file
1192 // Date : 24/04/2009
1193 // =============================================================================
1195 function desc_out = x2f_read_CHAPTER(file_in)
1197 desc_out = struct();
1201 // Check number of input arguments
1202 // =========================================================================
1205 error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"x2f_read_CHAPTER",1));
1208 // Check input arguments value
1209 // =========================================================================
1211 if regexp( file_in,"/CHAPTER$/") == [] then
1212 error(msprintf(gettext("%s: Wrong value for input argument #%d: A string that end with CHAPTER expected.\n"),"x2f_read_CHAPTER",1));
1215 // Check the input file existence
1216 // =========================================================================
1218 if fileinfo( file_in ) == [] then
1219 error(msprintf(gettext("%s: Wrong value for input argument #%d: A valid existing file is expected.\n"),"x2f_read_CHAPTER",1));
1222 // ... and now, Action
1223 // =========================================================================
1225 FILETOPARSE = mgetl(file_in);
1229 for i=1:size(FILETOPARSE,"*")
1231 // Second case : Current field continuation
1232 if (regexp(FILETOPARSE(i),"/^\s/","o") == 1) & (current_field <> "") then
1233 current_value = part(FILETOPARSE(i),2:length(FILETOPARSE(i)));
1234 desc_out(current_field) = [ desc_out(current_field) ; current_value ];
1238 // First case : new field
1239 if regexp(FILETOPARSE(i),"/^[a-zA-Z][a-zA-Z0-9_]*\s*=\s*/","o") == 1 then
1240 [current_field_start, current_field_end] = regexp(FILETOPARSE(i),"/\s*=\s*/","o")
1241 current_field = part(FILETOPARSE(i),1:current_field_start-1);
1242 current_value = part(FILETOPARSE(i),current_field_end+1:length(FILETOPARSE(i)));
1243 desc_out(current_field) = current_value;
1247 // Third case : Blank line
1248 if length(stripblanks(FILETOPARSE(i))) == 0 then
1253 error(msprintf(gettext("%s: The CHAPTER file is not well formated at line %d\n"),"x2f_read_CHAPTER",i));
1259 // =============================================================================
1260 // desc_out = x2f_read_lsb(file_in)
1261 // Parse a last_successful_build file
1263 // Date : 24/04/2009
1264 // =============================================================================
1266 function desc_out = x2f_read_lsb(file_in)
1268 desc_out = struct();
1271 // Check number of input arguments
1272 // =========================================================================
1275 error(msprintf(gettext("%s: Wrong number of input argument: %d to %d expected.\n"),"x2f_read_lsb",1));
1278 // Check input arguments value
1279 // =========================================================================
1281 if regexp( file_in,"/\.last_successful_build$/") == [] then
1282 error(msprintf(gettext("%s: Wrong value for input argument #%d: A string that end with .last_successful_build expected.\n"),"x2f_read_lsb",1));
1285 // Check the input file existence
1286 // =========================================================================
1288 if fileinfo( file_in ) == [] then
1289 error(msprintf(gettext("%s: Wrong value for input argument #%d: A valid existing file is expected.\n"),"x2f_read_lsb",1));
1292 // ... and now, Action
1293 // =========================================================================
1295 FILETOPARSE = stripblanks(mgetl(file_in));
1297 for i=1:size(FILETOPARSE,"*")
1299 // First case : new field
1300 if regexp(FILETOPARSE(i),"/^[a-zA-Z][a-zA-Z0-9_]*\s=\s/","o") == 1 then
1301 current_field_length = regexp(FILETOPARSE(i),"/\s=\s/","o")
1302 current_field = part(FILETOPARSE(i),1:current_field_length-1);
1303 current_value = part(FILETOPARSE(i),current_field_length+3:length(FILETOPARSE(i)));
1305 if regexp(current_value,"/^[0-9]+$/") == [] then
1306 error(msprintf(gettext("%s: The last_successful_build file is not well formated at line %d\n"),"x2f_read_lsb",i));
1309 desc_out(current_field) = strtod(current_value);
1313 // Third case : Blank line
1314 if length(FILETOPARSE(i)) == 0 then
1319 error(msprintf(gettext("%s: The last_successful_build file is not well formated at line %d\n"),"x2f_read_lsb",i));
1325 // =============================================================================
1326 // desc_out = x2f_cat( desc_in_1 , desc_in_2)
1328 // Concatenate two mlist
1330 // Date : 27/04/2009
1331 // =============================================================================
1333 function desc_out = x2f_cat(desc_in_1,desc_in_2)
1337 // Check number of input arguments
1338 // =========================================================================
1341 error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_cat",2));
1344 // Check input arguments type
1345 // =========================================================================
1347 if type(desc_in_1) <> 17 then
1348 error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_cat",1));
1351 if type(desc_in_2) <> 17 then
1352 error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_cat",2));
1355 // ... and now, Action
1356 // =========================================================================
1358 fields_in_2 = getfield(1,desc_in_2);
1359 fields_in_2(1:2) = [];
1361 if or(isfield(desc_in_1,fields_in_2)) then
1362 error(msprintf(gettext("%s: The 2 mlist must not have any field in common .\n"),"x2f_cat"));
1365 desc_out = desc_in_1;
1367 for i=1:size(fields_in_2,"*")
1368 desc_out(fields_in_2(i)) = desc_in_2(fields_in_2(i));
1373 // =============================================================================
1374 // master_document = x2f_tree_to_master( tree )
1376 // Date : 27/04/2009
1377 // =============================================================================
1379 function master_document = x2f_tree_to_master( tree )
1383 // Check number of input arguments
1384 // =========================================================================
1387 error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_tree_to_master",1));
1390 // Check input arguments type
1391 // =========================================================================
1393 if type(tree) <> 17 then
1394 error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_tree_to_master",1));
1397 // if a master.xml exists in the directory, return this file
1398 // =========================================================================
1400 if isfield(tree,"master.xml") & tree("master.xml") then
1401 str = mgetl( tree("path") + "master.xml" );
1406 // =========================================================================
1408 if isfield(tree,"language") then
1409 language = tree("language");
1414 master_document = ["<?xml version=""1.0"" encoding=""UTF-8""?>";..
1416 "<!--Begin Entities-->"];
1418 // Get the list of all xml files present in this tree
1419 tree_xmllist = x2f_cat_xmllist( tree , [] )
1421 // Process the path if under windows
1422 if getos() == "Windows" then
1423 tree_xmllist(:,2) = "file:///"+ strsubst(getlongpathname(tree_xmllist(:,2)) ,"\","/");
1427 master_document = [ master_document ; "<!ENTITY "+tree_xmllist(:,1)+" SYSTEM """+tree_xmllist(:,2)+""">" ]
1432 if isfield(tree,"book_title") & (tree("book_title") <> "") then
1433 // title defined in CHAPTER
1434 book_title = tree("book_title");
1437 elseif isfield(tree,"title_addchapter") & (tree("title_addchapter") <> "") then
1438 // title defined in addchapter.sce
1439 book_title = tree("title_addchapter");
1442 // title built with the directory name
1443 book_title = tree("title_default");
1446 book_title = strsubst(book_title,"&" ,"&");
1447 book_title = strsubst(book_title,"""" ,""");
1448 book_title = strsubst(book_title,">" ,">");
1449 book_title = strsubst(book_title,"<" ,"<");
1451 master_document = [ master_document; ..
1452 "<!--End Entities-->"; ..
1454 "<book version=""5.0-subset Scilab"" xml:lang="""+language+""""; ..
1455 " xmlns=""http://docbook.org/ns/docbook"""; ..
1456 " xmlns:xlink=""http://www.w3.org/1999/xlink"""; ..
1457 " xmlns:xi=""http://www.w3.org/2001/XInclude"""; ..
1458 " xmlns:svg=""http://www.w3.org/2000/svg"""; ..
1459 " xmlns:mml=""http://www.w3.org/1998/Math/MathML"""; ..
1460 " xmlns:html=""http://www.w3.org/1999/xhtml"""; ..
1461 " xmlns:db=""http://docbook.org/ns/docbook"">"; ..
1462 " <info xml:id=''"+x2f_title2id(book_title)+"_manual''>"; ..
1463 " <title>"+book_title+"</title>"; ..
1468 // =========================================================================
1471 if isfield(tree,"title") & (tree("title") <> "") then
1472 // title defined in CHAPTER
1473 section_title = tree("title");
1474 elseif isfield(tree,"title_addchapter") & (tree("title_addchapter") <> "") then
1475 // title defined in addchapter.sce
1476 section_title = tree("title_addchapter");
1478 // title built with the directory name
1479 section_title = tree("title_default");
1482 // xml_list management
1483 // =========================================================================
1487 if isfield(tree,"xml_list") then
1488 xmllist = tree("xml_list");
1489 if xmllist <> [] then
1490 master_document = [ master_document ; "<part xml:id=''section_"+getmd5(strsubst(tree("path"),SCI,""),"string")+"''>" ];
1491 master_document = [ master_document ; "<title>"+section_title+"</title>" ];
1492 master_document = [ master_document ; "&"+xmllist(:,1)+";" ];
1498 // =========================================================================
1500 my_subtrees = getfield(1,tree);
1501 my_subtrees(find(part(my_subtrees,1:4)<>"dir_")) = [];
1503 for i=1:size(my_subtrees,"*")
1504 master_document = [ master_document ; x2f_tree_to_section( tree(my_subtrees(i)) , offset ) ];
1507 // End of master document
1508 // =========================================================================
1511 master_document = [ master_document ; "</part>" ];
1514 master_document = [ master_document; "</book>" ];
1518 // =============================================================================
1519 // master_section = x2f_tree_to_section( tree , offset )
1521 // Date : 27/04/2009
1522 // =============================================================================
1524 function master_section = x2f_tree_to_section( tree , offset )
1528 // Check number of input arguments
1529 // =========================================================================
1532 error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_tree_to_section",2));
1535 // Check input arguments type
1536 // =========================================================================
1538 if type(tree) <> 17 then
1539 error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_tree_to_section",1));
1542 if type(offset) <> 1 then
1543 error(msprintf(gettext("%s: Wrong type for input argument #%d: An integer expected.\n"),"x2f_tree_to_section",2));
1546 // And now, action ...
1547 // =========================================================================
1550 // Section Type management
1562 section_types = [ ..
1572 if isfield(tree,"level") & ((tree("level") + offset)>0) & ((tree("level") + offset)<8) then
1573 section_type = section_types( tree("level") + offset + 1 );
1575 section_type = "reference";
1582 if isfield(tree,"title_addchapter") & (tree("title_addchapter") <> "") then
1583 // title defined in addchapter.sce
1584 section_title = tree("title_addchapter");
1585 elseif isfield(tree,"title") & (tree("title") <> "") then
1586 // title defined in CHAPTER
1587 section_title = tree("title");
1589 // title built with the directory name
1590 section_title = tree("title_default");
1593 if (isfield(tree, "xml_id")) then
1594 xml_id = tree("xml_id");
1596 xml_id = "section_"+getmd5(strsubst(tree("path"),SCI,""),"string");
1599 section_title = strsubst(section_title,"&" ,"&");
1600 section_title = strsubst(section_title,"""" ,""");
1601 section_title = strsubst(section_title,">" ,">");
1602 section_title = strsubst(section_title,"<" ,"<");
1604 master_section = [];
1605 master_section = [ master_section ; "<"+section_type+" xml:id=''" + xml_id + "''>" ];
1606 master_section = [ master_section ; "<title>"+section_title+"</title>" ];
1609 // =========================================================================
1611 my_subtrees = getfield(1,tree);
1612 my_subtrees(find(part(my_subtrees,1:4)<>"dir_")) = [];
1614 for i=1:size(my_subtrees,"*")
1615 master_section = [ master_section ; x2f_tree_to_section( tree(my_subtrees(i)) , offset ) ];
1619 // =========================================================================
1621 if isfield(tree,"xml_list") then
1622 xmllist = tree("xml_list");
1623 if xmllist <> [] then
1624 master_section = [ master_section ; "&"+xmllist(:,1)+";" ];
1628 master_section = [ master_section ; "</"+section_type+">" ];
1632 // =============================================================================
1633 // tree_out = x2f_merge_trees( tree_in_1 , tree_in_2 )
1635 // Date : 27/04/2009
1636 // =============================================================================
1638 function tree_out = x2f_merge_trees( tree_in_1 , tree_in_2 )
1640 // tree_in_1 : reference tree
1641 // tree_in_2 : tree to fill
1645 // Check number of input arguments
1646 // =========================================================================
1649 error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_merge_trees",1));
1652 // Check input arguments type
1653 // =========================================================================
1655 if type(tree_in_1) <> 17 then
1656 error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_merge_trees",1));
1659 if type(tree_in_2) <> 17 then
1660 error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_merge_trees",2));
1663 tree_out = tree_in_2;
1666 // =========================================================================
1668 my_subtrees = getfield(1,tree_in_1);
1669 my_subtrees(find(part(my_subtrees,1:4)<>"dir_")) = [];
1671 for i=1:size(my_subtrees,"*")
1672 // Check if the subtree exists in tree_in_2
1673 if ~isfield(tree_in_2,my_subtrees(i)) then
1674 // if not, copy the whole subtree in tree_in_2
1675 this_subtree = tree_in_1(my_subtrees(i));
1676 tree_out(my_subtrees(i)) = tree_in_1(my_subtrees(i));
1677 tree_out("xml_number") = tree_out("xml_number") + this_subtree("xml_number");
1680 // if yes, iterate with x2f_merge_trees
1681 this_subtree_before = tree_in_2(my_subtrees(i))
1682 xml_number_before = this_subtree_before("xml_number");
1683 this_subtree_after = x2f_merge_trees( tree_in_1(my_subtrees(i)) , this_subtree_before );
1684 xml_number_after = this_subtree_after("xml_number");
1686 tree_out(my_subtrees(i)) = this_subtree_after;
1687 tree_out("xml_number") = tree_out("xml_number") + xml_number_after - xml_number_before;
1691 // XML list management
1692 // =========================================================================
1694 if isfield(tree_in_1,"xml_list") then
1695 xmllist_1 = tree_in_1("xml_list");
1700 if isfield(tree_in_2,"xml_list") then
1701 xmllist_2 = tree_in_2("xml_list");
1706 xmllist_out = xmllist_2;
1708 for i=1:size(xmllist_1(:,4),"*")
1709 if find(xmllist_2(:,4) == xmllist_1(i,4)) == [] then
1710 xmllist_out = [ xmllist_out ; xmllist_1(i,:) ];
1711 tree_out("xml_number") = tree_out("xml_number") + 1;
1715 tree_out("xml_list") = xmllist_out;
1719 // =============================================================================
1720 // xmllist_out = x2f_cat_xmllist( tree , xmllist_in )
1722 // Returns a n x 3 matrix that list all xmlfile in this tree and subtrees
1724 // Date : 27/04/2009
1725 // =============================================================================
1727 function xmllist_out = x2f_cat_xmllist( tree , xmllist_in )
1730 xmllist_out = xmllist_in;
1732 // Check number of input arguments
1733 // =========================================================================
1736 error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_cat_xmllist",2));
1739 // Check input arguments type
1740 // =========================================================================
1742 if type(tree) <> 17 then
1743 error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_cat_xmllist",1));
1746 if (xmllist_in<> []) & (type(xmllist_in) <> 10) then
1747 error(msprintf(gettext("%s: Wrong type for input argument #%d: String array expected.\n"),"x2f_cat_xmllist",2));
1750 // This tree xml list to start
1751 // =========================================================================
1753 if isfield(tree,"xml_list") then
1754 xmllist_out = [ xmllist_out ; tree("xml_list") ];
1758 // =========================================================================
1760 my_subtrees = getfield(1,tree);
1761 my_subtrees(find(part(my_subtrees,1:4)<>"dir_")) = [];
1763 for i=1:size(my_subtrees,"*")
1764 xmllist_out = x2f_cat_xmllist( tree(my_subtrees(i)) , xmllist_out );
1769 // =============================================================================
1770 // section_id = x2f_title2id(title)
1772 // Returns a normalized string from <title> string
1774 // Date : 27/04/2009
1775 // =============================================================================
1777 function section_id = x2f_title2id(title_in)
1779 section_id = title_in;
1781 section_id = strsubst(section_id , "&" , "_" );
1783 section_id = strsubst(section_id , "À" , "A" );
1784 section_id = strsubst(section_id , "Á" , "A" );
1785 section_id = strsubst(section_id , "Â" , "A" );
1786 section_id = strsubst(section_id , "Ã" , "A" );
1787 section_id = strsubst(section_id , "Ä" , "A" );
1788 section_id = strsubst(section_id , "Å" , "A" );
1789 section_id = strsubst(section_id , "Æ" , "AE");
1790 section_id = strsubst(section_id , "Ç" , "C" );
1791 section_id = strsubst(section_id , "È" , "E" );
1792 section_id = strsubst(section_id , "É" , "E" );
1793 section_id = strsubst(section_id , "Ê" , "E" );
1794 section_id = strsubst(section_id , "Ë" , "E" );
1795 section_id = strsubst(section_id , "Ì" , "I" );
1796 section_id = strsubst(section_id , "Í" , "I" );
1797 section_id = strsubst(section_id , "Î" , "I" );
1798 section_id = strsubst(section_id , "Ï" , "I" );
1799 section_id = strsubst(section_id , "Ð" , "D" );
1800 section_id = strsubst(section_id , "Ñ" , "N" );
1801 section_id = strsubst(section_id , "Ò" , "O" );
1802 section_id = strsubst(section_id , "Ó" , "O" );
1803 section_id = strsubst(section_id , "Ô" , "O" );
1804 section_id = strsubst(section_id , "Õ" , "O" );
1805 section_id = strsubst(section_id , "Ö" , "O" );
1806 section_id = strsubst(section_id , "Ù" , "U" );
1807 section_id = strsubst(section_id , "Ú" , "U" );
1808 section_id = strsubst(section_id , "Û" , "U" );
1809 section_id = strsubst(section_id , "Ü" , "U" );
1810 section_id = strsubst(section_id , "Ý" , "Y" );
1811 section_id = strsubst(section_id , "à" , "a" );
1812 section_id = strsubst(section_id , "á" , "a" );
1813 section_id = strsubst(section_id , "â" , "a" );
1814 section_id = strsubst(section_id , "ã" , "a" );
1815 section_id = strsubst(section_id , "ä" , "a" );
1816 section_id = strsubst(section_id , "å" , "a" );
1817 section_id = strsubst(section_id , "æ" , "ae");
1818 section_id = strsubst(section_id , "ç" , "c" );
1819 section_id = strsubst(section_id , "è" , "e" );
1820 section_id = strsubst(section_id , "é" , "e" );
1821 section_id = strsubst(section_id , "ê" , "e" );
1822 section_id = strsubst(section_id , "ë" , "e" );
1823 section_id = strsubst(section_id , "ì" , "i" );
1824 section_id = strsubst(section_id , "í" , "i" );
1825 section_id = strsubst(section_id , "î" , "i" );
1826 section_id = strsubst(section_id , "ï" , "i" );
1827 section_id = strsubst(section_id , "ñ" , "n" );
1828 section_id = strsubst(section_id , "ò" , "o" );
1829 section_id = strsubst(section_id , "ó" , "o" );
1830 section_id = strsubst(section_id , "ô" , "o" );
1831 section_id = strsubst(section_id , "õ" , "o" );
1832 section_id = strsubst(section_id , "ö" , "o" );
1833 section_id = strsubst(section_id , "ù" , "u" );
1834 section_id = strsubst(section_id , "ú" , "u" );
1835 section_id = strsubst(section_id , "û" , "u" );
1836 section_id = strsubst(section_id , "ü" , "u" );
1837 section_id = strsubst(section_id , "ý" , "y" );
1838 section_id = strsubst(section_id , "ÿ" , "y" );
1840 section_id = strsubst(section_id , ":" , "" );
1841 section_id = strsubst(section_id , "\" , "_" );
1842 section_id = strsubst(section_id , "/" , "_" );
1843 section_id = strsubst(section_id , "''" , "_" );
1844 section_id = strsubst(section_id , " " , " " );
1845 section_id = strsubst(section_id , " " , "_" );
1846 section_id = strsubst(section_id , "[" , "" );
1847 section_id = strsubst(section_id , "]" , "" );
1849 section_id = convstr(section_id,"l");
1853 // =============================================================================
1854 // timestamp = x2f_get_most_recent( tree )
1856 // Return the timestamp associated with the most recent XML file, ... and its
1857 // path if a second output argument is precised
1859 // Date : 27/04/2009
1860 // =============================================================================
1862 function [timestamp,path] = x2f_get_most_recent( tree )
1868 // Check number of input arguments
1869 // =========================================================================
1872 error(msprintf(gettext("%s: Wrong number of input argument: %d expected.\n"),"x2f_get_most_recent",1));
1875 // Check input arguments type
1876 // =========================================================================
1878 if type(tree) <> 17 then
1879 error(msprintf(gettext("%s: Wrong type for input argument #%d: matrix oriented typed list expected.\n"),"x2f_cat_xmllist",1));
1882 // Get the full XML list
1883 // =========================================================================
1885 xmllist = x2f_cat_xmllist(tree,[]);
1887 [values,index] = gsort(strtod(xmllist(:,3)));
1889 timestamp = xmllist( index(1) , 3 );
1890 path = xmllist( index(1) , 2 );