Changeset 55 for trunk/src/editxml.m


Ignore:
Timestamp:
Mar 17, 2010, 10:26:41 AM (11 years ago)
Author:
sommeria
Message:

-use of a single parameter file PARAM.xml (instead of PARAM_WIN and PARAM_LINUX).
-correction of a bug for opening an existing projection object
-manual editing of vectors made available with the builtin netcdf tool.
-bug fix for reading netcdf files with the builtin netcdf tool.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/editxml.m

    r54 r55  
    185185    testupfile=0;
    186186    DataIn=get(get(hObject,'parent'),'UserData');
    187     if isfield(DataIn,'UpFile')&~isempty(DataIn.UpFile)
     187    if isfield(DataIn,'UpFile')&&~isempty(DataIn.UpFile)
    188188        [UpPath,UpName,UpExt]=fileparts(DataIn.UpFile{1});
    189189        if isequal(UpExt,'.xml')
     
    283283CurrentFile=fullfile(PathName,FileName);
    284284sizf=size(CurrentFile);
    285 if (~ischar(CurrentFile)|~isequal(sizf(1),1)),return;end% keep only character strings as input file name
     285if (~ischar(CurrentFile)||~isequal(sizf(1),1)),return;end% keep only character strings as input file name
    286286if exist(CurrentFile,'file')
    287287%     set(handles.CurrentAttributes,'UserDataIn',PathName); %store the path to the xml file
    288288    [CurPath,CurName,CurExt]=fileparts(CurrentFile);
    289289    if isequal(CurExt,'.xls')   
    290         if isfield(DataIn,'hfig_xls')&ishandle(DataIn.hfig_xls)
     290        if isfield(DataIn,'hfig_xls') && ishandle(DataIn.hfig_xls)
    291291            [hfig_xls]=read_xls(CurrentFile,DataIn.hfig_xls);
    292292        else
     
    310310t=xmltree(CurrentFile);%open the xml file
    311311head_element=get(t,1);
    312 if ~isfield(head_element,'name') | ~isfield(head_element,'attributes')
     312if ~isfield(head_element,'name') || ~isfield(head_element,'attributes')
    313313    msgbox_uvmat('ERROR','root element of the .xml file not in correct format')
    314314end
     
    317317xstest=0;
    318318for iattr=1:length(head_attr)
    319     if isequal(head_attr{iattr}.key,'xmlns:xsi')& isequal(head_attr{iattr}.val,'none')%no schema to read
     319    if isequal(head_attr{iattr}.key,'xmlns:xsi')&& isequal(head_attr{iattr}.val,'none')%no schema to read
    320320         xs=[];
    321321%          xstest=1;
    322322    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')
    324324        DataIn.Schema=head_attr{iattr}.val;
    325325        xs=xmltree(DataIn.Schema);%open the associated schema file
     
    332332    path_uvmat=which('editxml');% check the path detected for source file uvmat
    333333    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);
    370346        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
    372359        end
    373360    end
     
    376363if isempty(xs)
    377364    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')
    380365else
    381366    DataIn.xs_CurrentUid=find(xs,'/xs:schema/xs:element');%uid of the root element in the schema
     
    383368        [element,subelem]=get_xml(t,path,xs_element,1,xs_subelem);% read the corresponding xml data
    384369        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')
    387370end
    388371set(heditxml,'UserData',DataIn);%store the new input xml file name
     
    890873end
    891874set(handles.element_value,'UserData',node)
    892 if ~testedit && isfield(element,'attrup') & isfield(element.attrup,'source')&& ~isequal(element.attrup.source,'manual')
     875if ~testedit && isfield(element,'attrup') && isfield(element.attrup,'source')&& ~isequal(element.attrup.source,'manual')
    893876     set(handles.element_value,'Enable','inactive')
    894877else
Note: See TracChangeset for help on using the changeset viewer.