source: trunk/src/uvmat_doc/FUNCTIONS_DOC/editxml.html @ 37

Last change on this file since 37 was 37, checked in by sommeria, 14 years ago

create_grid.fig ,
uvmat_doc and all the included files added

File size: 125.1 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2                "http://www.w3.org/TR/REC-html40/loose.dtd">
3<html>
4<head>
5  <title>Description of editxml</title>
6  <meta name="keywords" content="editxml">
7  <meta name="description" content="'editxml': function for editing xml files using a xml schema (associated with the GUI editxml.fig)">
8  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
9  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
10  <meta name="robots" content="index, follow">
11  <link type="text/css" rel="stylesheet" href="../m2html.css">
12</head>
13<body>
14<a name="_top"></a>
15<div><a href="../index.html">Home</a> &gt;  <a href="index.html">.</a> &gt; editxml.m</div>
16
17<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
18<td align="right"><a href="index.html">Index for .&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
19
20<h1>editxml
21</h1>
22
23<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
24<div class="box"><strong>'editxml': function for editing xml files using a xml schema (associated with the GUI editxml.fig)</strong></div>
25
26<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
27<div class="box"><strong>function varargout = editxml(varargin) </strong></div>
28
29<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
30<div class="fragment"><pre class="comment">'editxml': function for editing xml files using a xml schema (associated with the GUI editxml.fig)
31------------------------------------------------------------------------
32 function heditxml=editxml(inputfile)
33
34OUTPUT: heditxml: graphic handle of the GUI
35
36INPUT: inputfile:  name of an xml file
37
38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
39  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
40AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
41     This file is part of the toolbox UVMAT.
42 
43     UVMAT is free software; you can redistribute it and/or modify
44     it under the terms of the GNU General Public License as published by
45     the Free Software Foundation; either version 2 of the License, or
46     (at your option) any later version.
47 
48     UVMAT is distributed in the hope that it will be useful,
49     but WITHOUT ANY WARRANTY; without even the implied warranty of
50     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
51     GNU General Public License (file UVMAT/COPYING.txt) for more details.
52AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</pre></div>
53
54<!-- crossreference -->
55<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
56This function calls:
57<ul style="list-style-image:url(../matlabicon.gif)">
58<li><a href="ListDir.html" class="code" title="function [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices_in,ListRecords_in)">ListDir</a>  'ListDir': scan the structure of the directory tree (for dataview.m)</li><li><a href="cell2tab.html" class="code" title="function Tabchar=cell2tab(Tabcell,separator)">cell2tab</a>     'cell2tab': transform a Matlab cell in a character array suitable for display in a table</li><li><a href="dataview.html" class="code" title="function varargout = dataview(varargin)">dataview</a>      TEST 'dataview': function for scanning directories in a campaign (TEST)</li><li><a href="read_xls.html" class="code" title="function [hfig_xls]=read_xls(fileinput,hfig)">read_xls</a>  'read_xls': function for reading and displaying Excel files</li><li><a href="uvmat.html" class="code" title="function varargout = uvmat(varargin)">uvmat</a>    'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization</li><li><a href="warndlg_uvmat.html" class="code" title="function hwarn=warndlg_uvmat(warntext,title)">warndlg_uvmat</a>  'warndlg_uvmat': display warning message (error, warning, confirmation) in a given figure</li></ul>
59This function is called by:
60<ul style="list-style-image:url(../matlabicon.gif)">
61<li><a href="civ.html" class="code" title="function varargout = civ(varargin)">civ</a>  'civ': function associated with the interface 'civ.fig' for PIV, spline interpolation and stereo PIV (patch)</li><li><a href="civ_3D.html" class="code" title="function varargout = civ_3D(varargin)">civ_3D</a>        'civ_3D': function associated with the interface 'civ_3D.fig' for PIV in volume</li><li><a href="dataview.html" class="code" title="function varargout = dataview(varargin)">dataview</a>       TEST 'dataview': function for scanning directories in a campaign (TEST)</li><li><a href="read_xls.html" class="code" title="function [hfig_xls]=read_xls(fileinput,hfig)">read_xls</a>  'read_xls': function for reading and displaying Excel files</li><li><a href="uvmat.html" class="code" title="function varargout = uvmat(varargin)">uvmat</a>    'uvmat': function associated with the GUI 'uvmat.fig' for images and data field visualization</li></ul>
62<!-- crossreference -->
63
64<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
65<ul style="list-style-image:url(../matlabicon.gif)">
66<li><a href="#_sub1" class="code">function editxml_OpeningFcn(hObject, eventdata, handles, varargin)</a></li><li><a href="#_sub2" class="code">function varargout = editxml_OutputFcn(hObject, eventdata, handles)</a></li><li><a href="#_sub3" class="code">function list_element_Callback(hObject, eventdata, handles)</a></li><li><a href="#_sub4" class="code">function move_up_Callback(hObject, eventdata, handles)</a></li><li><a href="#_sub5" class="code">function element_value_Callback(hObject, eventdata, handles)</a></li><li><a href="#_sub6" class="code">function browser_Callback(hObject, eventdata, handles)</a></li><li><a href="#_sub7" class="code">function CurrentFile_Callback(hObject, eventdata, handles)</a></li><li><a href="#_sub8" class="code">function [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,nodeinput)</a></li><li><a href="#_sub9" class="code">function [element,subelem]=get_xml(t,path,xs_element,node,xs_subelem)</a></li><li><a href="#_sub10" class="code">function update_list(handles,path,xs_element,element,node,xs_subelem,subelem)</a></li><li><a href="#_sub11" class="code">function SAVE_Callback(hObject, eventdata, handles)</a></li><li><a href="#_sub12" class="code">function t=set_element(t,RootUid,node,key,value)</a></li><li><a href="#_sub13" class="code">function element_attr_val_Callback(hObject, eventdata, handles)</a></li><li><a href="#_sub14" class="code">function ADD_Callback(hObject, eventdata, handles)</a></li><li><a href="#_sub15" class="code">function [Data,testsimple]=displ_xml(handles,t,root_uid,DataIn,heditxml)</a></li><li><a href="#_sub16" class="code">function update_ref_list(hh,xs_element,element,node,xs_subelem,subelem)</a></li><li><a href="#_sub17" class="code">function replicate_Callback(hObject, eventdata, handles)</a></li><li><a href="#_sub18" class="code">function HELP_Callback(hObject, eventdata, handles)</a></li><li><a href="#_sub19" class="code">function Export_Callback(hObject, eventdata, handles)</a></li><li><a href="#_sub20" class="code">function pushbutton9_Callback(hObject, eventdata, handles)</a></li></ul>
67<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
68<div class="fragment"><pre>0001 <span class="comment">%'editxml': function for editing xml files using a xml schema (associated with the GUI editxml.fig)</span>
690002 <span class="comment">%------------------------------------------------------------------------</span>
700003 <span class="comment">% function heditxml=editxml(inputfile)</span>
710004 <span class="comment">%</span>
720005 <span class="comment">%OUTPUT: heditxml: graphic handle of the GUI</span>
730006 <span class="comment">%</span>
740007 <span class="comment">%INPUT: inputfile:  name of an xml file</span>
750008 <span class="comment">%</span>
760009 <span class="comment">%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</span>
770010 <span class="comment">%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.</span>
780011 <span class="comment">%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</span>
790012 <span class="comment">%     This file is part of the toolbox UVMAT.</span>
800013 <span class="comment">%</span>
810014 <span class="comment">%     UVMAT is free software; you can redistribute it and/or modify</span>
820015 <span class="comment">%     it under the terms of the GNU General Public License as published by</span>
830016 <span class="comment">%     the Free Software Foundation; either version 2 of the License, or</span>
840017 <span class="comment">%     (at your option) any later version.</span>
850018 <span class="comment">%</span>
860019 <span class="comment">%     UVMAT is distributed in the hope that it will be useful,</span>
870020 <span class="comment">%     but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
880021 <span class="comment">%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
890022 <span class="comment">%     GNU General Public License (file UVMAT/COPYING.txt) for more details.</span>
900023 <span class="comment">%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</span>
910024
920025 <a name="_sub0" href="#_subfunctions" class="code">function varargout = editxml(varargin)</a>
930026
940027 <span class="comment">% Begin initialization code - DO NOT EDIT</span>
950028 gui_Singleton = 1;
960029 gui_State = struct(<span class="string">'gui_Name'</span>,       mfilename, <span class="keyword">...</span>
970030                    <span class="string">'gui_Singleton'</span>,  gui_Singleton, <span class="keyword">...</span>
980031                    <span class="string">'gui_OpeningFcn'</span>, @<a href="#_sub1" class="code" title="subfunction editxml_OpeningFcn(hObject, eventdata, handles, varargin)">editxml_OpeningFcn</a>, <span class="keyword">...</span>
990032                    <span class="string">'gui_OutputFcn'</span>,  @<a href="#_sub2" class="code" title="subfunction varargout = editxml_OutputFcn(hObject, eventdata, handles)">editxml_OutputFcn</a>, <span class="keyword">...</span>
1000033                    <span class="string">'gui_LayoutFcn'</span>,  [] , <span class="keyword">...</span>
1010034                    <span class="string">'gui_Callback'</span>,   []);
1020035 <span class="keyword">if</span> nargin &amp; isstr(varargin{1})
1030036     gui_State.gui_Callback = str2func(varargin{1});
1040037 <span class="keyword">end</span>
1050038
1060039 <span class="keyword">if</span> nargout
1070040     [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
1080041 <span class="keyword">else</span>
1090042     gui_mainfcn(gui_State, varargin{:});
1100043 <span class="keyword">end</span>
1110044 <span class="comment">% End initialization code - DO NOT EDIT</span>
1120045
1130046
1140047 <span class="comment">% --- Executes just before editxml is made visible.</span>
1150048 <a name="_sub1" href="#_subfunctions" class="code">function editxml_OpeningFcn(hObject, eventdata, handles, varargin)</a>
1160049 <span class="comment">% This function has no output args, see OutputFcn.</span>
1170050 <span class="comment">% hObject    handle to figure</span>
1180051 <span class="comment">% eventdata  reserved - to be defined in a future version of MATLAB</span>
1190052 <span class="comment">% handles    structure with handles and user data (see GUIDATA)</span>
1200053 <span class="comment">% varargin   command line arguments to editxml (see VARARGIN)</span>
1210054
1220055 <span class="comment">% set(handles.replicate,'String',['copy';'&lt;---'])</span>
1230056 <span class="keyword">if</span> nargin
1240057     CurrentFile=varargin{1}
1250058 <span class="keyword">else</span>
1260059     CurrentFile=[];
1270060 <span class="keyword">end</span>
1280061 <span class="comment">% if exist('varargin') &amp; length(varargin)&gt;=1</span>
1290062 <span class="comment">%     CurrentFile=cell2mat(varargin{1});</span>
1300063 <span class="comment">% else</span>
1310064 <span class="comment">%     CurrentFile=[];</span>
1320065 <span class="comment">% end</span>
1330066 <span class="comment">% Choose default command line output for editxml</span>
1340067 handles.output = hObject;
1350068 <span class="comment">% set(hObject,'Units','pixel')</span>
1360069 <span class="keyword">if</span> exist(CurrentFile,<span class="string">'file'</span>)
1370070     [PathName,Nme,FileExt]=fileparts(CurrentFile);
1380071     <span class="keyword">if</span> isequal(FileExt,<span class="string">'.xls'</span>)
1390072         DataIn.hfig_xls=<a href="read_xls.html" class="code" title="function [hfig_xls]=read_xls(fileinput,hfig)">read_xls</a>(CurrentFile);<span class="comment">% DataIn.hfig_xls=handle of the Excel display figure</span>
1400073         DataIn.CurrentUid=1;
1410074         figpos=get(hObject,<span class="string">'Position'</span>);<span class="comment">%position of the editxml interface</span>
1420075         figposunit=get(hObject,<span class="string">'Units'</span>);<span class="comment">%unity used to indicate position</span>
1430076         newfigpos=[figpos(1)-0.5*figpos(3) figpos(2) figpos(3) figpos(4)];
1440077         set(DataIn.hfig_xls,<span class="string">'Units'</span>,figposunit)
1450078         set(DataIn.hfig_xls,<span class="string">'Position'</span>,newfigpos); <span class="comment">%set position of the Excel display figure</span>
1460079         set(hObject,<span class="string">'UserData'</span>,DataIn)
1470080     <span class="keyword">else</span>
1480081         set(handles.CurrentFile,<span class="string">'String'</span>,CurrentFile)
1490082         <a href="#_sub7" class="code" title="subfunction CurrentFile_Callback(hObject, eventdata, handles)">CurrentFile_Callback</a>(hObject, eventdata, handles)
1500083     <span class="keyword">end</span>
1510084 <span class="keyword">end</span>
1520085 <span class="comment">% Update handles structure</span>
1530086 guidata(hObject, handles);
1540087
1550088 <span class="comment">%----------------------------------------------------------------</span>
1560089 <span class="comment">% --- Outputs from this function are returned to the command line.</span>
1570090 <a name="_sub2" href="#_subfunctions" class="code">function varargout = editxml_OutputFcn(hObject, eventdata, handles)</a>
1580091 <span class="comment">% varargout  cell array for returning output args (see VARARGOUT);</span>
1590092 <span class="comment">% hObject    handle to figure</span>
1600093 <span class="comment">% eventdata  reserved - to be defined in a future version of MATLAB</span>
1610094 <span class="comment">% handles    structure with handles and user data (see GUIDATA)</span>
1620095
1630096 <span class="comment">% Get default command line output from handles structure</span>
1640097 varargout{1} = handles.output;
1650098
1660099
1670100 <span class="comment">% --- Executes on selection change in list_element.</span>
1680101 <a name="_sub3" href="#_subfunctions" class="code">function list_element_Callback(hObject, eventdata, handles)</a>
1690102 <span class="keyword">global</span> t xs t_ref
1700103 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>);
1710104 bla=get(hObject,<span class="string">'String'</span>);
1720105 ind=get(hObject,<span class="string">'Value'</span>);
1730106 list=get(hObject,<span class="string">'UserData'</span>);
1740107 NewRootUid=list.uid(ind);
1750108 heditxml=get(hObject,<span class="string">'Parent'</span>);
1760109 DataIn=get(heditxml,<span class="string">'UserData'</span>);
1770110 <span class="keyword">if</span> ~isempty(xs)
1780111     xs_node=list.xs_uid(ind);<span class="comment">%xs_node of the subelement #ind</span>
1790112     [nodeup,path,xs_element,xs_subelem]=<a href="#_sub8" class="code" title="subfunction [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,nodeinput)">scan_schema</a>(xs,xs_node);
1800113     [element,subelem]=<a href="#_sub9" class="code" title="subfunction [element,subelem]=get_xml(t,path,xs_element,node,xs_subelem)">get_xml</a>(t,path,xs_element,NewRootUid,xs_subelem);
1810114     <a href="#_sub10" class="code" title="subfunction update_list(handles,path,xs_element,element,node,xs_subelem,subelem)">update_list</a>(handles,path,xs_element,element,NewRootUid,xs_subelem,subelem);
1820115     <span class="keyword">if</span> xs_element.subtest     
1830116         DataIn.CurrentUid=[DataIn.CurrentUid NewRootUid];<span class="comment">%record new current uid</span>
1840117         DataIn.xs_CurrentUid=[DataIn.xs_CurrentUid xs_node];<span class="comment">%record the new curent schema uid</span>
1850118     <span class="keyword">end</span>
1860119     
1870120 <span class="comment">%     %update the import file display</span>
1880121 <span class="comment">%     if isfield(DataIn,'h_ref')&amp;ishandle(DataIn.h_ref)</span>
1890122 <span class="comment">%         tag0_ref=find(t_ref,['/' path '/' xs_element.key]);</span>
1900123 <span class="comment">%         node_ref=list.index(ind);</span>
1910124 <span class="comment">%         if length(tag0_ref)&lt;node_ref</span>
1920125 <span class="comment">%             node_ref=length(tag0_ref);</span>
1930126 <span class="comment">%         end</span>
1940127 <span class="comment">%         [ref_element,ref_subelem]=get_xml(t_ref,path,xs_element,node_ref,xs_subelem);</span>
1950128 <span class="comment">%         update_ref_list(DataIn.h_ref,xs_element,ref_element,node_ref,xs_subelem,ref_subelem);</span>
1960129 <span class="comment">%     end</span>
1970130 set(get(hObject,<span class="string">'Parent'</span>),<span class="string">'UserData'</span>,DataIn);
1980131 <span class="keyword">else</span><span class="comment">%no schema</span>
1990132     [DataIn,testsimple]=<a href="#_sub15" class="code" title="subfunction [Data,testsimple]=displ_xml(handles,t,root_uid,DataIn,heditxml)">displ_xml</a>(handles,t,NewRootUid,DataIn,get(hObject,<span class="string">'parent'</span>));
2000133     <span class="keyword">if</span> ~testsimple
2010134         DataIn.CurrentUid=[DataIn.CurrentUid NewRootUid];<span class="comment">%record new current uid</span>
2020135         set(get(hObject,<span class="string">'Parent'</span>),<span class="string">'UserData'</span>,DataIn);
2030136     <span class="keyword">end</span>
2040137 <span class="keyword">end</span>
2050138
2060139 <span class="comment">%-------------------------------------------------</span>
2070140 <span class="comment">% --- Executes on button press in move_up.</span>
2080141 <a name="_sub4" href="#_subfunctions" class="code">function move_up_Callback(hObject, eventdata, handles)</a>
2090142 <span class="keyword">global</span> t xs t_ref
2100143 set(handles.export_list,<span class="string">'Value'</span>,1);<span class="comment">%</span>
2110144 set(handles.export_list,<span class="string">'String'</span>,<span class="string">''</span>);<span class="comment">% empty the export list</span>
2120145 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>);
2130146 CurrentElement=get(handles.CurrentElement,<span class="string">'String'</span>);
2140147 heditxml=get(handles.move_up,<span class="string">'parent'</span>);
2150148 test_root=0;
2160149 DataIn=get(heditxml,<span class="string">'UserData'</span>);
2170150 <span class="keyword">if</span> isfield(DataIn,<span class="string">'CurrentUid'</span>)&amp;length(DataIn.CurrentUid)&gt;1
2180151     nodeup=DataIn.CurrentUid(end-1);
2190152     DataIn.CurrentUid(end)=[];
2200153 <span class="keyword">else</span>
2210154     nodeup=[];
2220155 <span class="keyword">end</span>
2230156 <span class="keyword">if</span> isempty(xs)   
2240157     <span class="keyword">if</span> isempty(nodeup)
2250158         test_root=1;
2260159     <span class="keyword">else</span>
2270160         DataIn=<a href="#_sub15" class="code" title="subfunction [Data,testsimple]=displ_xml(handles,t,root_uid,DataIn,heditxml)">displ_xml</a>(handles,t,nodeup,DataIn,heditxml);
2280161     <span class="keyword">end</span>
2290162 <span class="keyword">else</span>
2300163     xs_nodeup=[];
2310164 <span class="comment">%     if isfield(DataIn,'xs_UpUid')</span>
2320165     <span class="keyword">if</span> isfield(DataIn,<span class="string">'xs_CurrentUid'</span>)&amp;length(DataIn.xs_CurrentUid)&gt;1
2330166 <span class="comment">%         xs_nodeup=DataIn.xs_UpUid</span>
2340167         xs_nodeup=DataIn.xs_CurrentUid(end-1);
2350168         DataIn.xs_CurrentUid(end)=[];<span class="comment">%uid of the root element in the schema</span>
2360169     <span class="keyword">end</span>
2370170     <span class="keyword">if</span> isempty(xs_nodeup)
2380171         test_root=1;
2390172     <span class="keyword">else</span>
2400173         [xs_nodeup,path,xs_element,xs_subelem]=<a href="#_sub8" class="code" title="subfunction [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,nodeinput)">scan_schema</a>(xs,xs_nodeup);
2410174         [element,subelem]=<a href="#_sub9" class="code" title="subfunction [element,subelem]=get_xml(t,path,xs_element,node,xs_subelem)">get_xml</a>(t,path,xs_element,nodeup,xs_subelem);
2420175         <a href="#_sub10" class="code" title="subfunction update_list(handles,path,xs_element,element,node,xs_subelem,subelem)">update_list</a>(handles,path,xs_element,element,nodeup,xs_subelem,subelem);
2430176         <span class="comment">%update the import file display</span>
2440177         <span class="keyword">if</span> isfield(DataIn,<span class="string">'h_ref'</span>)&amp;ishandle(DataIn.h_ref)
2450178             [ref_element,ref_subelem]=<a href="#_sub9" class="code" title="subfunction [element,subelem]=get_xml(t,path,xs_element,node,xs_subelem)">get_xml</a>(t_ref,path,xs_element,nodeup,xs_subelem);
2460179             <a href="#_sub16" class="code" title="subfunction update_ref_list(hh,xs_element,element,node,xs_subelem,subelem)">update_ref_list</a>(DataIn.h_ref,xs_element,ref_element,nodeup,xs_subelem,ref_subelem);
2470180         <span class="keyword">end</span>
2480181     <span class="keyword">end</span>
2490182     set(get(hObject,<span class="string">'parent'</span>),<span class="string">'UserData'</span>,DataIn);
2500183 <span class="keyword">end</span>
2510184 <span class="keyword">if</span> test_root<span class="comment">% we are a the root,</span>
2520185     testupfile=0;
2530186     DataIn=get(get(hObject,<span class="string">'parent'</span>),<span class="string">'UserData'</span>);
2540187     <span class="keyword">if</span> isfield(DataIn,<span class="string">'UpFile'</span>)&amp;~isempty(DataIn.UpFile)
2550188         [UpPath,UpName,UpExt]=fileparts(DataIn.UpFile{1});
2560189         <span class="keyword">if</span> isequal(UpExt,<span class="string">'.xml'</span>)
2570190             set(handles.CurrentFile,<span class="string">'String'</span>,DataIn.UpFile{1})
2580191             <a href="#_sub7" class="code" title="subfunction CurrentFile_Callback(hObject, eventdata, handles)">CurrentFile_Callback</a>(handles.CurrentFile,[],handles)
2590192             testupfile=1;
2600193             DataIn.UpFile{1}={};
2610194         <span class="keyword">end</span>
2620195     <span class="keyword">end</span>
2630196     <span class="keyword">if</span> ~testupfile  <span class="comment">%open the browser</span>
2640197         RootPath=fileparts(CurrentFile);
2650198             [FileName, PathName]=uigetfile( <span class="keyword">...</span>
2660199                {<span class="string">'*.xml'</span>, <span class="string">'(*.xml)'</span>;
2670200                 <span class="string">'*.xml'</span><span class="string">'.xml files '</span>; <span class="keyword">...</span>
2680201                 <span class="string">'*.*'</span><span class="string">'All Files (*.*)'</span>}, <span class="keyword">...</span>
2690202                 <span class="string">'Pick a file'</span>,RootPath); <span class="comment">%file browser</span>
2700203             fileinput_new=fullfile(PathName,FileName);
2710204             set(handles.CurrentFile,<span class="string">'String'</span>,fileinput_new)
2720205             <a href="#_sub7" class="code" title="subfunction CurrentFile_Callback(hObject, eventdata, handles)">CurrentFile_Callback</a>(handles.CurrentFile,[],handles)
2730206      <span class="keyword">end</span>
2740207 <span class="keyword">end</span>
2750208 set(heditxml,<span class="string">'UserData'</span>,DataIn);
2760209 <span class="comment">%---------------------------------------------------------</span>
2770210 <span class="comment">%edit element value</span>
2780211 <a name="_sub5" href="#_subfunctions" class="code">function element_value_Callback(hObject, eventdata, handles)</a>
2790212 <span class="comment">%----------------------------------------------------------</span>
2800213 <span class="keyword">global</span> t xs
2810214 <span class="keyword">if</span> isequal(get(handles.element_value,<span class="string">'ForegroundColor'</span>),[0.7 0.7 0.7])
2820215     <span class="keyword">return</span><span class="comment">% edit element desactivated (grey display)</span>
2830216 <span class="keyword">end</span>
2840217 list_enum=get(handles.element_value,<span class="string">'String'</span>);
2850218 list_index=get(handles.element_value,<span class="string">'Value'</span>);
2860219 <span class="keyword">if</span> iscell(list_enum)
2870220     value=list_enum{list_index};
2880221 <span class="keyword">else</span>
2890222     value=list_enum;
2900223 <span class="keyword">end</span>
2910224 heditxml=get(handles.element_value,<span class="string">'Parent'</span>);
2920225 DataIn=get(heditxml,<span class="string">'UserData'</span>);
2930226 <span class="comment">%create the current root element if needed</span>
2940227 LengthElement=length(DataIn.CurrentUid);
2950228 FilledUid=find(DataIn.CurrentUid~=0);
2960229 LengthFilled=FilledUid(end);
2970230 <span class="keyword">for</span> irank=LengthFilled+1:LengthElement
2980231     attrib=attributes(xs,<span class="string">'get'</span>,DataIn.xs_CurrentUid(irank),1);
2990232     [t,DataIn.CurrentUid(irank)]=add(t,DataIn.CurrentUid(irank-1),<span class="string">'element'</span>,attrib.val);
3000233 <span class="keyword">end</span>
3010234 node_element=get(handles.element_value,<span class="string">'UserData'</span>);
3020235 element_key=get(handles.element_key,<span class="string">'String'</span>);
3030236 t=<a href="#_sub12" class="code" title="subfunction t=set_element(t,RootUid,node,key,value)">set_element</a>(t,DataIn.CurrentUid(end),node_element,element_key,value);
3040237 
3050238 set(heditxml,<span class="string">'UserData'</span>,DataIn)
3060239 <span class="comment">%update the current listing</span>
3070240 [nodeup,path,xs_element,xs_subelem]=<a href="#_sub8" class="code" title="subfunction [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,nodeinput)">scan_schema</a>(xs,DataIn.xs_CurrentUid(end));
3080241 [element,subelem]=<a href="#_sub9" class="code" title="subfunction [element,subelem]=get_xml(t,path,xs_element,node,xs_subelem)">get_xml</a>(t,path,xs_element,DataIn.CurrentUid(end),xs_subelem);
3090242 element_index=get(handles.list_element,<span class="string">'Value'</span>);
3100243 <a href="#_sub10" class="code" title="subfunction update_list(handles,path,xs_element,element,node,xs_subelem,subelem)">update_list</a>(handles,path,xs_element,element,DataIn.CurrentUid(end),xs_subelem,subelem);
3110244 set(handles.list_element,<span class="string">'Value'</span>,element_index);
3120245
3130246 <span class="comment">%</span>
3140247 <span class="comment">% % --- Executes on button press in inport_file.</span>
3150248 <span class="comment">% function inport_file_Callback(hObject, eventdata, handles)</span>
3160249 <span class="comment">% CurrentFile=get(handles.RefFile,'String');</span>
3170250 <span class="comment">% if isempty(CurrentFile)|isequal(CurrentFile,'')</span>
3180251 <span class="comment">%     CurrentFile=get(handles.CurrentFile,'String')</span>
3190252 <span class="comment">% end</span>
3200253 <span class="comment">% [FileName, PathName]=uigetfile( ...</span>
3210254 <span class="comment">%        {'*.xml', '(*.xml)';</span>
3220255 <span class="comment">%         '*.xml',  '.xml files '; ...</span>
3230256 <span class="comment">%         '*.*',  'All Files (*.*)'}, ...</span>
3240257 <span class="comment">%         'Pick a file',CurrentFile); %file browser</span>
3250258 <span class="comment">% fileinput=fullfile(PathName,FileName);</span>
3260259 <span class="comment">% sizf=size(fileinput);</span>
3270260 <span class="comment">% if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end% keep only character strings as input file name</span>
3280261 <span class="comment">% if exist(fileinput,'file')</span>
3290262 <span class="comment">%    set(handles.RefFile,'Visible','on')</span>
3300263 <span class="comment">%    set(handles.replicate,'Visible','on')</span>
3310264 <span class="comment">%    set(handles.RefFile,'String',fileinput)</span>
3320265 <span class="comment">%    RefFile_Callback(handles.RefFile, eventdata, handles)</span>
3330266 <span class="comment">% end</span>
3340267
3350268
3360269 <span class="comment">%------------------------------------------------------</span>
3370270 <span class="comment">% --- Executes on button press in browser.</span>
3380271 <a name="_sub6" href="#_subfunctions" class="code">function browser_Callback(hObject, eventdata, handles)</a>
3390272 <span class="comment">%-------------------------------------------------------</span>
3400273 heditxml=get(hObject,<span class="string">'parent'</span>);<span class="comment">%handle of the interface figure</span>
3410274 DataIn=get(heditxml,<span class="string">'UserData'</span>);<span class="comment">%get the current input xml file</span>
3420275 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>);
3430276 DataIn.Schema=[];<span class="comment">%schema input file put to [] by default</span>
3440277 [FileName, PathName]=uigetfile( <span class="keyword">...</span>
3450278        {<span class="string">'*.xml;*.xls'</span>,<span class="string">'(*.xml,*.xls)'</span>;
3460279         <span class="string">'*.xml'</span><span class="string">'.xml files '</span>; <span class="keyword">...</span>
3470280         <span class="string">'*.xls'</span><span class="string">'.xls files '</span>; <span class="keyword">...</span>
3480281         <span class="string">'*.*'</span><span class="string">'All Files (*.*)'</span>}, <span class="keyword">...</span>
3490282         <span class="string">'Pick a file'</span>,CurrentFile); <span class="comment">%file browser</span>
3500283 CurrentFile=fullfile(PathName,FileName);
3510284 sizf=size(CurrentFile);
3520285 <span class="keyword">if</span> (~ischar(CurrentFile)|~isequal(sizf(1),1)),<span class="keyword">return</span>;<span class="keyword">end</span><span class="comment">% keep only character strings as input file name</span>
3530286 <span class="keyword">if</span> exist(CurrentFile,<span class="string">'file'</span>)
3540287 <span class="comment">%     set(handles.CurrentAttributes,'UserDataIn',PathName); %store the path to the xml file</span>
3550288     [CurPath,CurName,CurExt]=fileparts(CurrentFile);
3560289     <span class="keyword">if</span> isequal(CurExt,<span class="string">'.xls'</span>)   
3570290         <span class="keyword">if</span> isfield(DataIn,<span class="string">'hfig_xls'</span>)&amp;ishandle(DataIn.hfig_xls)
3580291             [hfig_xls]=<a href="read_xls.html" class="code" title="function [hfig_xls]=read_xls(fileinput,hfig)">read_xls</a>(CurrentFile,DataIn.hfig_xls);
3590292         <span class="keyword">else</span>
3600293             [hfig_xls]=<a href="read_xls.html" class="code" title="function [hfig_xls]=read_xls(fileinput,hfig)">read_xls</a>(CurrentFile);
3610294         <span class="keyword">end</span>
3620295         figpos=get(heditxml,<span class="string">'Position'</span>);
3630296         newfigpos=[figpos(1)-0.25*figpos(3) figpos(2) 0.5*figpos(3) 0.5*figpos(4)];
3640297         set(hfig_xls,<span class="string">'Position'</span>,newfigpos)
3650298     <span class="keyword">else</span>
3660299         set(handles.CurrentFile,<span class="string">'String'</span>,CurrentFile)
3670300         <a href="#_sub7" class="code" title="subfunction CurrentFile_Callback(hObject, eventdata, handles)">CurrentFile_Callback</a>(hObject, eventdata, handles)
3680301      <span class="keyword">end</span>
3690302 <span class="keyword">end</span>
3700303
3710304 <span class="comment">%------------------------------------</span>
3720305 <a name="_sub7" href="#_subfunctions" class="code">function CurrentFile_Callback(hObject, eventdata, handles)</a>
3730306 <span class="keyword">global</span> t xs
3740307 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>);
3750308 heditxml=get(handles.CurrentFile,<span class="string">'parent'</span>);<span class="comment">%handles of the inteface</span>
3760309 DataIn=get(heditxml,<span class="string">'UserData'</span>);
3770310 t=xmltree(CurrentFile);<span class="comment">%open the xml file</span>
3780311 head_element=get(t,1);
3790312 <span class="keyword">if</span> ~isfield(head_element,<span class="string">'name'</span>) | ~isfield(head_element,<span class="string">'attributes'</span>)
3800313     <a href="warndlg_uvmat.html" class="code" title="function hwarn=warndlg_uvmat(warntext,title)">warndlg_uvmat</a>(<span class="string">'root element of the .xml file not in correct format'</span>,<span class="string">'ERROR'</span>)
3810314 <span class="keyword">end</span>
3820315 head_name=head_element.name;
3830316 head_attr=head_element.attributes;<span class="comment">% attribute of root gives the name of the associated schema</span>
3840317 xstest=0;
3850318 <span class="keyword">for</span> iattr=1:length(head_attr)
3860319     <span class="keyword">if</span> isequal(head_attr{iattr}.key,<span class="string">'xmlns:xsi'</span>)&amp; isequal(head_attr{iattr}.val,<span class="string">'none'</span>)<span class="comment">%no schema to read</span>
3870320          xs=[];
3880321 <span class="comment">%          xstest=1;</span>
3890322     <span class="keyword">end</span>
3900323     <span class="keyword">if</span> isequal(head_attr{iattr}.key,<span class="string">'xsi:noNamespaceSchemaLocation'</span>) &amp; exist(head_attr{iattr}.val,<span class="string">'file'</span>)
3910324         DataIn.Schema=head_attr{iattr}.val;
3920325         xs=xmltree(DataIn.Schema);<span class="comment">%open the associated schema file</span>
3930326         xstest=1;
3940327     <span class="keyword">end</span>
3950328 <span class="keyword">end</span>
3960329 <span class="keyword">if</span> xstest==0  <span class="comment">%look for the corresponding schema in the directory PARAM_LINUX.xml or PARAM_WIN.xml</span>
3970330     head_name=get(t,1,<span class="string">'name'</span>);
3980331     <span class="comment">%Path to shemas:</span>
3990332     path_uvmat=which(<span class="string">'editxml'</span>);<span class="comment">% check the path detected for source file uvmat</span>
4000333     path_UVMAT=fileparts(path_uvmat); <span class="comment">%path to UVMAT</span>
4010334     <span class="keyword">if</span> isunix
4020335         xmlparam=fullfile(path_UVMAT,<span class="string">'PARAM_LINUX.xml'</span>)
4030336         <span class="keyword">if</span> exist(xmlparam,<span class="string">'file'</span>)
4040337             tparam=xmltree(xmlparam);
4050338             sparam=convert(tparam);
4060339             <span class="keyword">if</span> isfield(sparam,<span class="string">'SchemaPath'</span>)
4070340                 schemapath=[fullfile(sparam.SchemaPath,head_name) <span class="string">'.xsd'</span>]
4080341             <span class="keyword">end</span>
4090342         <span class="keyword">end</span>     
4100343 <span class="comment">%         schemapath=['/coriolis/papillon/data/civbin/XML_SCHEMAS/' head_name '.xsd']%current dir for schema</span>
4110344     <span class="keyword">else</span>
4120345         xmlparam=fullfile(path_UVMAT,<span class="string">'PARAM_WIN.xml'</span>)
4130346         <span class="keyword">if</span> exist(xmlparam,<span class="string">'file'</span>)
4140347             tparam=xmltree(xmlparam);
4150348             sparam=convert(tparam)
4160349             <span class="keyword">if</span> isfield(sparam,<span class="string">'SchemaPath'</span>)
4170350                 schemapath=[fullfile(sparam.SchemaPath,head_name) <span class="string">'.xsd'</span>]
4180351             <span class="keyword">end</span>
4190352         <span class="keyword">end</span> 
4200353 <span class="comment">%         schemapath=['\\Papillon\data\civbin\XML_SCHEMAS\' head_name '.xsd']%current dir for schemas</span>
4210354     <span class="keyword">end</span>
4220355     <span class="keyword">if</span> exist(schemapath,<span class="string">'file'</span>)
4230356         xs=xmltree(schemapath);
4240357     <span class="keyword">else</span>
4250358         <a href="warndlg_uvmat.html" class="code" title="function hwarn=warndlg_uvmat(warntext,title)">warndlg_uvmat</a>([<span class="string">'The xml schema for '</span> CurrentFile <span class="string">' is unknown, check the schema path set in the xml file PARAM'</span>],<span class="string">'ERROR'</span>)
4260359         [FileName, PathName]=uigetfile( <span class="keyword">...</span>
4270360        {<span class="string">'*.xsd'</span>, <span class="string">'(*.xsd)'</span>;
4280361         <span class="string">'*.xsd'</span><span class="string">'.xsd files '</span>; <span class="keyword">...</span>
4290362         <span class="string">'*.*'</span><span class="string">'All Files (*.*)'</span>}, <span class="keyword">...</span>
4300363         [<span class="string">'Pick a .xsd schema'</span>] ,schemapath); <span class="comment">%file browser</span>
4310364         <span class="keyword">if</span> ischar(PathName)&amp;ischar(FileName)&amp; exist(fullfile(PathName,FileName),<span class="string">'file'</span>)
4320365             DataIn.Schema=fullfile(PathName,FileName);
4330366             xs=xmltree(DataIn.Schema);<span class="comment">%open the associated schema file</span>
4340367         <span class="keyword">else</span>
4350368             xs=[];
4360369         <span class="keyword">end</span>
4370370     <span class="keyword">end</span>
4380371 <span class="keyword">end</span>
4390372 DataIn.CurrentUid=1;
4400373 <span class="keyword">if</span> isempty(xs)
4410374     <a href="#_sub15" class="code" title="subfunction [Data,testsimple]=displ_xml(handles,t,root_uid,DataIn,heditxml)">displ_xml</a>(handles,t,1,DataIn,get(hObject,<span class="string">'parent'</span>));<span class="comment">%no associated schema, default  display of the xml file</span>
4420375 <span class="comment">%    set(handles.inport_file,'Visible','off')</span>
4430376 <span class="comment">%    set(handles.RefFile,'Visible','off')</span>
4440377 <span class="keyword">else</span>
4450378     DataIn.xs_CurrentUid=find(xs,<span class="string">'/xs:schema/xs:element'</span>);<span class="comment">%uid of the root element in the schema</span>
4460379     [nodeup,path,xs_element,xs_subelem]=<a href="#_sub8" class="code" title="subfunction [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,nodeinput)">scan_schema</a>(xs,DataIn.xs_CurrentUid);<span class="comment">%scan the schema at the root level</span>
4470380     [element,subelem]=<a href="#_sub9" class="code" title="subfunction [element,subelem]=get_xml(t,path,xs_element,node,xs_subelem)">get_xml</a>(t,path,xs_element,1,xs_subelem);<span class="comment">% read the corresponding xml data</span>
4480381     <a href="#_sub10" class="code" title="subfunction update_list(handles,path,xs_element,element,node,xs_subelem,subelem)">update_list</a>(handles,path,xs_element,element,1,xs_subelem,subelem);<span class="comment">%update the display of information on the interface</span>
4490382    <span class="comment">% set(handles.inport_file,'Visible','on')</span>
4500383    <span class="comment">% set(handles.RefFile,'Visible','on')</span>
4510384 <span class="keyword">end</span>
4520385 set(heditxml,<span class="string">'UserData'</span>,DataIn);<span class="comment">%store the new input xml file name</span>
4530386
4540387 <span class="comment">%-------------------------------------------------------</span>
4550388 <span class="comment">%  function scan_schema: read the xml schema xs</span>
4560389 <span class="comment">%--------------------------------------------------------</span>
4570390 <span class="comment">%OUTPUT:</span>
4580391 <span class="comment">%nodeup: parent node of nodeinput</span>
4590392 <span class="comment">%path: path to nodeinput in the tree</span>
4600393 <span class="comment">%xs_element: element corresponding to nodeinput</span>
4610394     <span class="comment">%xs_element.uid, =tag of the element in the schema (=nodeinput)</span>
4620395     <span class="comment">%xs_element.key: key label of nodeinput</span>
4630396     <span class="comment">%xs_element.type: type of data contained in the element</span>
4640397     <span class="comment">%xs_element.annot: annotation of nodeinput</span>
4650398     <span class="comment">%xs_element.attrib: list of accepted attributes keys for xs_element</span>
4660399     <span class="comment">%xs_element.enum: enumeration, list of accepted values for nodeinput</span>
4670400     <span class="comment">%xs_element.subtest: =1 if the element contains subelements in the schema, 0 else</span>
4680401   
4690402 <span class="comment">%xs_subelement(k): subelement #k of xs_element</span>
4700403     <span class="comment">%xs_subelem(k).node: node number in the schema</span>
4710404     <span class="comment">%xs_subelem(k).key: key name of the element</span>
4720405     <span class="comment">%xs_subelem(k).testsub: =1 if element contains subelements, 0 else</span>
4730406     <span class="comment">%xs_subelem(k).minOccurs: =0 for a non mandatory element, =1 else</span>
4740407     <span class="comment">%xs_subelem(k).maxOccurs</span>
4750408 <span class="comment">%</span>
4760409 <span class="comment">%INPUT:</span>
4770410 <span class="comment">%xs: schema xml tree</span>
4780411 <span class="comment">%nodeinput: tag of the current root element in the schema</span>
4790412 <a name="_sub8" href="#_subfunctions" class="code">function [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,nodeinput)</a>
4800413 nodeup=[];
4810414 path=[];
4820415 xs_element.key=[];
4830416 xs_element.type=[];
4840417 xs_element.annot=[];
4850418 xs_element.attrib=[];
4860419 xs_element.subtest=0;
4870420 xs_element.enum={};
4880421 xs_subelem=[];<span class="comment">%default</span>
4890422 <span class="comment">% get default nodeinput (root of the file) if not defined</span>
4900423 <span class="keyword">if</span> ~exist(<span class="string">'nodeinput'</span>) | isempty(nodeinput)<span class="comment">% we start at the root</span>
4910424     node=find(xs,<span class="string">'/xs:schema/xs:element'</span>);<span class="comment">%description of the root element</span>
4920425 <span class="keyword">else</span>
4930426     node=nodeinput;
4940427 <span class="keyword">end</span>
4950428 xs_element.uid=node;
4960429 <span class="comment">%get the key name and element_type of the element</span>
4970430 node_content=get(xs,node);
4980431 <span class="keyword">if</span> isempty(node_content),<span class="keyword">return</span>,<span class="keyword">end</span>;
4990432 <span class="keyword">if</span> ~isempty(node_content) &amp; isfield(node_content,<span class="string">'attributes'</span>)
5000433     attrib=node_content.attributes;
5010434     <span class="keyword">for</span> iattr=1:length(attrib)
5020435         struct=attrib{iattr};
5030436         <span class="keyword">if</span> isequal(struct.key,<span class="string">'name'</span>)
5040437             xs_element.key=struct.val; <span class="comment">% read element key name</span>
5050438         <span class="keyword">elseif</span> isequal(struct.key,<span class="string">'type'</span>)
5060439             xs_element.type=struct.val; <span class="comment">% read element key name</span>
5070440         <span class="keyword">end</span>
5080441     <span class="keyword">end</span>
5090442 <span class="keyword">end</span>
5100443
5110444 <span class="comment">%get the parent node of nodeinput</span>
5120445 <span class="keyword">if</span> ~isempty(node_content)
5130446     nodeup=get(xs,node,<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span>
5140447     <span class="keyword">if</span> ~isempty(nodeup)
5150448         nodeup=get(xs,nodeup(1),<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span>
5160449         <span class="keyword">if</span> isequal(nodeup,[])
5170450             <span class="comment">%OUVRIR FICHIER AMONT</span>
5180451             up=0;
5190452         <span class="keyword">else</span>
5200453             nodeup=get(xs,nodeup(1),<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span>
5210454         <span class="keyword">end</span>
5220455     <span class="keyword">end</span>
5230456 <span class="keyword">end</span>
5240457 <span class="comment">%get the path to 'nodeinput' in the schema</span>
5250458 up=1;
5260459 path=[];
5270460 <span class="keyword">if</span> ~isempty(nodeup)
5280461     attrib=attributes(xs,<span class="string">'get'</span>,nodeup,1);
5290462     path=attrib.val;
5300463     nodeup2=nodeup;
5310464     <span class="keyword">while</span> up==1;
5320465         nodeup2=get(xs,nodeup2(1),<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span>
5330466         nodeup2=get(xs,nodeup2(1),<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span>
5340467         <span class="keyword">if</span> isempty(nodeup2)
5350468             up=0;
5360469         <span class="keyword">else</span>
5370470             nodeup2=get(xs,nodeup2(1),<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span>
5380471             <span class="keyword">if</span> isempty(nodeup2)
5390472                 up=0;
5400473             <span class="keyword">else</span>
5410474                 attrib=attributes(xs,<span class="string">'get'</span>,nodeup2,1);
5420475                 path=[attrib.val <span class="string">'/'</span> path];
5430476             <span class="keyword">end</span>
5440477         <span class="keyword">end</span>
5450478     <span class="keyword">end</span>
5460479 <span class="keyword">end</span>   
5470480
5480481 <span class="comment">%explore the subtree in the schema file</span>
5490482 node1=children(xs,node); <span class="comment">%find the children of the root element</span>
5500483 test_sub=0; <span class="comment">%no subtree in the .xml file by default</span>
5510484 comment=<span class="string">''</span>;
5520485 element={};
5530486 minOccurs={};
5540487 maxOccurs={};
5550488 testsub={};
5560489 list_menu={};
5570490 text={};
5580491 <span class="keyword">if</span> ~isempty(node1) 
5590492   <span class="keyword">for</span> i=1:length(node1)
5600493     nodename1=get(xs,node1(i),<span class="string">'name'</span>);
5610494     node2=children(xs,node1(i));
5620495     <span class="keyword">if</span> isequal(nodename1,<span class="string">'xs:annotation'</span>)
5630496          <span class="keyword">for</span> j=1:length(node2)
5640497             nodename2=get(xs,node2(j),<span class="string">'name'</span>);
5650498             <span class="keyword">if</span> isequal(nodename2,<span class="string">'xs:documentation'</span>)
5660499                 node3=children(xs,node2(j));
5670500                 xs_element.annot=get(xs,node3,<span class="string">'value'</span>);<span class="comment">%read annotation</span>
5680501             <span class="keyword">end</span>
5690502         <span class="keyword">end</span>
5700503     <span class="comment">% pour les elements</span>
5710504     <span class="keyword">elseif</span> isequal(nodename1,<span class="string">'xs:simpleType'</span>)
5720505         <span class="keyword">for</span> j=1:length(node2)
5730506             nodename2=get(xs,node2(j),<span class="string">'name'</span>);
5740507             <span class="keyword">if</span> isequal(nodename2,<span class="string">'xs:restriction'</span>)
5750508                 node3=children(xs,node2(j));
5760509                 <span class="keyword">for</span> k=1:length(node3)
5770510                     nodename3=get(xs,node3(k),<span class="string">'name'</span>);
5780511                     <span class="keyword">if</span> isequal(nodename3,<span class="string">'xs:enumeration'</span>)
5790512                         node3_content=get(xs,node3(k));
5800513                         attr=node3_content.attributes;
5810514                         <span class="keyword">for</span> m=1:length(attr)
5820515                             struct=attr{m};
5830516                             <span class="keyword">if</span> isequal(struct.key,<span class="string">'value'</span>)
5840517                                 xs_element.enum{k}=struct.val; <span class="comment">% read enumeration</span>
5850518                             <span class="keyword">end</span>
5860519                         <span class="keyword">end</span>   
5870520                    <span class="keyword">end</span>
5880521                <span class="keyword">end</span>
5890522             <span class="keyword">end</span>
5900523         <span class="keyword">end</span>
5910524      <span class="keyword">elseif</span> isequal(nodename1,<span class="string">'xs:complexType'</span>)
5920525          <span class="keyword">for</span> j=1:length(node2)
5930526              nodename2=get(xs,node2(j),<span class="string">'name'</span>);
5940527              <span class="keyword">if</span> isequal(nodename2,<span class="string">'xs:attribute'</span>)
5950528                  node_content=get(xs,node2(j));
5960529                  attr=node_content.attributes;
5970530                  <span class="keyword">for</span> k=1:length(attr)
5980531                     struct=attr{k};<span class="comment">%read attributes</span>
5990532                     <span class="keyword">if</span> isequal(struct.key,<span class="string">'name'</span>)
6000533                         xs_element.attrib=struct.val; <span class="comment">%read attributes of main node</span>
6010534                     <span class="keyword">end</span>
6020535                  <span class="keyword">end</span>   
6030536              <span class="keyword">elseif</span> isequal(nodename2,<span class="string">'xs:sequence'</span>)
6040537                  xs_element.subtest=1;
6050538                  node3=children(xs,node2(j));<span class="comment">%nodes of the sequence</span>
6060539                  <span class="keyword">for</span> k=1:length(node3)
6070540                      xs_subelem(k).node=node3(k);
6080541                      xs_subelem(k).testsub=0;<span class="comment">%default</span>
6090542                      node_content=get(xs,node3(k));
6100543                      xs_subelem(k).minOccurs=1; <span class="comment">%default</span>
6110544                      xs_subelem(k).maxOccurs=1; <span class="comment">%default</span>
6120545 <span class="comment">%                      pref{k}=[]; %default</span>
6130546                      <span class="keyword">if</span> isequal(node_content.name,<span class="string">'xs:element'</span>)
6140547                         attr=node_content.attributes;
6150548 <span class="comment">%                         attr{:}.key</span>
6160549                         <span class="keyword">for</span> l=1:length(attr)
6170550                             <span class="keyword">if</span> isequal(attr{l}.key,<span class="string">'name'</span>)
6180551                                 xs_subelem(k).key=attr{l}.val;<span class="comment">%name of the element</span>
6190552                             <span class="keyword">elseif</span> isequal(attr{l}.key, <span class="string">'minOccurs'</span>)
6200553                                 xs_subelem(k).minOccurs=attr{l}.val;
6210554                             <span class="keyword">elseif</span> isequal(attr{l}.key, <span class="string">'maxOccurs'</span>)
6220555                                 xs_subelem(k).maxOccurs=attr{l}.val;
6230556                             <span class="keyword">end</span>
6240557                         <span class="keyword">end</span>
6250558                      <span class="keyword">end</span>
6260559                      node4=children(xs,node3(k));
6270560                      <span class="keyword">for</span> l=1:length(node4)
6280561                         res=get(xs,node4(l),<span class="string">'name'</span>);
6290562                         <span class="keyword">if</span> isequal(res,<span class="string">'xs:complexType'</span>)<span class="comment">%look whether the element k contains a subtree</span>
6300563                            node5=children(xs,node4(l));
6310564                            <span class="keyword">for</span> m=1:length(node5)
6320565                                res2=get(xs,node5(m),<span class="string">'name'</span>);
6330566                                <span class="keyword">if</span> isequal(res2,<span class="string">'xs:sequence'</span>)
6340567                                     xs_subelem(k).testsub=1; <span class="comment">%flag for the existence of a subtree</span>
6350568                                <span class="keyword">end</span>
6360569                            <span class="keyword">end</span>
6370570                         <span class="keyword">end</span>
6380571                      <span class="keyword">end</span>
6390572                  <span class="keyword">end</span>           
6400573
6410574              <span class="keyword">end</span>
6420575          <span class="keyword">end</span>     
6430576      <span class="keyword">end</span>   
6440577   <span class="keyword">end</span>
6450578 <span class="keyword">end</span>
6460579 <span class="comment">% look for predefined types</span>
6470580 <span class="keyword">if</span> length(xs_element.type)&gt;=3 &amp; (xs_element.type([1:3])~=<span class="string">'xs:'</span>)
6480581     node_type=find(xs,<span class="string">'/xs:schema/xs:simpleType'</span>)
6490582     <span class="keyword">for</span> i=1:length(node_type)
6500583         content=get(xs,node_type(i));
6510584         nodeattr=content.attributes;
6520585         <span class="keyword">if</span> ~isempty(nodeattr) &amp; isequal(nodeattr{1}.key,<span class="string">'name'</span>) &amp; isequal(nodeattr{1}.val,xs_element.type)
6530586             node1=children(xs,node_type(i));
6540587             node2=find(xs,node1,<span class="string">'name'</span>,<span class="string">'xs:restriction'</span>);
6550588 <span class="comment">%             nodename1=find(xs,</span>
6560589             node3=children(xs,node2);
6570590             node4=find(xs,node3,<span class="string">'name'</span>,<span class="string">'xs:enumeration'</span>);
6580591             <span class="keyword">for</span> ienum=1:length(node4)
6590592                 struct2=get(xs,node4(ienum));
6600593                 enumval=struct2.attributes;
6610594                 xs_element.enum{ienum}=enumval{1}.val;
6620595             <span class="keyword">end</span>
6630596         <span class="keyword">end</span>       
6640597      <span class="keyword">end</span>
6650598 <span class="keyword">end</span>
6660599
6670600 <span class="comment">%--------------------------------------------------------</span>
6680601 <span class="comment">%OUTPUT:</span>
6690602 <span class="comment">%element.val: value of the current element, =[] in the absence of chardata value</span>
6700603 <span class="comment">%node: node (iud) of the element in t</span>
6710604 <span class="comment">%element.attr_key{iattr}: attribute key #iattr of the current element</span>
6720605 <span class="comment">%element.attr_val{iattr}: attribute value #iattr of the current element</span>
6730606 <span class="comment">%element.attrup: %structure containing the attributes of the element, including the ones unheritated from parent nodes</span>
6740607 <span class="comment">%subelem(iline).val : value of subelement # iline, concatenated with corresponding attributes</span>
6750608 <span class="comment">%subelem(iline).xsindex: index k of the subelement #iline in the list xs_subelem of the schema</span>
6760609 <span class="comment">%subelem(iline).index: index of the subelement #iline inside its xs_subelement, =0 when the xs_subelement is absent in t</span>
6770610
6780611 <span class="comment">%INPUT:</span>
6790612 <span class="comment">%t: xml tree</span>
6800613 <span class="comment">%path: path to the current element in the schema</span>
6810614 <span class="comment">%xs_element: current element in the schema</span>
6820615     <span class="comment">%xs_element.key: key label</span>
6830616     <span class="comment">%xs_element.type: type of data contained in the element</span>
6840617     <span class="comment">%xs_element.annot: annotation of nodeinput</span>
6850618     <span class="comment">%xs_element.attrib: list of accepted attributes keys for xs_element</span>
6860619     <span class="comment">%xs_element.enum: enumeration, list of accepted values</span>
6870620     <span class="comment">%xs_element.subtest: =1 if the element contains subelements in the schema, 0 else</span>
6880621 <span class="comment">%index: index of the element, =1 in case of single occurence in xs_element,=0 in case of missing element</span>
6890622 <span class="comment">%xs_subelem(k): subelement #k of the current element in the schema</span>
6900623     <span class="comment">%xs_subelem(k).node: node iud of the</span>
6910624     <span class="comment">%xs_subelem(k).key: key name of the subelement #k in the schema</span>
6920625     <span class="comment">%xs_subelem(k).testsub: =1 if element contains subelements, 0 else</span>
6930626     <span class="comment">%xs_subelem(k).minOccurs</span>
6940627     <span class="comment">%xs_subelem(k).maxOccurs</span>
6950628
6960629 <a name="_sub9" href="#_subfunctions" class="code">function [element,subelem]=get_xml(t,path,xs_element,node,xs_subelem)</a>
6970630 element.attr_key=<span class="string">''</span>;<span class="comment">%default</span>
6980631 element.attr_val=<span class="string">''</span>;<span class="comment">%default</span>
6990632 element.val=<span class="string">''</span>;
7000633 <span class="comment">% element.type='';</span>
7010634 <span class="comment">% element.testmanual=testmanual %inheritates the input manual editing flag by default</span>
7020635 subelem=[]; <span class="comment">%default</span>
7030636 attrup=[];
7040637 <span class="comment">% node=[];</span>
7050638
7060639 <span class="comment">% %find the element properties in the xml file</span>
7070640 <span class="keyword">if</span> node &gt;= 1
7080641     elem_struct=get(t,node);
7090642     <span class="keyword">if</span> ~xs_element.subtest
7100643         elem_contents=get(t,elem_struct.contents);
7110644         <span class="keyword">if</span> isempty(elem_contents)
7120645             element.val=[];
7130646         <span class="keyword">else</span>
7140647             element.val=elem_contents.value
7150648         <span class="keyword">end</span>
7160649     <span class="keyword">end</span>
7170650     <span class="keyword">if</span> isfield(elem_struct,<span class="string">'attributes'</span>)
7180651         elem_attr=elem_struct.attributes;
7190652         <span class="keyword">for</span> iattr=1:length(elem_attr)
7200653             element.attr_key{iattr}=elem_attr{iattr}.key ;
7210654             element.attr_val{iattr}=elem_attr{iattr}.val;
7220655 <span class="comment">%             attrup=setfield(attrup,elem_attr{iattr}.key,elem_attr{iattr}.val);</span>
7230656            breakdetect=find(elem_attr{iattr}.key==<span class="string">'/'</span>| elem_attr{iattr}.key==<span class="string">':'</span>| elem_attr{iattr}.key==<span class="string">'.'</span>);<span class="comment">% find '/'</span>
7240657            <span class="keyword">if</span> isempty(breakdetect)
7250658 <span class="comment">%                 comline=['attrup.' elem_attr{iattr}.key '=' elem_attr{iattr}.val ';']</span>
7260659                 eval([<span class="string">'attrup.'</span> elem_attr{iattr}.key <span class="string">'='''</span> elem_attr{iattr}.val <span class="string">''';'</span>])
7270660            <span class="keyword">end</span>
7280661         <span class="keyword">end</span>
7290662     <span class="keyword">end</span>
7300663 <span class="keyword">end</span>
7310664 <span class="comment">%get the parent node attributes</span>
7320665 up=1;
7330666 <span class="keyword">if</span> node&gt;0
7340667     nodeup=node;
7350668     <span class="keyword">while</span> up==1;
7360669         nodeup=get(t,nodeup,<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span>
7370670         <span class="keyword">if</span> isempty(nodeup)
7380671             up=0;
7390672         <span class="keyword">else</span>
7400673             nodeup_content=get(t,nodeup);
7410674             attrib=nodeup_content.attributes;
7420675             <span class="keyword">for</span> iattr=1:length(attrib)
7430676                 key=attrib{iattr}.key;
7440677                 breakdetect=find(key==<span class="string">'/'</span>| key==<span class="string">':'</span>| key==<span class="string">'.'</span>);<span class="comment">% find '/'</span>
7450678                 <span class="keyword">if</span> ~isfield(attrup,key) &amp; isempty(breakdetect)
7460679                    eval([<span class="string">'attrup.'</span> key <span class="string">'='''</span> attrib{iattr}.val <span class="string">''';'</span>])
7470680                 <span class="keyword">end</span>
7480681             <span class="keyword">end</span>
7490682         <span class="keyword">end</span>
7500683     <span class="keyword">end</span>
7510684     element.attrup=attrup;
7520685 <span class="keyword">end</span>
7530686 <span class="comment">%find the subelement properties in the xml file</span>
7540687 <span class="keyword">if</span> xs_element.subtest
7550688    iline=0;
7560689    <span class="keyword">for</span> k=1:length(xs_subelem)<span class="comment">%node2: list of subelements in the sub-sequence</span>
7570690 <span class="comment">%     attr=attributes(xs,'get',node2(i),1);%</span>
7580691 <span class="comment">%     element=attr.val;%name of the element</span>
7590692      tag=find(t,[<span class="string">'/'</span> path <span class="string">'/'</span> xs_element.key <span class="string">'/'</span> xs_subelem(k).key]);<span class="comment">%look for the corresponding element node in the .xml tree</span>
7600693      struct_element=get(t,tag);<span class="comment">%get the content of the element</span>
7610694      <span class="keyword">if</span> isempty(struct_element)
7620695          iline=iline+1;
7630696          subelem(iline).uid=0;
7640697          subelem(iline).xsindex=k;
7650698          subelem(iline).index=0;
7660699 <span class="comment">%          subelem(iline).testmanual=element.testmanual;% inheritates the manual editing flag by default</span>
7670700          <span class="keyword">if</span> isequal(xs_subelem(k).minOccurs,<span class="string">'0'</span>)
7680701              subelem(iline).val=<span class="string">'[]'</span>;<span class="comment">%element value not mandatory in the schema</span>
7690702          <span class="keyword">else</span>
7700703              subelem(iline).val=<span class="string">'[MISSING]'</span>;<span class="comment">%element value mandatory in the schema</span>
7710704          <span class="keyword">end</span>
7720705 <span class="comment">%          subelem(iline).attrup=attrup; %inheritated attributes</span>
7730706      <span class="keyword">elseif</span> isequal(length(struct_element),1)
7740707          contents=get(t,struct_element.contents);
7750708          iline=iline+1;
7760709          subelem(iline).uid=tag;
7770710          subelem(iline).xsindex=k;
7780711          subelem(iline).index=1;
7790712 <span class="comment">%          subelem(iline).testmanual=element.testmanual;%</span>
7800713          <span class="keyword">if</span> isfield(contents,<span class="string">'value'</span>) &amp; ~isempty(contents.value)
7810714              subelem(iline).val=contents.value;
7820715          <span class="keyword">elseif</span> xs_subelem(k).testsub
7830716              subelem(iline).val=<span class="string">''</span>;
7840717          <span class="keyword">elseif</span> isequal(xs_subelem(k).minOccurs,0)
7850718              subelem(iline).val=<span class="string">'[]'</span>;<span class="comment">%element value not mandatory in the schema</span>
7860719          <span class="keyword">else</span>
7870720              subelem(iline).val=<span class="string">'[MISSING]'</span>;<span class="comment">%element value mandatory in the schema</span>
7880721          <span class="keyword">end</span>
7890722 <span class="comment">%          subelem(iline).attrup=attrup; %inheritated attributes</span>
7900723          <span class="keyword">if</span> isfield(struct_element,<span class="string">'attributes'</span>)
7910724             element_attr=struct_element.attributes;
7920725             attr_display=[];
7930726             <span class="keyword">for</span> iattr=1:length(element_attr)
7940727 <span class="comment">%                 attr_display{iline}=[attr_display ' , ' element_attr{iattr}.key '  =  ' element_attr{iattr}.val];</span>
7950728                 subelem(iline).val=[subelem(iline).val attr_display <span class="string">' , '</span> element_attr{iattr}.key <span class="string">'  =  '</span> element_attr{iattr}.val];
7960729 <span class="comment">%                 subelem(iline).attrup=setfield(subelem(iline).attrup,element_attr{iattr}.key,element_attr{iattr}.val);</span>
7970730             <span class="keyword">end</span>
7980731          <span class="keyword">end</span>
7990732      <span class="keyword">else</span><span class="comment">%case of a multiple element</span>
8000733          <span class="keyword">for</span> subindex=1:length(struct_element)
8010734              contents=get(t,struct_element{subindex}.contents);
8020735              iline=iline+1;
8030736              subelem(iline).index=subindex;<span class="comment">%index of the element</span>
8040737              subelem(iline).xsindex=k;
8050738 <span class="comment">%              subelem(iline).testmanual=element.testmanual;%</span>
8060739              <span class="keyword">if</span> isfield(contents,<span class="string">'value'</span>)&amp; ~isempty(contents.value)
8070740                  subelem(iline).val=contents.value;
8080741              <span class="keyword">elseif</span> xs_subelem(k).testsub
8090742                  subelem(iline).val=<span class="string">''</span>;
8100743              <span class="keyword">else</span>
8110744                  subelem(iline).val=<span class="string">'[]'</span>;
8120745              <span class="keyword">end</span>
8130746 <span class="comment">%              subelem(iline).attrup=attrup; %inheritated attributes</span>
8140747              <span class="keyword">if</span> isfield(struct_element{subindex},<span class="string">'attributes'</span>)
8150748                 element_attr=struct_element{subindex}.attributes;
8160749                 attr_display=[];
8170750                 <span class="keyword">for</span> iattr=1:length(element_attr)
8180751 <span class="comment">%                     attr_display{iline}=[attr_display ' , ' element_attr{iattr}.key '  =  ' element_attr{iattr}.val];</span>
8190752                     subelem(iline).val=[subelem(iline).val attr_display <span class="string">' , '</span> element_attr{iattr}.key <span class="string">'  =  '</span> element_attr{iattr}.val];
8200753 <span class="comment">%                     subelem(iline).attrup=setfield(subelem(iline).attrup,element_attr{iattr}.key,element_attr{iattr}.val);</span>
8210754                 <span class="keyword">end</span>
8220755             <span class="keyword">end</span>
8230756         <span class="keyword">end</span>
8240757      <span class="keyword">end</span>
8250758   <span class="keyword">end</span>
8260759 <span class="keyword">end</span>
8270760
8280761 <span class="comment">%-------------------------------------</span>
8290762 <span class="comment">%updates the interface</span>
8300763 <a name="_sub10" href="#_subfunctions" class="code">function update_list(handles,path,xs_element,element,node,xs_subelem,subelem)</a>
8310764 <span class="comment">%-----------------------------</span>
8320765 <span class="keyword">if</span> xs_element.subtest<span class="comment">% we list the sub-elements of root</span>
8330766     set(handles.export_list,<span class="string">'Value'</span>,1)
8340767     set(handles.export_list,<span class="string">'String'</span>,<span class="string">''</span>)<span class="comment">%flush the export list</span>
8350768     set(handles.CurrentElement,<span class="string">'String'</span>,[path <span class="string">'/'</span> xs_element.key])
8360769 <span class="comment">%     title_element.key=[path '/' xs_element.key];</span>
8370770 <span class="comment">%     if ~isempty(path)</span>
8380771 <span class="comment">%         xsnode_index=get(handles.list_element,'UserDataIn');</span>
8390772 <span class="comment">%         ind=get(handles.list_element,'Value');</span>
8400773 <span class="comment">%         title_element.index=xsnode_index(2,ind);</span>
8410774 <span class="comment">%     else</span>
8420775 <span class="comment">%         title_element.index=1;</span>
8430776 <span class="comment">%     end</span>
8440777 <span class="comment">%     title_element.xsnode=xs_element.uid;</span>
8450778 <span class="comment">%     title_element.node=node;</span>
8460779 <span class="comment">%     set(handles.CurrentFile,'UserDataIn',title_element)%element corresponding to the title</span>
8470780     set(handles.CurrentAnnotation,<span class="string">'String'</span>,xs_element.annot)
8480781     attr_col=[];
8490782     testedit=0;<span class="comment">% cannot edit elements by default</span>
8500783     <span class="keyword">for</span> iattr=1:length(element.attr_key)
8510784 <span class="comment">%          if isequal(element.attr_key{iattr},'source') &amp; isequal(element.attr_val{iattr},'manual')</span>
8520785 <span class="comment">%             testedit=1;</span>
8530786 <span class="comment">%         end</span>
8540787         attr_col=strvcat(attr_col,[element.attr_key{iattr} <span class="string">' = '</span> element.attr_val{iattr}]);
8550788     <span class="keyword">end</span>
8560789     set(handles.CurrentAttributes,<span class="string">'String'</span>,attr_col)
8570790     pref_col=<span class="string">''</span>;
8580791     key_col=<span class="string">''</span>;
8590792     equal_sign=<span class="string">''</span>;
8600793     val_col=<span class="string">''</span>;
8610794     <span class="keyword">for</span> iline=1:length(subelem)
8620795         xsindex=subelem(iline).xsindex;
8630796         index(iline)=subelem(iline).index;
8640797         subuid=subelem(iline).uid;
8650798         <span class="keyword">if</span> isempty(subuid)
8660799             list.uid(iline)=0;
8670800         <span class="keyword">else</span>
8680801             list.uid(iline)=subuid;
8690802         <span class="keyword">end</span>
8700803         node(iline)=xs_subelem(xsindex).node;
8710804 <span class="comment">%         testmanual(iline)=subelem(iline).testmanual;</span>
8720805         ikey=xs_subelem(xsindex).key;
8730806         <span class="keyword">if</span> xs_subelem(xsindex).testsub
8740807             ival=[<span class="string">' + '</span> subelem(iline).val];
8750808         <span class="keyword">else</span>
8760809             ival=[<span class="string">' = '</span> subelem(iline).val];
8770810         <span class="keyword">end</span>
8780811         key_col=strvcat(key_col,ikey);
8790812         val_col=strvcat(val_col,ival);
8800813     <span class="keyword">end</span>
8810814     list_element=[key_col val_col];
8820815     set(handles.list_element,<span class="string">'String'</span>,list_element)
8830816     set(handles.list_element,<span class="string">'Value'</span>,1)
8840817     list.xs_uid=node;
8850818     list.index=index;
8860819     set(handles.list_element,<span class="string">'UserData'</span>,list)
8870820     set(handles.element_attrib,<span class="string">'Visible'</span>,<span class="string">'off'</span>)
8880821     set(handles.element_key,<span class="string">'Visible'</span>,<span class="string">'off'</span>)
8890822     set(handles.element_value,<span class="string">'Visible'</span>,<span class="string">'off'</span>)
8900823 <span class="keyword">else</span> <span class="comment">% we edit an element</span>
8910824
8920825     export_list=get(handles.export_list,<span class="string">'String'</span>);<span class="comment">%export list</span>
8930826     testadd=1;
8940827     <span class="keyword">for</span> ilist=1:length(export_list)
8950828         <span class="keyword">if</span> isequal(xs_element.key,export_list{ilist})
8960829             testadd=0;       
8970830             <span class="keyword">break</span>
8980831         <span class="keyword">end</span>
8990832     <span class="keyword">end</span>
9000833     <span class="keyword">if</span> testadd
9010834         export_list=[export_list;{xs_element.key}];
9020835         ilist=length(export_list);
9030836     <span class="keyword">end</span>
9040837     set(handles.export_list,<span class="string">'String'</span>,export_list)
9050838     <span class="keyword">if</span> iscell(element.val)
9060839         element_val=element.val{1};
9070840     <span class="keyword">else</span>
9080841         element_val=element.val;
9090842     <span class="keyword">end</span>
9100843     set(handles.element_value,<span class="string">'String'</span>,element_val)
9110844     export_val=get(handles.export_list,<span class="string">'UserData'</span>);
9120845     export_val{ilist}=element_val;
9130846     set(handles.export_list,<span class="string">'UserData'</span>,export_val);
9140847     set(handles.element_annot,<span class="string">'String'</span>,xs_element.annot)
9150848     set(handles.element_type,<span class="string">'String'</span>,[<span class="string">'type:  '</span> xs_element.type])
9160849     attr_col=[];
9170850     testedit=0;<span class="comment">% cannot edit element by default</span>
9180851     <span class="keyword">for</span> iattr=1:length(element.attr_key)
9190852 <span class="comment">%         if isequal(element.attr_key{iattr},'source') &amp; isequal(element.attr_val{iattr},'manual')</span>
9200853 <span class="comment">%             testedit=1;</span>
9210854 <span class="comment">%         end</span>
9220855         attr_col=strvcat(attr_col,[element.attr_key{iattr} <span class="string">' = '</span> element.attr_val{iattr}]);
9230856     <span class="keyword">end</span>
9240857     set(handles.element_attrib,<span class="string">'String'</span>,attr_col)
9250858     set(handles.element_key,<span class="string">'String'</span>,xs_element.key)
9260859
9270860 
9280861     <span class="keyword">if</span> isempty(xs_element.enum)
9290862         set(handles.element_value,<span class="string">'Value'</span>,1)
9300863         set(handles.element_value,<span class="string">'Style'</span>,<span class="string">'edit'</span>)
9310864     <span class="keyword">else</span> <span class="comment">% case of an enumeration of possible values</span>
9320865          list_enum=[];
9330866          list_val=[];
9340867          <span class="keyword">for</span> ienum=1:length(xs_element.enum)
9350868              list_enum{ienum,1}=xs_element.enum{ienum};
9360869              <span class="keyword">if</span> isequal(xs_element.enum{ienum},element_val)
9370870                  list_val=ienum;
9380871              <span class="keyword">end</span>
9390872          <span class="keyword">end</span> 
9400873          <span class="keyword">if</span> isempty(list_val)
9410874              list_enum{length(xs_element.enum)+1,1}=[<span class="string">'['</span> element_val <span class="string">']'</span>];<span class="comment">%show the non-valid element between brackets</span>
9420875              list_val=length(xs_element.enum)+1;
9430876          <span class="keyword">end</span>
9440877          set(handles.element_value,<span class="string">'Style'</span>,<span class="string">'popupmenu'</span>)
9450878          set(handles.element_value,<span class="string">'String'</span>,list_enum)
9460879          set(handles.element_value,<span class="string">'Value'</span>,list_val)
9470880      <span class="keyword">end</span>
9480881      <span class="keyword">if</span> isempty(element.val)
9490882          testedit=1;<span class="comment">%allow element editing if value is missing</span>
9500883      <span class="keyword">end</span>     
9510884      set(handles.element_attrib,<span class="string">'Visible'</span>,<span class="string">'On'</span>)
9520885      set(handles.element_key,<span class="string">'Visible'</span>,<span class="string">'On'</span>)
9530886      set(handles.element_value,<span class="string">'Visible'</span>,<span class="string">'On'</span>)
9540887 <span class="keyword">end</span>
9550888 set(handles.element_value,<span class="string">'UserData'</span>,node)
9560889 <span class="keyword">if</span> ~testedit &amp;&amp; isfield(element,<span class="string">'attrup'</span>) &amp; isfield(element.attrup,<span class="string">'source'</span>)&amp;&amp; ~isequal(element.attrup.source,<span class="string">'manual'</span>)
9570890      set(handles.element_value,<span class="string">'Enable'</span>,<span class="string">'inactive'</span>)
9580891 <span class="keyword">else</span>
9590892     set(handles.element_value,<span class="string">'Enable'</span>,<span class="string">'on'</span>)
9600893 <span class="keyword">end</span>
9610894
9620895
9630896 <span class="comment">% --- Executes on button press in SAVE.</span>
9640897 <a name="_sub11" href="#_subfunctions" class="code">function SAVE_Callback(hObject, eventdata, handles)</a>
9650898 <span class="keyword">global</span> t
9660899 DataIn=get(get(handles.SAVE,<span class="string">'parent'</span>),<span class="string">'UserData'</span>);
9670900 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>);
9680901 <span class="keyword">if</span> isfield(DataIn,<span class="string">'Schema'</span>)
9690902 <span class="keyword">if</span> ~isempty(DataIn.Schema)<span class="comment">% update ref to schema</span>
9700903     attrxsd=attributes(t,<span class="string">'get'</span>,1);
9710904     setest=0;
9720905     <span class="keyword">for</span> iattr=1:length(attrxsd)
9730906         <span class="keyword">if</span> isequal(attrxsd{iattr}.key,<span class="string">'xsi:noNamespaceSchemaLocation'</span>)
9740907             t= attributes(t,<span class="string">'set'</span>,1,iattr,<span class="string">'xsi:noNamespaceSchemaLocation'</span>,DataIn.Schema);
9750908             setest=1;
9760909         <span class="keyword">end</span>
9770910     <span class="keyword">end</span>
9780911     <span class="keyword">if</span> setest==0;
9790912         t=attributes(t,<span class="string">'add'</span>,1,<span class="string">'xmlns:xsi'</span>,<span class="string">'http://www.w3.org/2001/XMLSchema-instance'</span>);
9800913         t= attributes(t,<span class="string">'add'</span>,1,<span class="string">'xsi:noNamespaceSchemaLocation'</span>,DataIn.Schema);
9810914     <span class="keyword">end</span>
9820915 <span class="keyword">end</span>
9830916 <span class="keyword">end</span>
9840917 copyfile(CurrentFile,[CurrentFile <span class="string">'.bak'</span>]);
9850918 save(t,CurrentFile);
9860919
9870920 <span class="comment">%-------------------------------------</span>
9880921 <span class="comment">% creates and/or set values to an element in t</span>
9890922 <span class="comment">%t: xml tree</span>
9900923 <span class="comment">%RootUid: uid of t under which we introduce an element</span>
9910924 <span class="comment">%node: uid of the element that we correct, if =0, a new element is created</span>
9920925 <span class="comment">%key: key name of the element</span>
9930926 <span class="comment">%value: new value of the element</span>
9940927 <a name="_sub12" href="#_subfunctions" class="code">function t=set_element(t,RootUid,node,key,value)</a>
9950928 <span class="comment">%create the subelement if needed</span>
9960929 <span class="keyword">if</span> isequal(node,0)   
9970930    [t,node]= add(t,RootUid,<span class="string">'element'</span>,key);
9980931 <span class="keyword">end</span>
9990932 node_chardata=children(t,node); <span class="comment">%corresponding data node</span>
10000933 <span class="keyword">if</span> isempty(node_chardata)<span class="comment">%if the data does not exist in t, create it</span>
10010934     t=add(t,node,<span class="string">'chardata'</span>,value);
10020935 <span class="keyword">elseif</span> isequal(length(node_chardata),1)&amp;isequal(get(t,node_chardata,<span class="string">'type'</span>),<span class="string">'chardata'</span>)<span class="comment">% update only a simple element with 'chardata'</span>
10030936     t=set(t,node_chardata,<span class="string">'value'</span>,value);<span class="comment">%modify existing data</span>
10040937 <span class="keyword">end</span> 
10050938 attr=attributes(t,<span class="string">'get'</span>,node);
10060939 <span class="keyword">if</span> isempty(attr)
10070940     t=attributes(t,<span class="string">'add'</span>,node,<span class="string">'source'</span>,<span class="string">'manual'</span>);<span class="comment">%indicate a manual eidting</span>
10080941 <span class="keyword">end</span>
10090942
10100943 <span class="comment">% --- Executes on selection change in element_attr_val.</span>
10110944 <a name="_sub13" href="#_subfunctions" class="code">function element_attr_val_Callback(hObject, eventdata, handles)</a>
10120945 <span class="comment">% hObject    handle to element_attr_val (see GCBO)</span>
10130946 <span class="comment">% eventdata  reserved - to be defined in a future version of MATLAB</span>
10140947 <span class="comment">% handles    structure with handles and user data (see GUIDATA)</span>
10150948
10160949 <span class="comment">% Hints: contents = get(hObject,'String') returns element_attr_val contents as cell array</span>
10170950 <span class="comment">%        contents{get(hObject,'Value')} returns selected item from element_attr_val</span>
10180951
10190952
10200953 <span class="comment">% --- Executes on button press in ADD.</span>
10210954 <a name="_sub14" href="#_subfunctions" class="code">function ADD_Callback(hObject, eventdata, handles)</a>
10220955 <span class="comment">% hObject    handle to ADD (see GCBO)</span>
10230956 <span class="comment">% eventdata  reserved - to be defined in a future version of MATLAB</span>
10240957 <span class="comment">% handles    structure with handles and user data (see GUIDATA)</span>
10250958
10260959 <span class="comment">%----------------------------------------</span>
10270960 <span class="comment">%read an xml file without schema</span>
10280961 <a name="_sub15" href="#_subfunctions" class="code">function [Data,testsimple]=displ_xml(handles,t,root_uid,DataIn,heditxml)</a>
10290962 Data=DataIn;<span class="comment">%default</span>
10300963 <span class="keyword">if</span> ~isfield(Data,<span class="string">'CurrentUid'</span>)
10310964     Data.CurrentUid=[];
10320965 <span class="keyword">end</span>
10330966 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>);
10340967
10350968 <span class="comment">%display the current element</span>
10360969 root_element=get(t,root_uid);
10370970 uidparent=root_uid;
10380971 <span class="keyword">if</span> isfield(root_element,<span class="string">'name'</span>)
10390972     CurrentElement=root_element.name;
10400973     <span class="keyword">while</span> ~isequal(uidparent,1)<span class="comment">%while the first level has not been reached</span>
10410974         uidparent=parent(t,uidparent);
10420975         dirdat=get(t,uidparent);
10430976         <span class="keyword">if</span> isfield(dirdat,<span class="string">'name'</span>)                       
10440977             CurrentElement=[dirdat.name <span class="string">'/'</span> CurrentElement];
10450978         <span class="keyword">end</span>
10460979     <span class="keyword">end</span>
10470980     set(handles.CurrentElement,<span class="string">'String'</span>,CurrentElement)
10480981 <span class="keyword">end</span>
10490982 list_uid=children(t,root_uid);
10500983 <span class="comment">%case of a single element</span>
10510984 testsimple=0;
10520985 filedat=[];
10530986 <span class="keyword">if</span> ~isempty(list_uid)
10540987     filedat=get(t,list_uid(1))
10550988     <span class="keyword">if</span> isfield(filedat,<span class="string">'type'</span>) &amp; isequal(filedat.type,<span class="string">'chardata'</span>) &amp;isfield(filedat,<span class="string">'value'</span>)
10560989         testsimple=1;<span class="comment">%simple element</span>
10570990     <span class="keyword">end</span>
10580991 <span class="keyword">end</span>
10590992
10600993 <span class="comment">%attributes of the current element</span>
10610994 nbattrib= attributes(t,<span class="string">'length'</span>,root_uid);
10620995 testopen=0;
10630996 attr_col=[];
10640997 <span class="keyword">for</span> iattr=1:nbattrib
10650998     attr= attributes(t,<span class="string">'get'</span>,root_uid,iattr);
10660999     <span class="keyword">if</span> isequal(attr.key,<span class="string">'source'</span>)<span class="comment">% look for 'source' attribute</span>
10671000         <span class="keyword">if</span> isequal(attr.val,<span class="string">'file'</span>)<span class="comment">%if the source is 'file', look for the path and open it</span>
10681001            <span class="keyword">if</span> isfield(filedat,<span class="string">'type'</span>) &amp; isequal(filedat.type,<span class="string">'chardata'</span>) &amp;isfield(filedat,<span class="string">'value'</span>)
10691002                cur_file=filedat.value;
10701003                uidparent=root_uid;<span class="comment">%initialization</span>
10711004                <span class="keyword">while</span> ~isequal(uidparent,1)<span class="comment">%while the first level has not been reached</span>
10721005                     uidparent=parent(t,uidparent);
10731006                     dirdat=get(t,uidparent);
10741007                     <span class="keyword">if</span> isfield(dirdat,<span class="string">'type'</span>) &amp; isequal(dirdat.type,<span class="string">'element'</span>) &amp; isfield(dirdat,<span class="string">'name'</span>)
10751008                         nbattrib_up= attributes(t,<span class="string">'length'</span>,uidparent);
10761009                         <span class="keyword">for</span> iattr_up=1:nbattrib_up
10771010                             attr= attributes(t,<span class="string">'get'</span>,uidparent,iattr_up);
10781011 <span class="comment">%                             if isequal(attr.key,'source')&amp;isequal(attr.val,'directory')% look for 'source' attribute</span>
10791012                               <span class="keyword">if</span> isequal(attr.key,<span class="string">'DirName'</span>)
10801013                                  cur_file=fullfile(attr.val,cur_file);
10811014                              <span class="keyword">end</span>
10821015                         <span class="keyword">end</span>
10831016                     <span class="keyword">end</span>
10841017                <span class="keyword">end</span>
10851018                RootPath=fileparts(CurrentFile);<span class="comment">%path to the current .xml file</span>
10861019                cur_file=fullfile(RootPath,cur_file)
10871020                set(handles.CurrentAttributes,<span class="string">'UserData'</span>,cur_file)<span class="comment">%will be searched by uvmat</span>
10881021                [path,fil,ext]=fileparts(cur_file);
10891022                <span class="keyword">if</span> ~exist(cur_file,<span class="string">'file'</span>)
10901023                    <a href="warndlg_uvmat.html" class="code" title="function hwarn=warndlg_uvmat(warntext,title)">warndlg_uvmat</a>([<span class="string">'non-existent link file'</span> cur_file],<span class="string">'ERROR'</span>) <span class="comment">% A FAIRE: propose to updtate the .xml file</span>
10911024                    <span class="keyword">return</span>
10921025                <span class="keyword">elseif</span> isequal(ext,<span class="string">'.xml'</span>)
10931026                    <span class="keyword">if</span> ~isfield(Data,<span class="string">'UpFile'</span>)
10941027                        Data.UpFile={CurrentFile};
10951028                    <span class="keyword">else</span>
10961029                        Data.UpFile=[{CurrentFile};Data.UpFile];
10971030                    <span class="keyword">end</span>
10981031                    set(heditxml,<span class="string">'UserData'</span>,Data)
10991032                    set(handles.CurrentFile,<span class="string">'String'</span>,cur_file)
11001033                    <a href="#_sub7" class="code" title="subfunction CurrentFile_Callback(hObject, eventdata, handles)">CurrentFile_Callback</a>(handles.CurrentFile, [], handles)
11011034                <span class="keyword">else</span>
11021035                    <span class="keyword">if</span> isequal(get(heditxml,<span class="string">'Tag'</span>),<span class="string">'browser'</span>); <span class="comment">%if editxml has been called as a browser</span>
11031036                        set(heditxml,<span class="string">'Tag'</span>,<span class="string">'idle'</span>)<span class="comment">% signal for uvmat browser</span>
11041037                    <span class="keyword">else</span>
11051038                        <a href="uvmat.html" class="code" title="function varargout = uvmat(varargin)">uvmat</a>({cur_file}); <span class="comment">%open the link fiel with uvmat</span>
11061039                    <span class="keyword">end</span>
11071040                    <span class="keyword">return</span>
11081041                <span class="keyword">end</span>
11091042            <span class="keyword">end</span>
11101043        <span class="comment">%elseif isequal(attr.val,'dir') A FAIRE : check directory</span>
11111044        <span class="comment">%else A FAIRE: edit the element</span>
11121045         <span class="keyword">end</span> 
11131046     <span class="keyword">end</span>
11141047     attr_col=strvcat(attr_col,[attr.key <span class="string">' = '</span> attr.val]);
11151048 <span class="keyword">end</span>
11161049 set(handles.CurrentAttributes,<span class="string">'String'</span>,attr_col)
11171050
11181051 <span class="comment">%list subtree</span>
11191052 <span class="keyword">if</span> ~testsimple
11201053     list_element=[];
11211054 <span class="comment">%      Data.CurrentUid=[Data.CurrentUid root_uid]%record new current uid</span>
11221055     <span class="keyword">for</span> iline=1:length(list_uid)
11231056         element=get(t,list_uid(iline));
11241057         <span class="keyword">if</span> isfield(element,<span class="string">'type'</span>)&amp;isequal(element.type,<span class="string">'element'</span>)
11251058              list_element{iline,2}=element.name;
11261059              child_uid=children(t,list_uid(iline));
11271060              subelem=get(t,child_uid);
11281061              <span class="keyword">if</span> isfield(subelem,<span class="string">'type'</span>)&amp; isfield(subelem,<span class="string">'value'</span>) &amp; isequal(subelem.type,<span class="string">'chardata'</span>)
11291062                 data_read=subelem.value;
11301063                 list_element{iline,3}=[<span class="string">'= '</span> data_read];
11311064             <span class="keyword">end</span>
11321065             <span class="keyword">if</span> iscell(subelem)|(isfield(subelem,<span class="string">'type'</span>)&amp;isequal(subelem.type,<span class="string">'element'</span>))
11331066                 list_element{iline,1}=<span class="string">'+ '</span>;<span class="comment">%sign for subtree existence</span>
11341067             <span class="keyword">else</span>
11351068                 list_element{iline,1}=<span class="string">'  '</span>;
11361069             <span class="keyword">end</span>
11371070             nbattr=attributes(t,<span class="string">'length'</span>,list_uid(iline));
11381071             <span class="keyword">if</span> nbattr==1
11391072                 attr=attributes(t,<span class="string">'get'</span>,list_uid(iline));
11401073                 list_element{iline,4}=[attr.key <span class="string">'='</span>];
11411074                 list_element{iline,5}=attr.val;
11421075             <span class="keyword">elseif</span> nbattr&gt;1
11431076                 <span class="keyword">for</span> iattr=1:nbattr
11441077                     attr=attributes(t,<span class="string">'get'</span>,list_uid(iline),iattr);
11451078                     list_element{iline,2+2*iattr}=[attr.key <span class="string">'='</span>];
11461079                     list_element{iline,3+2*iattr}=attr.val;
11471080                 <span class="keyword">end</span>
11481081             <span class="keyword">end</span>
11491082         <span class="keyword">end</span>
11501083     <span class="keyword">end</span>
11511084     set(handles.list_element,<span class="string">'Value'</span>,1)<span class="comment">%select the first line of list_element by default</span>
11521085     set(handles.list_element,<span class="string">'String'</span>,<a href="cell2tab.html" class="code" title="function Tabchar=cell2tab(Tabcell,separator)">cell2tab</a>(list_element,<span class="string">' '</span>) )
11531086     list.uid=list_uid;
11541087     set(handles.list_element,<span class="string">'UserData'</span>,list)
11551088 <span class="keyword">end</span>
11561089 <span class="comment">%---------------------------------------------------------</span>
11571090 <span class="comment">%-------------------------------------</span>
11581091 <span class="comment">%updates the interface</span>
11591092 <a name="_sub16" href="#_subfunctions" class="code">function update_ref_list(hh,xs_element,element,node,xs_subelem,subelem)</a>
11601093 <span class="comment">%-----------------------------</span>
11611094 pref_col=<span class="string">''</span>;
11621095 key_col=<span class="string">''</span>;
11631096 equal_sign=<span class="string">''</span>;
11641097 val_col=<span class="string">''</span>;
11651098 <span class="keyword">for</span> iline=1:length(subelem)
11661099     xsindex=subelem(iline).xsindex;
11671100     indexcur=subelem(iline).index;
11681101     subuid=subelem(iline).uid;
11691102         <span class="keyword">if</span> isempty(subuid)
11701103              RefDataIn.uid(iline)=0;
11711104         <span class="keyword">else</span>
11721105              RefDataIn.uid(iline)=subuid;
11731106         <span class="keyword">end</span>
11741107     index(iline)=indexcur;
11751108     node(iline)=xs_subelem(xsindex).node;
11761109 <span class="comment">%         testmanual(iline)=subelem(iline).testmanual;</span>
11771110     ikey=xs_subelem(xsindex).key;
11781111     <span class="keyword">if</span> xs_subelem(xsindex).testsub
11791112         ival=[<span class="string">' + '</span> subelem(iline).val];
11801113     <span class="keyword">else</span>
11811114         ival=[<span class="string">' = '</span> subelem(iline).val];
11821115     <span class="keyword">end</span>
11831116     key_col=strvcat(key_col,ikey);
11841117     val_col=strvcat(val_col,ival);
11851118 <span class="keyword">end</span>
11861119 RefDataIn.xs_uid=node;
11871120 list_element=[key_col val_col];
11881121 siztext=size(list_element);
11891122 set(hh,<span class="string">'Value'</span>,[1:siztext(1)])
11901123 set(hh,<span class="string">'String'</span>,list_element)
11911124 set(hh,<span class="string">'UserData'</span>,RefDataIn)
11921125
11931126 <span class="comment">%</span>
11941127 <span class="comment">% function RefFile_Callback(hObject, eventdata, handles)</span>
11951128 <span class="comment">% global t_ref xs</span>
11961129 <span class="comment">% t_ref=xmltree(get(hObject,'String'));%open the xml file fileinput</span>
11971130 <span class="comment">% heditxml=get(hObject,'parent');</span>
11981131 <span class="comment">% DataIn=get(get(hObject,'parent'),'UserData');</span>
11991132 <span class="comment">% % set(heditxml,'Units','pixel')</span>
12001133 <span class="comment">% figpos=get(heditxml,'Position')</span>
12011134 <span class="comment">% % title_element=get(handles.element_cur,'UserDataIn');</span>
12021135 <span class="comment">% % xs_node=xsnode_index(1,ind);</span>
12031136 <span class="comment">% % index_chosen=xsnode_index(2,ind);</span>
12041137 <span class="comment">% if isfield(DataIn,'fig_ref')&amp;ishandle(DataIn.fig_ref)</span>
12051138 <span class="comment">%     figure(DataIn.fig_ref);</span>
12061139 <span class="comment">% else</span>
12071140 <span class="comment">%     DataIn.fig_ref=figure;</span>
12081141 <span class="comment">% end</span>
12091142 <span class="comment">% set(DataIn.fig_ref,'Name',get(hObject,'String'))</span>
12101143 <span class="comment">% set(DataIn.fig_ref,'MenuBar','none')</span>
12111144 <span class="comment">% newfigpos=[figpos(1)+figpos(3) figpos(2)+0.4*figpos(4) 0.5*figpos(3) 0.3*figpos(4)];</span>
12121145 <span class="comment">% set(DataIn.fig_ref,'Units','normalized')</span>
12131146 <span class="comment">% set(DataIn.fig_ref,'Position',newfigpos)</span>
12141147 <span class="comment">% DataIn.h_ref=uicontrol('Style','listbox', 'Max',2,'Units','pixel','Position', [0 0 newfigpos(3) newfigpos(4)], ...</span>
12151148 <span class="comment">%         'FontName','FixedWidth','Tag','listbox');</span>
12161149 <span class="comment">% if isfield(DataIn,'xs_CurrentUid');</span>
12171150 <span class="comment">%     xs_CurrentUid=DataIn.xs_CurrentUid(end);</span>
12181151 <span class="comment">% else</span>
12191152 <span class="comment">%     DataIn.xs_CurrentUid=find(xs,'/xs:schema/xs:element');%uid of the root element in the schema</span>
12201153 <span class="comment">% end</span>
12211154 <span class="comment">% [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,xs_CurrentUid(end));</span>
12221155 <span class="comment">% xs_element.key</span>
12231156 <span class="comment">% tag0=find(t_ref,['/' path '/' xs_element.key]);</span>
12241157 <span class="comment">% if length(tag0)&gt;=1</span>
12251158 <span class="comment">%     CurrentRefNode=tag0(1);%chose the first occurence of the element</span>
12261159 <span class="comment">% else</span>
12271160 <span class="comment">%     CurrentRefNode=0;</span>
12281161 <span class="comment">% end</span>
12291162 <span class="comment">% [ref_element,ref_subelem]=get_xml(t_ref,path,xs_element,CurrentRefNode,xs_subelem);</span>
12301163 <span class="comment">% update_ref_list(DataIn.h_ref,xs_element,ref_element,CurrentRefNode,xs_subelem,ref_subelem);</span>
12311164 <span class="comment">% siztext=size(get(DataIn.h_ref,'String'));</span>
12321165 <span class="comment">% set(DataIn.h_ref,'Value',[1:siztext(1)]); %select the whole list by default</span>
12331166 <span class="comment">% set(heditxml,'UserData',DataIn)</span>
12341167 <span class="comment">% set(handles.ref_data,'Value',siztext(1)); %select the whole list by default</span>
12351168 <span class="comment">% 'TESTimport'</span>
12361169 <span class="comment">% title_element=get(handles.element_cur,'UserDataIn')</span>
12371170 <span class="comment">% xs_node=title_element.xsnode;%uid of the element in the schema</span>
12381171 <span class="comment">% node=title_element.node;</span>
12391172 <span class="comment">% t=flush(t,node);%removes the corresponding subtree in t</span>
12401173 <span class="comment">% [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,xs_node);%scan the schema</span>
12411174 <span class="comment">% tag0=find(t_import,['/' path '/' xs_element.key])</span>
12421175 <span class="comment">% if isempty(tag)</span>
12431176 <span class="comment">%     errordlg(['element /' path '/' xs_element.key ' not found in' fileinput])</span>
12441177 <span class="comment">%     return</span>
12451178 <span class="comment">% end</span>
12461179 <span class="comment">% % [element_import,node_import]=get_xml(t_import,path,xs_element,1,xs_subelem);% read the corresponding xml data</span>
12471180 <span class="comment">% node2_import=children(t_import,tag0);</span>
12481181 <span class="comment">% % t_import=branch(t_import,node_import);% extract branch of the new file</span>
12491182 <span class="comment">% % %removes the corresponding subtree in t</span>
12501183 <span class="comment">% for inode=1:length(node2_import)</span>
12511184 <span class="comment">%     struct=get(t_import,node2_import(inode))</span>
12521185 <span class="comment">%     if isfield(struct,'type') &amp; isfield(struct,'name')%if the node is an elmeent type</span>
12531186 <span class="comment">%         node3_import=children(t_import,node2_import(inode))</span>
12541187 <span class="comment">%        [t,newuid]=add(t,node,struct.type,struct.name);</span>
12551188 <span class="comment">%        for inode2=1:length(node3_import)</span>
12561189 <span class="comment">%            struct2=get(t_import,node3_import(inode2))</span>
12571190 <span class="comment">%            if isequal(struct2.type,'chardata')</span>
12581191 <span class="comment">%                 t=add(t,newuid,'chardata',struct2.value);</span>
12591192 <span class="comment">%             end</span>
12601193 <span class="comment">%         end</span>
12611194 <span class="comment">%     end</span>
12621195 <span class="comment">% end</span>
12631196 <span class="comment">% --- Executes on button press in replicate.</span>
12641197 <a name="_sub17" href="#_subfunctions" class="code">function replicate_Callback(hObject, eventdata, handles)</a>
12651198 <span class="keyword">global</span> xs  t
12661199
12671200 export_list=get(handles.export_list,<span class="string">'String'</span>);
12681201 export_val=get(handles.export_list,<span class="string">'UserData'</span>);
12691202 heditxml=get(handles.replicate,<span class="string">'parent'</span>);
12701203 Data=get(heditxml,<span class="string">'UserData'</span>)
12711204
12721205 hdataview=findobj(allchild(0),<span class="string">'Name'</span>,<span class="string">'dataview'</span>)
12731206 <span class="keyword">if</span> isempty(hdataview)
12741207     hdataview=<a href="dataview.html" class="code" title="function varargout = dataview(varargin)">dataview</a>;
12751208     <span class="keyword">return</span>
12761209 <span class="keyword">end</span>
12771210 hhdataview=guidata(hdataview);
12781211 CurrentPath=get(hhdataview.CurrentFile,<span class="string">'String'</span>);
12791212 ListExperiments=get(hhdataview.ListExperiments,<span class="string">'String'</span>);
12801213 Value=get(hhdataview.ListExperiments,<span class="string">'Value'</span>);
12811214 <span class="keyword">if</span> ~isequal(Value,1)
12821215     ListExperiments=ListExperiments(Value);
12831216 <span class="keyword">end</span>
12841217 ListDevices=get(hhdataview.ListDevices,<span class="string">'String'</span>);
12851218 Value=get(hhdataview.ListDevices,<span class="string">'Value'</span>);
12861219 <span class="keyword">if</span> ~isequal(Value,1)
12871220     ListDevices=ListDevices(Value);
12881221 <span class="keyword">end</span>
12891222 ListRecords=get(hhdataview.ListRecords,<span class="string">'String'</span>);
12901223 Value=get(hhdataview.ListRecords,<span class="string">'Value'</span>);
12911224 <span class="keyword">if</span> ~isequal(Value,1)
12921225     ListRecords=ListRecords(Value);
12931226 <span class="keyword">end</span>
12941227 <span class="comment">% uvmat('runplus_Callback',hObject,eventdata,handleshaxes)</span>
12951228 [ListDevices,ListRecords,ListXml,List]=<a href="ListDir.html" class="code" title="function [ListDevices,ListRecords,ListXml,List]=ListDir(CurrentPath,ListExperiments,ListDevices_in,ListRecords_in)">ListDir</a>(CurrentPath,ListExperiments,ListDevices,ListRecords);
12961229 ListXml=get(hhdataview.ListXml,<span class="string">'String'</span>);
12971230 Value=get(hhdataview.ListXml,<span class="string">'Value'</span>);
12981231 <span class="keyword">if</span> isequal(Value,1)
12991232     <a href="warndlg_uvmat.html" class="code" title="function hwarn=warndlg_uvmat(warntext,title)">warndlg_uvmat</a>(<span class="string">'you need to select the xml files to edit'</span>,<span class="string">'ERROR'</span>)
13001233     <span class="keyword">return</span>
13011234 <span class="keyword">end</span>
13021235 ListXml=ListXml(Value);<span class="comment">%list of</span>
13031236 <span class="keyword">for</span> iexp=1:length(List.Experiment)
13041237     ExpName=List.Experiment{iexp}.name;
13051238     <span class="keyword">if</span> isfield(List.Experiment{iexp},<span class="string">'Device'</span>)
13061239         <span class="keyword">for</span> idevice=1:length(List.Experiment{iexp}.Device)
13071240             DeviceName=List.Experiment{iexp}.Device{idevice}.name;       
13081241             <span class="keyword">if</span> isfield(List.Experiment{iexp}.Device{idevice},<span class="string">'xmlfile'</span>)
13091242                 <span class="keyword">for</span> ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile)
13101243                     FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml};
13111244                     <span class="keyword">for</span> ilistxml=1:length(ListXml)
13121245                         <span class="keyword">if</span> isequal(FileName,ListXml{ilistxml})
13131246                             xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName);
13141247                             t_export=xmltree(xmlfullname);
13151248                             rootelement=get(t_export,1,<span class="string">'name'</span>);
13161249                             uidlist=Data.CurrentUid;
13171250                             <span class="keyword">if</span> isequal(rootelement,get(t,1,<span class="string">'name'</span>))
13181251                                 backupfile=xmlfullname;
13191252                                 testexist=2;
13201253                                 <span class="keyword">while</span> testexist==2
13211254                                    backupfile=[backupfile <span class="string">'~'</span>];
13221255                                    testexist=exist(backupfile,<span class="string">'file'</span>);
13231256                                 <span class="keyword">end</span>
13241257                                 [success,message]=copyfile(xmlfullname,backupfile);<span class="comment">%make backup</span>
13251258                                 <span class="keyword">if</span> ~isequal(success,1)
13261259                                     <a href="warndlg_uvmat.html" class="code" title="function hwarn=warndlg_uvmat(warntext,title)">warndlg_uvmat</a>([<span class="string">'Error in the backup of '</span> xmlfullname],<span class="string">'ERROR'</span>)
13271260                                     <span class="keyword">return</span>
13281261                                 <span class="keyword">end</span>
13291262                                 findstr=[<span class="string">'/'</span> rootelement];
13301263                                 uid_export(1)=1;
13311264                                 <span class="comment">% fill the root elements if absent</span>
13321265                                 <span class="keyword">for</span> index=2:length(uidlist)
13331266                                     name_t=get(t,uidlist(index),<span class="string">'name'</span>)
13341267                                     findstr=[findstr <span class="string">'/'</span> name_t]
13351268                                     uid=find(t_export,findstr)
13361269                                     <span class="keyword">if</span> isempty(uid)
13371270                                         [t_export,uid_export(index)]=add(t_export,uid_export(index-1),<span class="string">'element'</span>,name_t);
13381271                                     <span class="keyword">else</span>
13391272                                         uid_export(index)=uid;
13401273                                     <span class="keyword">end</span>                           
13411274                                 <span class="keyword">end</span>
13421275                                 <span class="comment">% chardata......</span>
13431276                             <span class="keyword">end</span>
13441277                             <span class="keyword">break</span>
13451278                         <span class="keyword">end</span>
13461279                     <span class="keyword">end</span>
13471280 <span class="comment">%                     [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest);</span>
13481281 <span class="comment">%                     if test</span>
13491282 <span class="comment">%                         [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated']</span>
13501283 <span class="comment">%                     end</span>
13511284                 <span class="keyword">end</span>
13521285              <span class="keyword">elseif</span> isfield(List.Experiment{iexp}.Device{idevice},<span class="string">'Record'</span>)
13531286                 <span class="keyword">for</span> irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record)
13541287                     RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name;
13551288                     <span class="keyword">if</span> isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},<span class="string">'xmlfile'</span>)
13561289                         <span class="keyword">for</span> ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile)
13571290                             FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml};
13581291                             <span class="keyword">for</span> ilistxml=1:length(ListXml)
13591292                                 <span class="keyword">if</span> isequal(FileName,ListXml{ilistxml})
13601293                                     xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName)
13611294                                     <span class="keyword">break</span>
13621295                                 <span class="keyword">end</span>
13631296                             <span class="keyword">end</span>
13641297 <span class="comment">%                             [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest);</span>
13651298 <span class="comment">%                             if test</span>
13661299 <span class="comment">%                                 [FileName ' , Heading updated']</span>
13671300 <span class="comment">%                             end</span>
13681301                         <span class="keyword">end</span>
13691302                     <span class="keyword">end</span>
13701303                 <span class="keyword">end</span>
13711304             <span class="keyword">end</span>
13721305         <span class="keyword">end</span>
13731306     <span class="keyword">end</span>
13741307 <span class="keyword">end</span>
13751308 <span class="keyword">return</span>
13761309 <span class="comment">%%%%%%%%%%% A REVOIR</span>
13771310 <span class="comment">% Copier la liste des elements selectionnés dans dataview</span>
13781311 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span>
13791312 <span class="comment">%ANCIEN:</span>
13801313 heditxml=get(hObject,<span class="string">'parent'</span>);
13811314 DataIn=get(heditxml,<span class="string">'UserData'</span>);
13821315 <span class="keyword">if</span> ~isfield(DataIn,<span class="string">'h_ref'</span>)
13831316     DataIn.h_ref=[];
13841317 <span class="keyword">end</span>
13851318 <span class="keyword">if</span> ~ishandle(DataIn.h_ref)
13861319     errordlg(<span class="string">'no source file opened for import'</span>)
13871320     <span class="keyword">return</span>
13881321 <span class="keyword">end</span>
13891322 <span class="comment">%create the current root element if needed</span>
13901323 LengthElement=length(DataIn.CurrentUid);
13911324 FilledUid=find(DataIn.CurrentUid~=0);
13921325 LengthFilled=FilledUid(end);
13931326 <span class="keyword">for</span> irank=LengthFilled+1:LengthElement
13941327     attrib=attributes(xs,<span class="string">'get'</span>,DataIn.xs_CurrentUid(irank),1);
13951328     [t,DataIn.CurrentUid(irank)]=add(t,DataIn.CurrentUid(irank-1),<span class="string">'element'</span>,attrib.val);
13961329 <span class="keyword">end</span>
13971330
13981331 <span class="comment">%copy list of subelements</span>
13991332 RefDataIn=get(DataIn.h_ref,<span class="string">'UserData'</span>);
14001333 list=get(handles.list_element,<span class="string">'UserData'</span>);<span class="comment">%=,[node;index]</span>
14011334 <span class="keyword">for</span> ilist=get(DataIn.h_ref,<span class="string">'Value'</span>)
14021335     node_content=get(xs,RefDataIn.xs_uid(ilist));
14031336     <span class="keyword">if</span> ~isempty(node_content) &amp; isfield(node_content,<span class="string">'attributes'</span>)
14041337         attrib=node_content.attributes;
14051338         <span class="keyword">for</span> iattr=1:length(attrib)
14061339             struct=attrib{iattr};
14071340             <span class="keyword">if</span> isequal(struct.key,<span class="string">'name'</span>)
14081341                 key=struct.val; <span class="comment">% read element key name</span>
14091342             <span class="keyword">end</span>
14101343         <span class="keyword">end</span>
14111344     <span class="keyword">end</span>
14121345     value=<span class="string">''</span>;
14131346     <span class="keyword">if</span> ~isequal(RefDataIn.uid(ilist),0)
14141347         child_uid=children(t_ref,RefDataIn.uid(ilist));     
14151348         <span class="keyword">if</span> isequal(length(child_uid),1)
14161349             content=get(t_ref,child_uid);
14171350             <span class="keyword">if</span> isfield(content,<span class="string">'type'</span>) &amp;isfield(content,<span class="string">'value'</span>)&amp; isequal(content.type,<span class="string">'chardata'</span>)
14181351                 value=content.value;
14191352             <span class="keyword">end</span>
14201353         <span class="keyword">end</span>
14211354     <span class="keyword">end</span>
14221355     t=<a href="#_sub12" class="code" title="subfunction t=set_element(t,RootUid,node,key,value)">set_element</a>(t,DataIn.CurrentUid(end),list.uid(ilist),key,value);
14231356 <span class="keyword">end</span>
14241357 set(heditxml,<span class="string">'UserData'</span>,DataIn)
14251358 <span class="comment">%update the current listing</span>
14261359 [nodeup,path,xs_element,xs_subelem]=<a href="#_sub8" class="code" title="subfunction [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,nodeinput)">scan_schema</a>(xs,DataIn.xs_CurrentUid(end));
14271360 [element,subelem]=<a href="#_sub9" class="code" title="subfunction [element,subelem]=get_xml(t,path,xs_element,node,xs_subelem)">get_xml</a>(t,path,xs_element,DataIn.CurrentUid(end),xs_subelem);
14281361 <a href="#_sub10" class="code" title="subfunction update_list(handles,path,xs_element,element,node,xs_subelem,subelem)">update_list</a>(handles,path,xs_element,element,DataIn.CurrentUid(end),xs_subelem,subelem);
14291362 <span class="comment">% t=set_xml(t,xs_DataIn,subelem)</span>
14301363 <span class="comment">%edit list of subelments:</span>
14311364
14321365 <span class="comment">%A REVOIR</span>
14331366 <span class="comment">% xsnode_index=get(handles.list_element,'UserDataIn')</span>
14341367 <span class="comment">% xs_node=xsnode_index(1,ind);</span>
14351368 <span class="comment">% RefDataIn=get(handles.ref_data,'UserDataIn');</span>
14361369 <span class="comment">% subelem=RefDataIn.subelem;</span>
14371370 <span class="comment">% xsnode_index=get(handles.list_element,'UserDataIn');%data on the xs_nodes of the subelements</span>
14381371 <span class="comment">% ref_list=get(handles.ref_data,'Value');%selected indices in the list of reference subelements</span>
14391372 <span class="comment">% xs_node=xsnode_index(1,ref_list);%xs_nodes of the selected subelements</span>
14401373 <span class="comment">% % index_chosen=xsnode_index(2,ref_list);% indices in the list of occurence for a subelement</span>
14411374 <span class="comment">% % for ilist=ref_list</span>
14421375 <span class="comment">% ilist=1;</span>
14431376 <span class="comment">% while icontinue</span>
14441377 <span class="comment">%     'TESTCOPY'</span>
14451378 <span class="comment">%     [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,xs_node(ilist))</span>
14461379 <span class="comment">%     xs_subelem.key</span>
14471380 <span class="comment">%     tsub=subelem(ilist).tsub</span>
14481381 <span class="comment">%     xsnode_index(2,ilist)</span>
14491382 <span class="comment">%     [ref_elem,ref_node,ref_subelem]=get_xml(tsub,'',xs_element,1,xs_subelem)</span>
14501383 <span class="comment">%     ref_subelem.val</span>
14511384 <span class="comment">%     testedit= ~isfield(element.attrup,'source') | isequal(element.attrup.source,'manual') %| element vide</span>
14521385 <span class="comment">%</span>
14531386 <span class="comment">%</span>
14541387 <span class="comment">%     icontinue=0</span>
14551388 <span class="comment">% end</span>
14561389 <span class="comment">% function [element,node,subelem]=get_xml(t,path,xs_element,node,xs_subelem)</span>
14571390 <span class="comment">% element.attr_key='';%default</span>
14581391 <span class="comment">% element.attr_val='';%default</span>
14591392 <span class="comment">% element.val='';</span>
14601393 <span class="comment">% % element.type='';</span>
14611394 <span class="comment">% % element.testmanual=testmanual %inheritates the input manual editing flag by default</span>
14621395 <span class="comment">% subelem=[]; %default</span>
14631396 <span class="comment">% attrup=[];</span>
14641397 <span class="comment">% % node=[];</span>
14651398 <span class="comment">%</span>
14661399 <span class="comment">% % %find the element properties in the xml file</span>
14671400 <span class="comment">% if node &gt;= 1</span>
14681401 <span class="comment">%     elem_struct=get(t,node);</span>
14691402 <span class="comment">%     if ~xs_element.subtest</span>
14701403 <span class="comment">%         elem_contents=get(t,elem_struct.contents);</span>
14711404 <span class="comment">%         if isempty(elem_contents)</span>
14721405 <span class="comment">%             element.val=[];</span>
14731406 <span class="comment">%         else</span>
14741407 <span class="comment">%             element.val=elem_contents.value</span>
14751408 <span class="comment">%         end</span>
14761409 <span class="comment">%     end</span>
14771410 <span class="comment">%     if isfield(elem_struct,'attributes')</span>
14781411 <span class="comment">%         elem_attr=elem_struct.attributes;</span>
14791412 <span class="comment">%         for iattr=1:length(elem_attr)</span>
14801413 <span class="comment">%             element.attr_key{iattr}=elem_attr{iattr}.key ;</span>
14811414 <span class="comment">%             element.attr_val{iattr}=elem_attr{iattr}.val;</span>
14821415 <span class="comment">% %             attrup=setfield(attrup,elem_attr{iattr}.key,elem_attr{iattr}.val);</span>
14831416 <span class="comment">%            breakdetect=find(elem_attr{iattr}.key=='/'| elem_attr{iattr}.key==':'| elem_attr{iattr}.key=='.');% find '/'</span>
14841417 <span class="comment">%            if isempty(breakdetect)</span>
14851418 <span class="comment">% %                 comline=['attrup.' elem_attr{iattr}.key '=' elem_attr{iattr}.val ';']</span>
14861419 <span class="comment">%                 eval(['attrup.' elem_attr{iattr}.key '=''' elem_attr{iattr}.val ''';'])</span>
14871420 <span class="comment">%            end</span>
14881421 <span class="comment">%         end</span>
14891422 <span class="comment">%     end</span>
14901423 <span class="comment">% end</span>
14911424 <span class="comment">% %get the parent node attributes</span>
14921425 <span class="comment">% up=1</span>
14931426 <span class="comment">% if node&gt;0</span>
14941427 <span class="comment">%     nodeup=node;</span>
14951428 <span class="comment">%     while up==1;</span>
14961429 <span class="comment">%         nodeup=get(t,nodeup,'parent');%move up to the parent in the tree</span>
14971430 <span class="comment">%         if isempty(nodeup)</span>
14981431 <span class="comment">%             up=0;</span>
14991432 <span class="comment">%         else</span>
15001433 <span class="comment">%             nodeup_content=get(t,nodeup);</span>
15011434 <span class="comment">%             attrib=nodeup_content.attributes;</span>
15021435 <span class="comment">%             for iattr=1:length(attrib)</span>
15031436 <span class="comment">%                 key=attrib{iattr}.key;</span>
15041437 <span class="comment">%                 breakdetect=find(key=='/'| key==':'| key=='.');% find '/'</span>
15051438 <span class="comment">%                 if ~isfield(attrup,key) &amp; isempty(breakdetect)</span>
15061439 <span class="comment">%                    eval(['attrup.' key '=''' attrib{iattr}.val ''';'])</span>
15071440 <span class="comment">%                 end</span>
15081441 <span class="comment">%             end</span>
15091442 <span class="comment">%         end</span>
15101443 <span class="comment">%     end</span>
15111444 <span class="comment">%     element.attrup=attrup;</span>
15121445 <span class="comment">% end</span>
15131446 <span class="comment">% %find the subelement properties in the xml file</span>
15141447 <span class="comment">% if xs_element.subtest</span>
15151448 <span class="comment">%    iline=0;</span>
15161449 <span class="comment">%    for k=1:length(xs_subelem)%node2: list of subelements in the sub-sequence</span>
15171450 <span class="comment">% %     attr=attributes(xs,'get',node2(i),1);%</span>
15181451 <span class="comment">% %     element=attr.val;%name of the element</span>
15191452 <span class="comment">%      tag=find(t,['/' path '/' xs_element.key '/' xs_subelem(k).key]);%look for the corresponding element node in the .xml tree</span>
15201453 <span class="comment">%      struct_element=get(t,tag);%get the content of the element</span>
15211454 <span class="comment">%      if isempty(struct_element)</span>
15221455 <span class="comment">%          iline=iline+1;</span>
15231456 <span class="comment">%          subelem(iline).xsindex=k;</span>
15241457 <span class="comment">%          subelem(iline).index=0;</span>
15251458 <span class="comment">% %          subelem(iline).testmanual=element.testmanual;% inheritates the manual editing flag by default</span>
15261459 <span class="comment">%          if isequal(xs_subelem(k).minOccurs,0)</span>
15271460 <span class="comment">%              subelem(iline).val='[]';%element value not mandatory in the schema</span>
15281461 <span class="comment">%          else</span>
15291462 <span class="comment">%              subelem(iline).val='[MISSING]';%element value mandatory in the schema</span>
15301463 <span class="comment">%          end</span>
15311464 <span class="comment">% %          subelem(iline).attrup=attrup; %inheritated attributes</span>
15321465 <span class="comment">%      elseif isequal(length(struct_element),1)</span>
15331466 <span class="comment">%          contents=get(t,struct_element.contents);</span>
15341467 <span class="comment">%          iline=iline+1;</span>
15351468 <span class="comment">%          subelem(iline).xsindex=k;</span>
15361469 <span class="comment">%          subelem(iline).index=1;</span>
15371470 <span class="comment">% %          subelem(iline).testmanual=element.testmanual;%</span>
15381471 <span class="comment">%          if isfield(contents,'value') &amp; ~isempty(contents.value)</span>
15391472 <span class="comment">%              subelem(iline).val=contents.value;</span>
15401473 <span class="comment">%          elseif xs_subelem(k).testsub</span>
15411474 <span class="comment">%              subelem(iline).val='';</span>
15421475 <span class="comment">%          elseif isequal(xs_subelem(k).minOccurs,0)</span>
15431476 <span class="comment">%              subelem(iline).val='[]';%element value not mandatory in the schema</span>
15441477 <span class="comment">%          else</span>
15451478 <span class="comment">%              subelem(iline).val='[MISSING]';%element value mandatory in the schema</span>
15461479 <span class="comment">%          end</span>
15471480 <span class="comment">% %          subelem(iline).attrup=attrup; %inheritated attributes</span>
15481481 <span class="comment">%          if isfield(struct_element,'attributes')</span>
15491482 <span class="comment">%             element_attr=struct_element.attributes;</span>
15501483 <span class="comment">%             attr_display=[];</span>
15511484 <span class="comment">%             for iattr=1:length(element_attr)</span>
15521485 <span class="comment">% %                 attr_display{iline}=[attr_display ' , ' element_attr{iattr}.key '  =  ' element_attr{iattr}.val];</span>
15531486 <span class="comment">%                 subelem(iline).val=[subelem(iline).val attr_display ' , ' element_attr{iattr}.key '  =  ' element_attr{iattr}.val];</span>
15541487 <span class="comment">% %                 subelem(iline).attrup=setfield(subelem(iline).attrup,element_attr{iattr}.key,element_attr{iattr}.val);</span>
15551488 <span class="comment">%             end</span>
15561489 <span class="comment">%          end</span>
15571490 <span class="comment">%      else%case of a multiple element</span>
15581491 <span class="comment">%          for subindex=1:length(struct_element)</span>
15591492 <span class="comment">%              contents=get(t,struct_element{subindex}.contents);</span>
15601493 <span class="comment">%              iline=iline+1;</span>
15611494 <span class="comment">%              subelem(iline).index=subindex;%index of the element</span>
15621495 <span class="comment">%              subelem(iline).xsindex=k;</span>
15631496 <span class="comment">% %              subelem(iline).testmanual=element.testmanual;%</span>
15641497 <span class="comment">%              if isfield(contents,'value')&amp; ~isempty(contents.value)</span>
15651498 <span class="comment">%                  subelem(iline).val=contents.value;</span>
15661499 <span class="comment">%              elseif xs_subelem(k).testsub</span>
15671500 <span class="comment">%                  subelem(iline).val='';</span>
15681501 <span class="comment">%              else</span>
15691502 <span class="comment">%                  subelem(iline).val='[]';</span>
15701503 <span class="comment">%              end</span>
15711504 <span class="comment">% %              subelem(iline).attrup=attrup; %inheritated attributes</span>
15721505 <span class="comment">%              if isfield(struct_element{subindex},'attributes')</span>
15731506 <span class="comment">%                 element_attr=struct_element{subindex}.attributes;</span>
15741507 <span class="comment">%                 attr_display=[];</span>
15751508 <span class="comment">%                 for iattr=1:length(element_attr)</span>
15761509 <span class="comment">% %                     attr_display{iline}=[attr_display ' , ' element_attr{iattr}.key '  =  ' element_attr{iattr}.val];</span>
15771510 <span class="comment">%                     subelem(iline).val=[subelem(iline).val attr_display ' , ' element_attr{iattr}.key '  =  ' element_attr{iattr}.val];</span>
15781511 <span class="comment">% %                     subelem(iline).attrup=setfield(subelem(iline).attrup,element_attr{iattr}.key,element_attr{iattr}.val);</span>
15791512 <span class="comment">%                 end</span>
15801513 <span class="comment">%             end</span>
15811514 <span class="comment">%         end</span>
15821515 <span class="comment">%      end</span>
15831516 <span class="comment">%   end</span>
15841517 <span class="comment">% end</span>
15851518
15861519
15871520 <span class="comment">% --- Executes on button press in HELP.</span>
15881521 <a name="_sub18" href="#_subfunctions" class="code">function HELP_Callback(hObject, eventdata, handles)</a>
15891522 path_to_uvmat=which (<span class="string">'uvmat'</span>)<span class="comment">% check the path of uvmat</span>
15901523 pathelp=fileparts(path_to_uvmat);
15911524 helpfile=fullfile(pathelp,<span class="string">'UVMAT_DOC'</span>,<span class="string">'uvmat_doc.html'</span>);
15921525 <span class="keyword">if</span> isempty(dir(helpfile)), errordlg(<span class="string">'Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC'</span>)
15931526 <span class="keyword">else</span>
15941527 web([helpfile <span class="string">'#editxml'</span>])   
15951528 <span class="keyword">end</span>
15961529
15971530
15981531 <span class="comment">% --- Executes on button press in Export.</span>
15991532 <a name="_sub19" href="#_subfunctions" class="code">function Export_Callback(hObject, eventdata, handles)</a>
16001533 val=get(handles.Export,<span class="string">'Value'</span>);
16011534 <span class="keyword">if</span> val
16021535     set(handles.Export,<span class="string">'BackgroundColor'</span>,[0 1 0])
16031536     set(handles.export_list,<span class="string">'Visible'</span>,<span class="string">'on'</span>)
16041537     set(handles.replicate,<span class="string">'Visible'</span>,<span class="string">'on'</span>)
16051538     h_dataview=findobj(allchild(0),<span class="string">'name'</span>,<a href="dataview.html" class="code" title="function varargout = dataview(varargin)">dataview</a>');
16061539     <span class="keyword">if</span> isempty(h_dataview)
16071540        <span class="comment">% CurrentFile=get(handles.CurrentFile,'String');</span>
16081541         <a href="dataview.html" class="code" title="function varargout = dataview(varargin)">dataview</a>;
16091542     <span class="keyword">end</span>
16101543 <span class="keyword">else</span>
16111544      set(handles.Export,<span class="string">'BackgroundColor'</span>,[0.7 0.7 0.7])
16121545     set(handles.export_list,<span class="string">'Visible'</span>,<span class="string">'off'</span>)
16131546     set(handles.replicate,<span class="string">'Visible'</span>,<span class="string">'off'</span>)
16141547 <span class="keyword">end</span>
16151548
16161549
16171550 <span class="comment">% --- Executes on button press in pushbutton9.</span>
16181551 <a name="_sub20" href="#_subfunctions" class="code">function pushbutton9_Callback(hObject, eventdata, handles)</a>
16191552 <span class="comment">% hObject    handle to pushbutton9 (see GCBO)</span>
16201553 <span class="comment">% eventdata  reserved - to be defined in a future version of MATLAB</span>
16211554 <span class="comment">% handles    structure with handles and user data (see GUIDATA)</span>
16221555
16231556</pre></div>
1624<hr><address>Generated on Fri 13-Nov-2009 11:17:03 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
1625</body>
1626</html>
Note: See TracBrowser for help on using the repository browser.