Changeset 498 for trunk/src/update_imadoc.m
- Timestamp:
- Jul 23, 2012, 8:44:33 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/update_imadoc.m
r414 r498 10 10 errormsg=''; 11 11 testappend=0; 12 if exist(outputfile,'file');%=1 if the output file already exists, 0 else 12 %% backup the output file if it already exist, and read it 13 if exist(outputfile,'file');%=1 if the output file already exists, 0 else 13 14 testappend=1; 14 t=xmltree(outputfile); %read the file15 15 backupfile=outputfile; 16 16 testexist=2; 17 17 while testexist==2 18 backupfile=[backupfile '~'];19 testexist=exist(backupfile,'file');18 backupfile=[backupfile '~']; 19 testexist=exist(backupfile,'file'); 20 20 end 21 21 [success,message]=copyfile(outputfile,backupfile);%make backup 22 if success==0 23 errormsg=message; 22 if success~=1 23 errormsg=['errror in xml file backup: ' message]; 24 return 24 25 end 25 uid=find(t,'ImaDoc'); 26 if ~isequal(uid,1) 27 return 28 end 29 %if the xml file is ImaDoc 30 uid_calib=find(t,'ImaDoc/GeometryCalib'); 31 if isempty(uid_calib) %if GeometryCalib does not already exists, create it 32 [t,uid_calib]=add(t,1,'element','GeometryCalib'); 33 else %if GeometryCalib already exists, delete its content 34 if isequal(success,1) 35 delete(outputfile) 36 else 37 return 26 t=xmltree(outputfile); %read the file 27 title=get(t,1,'name'); 28 if strcmp(title,'ImaDoc')) 29 testappend=1; 30 %if the xml file is ImaDoc 31 uid_calib=find(t,'ImaDoc/GeometryCalib'); 32 if isempty(uid_calib) %if GeometryCalib does not already exists, create it 33 [t,uid_calib]=add(t,1,'element','GeometryCalib'); 34 else %if GeometryCalib already exists, delete its content 35 uid_child=children(t,uid_calib); 36 t=delete(t,uid_child); 38 37 end 39 uid_child=children(t,uid_calib);40 t=delete(t,uid_child);41 38 end 42 39 end 43 %create a new xml file 40 41 %% create a new xml file 44 42 if ~testappend 45 43 t=xmltree; … … 69 67 [t,uid_calib]=add(t,1,'element','GeometryCalib'); 70 68 end 69 70 %% save the output file 71 71 t=struct2xml(GeometryCalib,t,uid_calib); 72 72 save(t,outputfile);
Note: See TracChangeset
for help on using the changeset viewer.