Changeset 55 for trunk/src/editxml.m
- Timestamp:
- Mar 17, 2010, 10:26:41 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/editxml.m
r54 r55 185 185 testupfile=0; 186 186 DataIn=get(get(hObject,'parent'),'UserData'); 187 if isfield(DataIn,'UpFile')& ~isempty(DataIn.UpFile)187 if isfield(DataIn,'UpFile')&&~isempty(DataIn.UpFile) 188 188 [UpPath,UpName,UpExt]=fileparts(DataIn.UpFile{1}); 189 189 if isequal(UpExt,'.xml') … … 283 283 CurrentFile=fullfile(PathName,FileName); 284 284 sizf=size(CurrentFile); 285 if (~ischar(CurrentFile)| ~isequal(sizf(1),1)),return;end% keep only character strings as input file name285 if (~ischar(CurrentFile)||~isequal(sizf(1),1)),return;end% keep only character strings as input file name 286 286 if exist(CurrentFile,'file') 287 287 % set(handles.CurrentAttributes,'UserDataIn',PathName); %store the path to the xml file 288 288 [CurPath,CurName,CurExt]=fileparts(CurrentFile); 289 289 if isequal(CurExt,'.xls') 290 if isfield(DataIn,'hfig_xls') &ishandle(DataIn.hfig_xls)290 if isfield(DataIn,'hfig_xls') && ishandle(DataIn.hfig_xls) 291 291 [hfig_xls]=read_xls(CurrentFile,DataIn.hfig_xls); 292 292 else … … 310 310 t=xmltree(CurrentFile);%open the xml file 311 311 head_element=get(t,1); 312 if ~isfield(head_element,'name') | ~isfield(head_element,'attributes')312 if ~isfield(head_element,'name') || ~isfield(head_element,'attributes') 313 313 msgbox_uvmat('ERROR','root element of the .xml file not in correct format') 314 314 end … … 317 317 xstest=0; 318 318 for iattr=1:length(head_attr) 319 if isequal(head_attr{iattr}.key,'xmlns:xsi')& isequal(head_attr{iattr}.val,'none')%no schema to read319 if isequal(head_attr{iattr}.key,'xmlns:xsi')&& isequal(head_attr{iattr}.val,'none')%no schema to read 320 320 xs=[]; 321 321 % xstest=1; 322 322 end 323 if isequal(head_attr{iattr}.key,'xsi:noNamespaceSchemaLocation') & exist(head_attr{iattr}.val,'file')323 if isequal(head_attr{iattr}.key,'xsi:noNamespaceSchemaLocation') && exist(head_attr{iattr}.val,'file') 324 324 DataIn.Schema=head_attr{iattr}.val; 325 325 xs=xmltree(DataIn.Schema);%open the associated schema file … … 332 332 path_uvmat=which('editxml');% check the path detected for source file uvmat 333 333 path_UVMAT=fileparts(path_uvmat); %path to UVMAT 334 % if isunix 335 xmlparam=fullfile(path_UVMAT,'PARAM.xml'); 336 if exist(xmlparam,'file') 337 tparam=xmltree(xmlparam); 338 sparam=convert(tparam); 339 if isfield(sparam,'SchemaPath') 340 schemapath=[fullfile(sparam.SchemaPath,head_name) '.xsd'] 341 end 342 if exist(fullfile(path_UVMAT,schemapath) 343 schemapath=fullfile(path_UVMAT,schemapath);%look for relative path definition 344 end 345 schemapath=fullfile(path_UVMAT,schemapath); 346 % schemapath=['/coriolis/papillon/data/civbin/XML_SCHEMAS/' head_name '.xsd']%current dir for schema 347 % else 348 % xmlparam=fullfile(path_UVMAT,'PARAM_WIN.xml') 349 % if exist(xmlparam,'file') 350 % tparam=xmltree(xmlparam); 351 % sparam=convert(tparam) 352 % if isfield(sparam,'SchemaPath') 353 % schemapath=[fullfile(sparam.SchemaPath,head_name) '.xsd'] 354 % end 355 % end 356 % schemapath=['\\Papillon\data\civbin\XML_SCHEMAS\' head_name '.xsd']%current dir for schemas 357 % end 358 if exist(schemapath,'file') 359 xs=xmltree(schemapath); 360 else 361 msgbox_uvmat('ERROR',['The xml schema for ' CurrentFile ' is unknown, check the schema path set in the file PARAM.xml']) 362 [FileName, PathName]=uigetfile( ... 363 {'*.xsd', '(*.xsd)'; 364 '*.xsd', '.xsd files '; ... 365 '*.*', 'All Files (*.*)'}, ... 366 ['Pick a .xsd schema'] ,schemapath); %file browser 367 if ischar(PathName)&ischar(FileName)& exist(fullfile(PathName,FileName),'file') 368 DataIn.Schema=fullfile(PathName,FileName); 369 xs=xmltree(DataIn.Schema);%open the associated schema file 334 xmlparam=fullfile(path_UVMAT,'PARAM.xml'); 335 if exist(xmlparam,'file') 336 tparam=xmltree(xmlparam); 337 sparam=convert(tparam); 338 if isfield(sparam,'SchemaPath') 339 schemafile=[fullfile(sparam.SchemaPath,head_name) '.xsd']; 340 end 341 if ~exist(schemafile,'file') 342 schemafile=fullfile(path_UVMAT,schemafile);%look for relative path definition 343 end 344 if exist(schemafile,'file') 345 xs=xmltree(schemafile); 370 346 else 371 xs=[]; 347 msgbox_uvmat('ERROR',['The xml schema for ' CurrentFile ' is unknown, check the schema path set in the file PARAM.xml']) 348 [FileName, PathName]=uigetfile( ... 349 {'*.xsd', '(*.xsd)'; 350 '*.xsd', '.xsd files '; ... 351 '*.*', 'All Files (*.*)'}, ... 352 'Pick a .xsd schema' ,schemapath); %file browser 353 if ischar(PathName) && ischar(FileName) && exist(fullfile(PathName,FileName),'file') 354 DataIn.Schema=fullfile(PathName,FileName); 355 xs=xmltree(DataIn.Schema);%open the associated schema file 356 else 357 xs=[]; 358 end 372 359 end 373 360 end … … 376 363 if isempty(xs) 377 364 displ_xml(handles,t,1,DataIn,get(hObject,'parent'));%no associated schema, default display of the xml file 378 % set(handles.inport_file,'Visible','off')379 % set(handles.RefFile,'Visible','off')380 365 else 381 366 DataIn.xs_CurrentUid=find(xs,'/xs:schema/xs:element');%uid of the root element in the schema … … 383 368 [element,subelem]=get_xml(t,path,xs_element,1,xs_subelem);% read the corresponding xml data 384 369 update_list(handles,path,xs_element,element,1,xs_subelem,subelem);%update the display of information on the interface 385 % set(handles.inport_file,'Visible','on')386 % set(handles.RefFile,'Visible','on')387 370 end 388 371 set(heditxml,'UserData',DataIn);%store the new input xml file name … … 890 873 end 891 874 set(handles.element_value,'UserData',node) 892 if ~testedit && isfield(element,'attrup') & isfield(element.attrup,'source')&& ~isequal(element.attrup.source,'manual')875 if ~testedit && isfield(element,'attrup') && isfield(element.attrup,'source')&& ~isequal(element.attrup.source,'manual') 893 876 set(handles.element_value,'Enable','inactive') 894 877 else
Note: See TracChangeset
for help on using the changeset viewer.