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 © 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> > <a href="index.html">.</a> > editxml.m</div> |
---|
16 | |
---|
17 | <!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td> |
---|
18 | <td align="right"><a href="index.html">Index for . <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 | |
---|
34 | OUTPUT: heditxml: graphic handle of the GUI |
---|
35 | |
---|
36 | INPUT: inputfile: name of an xml file |
---|
37 | |
---|
38 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
39 | Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org. |
---|
40 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA |
---|
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. |
---|
52 | AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</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> |
---|
56 | This 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> |
---|
59 | This 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> |
---|
69 | 0002 <span class="comment">%------------------------------------------------------------------------</span> |
---|
70 | 0003 <span class="comment">% function heditxml=editxml(inputfile)</span> |
---|
71 | 0004 <span class="comment">%</span> |
---|
72 | 0005 <span class="comment">%OUTPUT: heditxml: graphic handle of the GUI</span> |
---|
73 | 0006 <span class="comment">%</span> |
---|
74 | 0007 <span class="comment">%INPUT: inputfile: name of an xml file</span> |
---|
75 | 0008 <span class="comment">%</span> |
---|
76 | 0009 <span class="comment">%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</span> |
---|
77 | 0010 <span class="comment">% Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.</span> |
---|
78 | 0011 <span class="comment">%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</span> |
---|
79 | 0012 <span class="comment">% This file is part of the toolbox UVMAT.</span> |
---|
80 | 0013 <span class="comment">%</span> |
---|
81 | 0014 <span class="comment">% UVMAT is free software; you can redistribute it and/or modify</span> |
---|
82 | 0015 <span class="comment">% it under the terms of the GNU General Public License as published by</span> |
---|
83 | 0016 <span class="comment">% the Free Software Foundation; either version 2 of the License, or</span> |
---|
84 | 0017 <span class="comment">% (at your option) any later version.</span> |
---|
85 | 0018 <span class="comment">%</span> |
---|
86 | 0019 <span class="comment">% UVMAT is distributed in the hope that it will be useful,</span> |
---|
87 | 0020 <span class="comment">% but WITHOUT ANY WARRANTY; without even the implied warranty of</span> |
---|
88 | 0021 <span class="comment">% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span> |
---|
89 | 0022 <span class="comment">% GNU General Public License (file UVMAT/COPYING.txt) for more details.</span> |
---|
90 | 0023 <span class="comment">%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA</span> |
---|
91 | 0024 |
---|
92 | 0025 <a name="_sub0" href="#_subfunctions" class="code">function varargout = editxml(varargin)</a> |
---|
93 | 0026 |
---|
94 | 0027 <span class="comment">% Begin initialization code - DO NOT EDIT</span> |
---|
95 | 0028 gui_Singleton = 1; |
---|
96 | 0029 gui_State = struct(<span class="string">'gui_Name'</span>, mfilename, <span class="keyword">...</span> |
---|
97 | 0030 <span class="string">'gui_Singleton'</span>, gui_Singleton, <span class="keyword">...</span> |
---|
98 | 0031 <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> |
---|
99 | 0032 <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> |
---|
100 | 0033 <span class="string">'gui_LayoutFcn'</span>, [] , <span class="keyword">...</span> |
---|
101 | 0034 <span class="string">'gui_Callback'</span>, []); |
---|
102 | 0035 <span class="keyword">if</span> nargin & isstr(varargin{1}) |
---|
103 | 0036 gui_State.gui_Callback = str2func(varargin{1}); |
---|
104 | 0037 <span class="keyword">end</span> |
---|
105 | 0038 |
---|
106 | 0039 <span class="keyword">if</span> nargout |
---|
107 | 0040 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); |
---|
108 | 0041 <span class="keyword">else</span> |
---|
109 | 0042 gui_mainfcn(gui_State, varargin{:}); |
---|
110 | 0043 <span class="keyword">end</span> |
---|
111 | 0044 <span class="comment">% End initialization code - DO NOT EDIT</span> |
---|
112 | 0045 |
---|
113 | 0046 |
---|
114 | 0047 <span class="comment">% --- Executes just before editxml is made visible.</span> |
---|
115 | 0048 <a name="_sub1" href="#_subfunctions" class="code">function editxml_OpeningFcn(hObject, eventdata, handles, varargin)</a> |
---|
116 | 0049 <span class="comment">% This function has no output args, see OutputFcn.</span> |
---|
117 | 0050 <span class="comment">% hObject handle to figure</span> |
---|
118 | 0051 <span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span> |
---|
119 | 0052 <span class="comment">% handles structure with handles and user data (see GUIDATA)</span> |
---|
120 | 0053 <span class="comment">% varargin command line arguments to editxml (see VARARGIN)</span> |
---|
121 | 0054 |
---|
122 | 0055 <span class="comment">% set(handles.replicate,'String',['copy';'<---'])</span> |
---|
123 | 0056 <span class="keyword">if</span> nargin |
---|
124 | 0057 CurrentFile=varargin{1} |
---|
125 | 0058 <span class="keyword">else</span> |
---|
126 | 0059 CurrentFile=[]; |
---|
127 | 0060 <span class="keyword">end</span> |
---|
128 | 0061 <span class="comment">% if exist('varargin') & length(varargin)>=1</span> |
---|
129 | 0062 <span class="comment">% CurrentFile=cell2mat(varargin{1});</span> |
---|
130 | 0063 <span class="comment">% else</span> |
---|
131 | 0064 <span class="comment">% CurrentFile=[];</span> |
---|
132 | 0065 <span class="comment">% end</span> |
---|
133 | 0066 <span class="comment">% Choose default command line output for editxml</span> |
---|
134 | 0067 handles.output = hObject; |
---|
135 | 0068 <span class="comment">% set(hObject,'Units','pixel')</span> |
---|
136 | 0069 <span class="keyword">if</span> exist(CurrentFile,<span class="string">'file'</span>) |
---|
137 | 0070 [PathName,Nme,FileExt]=fileparts(CurrentFile); |
---|
138 | 0071 <span class="keyword">if</span> isequal(FileExt,<span class="string">'.xls'</span>) |
---|
139 | 0072 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> |
---|
140 | 0073 DataIn.CurrentUid=1; |
---|
141 | 0074 figpos=get(hObject,<span class="string">'Position'</span>);<span class="comment">%position of the editxml interface</span> |
---|
142 | 0075 figposunit=get(hObject,<span class="string">'Units'</span>);<span class="comment">%unity used to indicate position</span> |
---|
143 | 0076 newfigpos=[figpos(1)-0.5*figpos(3) figpos(2) figpos(3) figpos(4)]; |
---|
144 | 0077 set(DataIn.hfig_xls,<span class="string">'Units'</span>,figposunit) |
---|
145 | 0078 set(DataIn.hfig_xls,<span class="string">'Position'</span>,newfigpos); <span class="comment">%set position of the Excel display figure</span> |
---|
146 | 0079 set(hObject,<span class="string">'UserData'</span>,DataIn) |
---|
147 | 0080 <span class="keyword">else</span> |
---|
148 | 0081 set(handles.CurrentFile,<span class="string">'String'</span>,CurrentFile) |
---|
149 | 0082 <a href="#_sub7" class="code" title="subfunction CurrentFile_Callback(hObject, eventdata, handles)">CurrentFile_Callback</a>(hObject, eventdata, handles) |
---|
150 | 0083 <span class="keyword">end</span> |
---|
151 | 0084 <span class="keyword">end</span> |
---|
152 | 0085 <span class="comment">% Update handles structure</span> |
---|
153 | 0086 guidata(hObject, handles); |
---|
154 | 0087 |
---|
155 | 0088 <span class="comment">%----------------------------------------------------------------</span> |
---|
156 | 0089 <span class="comment">% --- Outputs from this function are returned to the command line.</span> |
---|
157 | 0090 <a name="_sub2" href="#_subfunctions" class="code">function varargout = editxml_OutputFcn(hObject, eventdata, handles)</a> |
---|
158 | 0091 <span class="comment">% varargout cell array for returning output args (see VARARGOUT);</span> |
---|
159 | 0092 <span class="comment">% hObject handle to figure</span> |
---|
160 | 0093 <span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span> |
---|
161 | 0094 <span class="comment">% handles structure with handles and user data (see GUIDATA)</span> |
---|
162 | 0095 |
---|
163 | 0096 <span class="comment">% Get default command line output from handles structure</span> |
---|
164 | 0097 varargout{1} = handles.output; |
---|
165 | 0098 |
---|
166 | 0099 |
---|
167 | 0100 <span class="comment">% --- Executes on selection change in list_element.</span> |
---|
168 | 0101 <a name="_sub3" href="#_subfunctions" class="code">function list_element_Callback(hObject, eventdata, handles)</a> |
---|
169 | 0102 <span class="keyword">global</span> t xs t_ref |
---|
170 | 0103 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>); |
---|
171 | 0104 bla=get(hObject,<span class="string">'String'</span>); |
---|
172 | 0105 ind=get(hObject,<span class="string">'Value'</span>); |
---|
173 | 0106 list=get(hObject,<span class="string">'UserData'</span>); |
---|
174 | 0107 NewRootUid=list.uid(ind); |
---|
175 | 0108 heditxml=get(hObject,<span class="string">'Parent'</span>); |
---|
176 | 0109 DataIn=get(heditxml,<span class="string">'UserData'</span>); |
---|
177 | 0110 <span class="keyword">if</span> ~isempty(xs) |
---|
178 | 0111 xs_node=list.xs_uid(ind);<span class="comment">%xs_node of the subelement #ind</span> |
---|
179 | 0112 [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); |
---|
180 | 0113 [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); |
---|
181 | 0114 <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); |
---|
182 | 0115 <span class="keyword">if</span> xs_element.subtest |
---|
183 | 0116 DataIn.CurrentUid=[DataIn.CurrentUid NewRootUid];<span class="comment">%record new current uid</span> |
---|
184 | 0117 DataIn.xs_CurrentUid=[DataIn.xs_CurrentUid xs_node];<span class="comment">%record the new curent schema uid</span> |
---|
185 | 0118 <span class="keyword">end</span> |
---|
186 | 0119 |
---|
187 | 0120 <span class="comment">% %update the import file display</span> |
---|
188 | 0121 <span class="comment">% if isfield(DataIn,'h_ref')&ishandle(DataIn.h_ref)</span> |
---|
189 | 0122 <span class="comment">% tag0_ref=find(t_ref,['/' path '/' xs_element.key]);</span> |
---|
190 | 0123 <span class="comment">% node_ref=list.index(ind);</span> |
---|
191 | 0124 <span class="comment">% if length(tag0_ref)<node_ref</span> |
---|
192 | 0125 <span class="comment">% node_ref=length(tag0_ref);</span> |
---|
193 | 0126 <span class="comment">% end</span> |
---|
194 | 0127 <span class="comment">% [ref_element,ref_subelem]=get_xml(t_ref,path,xs_element,node_ref,xs_subelem);</span> |
---|
195 | 0128 <span class="comment">% update_ref_list(DataIn.h_ref,xs_element,ref_element,node_ref,xs_subelem,ref_subelem);</span> |
---|
196 | 0129 <span class="comment">% end</span> |
---|
197 | 0130 set(get(hObject,<span class="string">'Parent'</span>),<span class="string">'UserData'</span>,DataIn); |
---|
198 | 0131 <span class="keyword">else</span><span class="comment">%no schema</span> |
---|
199 | 0132 [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>)); |
---|
200 | 0133 <span class="keyword">if</span> ~testsimple |
---|
201 | 0134 DataIn.CurrentUid=[DataIn.CurrentUid NewRootUid];<span class="comment">%record new current uid</span> |
---|
202 | 0135 set(get(hObject,<span class="string">'Parent'</span>),<span class="string">'UserData'</span>,DataIn); |
---|
203 | 0136 <span class="keyword">end</span> |
---|
204 | 0137 <span class="keyword">end</span> |
---|
205 | 0138 |
---|
206 | 0139 <span class="comment">%-------------------------------------------------</span> |
---|
207 | 0140 <span class="comment">% --- Executes on button press in move_up.</span> |
---|
208 | 0141 <a name="_sub4" href="#_subfunctions" class="code">function move_up_Callback(hObject, eventdata, handles)</a> |
---|
209 | 0142 <span class="keyword">global</span> t xs t_ref |
---|
210 | 0143 set(handles.export_list,<span class="string">'Value'</span>,1);<span class="comment">%</span> |
---|
211 | 0144 set(handles.export_list,<span class="string">'String'</span>,<span class="string">''</span>);<span class="comment">% empty the export list</span> |
---|
212 | 0145 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>); |
---|
213 | 0146 CurrentElement=get(handles.CurrentElement,<span class="string">'String'</span>); |
---|
214 | 0147 heditxml=get(handles.move_up,<span class="string">'parent'</span>); |
---|
215 | 0148 test_root=0; |
---|
216 | 0149 DataIn=get(heditxml,<span class="string">'UserData'</span>); |
---|
217 | 0150 <span class="keyword">if</span> isfield(DataIn,<span class="string">'CurrentUid'</span>)&length(DataIn.CurrentUid)>1 |
---|
218 | 0151 nodeup=DataIn.CurrentUid(end-1); |
---|
219 | 0152 DataIn.CurrentUid(end)=[]; |
---|
220 | 0153 <span class="keyword">else</span> |
---|
221 | 0154 nodeup=[]; |
---|
222 | 0155 <span class="keyword">end</span> |
---|
223 | 0156 <span class="keyword">if</span> isempty(xs) |
---|
224 | 0157 <span class="keyword">if</span> isempty(nodeup) |
---|
225 | 0158 test_root=1; |
---|
226 | 0159 <span class="keyword">else</span> |
---|
227 | 0160 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); |
---|
228 | 0161 <span class="keyword">end</span> |
---|
229 | 0162 <span class="keyword">else</span> |
---|
230 | 0163 xs_nodeup=[]; |
---|
231 | 0164 <span class="comment">% if isfield(DataIn,'xs_UpUid')</span> |
---|
232 | 0165 <span class="keyword">if</span> isfield(DataIn,<span class="string">'xs_CurrentUid'</span>)&length(DataIn.xs_CurrentUid)>1 |
---|
233 | 0166 <span class="comment">% xs_nodeup=DataIn.xs_UpUid</span> |
---|
234 | 0167 xs_nodeup=DataIn.xs_CurrentUid(end-1); |
---|
235 | 0168 DataIn.xs_CurrentUid(end)=[];<span class="comment">%uid of the root element in the schema</span> |
---|
236 | 0169 <span class="keyword">end</span> |
---|
237 | 0170 <span class="keyword">if</span> isempty(xs_nodeup) |
---|
238 | 0171 test_root=1; |
---|
239 | 0172 <span class="keyword">else</span> |
---|
240 | 0173 [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); |
---|
241 | 0174 [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); |
---|
242 | 0175 <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); |
---|
243 | 0176 <span class="comment">%update the import file display</span> |
---|
244 | 0177 <span class="keyword">if</span> isfield(DataIn,<span class="string">'h_ref'</span>)&ishandle(DataIn.h_ref) |
---|
245 | 0178 [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); |
---|
246 | 0179 <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); |
---|
247 | 0180 <span class="keyword">end</span> |
---|
248 | 0181 <span class="keyword">end</span> |
---|
249 | 0182 set(get(hObject,<span class="string">'parent'</span>),<span class="string">'UserData'</span>,DataIn); |
---|
250 | 0183 <span class="keyword">end</span> |
---|
251 | 0184 <span class="keyword">if</span> test_root<span class="comment">% we are a the root,</span> |
---|
252 | 0185 testupfile=0; |
---|
253 | 0186 DataIn=get(get(hObject,<span class="string">'parent'</span>),<span class="string">'UserData'</span>); |
---|
254 | 0187 <span class="keyword">if</span> isfield(DataIn,<span class="string">'UpFile'</span>)&~isempty(DataIn.UpFile) |
---|
255 | 0188 [UpPath,UpName,UpExt]=fileparts(DataIn.UpFile{1}); |
---|
256 | 0189 <span class="keyword">if</span> isequal(UpExt,<span class="string">'.xml'</span>) |
---|
257 | 0190 set(handles.CurrentFile,<span class="string">'String'</span>,DataIn.UpFile{1}) |
---|
258 | 0191 <a href="#_sub7" class="code" title="subfunction CurrentFile_Callback(hObject, eventdata, handles)">CurrentFile_Callback</a>(handles.CurrentFile,[],handles) |
---|
259 | 0192 testupfile=1; |
---|
260 | 0193 DataIn.UpFile{1}={}; |
---|
261 | 0194 <span class="keyword">end</span> |
---|
262 | 0195 <span class="keyword">end</span> |
---|
263 | 0196 <span class="keyword">if</span> ~testupfile <span class="comment">%open the browser</span> |
---|
264 | 0197 RootPath=fileparts(CurrentFile); |
---|
265 | 0198 [FileName, PathName]=uigetfile( <span class="keyword">...</span> |
---|
266 | 0199 {<span class="string">'*.xml'</span>, <span class="string">'(*.xml)'</span>; |
---|
267 | 0200 <span class="string">'*.xml'</span>, <span class="string">'.xml files '</span>; <span class="keyword">...</span> |
---|
268 | 0201 <span class="string">'*.*'</span>, <span class="string">'All Files (*.*)'</span>}, <span class="keyword">...</span> |
---|
269 | 0202 <span class="string">'Pick a file'</span>,RootPath); <span class="comment">%file browser</span> |
---|
270 | 0203 fileinput_new=fullfile(PathName,FileName); |
---|
271 | 0204 set(handles.CurrentFile,<span class="string">'String'</span>,fileinput_new) |
---|
272 | 0205 <a href="#_sub7" class="code" title="subfunction CurrentFile_Callback(hObject, eventdata, handles)">CurrentFile_Callback</a>(handles.CurrentFile,[],handles) |
---|
273 | 0206 <span class="keyword">end</span> |
---|
274 | 0207 <span class="keyword">end</span> |
---|
275 | 0208 set(heditxml,<span class="string">'UserData'</span>,DataIn); |
---|
276 | 0209 <span class="comment">%---------------------------------------------------------</span> |
---|
277 | 0210 <span class="comment">%edit element value</span> |
---|
278 | 0211 <a name="_sub5" href="#_subfunctions" class="code">function element_value_Callback(hObject, eventdata, handles)</a> |
---|
279 | 0212 <span class="comment">%----------------------------------------------------------</span> |
---|
280 | 0213 <span class="keyword">global</span> t xs |
---|
281 | 0214 <span class="keyword">if</span> isequal(get(handles.element_value,<span class="string">'ForegroundColor'</span>),[0.7 0.7 0.7]) |
---|
282 | 0215 <span class="keyword">return</span><span class="comment">% edit element desactivated (grey display)</span> |
---|
283 | 0216 <span class="keyword">end</span> |
---|
284 | 0217 list_enum=get(handles.element_value,<span class="string">'String'</span>); |
---|
285 | 0218 list_index=get(handles.element_value,<span class="string">'Value'</span>); |
---|
286 | 0219 <span class="keyword">if</span> iscell(list_enum) |
---|
287 | 0220 value=list_enum{list_index}; |
---|
288 | 0221 <span class="keyword">else</span> |
---|
289 | 0222 value=list_enum; |
---|
290 | 0223 <span class="keyword">end</span> |
---|
291 | 0224 heditxml=get(handles.element_value,<span class="string">'Parent'</span>); |
---|
292 | 0225 DataIn=get(heditxml,<span class="string">'UserData'</span>); |
---|
293 | 0226 <span class="comment">%create the current root element if needed</span> |
---|
294 | 0227 LengthElement=length(DataIn.CurrentUid); |
---|
295 | 0228 FilledUid=find(DataIn.CurrentUid~=0); |
---|
296 | 0229 LengthFilled=FilledUid(end); |
---|
297 | 0230 <span class="keyword">for</span> irank=LengthFilled+1:LengthElement |
---|
298 | 0231 attrib=attributes(xs,<span class="string">'get'</span>,DataIn.xs_CurrentUid(irank),1); |
---|
299 | 0232 [t,DataIn.CurrentUid(irank)]=add(t,DataIn.CurrentUid(irank-1),<span class="string">'element'</span>,attrib.val); |
---|
300 | 0233 <span class="keyword">end</span> |
---|
301 | 0234 node_element=get(handles.element_value,<span class="string">'UserData'</span>); |
---|
302 | 0235 element_key=get(handles.element_key,<span class="string">'String'</span>); |
---|
303 | 0236 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); |
---|
304 | 0237 |
---|
305 | 0238 set(heditxml,<span class="string">'UserData'</span>,DataIn) |
---|
306 | 0239 <span class="comment">%update the current listing</span> |
---|
307 | 0240 [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)); |
---|
308 | 0241 [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); |
---|
309 | 0242 element_index=get(handles.list_element,<span class="string">'Value'</span>); |
---|
310 | 0243 <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); |
---|
311 | 0244 set(handles.list_element,<span class="string">'Value'</span>,element_index); |
---|
312 | 0245 |
---|
313 | 0246 <span class="comment">%</span> |
---|
314 | 0247 <span class="comment">% % --- Executes on button press in inport_file.</span> |
---|
315 | 0248 <span class="comment">% function inport_file_Callback(hObject, eventdata, handles)</span> |
---|
316 | 0249 <span class="comment">% CurrentFile=get(handles.RefFile,'String');</span> |
---|
317 | 0250 <span class="comment">% if isempty(CurrentFile)|isequal(CurrentFile,'')</span> |
---|
318 | 0251 <span class="comment">% CurrentFile=get(handles.CurrentFile,'String')</span> |
---|
319 | 0252 <span class="comment">% end</span> |
---|
320 | 0253 <span class="comment">% [FileName, PathName]=uigetfile( ...</span> |
---|
321 | 0254 <span class="comment">% {'*.xml', '(*.xml)';</span> |
---|
322 | 0255 <span class="comment">% '*.xml', '.xml files '; ...</span> |
---|
323 | 0256 <span class="comment">% '*.*', 'All Files (*.*)'}, ...</span> |
---|
324 | 0257 <span class="comment">% 'Pick a file',CurrentFile); %file browser</span> |
---|
325 | 0258 <span class="comment">% fileinput=fullfile(PathName,FileName);</span> |
---|
326 | 0259 <span class="comment">% sizf=size(fileinput);</span> |
---|
327 | 0260 <span class="comment">% if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end% keep only character strings as input file name</span> |
---|
328 | 0261 <span class="comment">% if exist(fileinput,'file')</span> |
---|
329 | 0262 <span class="comment">% set(handles.RefFile,'Visible','on')</span> |
---|
330 | 0263 <span class="comment">% set(handles.replicate,'Visible','on')</span> |
---|
331 | 0264 <span class="comment">% set(handles.RefFile,'String',fileinput)</span> |
---|
332 | 0265 <span class="comment">% RefFile_Callback(handles.RefFile, eventdata, handles)</span> |
---|
333 | 0266 <span class="comment">% end</span> |
---|
334 | 0267 |
---|
335 | 0268 |
---|
336 | 0269 <span class="comment">%------------------------------------------------------</span> |
---|
337 | 0270 <span class="comment">% --- Executes on button press in browser.</span> |
---|
338 | 0271 <a name="_sub6" href="#_subfunctions" class="code">function browser_Callback(hObject, eventdata, handles)</a> |
---|
339 | 0272 <span class="comment">%-------------------------------------------------------</span> |
---|
340 | 0273 heditxml=get(hObject,<span class="string">'parent'</span>);<span class="comment">%handle of the interface figure</span> |
---|
341 | 0274 DataIn=get(heditxml,<span class="string">'UserData'</span>);<span class="comment">%get the current input xml file</span> |
---|
342 | 0275 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>); |
---|
343 | 0276 DataIn.Schema=[];<span class="comment">%schema input file put to [] by default</span> |
---|
344 | 0277 [FileName, PathName]=uigetfile( <span class="keyword">...</span> |
---|
345 | 0278 {<span class="string">'*.xml;*.xls'</span>,<span class="string">'(*.xml,*.xls)'</span>; |
---|
346 | 0279 <span class="string">'*.xml'</span>, <span class="string">'.xml files '</span>; <span class="keyword">...</span> |
---|
347 | 0280 <span class="string">'*.xls'</span>, <span class="string">'.xls files '</span>; <span class="keyword">...</span> |
---|
348 | 0281 <span class="string">'*.*'</span>, <span class="string">'All Files (*.*)'</span>}, <span class="keyword">...</span> |
---|
349 | 0282 <span class="string">'Pick a file'</span>,CurrentFile); <span class="comment">%file browser</span> |
---|
350 | 0283 CurrentFile=fullfile(PathName,FileName); |
---|
351 | 0284 sizf=size(CurrentFile); |
---|
352 | 0285 <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> |
---|
353 | 0286 <span class="keyword">if</span> exist(CurrentFile,<span class="string">'file'</span>) |
---|
354 | 0287 <span class="comment">% set(handles.CurrentAttributes,'UserDataIn',PathName); %store the path to the xml file</span> |
---|
355 | 0288 [CurPath,CurName,CurExt]=fileparts(CurrentFile); |
---|
356 | 0289 <span class="keyword">if</span> isequal(CurExt,<span class="string">'.xls'</span>) |
---|
357 | 0290 <span class="keyword">if</span> isfield(DataIn,<span class="string">'hfig_xls'</span>)&ishandle(DataIn.hfig_xls) |
---|
358 | 0291 [hfig_xls]=<a href="read_xls.html" class="code" title="function [hfig_xls]=read_xls(fileinput,hfig)">read_xls</a>(CurrentFile,DataIn.hfig_xls); |
---|
359 | 0292 <span class="keyword">else</span> |
---|
360 | 0293 [hfig_xls]=<a href="read_xls.html" class="code" title="function [hfig_xls]=read_xls(fileinput,hfig)">read_xls</a>(CurrentFile); |
---|
361 | 0294 <span class="keyword">end</span> |
---|
362 | 0295 figpos=get(heditxml,<span class="string">'Position'</span>); |
---|
363 | 0296 newfigpos=[figpos(1)-0.25*figpos(3) figpos(2) 0.5*figpos(3) 0.5*figpos(4)]; |
---|
364 | 0297 set(hfig_xls,<span class="string">'Position'</span>,newfigpos) |
---|
365 | 0298 <span class="keyword">else</span> |
---|
366 | 0299 set(handles.CurrentFile,<span class="string">'String'</span>,CurrentFile) |
---|
367 | 0300 <a href="#_sub7" class="code" title="subfunction CurrentFile_Callback(hObject, eventdata, handles)">CurrentFile_Callback</a>(hObject, eventdata, handles) |
---|
368 | 0301 <span class="keyword">end</span> |
---|
369 | 0302 <span class="keyword">end</span> |
---|
370 | 0303 |
---|
371 | 0304 <span class="comment">%------------------------------------</span> |
---|
372 | 0305 <a name="_sub7" href="#_subfunctions" class="code">function CurrentFile_Callback(hObject, eventdata, handles)</a> |
---|
373 | 0306 <span class="keyword">global</span> t xs |
---|
374 | 0307 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>); |
---|
375 | 0308 heditxml=get(handles.CurrentFile,<span class="string">'parent'</span>);<span class="comment">%handles of the inteface</span> |
---|
376 | 0309 DataIn=get(heditxml,<span class="string">'UserData'</span>); |
---|
377 | 0310 t=xmltree(CurrentFile);<span class="comment">%open the xml file</span> |
---|
378 | 0311 head_element=get(t,1); |
---|
379 | 0312 <span class="keyword">if</span> ~isfield(head_element,<span class="string">'name'</span>) | ~isfield(head_element,<span class="string">'attributes'</span>) |
---|
380 | 0313 <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>) |
---|
381 | 0314 <span class="keyword">end</span> |
---|
382 | 0315 head_name=head_element.name; |
---|
383 | 0316 head_attr=head_element.attributes;<span class="comment">% attribute of root gives the name of the associated schema</span> |
---|
384 | 0317 xstest=0; |
---|
385 | 0318 <span class="keyword">for</span> iattr=1:length(head_attr) |
---|
386 | 0319 <span class="keyword">if</span> isequal(head_attr{iattr}.key,<span class="string">'xmlns:xsi'</span>)& isequal(head_attr{iattr}.val,<span class="string">'none'</span>)<span class="comment">%no schema to read</span> |
---|
387 | 0320 xs=[]; |
---|
388 | 0321 <span class="comment">% xstest=1;</span> |
---|
389 | 0322 <span class="keyword">end</span> |
---|
390 | 0323 <span class="keyword">if</span> isequal(head_attr{iattr}.key,<span class="string">'xsi:noNamespaceSchemaLocation'</span>) & exist(head_attr{iattr}.val,<span class="string">'file'</span>) |
---|
391 | 0324 DataIn.Schema=head_attr{iattr}.val; |
---|
392 | 0325 xs=xmltree(DataIn.Schema);<span class="comment">%open the associated schema file</span> |
---|
393 | 0326 xstest=1; |
---|
394 | 0327 <span class="keyword">end</span> |
---|
395 | 0328 <span class="keyword">end</span> |
---|
396 | 0329 <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> |
---|
397 | 0330 head_name=get(t,1,<span class="string">'name'</span>); |
---|
398 | 0331 <span class="comment">%Path to shemas:</span> |
---|
399 | 0332 path_uvmat=which(<span class="string">'editxml'</span>);<span class="comment">% check the path detected for source file uvmat</span> |
---|
400 | 0333 path_UVMAT=fileparts(path_uvmat); <span class="comment">%path to UVMAT</span> |
---|
401 | 0334 <span class="keyword">if</span> isunix |
---|
402 | 0335 xmlparam=fullfile(path_UVMAT,<span class="string">'PARAM_LINUX.xml'</span>) |
---|
403 | 0336 <span class="keyword">if</span> exist(xmlparam,<span class="string">'file'</span>) |
---|
404 | 0337 tparam=xmltree(xmlparam); |
---|
405 | 0338 sparam=convert(tparam); |
---|
406 | 0339 <span class="keyword">if</span> isfield(sparam,<span class="string">'SchemaPath'</span>) |
---|
407 | 0340 schemapath=[fullfile(sparam.SchemaPath,head_name) <span class="string">'.xsd'</span>] |
---|
408 | 0341 <span class="keyword">end</span> |
---|
409 | 0342 <span class="keyword">end</span> |
---|
410 | 0343 <span class="comment">% schemapath=['/coriolis/papillon/data/civbin/XML_SCHEMAS/' head_name '.xsd']%current dir for schema</span> |
---|
411 | 0344 <span class="keyword">else</span> |
---|
412 | 0345 xmlparam=fullfile(path_UVMAT,<span class="string">'PARAM_WIN.xml'</span>) |
---|
413 | 0346 <span class="keyword">if</span> exist(xmlparam,<span class="string">'file'</span>) |
---|
414 | 0347 tparam=xmltree(xmlparam); |
---|
415 | 0348 sparam=convert(tparam) |
---|
416 | 0349 <span class="keyword">if</span> isfield(sparam,<span class="string">'SchemaPath'</span>) |
---|
417 | 0350 schemapath=[fullfile(sparam.SchemaPath,head_name) <span class="string">'.xsd'</span>] |
---|
418 | 0351 <span class="keyword">end</span> |
---|
419 | 0352 <span class="keyword">end</span> |
---|
420 | 0353 <span class="comment">% schemapath=['\\Papillon\data\civbin\XML_SCHEMAS\' head_name '.xsd']%current dir for schemas</span> |
---|
421 | 0354 <span class="keyword">end</span> |
---|
422 | 0355 <span class="keyword">if</span> exist(schemapath,<span class="string">'file'</span>) |
---|
423 | 0356 xs=xmltree(schemapath); |
---|
424 | 0357 <span class="keyword">else</span> |
---|
425 | 0358 <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>) |
---|
426 | 0359 [FileName, PathName]=uigetfile( <span class="keyword">...</span> |
---|
427 | 0360 {<span class="string">'*.xsd'</span>, <span class="string">'(*.xsd)'</span>; |
---|
428 | 0361 <span class="string">'*.xsd'</span>, <span class="string">'.xsd files '</span>; <span class="keyword">...</span> |
---|
429 | 0362 <span class="string">'*.*'</span>, <span class="string">'All Files (*.*)'</span>}, <span class="keyword">...</span> |
---|
430 | 0363 [<span class="string">'Pick a .xsd schema'</span>] ,schemapath); <span class="comment">%file browser</span> |
---|
431 | 0364 <span class="keyword">if</span> ischar(PathName)&ischar(FileName)& exist(fullfile(PathName,FileName),<span class="string">'file'</span>) |
---|
432 | 0365 DataIn.Schema=fullfile(PathName,FileName); |
---|
433 | 0366 xs=xmltree(DataIn.Schema);<span class="comment">%open the associated schema file</span> |
---|
434 | 0367 <span class="keyword">else</span> |
---|
435 | 0368 xs=[]; |
---|
436 | 0369 <span class="keyword">end</span> |
---|
437 | 0370 <span class="keyword">end</span> |
---|
438 | 0371 <span class="keyword">end</span> |
---|
439 | 0372 DataIn.CurrentUid=1; |
---|
440 | 0373 <span class="keyword">if</span> isempty(xs) |
---|
441 | 0374 <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> |
---|
442 | 0375 <span class="comment">% set(handles.inport_file,'Visible','off')</span> |
---|
443 | 0376 <span class="comment">% set(handles.RefFile,'Visible','off')</span> |
---|
444 | 0377 <span class="keyword">else</span> |
---|
445 | 0378 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> |
---|
446 | 0379 [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> |
---|
447 | 0380 [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> |
---|
448 | 0381 <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> |
---|
449 | 0382 <span class="comment">% set(handles.inport_file,'Visible','on')</span> |
---|
450 | 0383 <span class="comment">% set(handles.RefFile,'Visible','on')</span> |
---|
451 | 0384 <span class="keyword">end</span> |
---|
452 | 0385 set(heditxml,<span class="string">'UserData'</span>,DataIn);<span class="comment">%store the new input xml file name</span> |
---|
453 | 0386 |
---|
454 | 0387 <span class="comment">%-------------------------------------------------------</span> |
---|
455 | 0388 <span class="comment">% function scan_schema: read the xml schema xs</span> |
---|
456 | 0389 <span class="comment">%--------------------------------------------------------</span> |
---|
457 | 0390 <span class="comment">%OUTPUT:</span> |
---|
458 | 0391 <span class="comment">%nodeup: parent node of nodeinput</span> |
---|
459 | 0392 <span class="comment">%path: path to nodeinput in the tree</span> |
---|
460 | 0393 <span class="comment">%xs_element: element corresponding to nodeinput</span> |
---|
461 | 0394 <span class="comment">%xs_element.uid, =tag of the element in the schema (=nodeinput)</span> |
---|
462 | 0395 <span class="comment">%xs_element.key: key label of nodeinput</span> |
---|
463 | 0396 <span class="comment">%xs_element.type: type of data contained in the element</span> |
---|
464 | 0397 <span class="comment">%xs_element.annot: annotation of nodeinput</span> |
---|
465 | 0398 <span class="comment">%xs_element.attrib: list of accepted attributes keys for xs_element</span> |
---|
466 | 0399 <span class="comment">%xs_element.enum: enumeration, list of accepted values for nodeinput</span> |
---|
467 | 0400 <span class="comment">%xs_element.subtest: =1 if the element contains subelements in the schema, 0 else</span> |
---|
468 | 0401 |
---|
469 | 0402 <span class="comment">%xs_subelement(k): subelement #k of xs_element</span> |
---|
470 | 0403 <span class="comment">%xs_subelem(k).node: node number in the schema</span> |
---|
471 | 0404 <span class="comment">%xs_subelem(k).key: key name of the element</span> |
---|
472 | 0405 <span class="comment">%xs_subelem(k).testsub: =1 if element contains subelements, 0 else</span> |
---|
473 | 0406 <span class="comment">%xs_subelem(k).minOccurs: =0 for a non mandatory element, =1 else</span> |
---|
474 | 0407 <span class="comment">%xs_subelem(k).maxOccurs</span> |
---|
475 | 0408 <span class="comment">%</span> |
---|
476 | 0409 <span class="comment">%INPUT:</span> |
---|
477 | 0410 <span class="comment">%xs: schema xml tree</span> |
---|
478 | 0411 <span class="comment">%nodeinput: tag of the current root element in the schema</span> |
---|
479 | 0412 <a name="_sub8" href="#_subfunctions" class="code">function [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,nodeinput)</a> |
---|
480 | 0413 nodeup=[]; |
---|
481 | 0414 path=[]; |
---|
482 | 0415 xs_element.key=[]; |
---|
483 | 0416 xs_element.type=[]; |
---|
484 | 0417 xs_element.annot=[]; |
---|
485 | 0418 xs_element.attrib=[]; |
---|
486 | 0419 xs_element.subtest=0; |
---|
487 | 0420 xs_element.enum={}; |
---|
488 | 0421 xs_subelem=[];<span class="comment">%default</span> |
---|
489 | 0422 <span class="comment">% get default nodeinput (root of the file) if not defined</span> |
---|
490 | 0423 <span class="keyword">if</span> ~exist(<span class="string">'nodeinput'</span>) | isempty(nodeinput)<span class="comment">% we start at the root</span> |
---|
491 | 0424 node=find(xs,<span class="string">'/xs:schema/xs:element'</span>);<span class="comment">%description of the root element</span> |
---|
492 | 0425 <span class="keyword">else</span> |
---|
493 | 0426 node=nodeinput; |
---|
494 | 0427 <span class="keyword">end</span> |
---|
495 | 0428 xs_element.uid=node; |
---|
496 | 0429 <span class="comment">%get the key name and element_type of the element</span> |
---|
497 | 0430 node_content=get(xs,node); |
---|
498 | 0431 <span class="keyword">if</span> isempty(node_content),<span class="keyword">return</span>,<span class="keyword">end</span>; |
---|
499 | 0432 <span class="keyword">if</span> ~isempty(node_content) & isfield(node_content,<span class="string">'attributes'</span>) |
---|
500 | 0433 attrib=node_content.attributes; |
---|
501 | 0434 <span class="keyword">for</span> iattr=1:length(attrib) |
---|
502 | 0435 struct=attrib{iattr}; |
---|
503 | 0436 <span class="keyword">if</span> isequal(struct.key,<span class="string">'name'</span>) |
---|
504 | 0437 xs_element.key=struct.val; <span class="comment">% read element key name</span> |
---|
505 | 0438 <span class="keyword">elseif</span> isequal(struct.key,<span class="string">'type'</span>) |
---|
506 | 0439 xs_element.type=struct.val; <span class="comment">% read element key name</span> |
---|
507 | 0440 <span class="keyword">end</span> |
---|
508 | 0441 <span class="keyword">end</span> |
---|
509 | 0442 <span class="keyword">end</span> |
---|
510 | 0443 |
---|
511 | 0444 <span class="comment">%get the parent node of nodeinput</span> |
---|
512 | 0445 <span class="keyword">if</span> ~isempty(node_content) |
---|
513 | 0446 nodeup=get(xs,node,<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span> |
---|
514 | 0447 <span class="keyword">if</span> ~isempty(nodeup) |
---|
515 | 0448 nodeup=get(xs,nodeup(1),<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span> |
---|
516 | 0449 <span class="keyword">if</span> isequal(nodeup,[]) |
---|
517 | 0450 <span class="comment">%OUVRIR FICHIER AMONT</span> |
---|
518 | 0451 up=0; |
---|
519 | 0452 <span class="keyword">else</span> |
---|
520 | 0453 nodeup=get(xs,nodeup(1),<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span> |
---|
521 | 0454 <span class="keyword">end</span> |
---|
522 | 0455 <span class="keyword">end</span> |
---|
523 | 0456 <span class="keyword">end</span> |
---|
524 | 0457 <span class="comment">%get the path to 'nodeinput' in the schema</span> |
---|
525 | 0458 up=1; |
---|
526 | 0459 path=[]; |
---|
527 | 0460 <span class="keyword">if</span> ~isempty(nodeup) |
---|
528 | 0461 attrib=attributes(xs,<span class="string">'get'</span>,nodeup,1); |
---|
529 | 0462 path=attrib.val; |
---|
530 | 0463 nodeup2=nodeup; |
---|
531 | 0464 <span class="keyword">while</span> up==1; |
---|
532 | 0465 nodeup2=get(xs,nodeup2(1),<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span> |
---|
533 | 0466 nodeup2=get(xs,nodeup2(1),<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span> |
---|
534 | 0467 <span class="keyword">if</span> isempty(nodeup2) |
---|
535 | 0468 up=0; |
---|
536 | 0469 <span class="keyword">else</span> |
---|
537 | 0470 nodeup2=get(xs,nodeup2(1),<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span> |
---|
538 | 0471 <span class="keyword">if</span> isempty(nodeup2) |
---|
539 | 0472 up=0; |
---|
540 | 0473 <span class="keyword">else</span> |
---|
541 | 0474 attrib=attributes(xs,<span class="string">'get'</span>,nodeup2,1); |
---|
542 | 0475 path=[attrib.val <span class="string">'/'</span> path]; |
---|
543 | 0476 <span class="keyword">end</span> |
---|
544 | 0477 <span class="keyword">end</span> |
---|
545 | 0478 <span class="keyword">end</span> |
---|
546 | 0479 <span class="keyword">end</span> |
---|
547 | 0480 |
---|
548 | 0481 <span class="comment">%explore the subtree in the schema file</span> |
---|
549 | 0482 node1=children(xs,node); <span class="comment">%find the children of the root element</span> |
---|
550 | 0483 test_sub=0; <span class="comment">%no subtree in the .xml file by default</span> |
---|
551 | 0484 comment=<span class="string">''</span>; |
---|
552 | 0485 element={}; |
---|
553 | 0486 minOccurs={}; |
---|
554 | 0487 maxOccurs={}; |
---|
555 | 0488 testsub={}; |
---|
556 | 0489 list_menu={}; |
---|
557 | 0490 text={}; |
---|
558 | 0491 <span class="keyword">if</span> ~isempty(node1) |
---|
559 | 0492 <span class="keyword">for</span> i=1:length(node1) |
---|
560 | 0493 nodename1=get(xs,node1(i),<span class="string">'name'</span>); |
---|
561 | 0494 node2=children(xs,node1(i)); |
---|
562 | 0495 <span class="keyword">if</span> isequal(nodename1,<span class="string">'xs:annotation'</span>) |
---|
563 | 0496 <span class="keyword">for</span> j=1:length(node2) |
---|
564 | 0497 nodename2=get(xs,node2(j),<span class="string">'name'</span>); |
---|
565 | 0498 <span class="keyword">if</span> isequal(nodename2,<span class="string">'xs:documentation'</span>) |
---|
566 | 0499 node3=children(xs,node2(j)); |
---|
567 | 0500 xs_element.annot=get(xs,node3,<span class="string">'value'</span>);<span class="comment">%read annotation</span> |
---|
568 | 0501 <span class="keyword">end</span> |
---|
569 | 0502 <span class="keyword">end</span> |
---|
570 | 0503 <span class="comment">% pour les elements</span> |
---|
571 | 0504 <span class="keyword">elseif</span> isequal(nodename1,<span class="string">'xs:simpleType'</span>) |
---|
572 | 0505 <span class="keyword">for</span> j=1:length(node2) |
---|
573 | 0506 nodename2=get(xs,node2(j),<span class="string">'name'</span>); |
---|
574 | 0507 <span class="keyword">if</span> isequal(nodename2,<span class="string">'xs:restriction'</span>) |
---|
575 | 0508 node3=children(xs,node2(j)); |
---|
576 | 0509 <span class="keyword">for</span> k=1:length(node3) |
---|
577 | 0510 nodename3=get(xs,node3(k),<span class="string">'name'</span>); |
---|
578 | 0511 <span class="keyword">if</span> isequal(nodename3,<span class="string">'xs:enumeration'</span>) |
---|
579 | 0512 node3_content=get(xs,node3(k)); |
---|
580 | 0513 attr=node3_content.attributes; |
---|
581 | 0514 <span class="keyword">for</span> m=1:length(attr) |
---|
582 | 0515 struct=attr{m}; |
---|
583 | 0516 <span class="keyword">if</span> isequal(struct.key,<span class="string">'value'</span>) |
---|
584 | 0517 xs_element.enum{k}=struct.val; <span class="comment">% read enumeration</span> |
---|
585 | 0518 <span class="keyword">end</span> |
---|
586 | 0519 <span class="keyword">end</span> |
---|
587 | 0520 <span class="keyword">end</span> |
---|
588 | 0521 <span class="keyword">end</span> |
---|
589 | 0522 <span class="keyword">end</span> |
---|
590 | 0523 <span class="keyword">end</span> |
---|
591 | 0524 <span class="keyword">elseif</span> isequal(nodename1,<span class="string">'xs:complexType'</span>) |
---|
592 | 0525 <span class="keyword">for</span> j=1:length(node2) |
---|
593 | 0526 nodename2=get(xs,node2(j),<span class="string">'name'</span>); |
---|
594 | 0527 <span class="keyword">if</span> isequal(nodename2,<span class="string">'xs:attribute'</span>) |
---|
595 | 0528 node_content=get(xs,node2(j)); |
---|
596 | 0529 attr=node_content.attributes; |
---|
597 | 0530 <span class="keyword">for</span> k=1:length(attr) |
---|
598 | 0531 struct=attr{k};<span class="comment">%read attributes</span> |
---|
599 | 0532 <span class="keyword">if</span> isequal(struct.key,<span class="string">'name'</span>) |
---|
600 | 0533 xs_element.attrib=struct.val; <span class="comment">%read attributes of main node</span> |
---|
601 | 0534 <span class="keyword">end</span> |
---|
602 | 0535 <span class="keyword">end</span> |
---|
603 | 0536 <span class="keyword">elseif</span> isequal(nodename2,<span class="string">'xs:sequence'</span>) |
---|
604 | 0537 xs_element.subtest=1; |
---|
605 | 0538 node3=children(xs,node2(j));<span class="comment">%nodes of the sequence</span> |
---|
606 | 0539 <span class="keyword">for</span> k=1:length(node3) |
---|
607 | 0540 xs_subelem(k).node=node3(k); |
---|
608 | 0541 xs_subelem(k).testsub=0;<span class="comment">%default</span> |
---|
609 | 0542 node_content=get(xs,node3(k)); |
---|
610 | 0543 xs_subelem(k).minOccurs=1; <span class="comment">%default</span> |
---|
611 | 0544 xs_subelem(k).maxOccurs=1; <span class="comment">%default</span> |
---|
612 | 0545 <span class="comment">% pref{k}=[]; %default</span> |
---|
613 | 0546 <span class="keyword">if</span> isequal(node_content.name,<span class="string">'xs:element'</span>) |
---|
614 | 0547 attr=node_content.attributes; |
---|
615 | 0548 <span class="comment">% attr{:}.key</span> |
---|
616 | 0549 <span class="keyword">for</span> l=1:length(attr) |
---|
617 | 0550 <span class="keyword">if</span> isequal(attr{l}.key,<span class="string">'name'</span>) |
---|
618 | 0551 xs_subelem(k).key=attr{l}.val;<span class="comment">%name of the element</span> |
---|
619 | 0552 <span class="keyword">elseif</span> isequal(attr{l}.key, <span class="string">'minOccurs'</span>) |
---|
620 | 0553 xs_subelem(k).minOccurs=attr{l}.val; |
---|
621 | 0554 <span class="keyword">elseif</span> isequal(attr{l}.key, <span class="string">'maxOccurs'</span>) |
---|
622 | 0555 xs_subelem(k).maxOccurs=attr{l}.val; |
---|
623 | 0556 <span class="keyword">end</span> |
---|
624 | 0557 <span class="keyword">end</span> |
---|
625 | 0558 <span class="keyword">end</span> |
---|
626 | 0559 node4=children(xs,node3(k)); |
---|
627 | 0560 <span class="keyword">for</span> l=1:length(node4) |
---|
628 | 0561 res=get(xs,node4(l),<span class="string">'name'</span>); |
---|
629 | 0562 <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> |
---|
630 | 0563 node5=children(xs,node4(l)); |
---|
631 | 0564 <span class="keyword">for</span> m=1:length(node5) |
---|
632 | 0565 res2=get(xs,node5(m),<span class="string">'name'</span>); |
---|
633 | 0566 <span class="keyword">if</span> isequal(res2,<span class="string">'xs:sequence'</span>) |
---|
634 | 0567 xs_subelem(k).testsub=1; <span class="comment">%flag for the existence of a subtree</span> |
---|
635 | 0568 <span class="keyword">end</span> |
---|
636 | 0569 <span class="keyword">end</span> |
---|
637 | 0570 <span class="keyword">end</span> |
---|
638 | 0571 <span class="keyword">end</span> |
---|
639 | 0572 <span class="keyword">end</span> |
---|
640 | 0573 |
---|
641 | 0574 <span class="keyword">end</span> |
---|
642 | 0575 <span class="keyword">end</span> |
---|
643 | 0576 <span class="keyword">end</span> |
---|
644 | 0577 <span class="keyword">end</span> |
---|
645 | 0578 <span class="keyword">end</span> |
---|
646 | 0579 <span class="comment">% look for predefined types</span> |
---|
647 | 0580 <span class="keyword">if</span> length(xs_element.type)>=3 & (xs_element.type([1:3])~=<span class="string">'xs:'</span>) |
---|
648 | 0581 node_type=find(xs,<span class="string">'/xs:schema/xs:simpleType'</span>) |
---|
649 | 0582 <span class="keyword">for</span> i=1:length(node_type) |
---|
650 | 0583 content=get(xs,node_type(i)); |
---|
651 | 0584 nodeattr=content.attributes; |
---|
652 | 0585 <span class="keyword">if</span> ~isempty(nodeattr) & isequal(nodeattr{1}.key,<span class="string">'name'</span>) & isequal(nodeattr{1}.val,xs_element.type) |
---|
653 | 0586 node1=children(xs,node_type(i)); |
---|
654 | 0587 node2=find(xs,node1,<span class="string">'name'</span>,<span class="string">'xs:restriction'</span>); |
---|
655 | 0588 <span class="comment">% nodename1=find(xs,</span> |
---|
656 | 0589 node3=children(xs,node2); |
---|
657 | 0590 node4=find(xs,node3,<span class="string">'name'</span>,<span class="string">'xs:enumeration'</span>); |
---|
658 | 0591 <span class="keyword">for</span> ienum=1:length(node4) |
---|
659 | 0592 struct2=get(xs,node4(ienum)); |
---|
660 | 0593 enumval=struct2.attributes; |
---|
661 | 0594 xs_element.enum{ienum}=enumval{1}.val; |
---|
662 | 0595 <span class="keyword">end</span> |
---|
663 | 0596 <span class="keyword">end</span> |
---|
664 | 0597 <span class="keyword">end</span> |
---|
665 | 0598 <span class="keyword">end</span> |
---|
666 | 0599 |
---|
667 | 0600 <span class="comment">%--------------------------------------------------------</span> |
---|
668 | 0601 <span class="comment">%OUTPUT:</span> |
---|
669 | 0602 <span class="comment">%element.val: value of the current element, =[] in the absence of chardata value</span> |
---|
670 | 0603 <span class="comment">%node: node (iud) of the element in t</span> |
---|
671 | 0604 <span class="comment">%element.attr_key{iattr}: attribute key #iattr of the current element</span> |
---|
672 | 0605 <span class="comment">%element.attr_val{iattr}: attribute value #iattr of the current element</span> |
---|
673 | 0606 <span class="comment">%element.attrup: %structure containing the attributes of the element, including the ones unheritated from parent nodes</span> |
---|
674 | 0607 <span class="comment">%subelem(iline).val : value of subelement # iline, concatenated with corresponding attributes</span> |
---|
675 | 0608 <span class="comment">%subelem(iline).xsindex: index k of the subelement #iline in the list xs_subelem of the schema</span> |
---|
676 | 0609 <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> |
---|
677 | 0610 |
---|
678 | 0611 <span class="comment">%INPUT:</span> |
---|
679 | 0612 <span class="comment">%t: xml tree</span> |
---|
680 | 0613 <span class="comment">%path: path to the current element in the schema</span> |
---|
681 | 0614 <span class="comment">%xs_element: current element in the schema</span> |
---|
682 | 0615 <span class="comment">%xs_element.key: key label</span> |
---|
683 | 0616 <span class="comment">%xs_element.type: type of data contained in the element</span> |
---|
684 | 0617 <span class="comment">%xs_element.annot: annotation of nodeinput</span> |
---|
685 | 0618 <span class="comment">%xs_element.attrib: list of accepted attributes keys for xs_element</span> |
---|
686 | 0619 <span class="comment">%xs_element.enum: enumeration, list of accepted values</span> |
---|
687 | 0620 <span class="comment">%xs_element.subtest: =1 if the element contains subelements in the schema, 0 else</span> |
---|
688 | 0621 <span class="comment">%index: index of the element, =1 in case of single occurence in xs_element,=0 in case of missing element</span> |
---|
689 | 0622 <span class="comment">%xs_subelem(k): subelement #k of the current element in the schema</span> |
---|
690 | 0623 <span class="comment">%xs_subelem(k).node: node iud of the</span> |
---|
691 | 0624 <span class="comment">%xs_subelem(k).key: key name of the subelement #k in the schema</span> |
---|
692 | 0625 <span class="comment">%xs_subelem(k).testsub: =1 if element contains subelements, 0 else</span> |
---|
693 | 0626 <span class="comment">%xs_subelem(k).minOccurs</span> |
---|
694 | 0627 <span class="comment">%xs_subelem(k).maxOccurs</span> |
---|
695 | 0628 |
---|
696 | 0629 <a name="_sub9" href="#_subfunctions" class="code">function [element,subelem]=get_xml(t,path,xs_element,node,xs_subelem)</a> |
---|
697 | 0630 element.attr_key=<span class="string">''</span>;<span class="comment">%default</span> |
---|
698 | 0631 element.attr_val=<span class="string">''</span>;<span class="comment">%default</span> |
---|
699 | 0632 element.val=<span class="string">''</span>; |
---|
700 | 0633 <span class="comment">% element.type='';</span> |
---|
701 | 0634 <span class="comment">% element.testmanual=testmanual %inheritates the input manual editing flag by default</span> |
---|
702 | 0635 subelem=[]; <span class="comment">%default</span> |
---|
703 | 0636 attrup=[]; |
---|
704 | 0637 <span class="comment">% node=[];</span> |
---|
705 | 0638 |
---|
706 | 0639 <span class="comment">% %find the element properties in the xml file</span> |
---|
707 | 0640 <span class="keyword">if</span> node >= 1 |
---|
708 | 0641 elem_struct=get(t,node); |
---|
709 | 0642 <span class="keyword">if</span> ~xs_element.subtest |
---|
710 | 0643 elem_contents=get(t,elem_struct.contents); |
---|
711 | 0644 <span class="keyword">if</span> isempty(elem_contents) |
---|
712 | 0645 element.val=[]; |
---|
713 | 0646 <span class="keyword">else</span> |
---|
714 | 0647 element.val=elem_contents.value |
---|
715 | 0648 <span class="keyword">end</span> |
---|
716 | 0649 <span class="keyword">end</span> |
---|
717 | 0650 <span class="keyword">if</span> isfield(elem_struct,<span class="string">'attributes'</span>) |
---|
718 | 0651 elem_attr=elem_struct.attributes; |
---|
719 | 0652 <span class="keyword">for</span> iattr=1:length(elem_attr) |
---|
720 | 0653 element.attr_key{iattr}=elem_attr{iattr}.key ; |
---|
721 | 0654 element.attr_val{iattr}=elem_attr{iattr}.val; |
---|
722 | 0655 <span class="comment">% attrup=setfield(attrup,elem_attr{iattr}.key,elem_attr{iattr}.val);</span> |
---|
723 | 0656 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> |
---|
724 | 0657 <span class="keyword">if</span> isempty(breakdetect) |
---|
725 | 0658 <span class="comment">% comline=['attrup.' elem_attr{iattr}.key '=' elem_attr{iattr}.val ';']</span> |
---|
726 | 0659 eval([<span class="string">'attrup.'</span> elem_attr{iattr}.key <span class="string">'='''</span> elem_attr{iattr}.val <span class="string">''';'</span>]) |
---|
727 | 0660 <span class="keyword">end</span> |
---|
728 | 0661 <span class="keyword">end</span> |
---|
729 | 0662 <span class="keyword">end</span> |
---|
730 | 0663 <span class="keyword">end</span> |
---|
731 | 0664 <span class="comment">%get the parent node attributes</span> |
---|
732 | 0665 up=1; |
---|
733 | 0666 <span class="keyword">if</span> node>0 |
---|
734 | 0667 nodeup=node; |
---|
735 | 0668 <span class="keyword">while</span> up==1; |
---|
736 | 0669 nodeup=get(t,nodeup,<span class="string">'parent'</span>);<span class="comment">%move up to the parent in the tree</span> |
---|
737 | 0670 <span class="keyword">if</span> isempty(nodeup) |
---|
738 | 0671 up=0; |
---|
739 | 0672 <span class="keyword">else</span> |
---|
740 | 0673 nodeup_content=get(t,nodeup); |
---|
741 | 0674 attrib=nodeup_content.attributes; |
---|
742 | 0675 <span class="keyword">for</span> iattr=1:length(attrib) |
---|
743 | 0676 key=attrib{iattr}.key; |
---|
744 | 0677 breakdetect=find(key==<span class="string">'/'</span>| key==<span class="string">':'</span>| key==<span class="string">'.'</span>);<span class="comment">% find '/'</span> |
---|
745 | 0678 <span class="keyword">if</span> ~isfield(attrup,key) & isempty(breakdetect) |
---|
746 | 0679 eval([<span class="string">'attrup.'</span> key <span class="string">'='''</span> attrib{iattr}.val <span class="string">''';'</span>]) |
---|
747 | 0680 <span class="keyword">end</span> |
---|
748 | 0681 <span class="keyword">end</span> |
---|
749 | 0682 <span class="keyword">end</span> |
---|
750 | 0683 <span class="keyword">end</span> |
---|
751 | 0684 element.attrup=attrup; |
---|
752 | 0685 <span class="keyword">end</span> |
---|
753 | 0686 <span class="comment">%find the subelement properties in the xml file</span> |
---|
754 | 0687 <span class="keyword">if</span> xs_element.subtest |
---|
755 | 0688 iline=0; |
---|
756 | 0689 <span class="keyword">for</span> k=1:length(xs_subelem)<span class="comment">%node2: list of subelements in the sub-sequence</span> |
---|
757 | 0690 <span class="comment">% attr=attributes(xs,'get',node2(i),1);%</span> |
---|
758 | 0691 <span class="comment">% element=attr.val;%name of the element</span> |
---|
759 | 0692 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> |
---|
760 | 0693 struct_element=get(t,tag);<span class="comment">%get the content of the element</span> |
---|
761 | 0694 <span class="keyword">if</span> isempty(struct_element) |
---|
762 | 0695 iline=iline+1; |
---|
763 | 0696 subelem(iline).uid=0; |
---|
764 | 0697 subelem(iline).xsindex=k; |
---|
765 | 0698 subelem(iline).index=0; |
---|
766 | 0699 <span class="comment">% subelem(iline).testmanual=element.testmanual;% inheritates the manual editing flag by default</span> |
---|
767 | 0700 <span class="keyword">if</span> isequal(xs_subelem(k).minOccurs,<span class="string">'0'</span>) |
---|
768 | 0701 subelem(iline).val=<span class="string">'[]'</span>;<span class="comment">%element value not mandatory in the schema</span> |
---|
769 | 0702 <span class="keyword">else</span> |
---|
770 | 0703 subelem(iline).val=<span class="string">'[MISSING]'</span>;<span class="comment">%element value mandatory in the schema</span> |
---|
771 | 0704 <span class="keyword">end</span> |
---|
772 | 0705 <span class="comment">% subelem(iline).attrup=attrup; %inheritated attributes</span> |
---|
773 | 0706 <span class="keyword">elseif</span> isequal(length(struct_element),1) |
---|
774 | 0707 contents=get(t,struct_element.contents); |
---|
775 | 0708 iline=iline+1; |
---|
776 | 0709 subelem(iline).uid=tag; |
---|
777 | 0710 subelem(iline).xsindex=k; |
---|
778 | 0711 subelem(iline).index=1; |
---|
779 | 0712 <span class="comment">% subelem(iline).testmanual=element.testmanual;%</span> |
---|
780 | 0713 <span class="keyword">if</span> isfield(contents,<span class="string">'value'</span>) & ~isempty(contents.value) |
---|
781 | 0714 subelem(iline).val=contents.value; |
---|
782 | 0715 <span class="keyword">elseif</span> xs_subelem(k).testsub |
---|
783 | 0716 subelem(iline).val=<span class="string">''</span>; |
---|
784 | 0717 <span class="keyword">elseif</span> isequal(xs_subelem(k).minOccurs,0) |
---|
785 | 0718 subelem(iline).val=<span class="string">'[]'</span>;<span class="comment">%element value not mandatory in the schema</span> |
---|
786 | 0719 <span class="keyword">else</span> |
---|
787 | 0720 subelem(iline).val=<span class="string">'[MISSING]'</span>;<span class="comment">%element value mandatory in the schema</span> |
---|
788 | 0721 <span class="keyword">end</span> |
---|
789 | 0722 <span class="comment">% subelem(iline).attrup=attrup; %inheritated attributes</span> |
---|
790 | 0723 <span class="keyword">if</span> isfield(struct_element,<span class="string">'attributes'</span>) |
---|
791 | 0724 element_attr=struct_element.attributes; |
---|
792 | 0725 attr_display=[]; |
---|
793 | 0726 <span class="keyword">for</span> iattr=1:length(element_attr) |
---|
794 | 0727 <span class="comment">% attr_display{iline}=[attr_display ' , ' element_attr{iattr}.key ' = ' element_attr{iattr}.val];</span> |
---|
795 | 0728 subelem(iline).val=[subelem(iline).val attr_display <span class="string">' , '</span> element_attr{iattr}.key <span class="string">' = '</span> element_attr{iattr}.val]; |
---|
796 | 0729 <span class="comment">% subelem(iline).attrup=setfield(subelem(iline).attrup,element_attr{iattr}.key,element_attr{iattr}.val);</span> |
---|
797 | 0730 <span class="keyword">end</span> |
---|
798 | 0731 <span class="keyword">end</span> |
---|
799 | 0732 <span class="keyword">else</span><span class="comment">%case of a multiple element</span> |
---|
800 | 0733 <span class="keyword">for</span> subindex=1:length(struct_element) |
---|
801 | 0734 contents=get(t,struct_element{subindex}.contents); |
---|
802 | 0735 iline=iline+1; |
---|
803 | 0736 subelem(iline).index=subindex;<span class="comment">%index of the element</span> |
---|
804 | 0737 subelem(iline).xsindex=k; |
---|
805 | 0738 <span class="comment">% subelem(iline).testmanual=element.testmanual;%</span> |
---|
806 | 0739 <span class="keyword">if</span> isfield(contents,<span class="string">'value'</span>)& ~isempty(contents.value) |
---|
807 | 0740 subelem(iline).val=contents.value; |
---|
808 | 0741 <span class="keyword">elseif</span> xs_subelem(k).testsub |
---|
809 | 0742 subelem(iline).val=<span class="string">''</span>; |
---|
810 | 0743 <span class="keyword">else</span> |
---|
811 | 0744 subelem(iline).val=<span class="string">'[]'</span>; |
---|
812 | 0745 <span class="keyword">end</span> |
---|
813 | 0746 <span class="comment">% subelem(iline).attrup=attrup; %inheritated attributes</span> |
---|
814 | 0747 <span class="keyword">if</span> isfield(struct_element{subindex},<span class="string">'attributes'</span>) |
---|
815 | 0748 element_attr=struct_element{subindex}.attributes; |
---|
816 | 0749 attr_display=[]; |
---|
817 | 0750 <span class="keyword">for</span> iattr=1:length(element_attr) |
---|
818 | 0751 <span class="comment">% attr_display{iline}=[attr_display ' , ' element_attr{iattr}.key ' = ' element_attr{iattr}.val];</span> |
---|
819 | 0752 subelem(iline).val=[subelem(iline).val attr_display <span class="string">' , '</span> element_attr{iattr}.key <span class="string">' = '</span> element_attr{iattr}.val]; |
---|
820 | 0753 <span class="comment">% subelem(iline).attrup=setfield(subelem(iline).attrup,element_attr{iattr}.key,element_attr{iattr}.val);</span> |
---|
821 | 0754 <span class="keyword">end</span> |
---|
822 | 0755 <span class="keyword">end</span> |
---|
823 | 0756 <span class="keyword">end</span> |
---|
824 | 0757 <span class="keyword">end</span> |
---|
825 | 0758 <span class="keyword">end</span> |
---|
826 | 0759 <span class="keyword">end</span> |
---|
827 | 0760 |
---|
828 | 0761 <span class="comment">%-------------------------------------</span> |
---|
829 | 0762 <span class="comment">%updates the interface</span> |
---|
830 | 0763 <a name="_sub10" href="#_subfunctions" class="code">function update_list(handles,path,xs_element,element,node,xs_subelem,subelem)</a> |
---|
831 | 0764 <span class="comment">%-----------------------------</span> |
---|
832 | 0765 <span class="keyword">if</span> xs_element.subtest<span class="comment">% we list the sub-elements of root</span> |
---|
833 | 0766 set(handles.export_list,<span class="string">'Value'</span>,1) |
---|
834 | 0767 set(handles.export_list,<span class="string">'String'</span>,<span class="string">''</span>)<span class="comment">%flush the export list</span> |
---|
835 | 0768 set(handles.CurrentElement,<span class="string">'String'</span>,[path <span class="string">'/'</span> xs_element.key]) |
---|
836 | 0769 <span class="comment">% title_element.key=[path '/' xs_element.key];</span> |
---|
837 | 0770 <span class="comment">% if ~isempty(path)</span> |
---|
838 | 0771 <span class="comment">% xsnode_index=get(handles.list_element,'UserDataIn');</span> |
---|
839 | 0772 <span class="comment">% ind=get(handles.list_element,'Value');</span> |
---|
840 | 0773 <span class="comment">% title_element.index=xsnode_index(2,ind);</span> |
---|
841 | 0774 <span class="comment">% else</span> |
---|
842 | 0775 <span class="comment">% title_element.index=1;</span> |
---|
843 | 0776 <span class="comment">% end</span> |
---|
844 | 0777 <span class="comment">% title_element.xsnode=xs_element.uid;</span> |
---|
845 | 0778 <span class="comment">% title_element.node=node;</span> |
---|
846 | 0779 <span class="comment">% set(handles.CurrentFile,'UserDataIn',title_element)%element corresponding to the title</span> |
---|
847 | 0780 set(handles.CurrentAnnotation,<span class="string">'String'</span>,xs_element.annot) |
---|
848 | 0781 attr_col=[]; |
---|
849 | 0782 testedit=0;<span class="comment">% cannot edit elements by default</span> |
---|
850 | 0783 <span class="keyword">for</span> iattr=1:length(element.attr_key) |
---|
851 | 0784 <span class="comment">% if isequal(element.attr_key{iattr},'source') & isequal(element.attr_val{iattr},'manual')</span> |
---|
852 | 0785 <span class="comment">% testedit=1;</span> |
---|
853 | 0786 <span class="comment">% end</span> |
---|
854 | 0787 attr_col=strvcat(attr_col,[element.attr_key{iattr} <span class="string">' = '</span> element.attr_val{iattr}]); |
---|
855 | 0788 <span class="keyword">end</span> |
---|
856 | 0789 set(handles.CurrentAttributes,<span class="string">'String'</span>,attr_col) |
---|
857 | 0790 pref_col=<span class="string">''</span>; |
---|
858 | 0791 key_col=<span class="string">''</span>; |
---|
859 | 0792 equal_sign=<span class="string">''</span>; |
---|
860 | 0793 val_col=<span class="string">''</span>; |
---|
861 | 0794 <span class="keyword">for</span> iline=1:length(subelem) |
---|
862 | 0795 xsindex=subelem(iline).xsindex; |
---|
863 | 0796 index(iline)=subelem(iline).index; |
---|
864 | 0797 subuid=subelem(iline).uid; |
---|
865 | 0798 <span class="keyword">if</span> isempty(subuid) |
---|
866 | 0799 list.uid(iline)=0; |
---|
867 | 0800 <span class="keyword">else</span> |
---|
868 | 0801 list.uid(iline)=subuid; |
---|
869 | 0802 <span class="keyword">end</span> |
---|
870 | 0803 node(iline)=xs_subelem(xsindex).node; |
---|
871 | 0804 <span class="comment">% testmanual(iline)=subelem(iline).testmanual;</span> |
---|
872 | 0805 ikey=xs_subelem(xsindex).key; |
---|
873 | 0806 <span class="keyword">if</span> xs_subelem(xsindex).testsub |
---|
874 | 0807 ival=[<span class="string">' + '</span> subelem(iline).val]; |
---|
875 | 0808 <span class="keyword">else</span> |
---|
876 | 0809 ival=[<span class="string">' = '</span> subelem(iline).val]; |
---|
877 | 0810 <span class="keyword">end</span> |
---|
878 | 0811 key_col=strvcat(key_col,ikey); |
---|
879 | 0812 val_col=strvcat(val_col,ival); |
---|
880 | 0813 <span class="keyword">end</span> |
---|
881 | 0814 list_element=[key_col val_col]; |
---|
882 | 0815 set(handles.list_element,<span class="string">'String'</span>,list_element) |
---|
883 | 0816 set(handles.list_element,<span class="string">'Value'</span>,1) |
---|
884 | 0817 list.xs_uid=node; |
---|
885 | 0818 list.index=index; |
---|
886 | 0819 set(handles.list_element,<span class="string">'UserData'</span>,list) |
---|
887 | 0820 set(handles.element_attrib,<span class="string">'Visible'</span>,<span class="string">'off'</span>) |
---|
888 | 0821 set(handles.element_key,<span class="string">'Visible'</span>,<span class="string">'off'</span>) |
---|
889 | 0822 set(handles.element_value,<span class="string">'Visible'</span>,<span class="string">'off'</span>) |
---|
890 | 0823 <span class="keyword">else</span> <span class="comment">% we edit an element</span> |
---|
891 | 0824 |
---|
892 | 0825 export_list=get(handles.export_list,<span class="string">'String'</span>);<span class="comment">%export list</span> |
---|
893 | 0826 testadd=1; |
---|
894 | 0827 <span class="keyword">for</span> ilist=1:length(export_list) |
---|
895 | 0828 <span class="keyword">if</span> isequal(xs_element.key,export_list{ilist}) |
---|
896 | 0829 testadd=0; |
---|
897 | 0830 <span class="keyword">break</span> |
---|
898 | 0831 <span class="keyword">end</span> |
---|
899 | 0832 <span class="keyword">end</span> |
---|
900 | 0833 <span class="keyword">if</span> testadd |
---|
901 | 0834 export_list=[export_list;{xs_element.key}]; |
---|
902 | 0835 ilist=length(export_list); |
---|
903 | 0836 <span class="keyword">end</span> |
---|
904 | 0837 set(handles.export_list,<span class="string">'String'</span>,export_list) |
---|
905 | 0838 <span class="keyword">if</span> iscell(element.val) |
---|
906 | 0839 element_val=element.val{1}; |
---|
907 | 0840 <span class="keyword">else</span> |
---|
908 | 0841 element_val=element.val; |
---|
909 | 0842 <span class="keyword">end</span> |
---|
910 | 0843 set(handles.element_value,<span class="string">'String'</span>,element_val) |
---|
911 | 0844 export_val=get(handles.export_list,<span class="string">'UserData'</span>); |
---|
912 | 0845 export_val{ilist}=element_val; |
---|
913 | 0846 set(handles.export_list,<span class="string">'UserData'</span>,export_val); |
---|
914 | 0847 set(handles.element_annot,<span class="string">'String'</span>,xs_element.annot) |
---|
915 | 0848 set(handles.element_type,<span class="string">'String'</span>,[<span class="string">'type: '</span> xs_element.type]) |
---|
916 | 0849 attr_col=[]; |
---|
917 | 0850 testedit=0;<span class="comment">% cannot edit element by default</span> |
---|
918 | 0851 <span class="keyword">for</span> iattr=1:length(element.attr_key) |
---|
919 | 0852 <span class="comment">% if isequal(element.attr_key{iattr},'source') & isequal(element.attr_val{iattr},'manual')</span> |
---|
920 | 0853 <span class="comment">% testedit=1;</span> |
---|
921 | 0854 <span class="comment">% end</span> |
---|
922 | 0855 attr_col=strvcat(attr_col,[element.attr_key{iattr} <span class="string">' = '</span> element.attr_val{iattr}]); |
---|
923 | 0856 <span class="keyword">end</span> |
---|
924 | 0857 set(handles.element_attrib,<span class="string">'String'</span>,attr_col) |
---|
925 | 0858 set(handles.element_key,<span class="string">'String'</span>,xs_element.key) |
---|
926 | 0859 |
---|
927 | 0860 |
---|
928 | 0861 <span class="keyword">if</span> isempty(xs_element.enum) |
---|
929 | 0862 set(handles.element_value,<span class="string">'Value'</span>,1) |
---|
930 | 0863 set(handles.element_value,<span class="string">'Style'</span>,<span class="string">'edit'</span>) |
---|
931 | 0864 <span class="keyword">else</span> <span class="comment">% case of an enumeration of possible values</span> |
---|
932 | 0865 list_enum=[]; |
---|
933 | 0866 list_val=[]; |
---|
934 | 0867 <span class="keyword">for</span> ienum=1:length(xs_element.enum) |
---|
935 | 0868 list_enum{ienum,1}=xs_element.enum{ienum}; |
---|
936 | 0869 <span class="keyword">if</span> isequal(xs_element.enum{ienum},element_val) |
---|
937 | 0870 list_val=ienum; |
---|
938 | 0871 <span class="keyword">end</span> |
---|
939 | 0872 <span class="keyword">end</span> |
---|
940 | 0873 <span class="keyword">if</span> isempty(list_val) |
---|
941 | 0874 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> |
---|
942 | 0875 list_val=length(xs_element.enum)+1; |
---|
943 | 0876 <span class="keyword">end</span> |
---|
944 | 0877 set(handles.element_value,<span class="string">'Style'</span>,<span class="string">'popupmenu'</span>) |
---|
945 | 0878 set(handles.element_value,<span class="string">'String'</span>,list_enum) |
---|
946 | 0879 set(handles.element_value,<span class="string">'Value'</span>,list_val) |
---|
947 | 0880 <span class="keyword">end</span> |
---|
948 | 0881 <span class="keyword">if</span> isempty(element.val) |
---|
949 | 0882 testedit=1;<span class="comment">%allow element editing if value is missing</span> |
---|
950 | 0883 <span class="keyword">end</span> |
---|
951 | 0884 set(handles.element_attrib,<span class="string">'Visible'</span>,<span class="string">'On'</span>) |
---|
952 | 0885 set(handles.element_key,<span class="string">'Visible'</span>,<span class="string">'On'</span>) |
---|
953 | 0886 set(handles.element_value,<span class="string">'Visible'</span>,<span class="string">'On'</span>) |
---|
954 | 0887 <span class="keyword">end</span> |
---|
955 | 0888 set(handles.element_value,<span class="string">'UserData'</span>,node) |
---|
956 | 0889 <span class="keyword">if</span> ~testedit && isfield(element,<span class="string">'attrup'</span>) & isfield(element.attrup,<span class="string">'source'</span>)&& ~isequal(element.attrup.source,<span class="string">'manual'</span>) |
---|
957 | 0890 set(handles.element_value,<span class="string">'Enable'</span>,<span class="string">'inactive'</span>) |
---|
958 | 0891 <span class="keyword">else</span> |
---|
959 | 0892 set(handles.element_value,<span class="string">'Enable'</span>,<span class="string">'on'</span>) |
---|
960 | 0893 <span class="keyword">end</span> |
---|
961 | 0894 |
---|
962 | 0895 |
---|
963 | 0896 <span class="comment">% --- Executes on button press in SAVE.</span> |
---|
964 | 0897 <a name="_sub11" href="#_subfunctions" class="code">function SAVE_Callback(hObject, eventdata, handles)</a> |
---|
965 | 0898 <span class="keyword">global</span> t |
---|
966 | 0899 DataIn=get(get(handles.SAVE,<span class="string">'parent'</span>),<span class="string">'UserData'</span>); |
---|
967 | 0900 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>); |
---|
968 | 0901 <span class="keyword">if</span> isfield(DataIn,<span class="string">'Schema'</span>) |
---|
969 | 0902 <span class="keyword">if</span> ~isempty(DataIn.Schema)<span class="comment">% update ref to schema</span> |
---|
970 | 0903 attrxsd=attributes(t,<span class="string">'get'</span>,1); |
---|
971 | 0904 setest=0; |
---|
972 | 0905 <span class="keyword">for</span> iattr=1:length(attrxsd) |
---|
973 | 0906 <span class="keyword">if</span> isequal(attrxsd{iattr}.key,<span class="string">'xsi:noNamespaceSchemaLocation'</span>) |
---|
974 | 0907 t= attributes(t,<span class="string">'set'</span>,1,iattr,<span class="string">'xsi:noNamespaceSchemaLocation'</span>,DataIn.Schema); |
---|
975 | 0908 setest=1; |
---|
976 | 0909 <span class="keyword">end</span> |
---|
977 | 0910 <span class="keyword">end</span> |
---|
978 | 0911 <span class="keyword">if</span> setest==0; |
---|
979 | 0912 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>); |
---|
980 | 0913 t= attributes(t,<span class="string">'add'</span>,1,<span class="string">'xsi:noNamespaceSchemaLocation'</span>,DataIn.Schema); |
---|
981 | 0914 <span class="keyword">end</span> |
---|
982 | 0915 <span class="keyword">end</span> |
---|
983 | 0916 <span class="keyword">end</span> |
---|
984 | 0917 copyfile(CurrentFile,[CurrentFile <span class="string">'.bak'</span>]); |
---|
985 | 0918 save(t,CurrentFile); |
---|
986 | 0919 |
---|
987 | 0920 <span class="comment">%-------------------------------------</span> |
---|
988 | 0921 <span class="comment">% creates and/or set values to an element in t</span> |
---|
989 | 0922 <span class="comment">%t: xml tree</span> |
---|
990 | 0923 <span class="comment">%RootUid: uid of t under which we introduce an element</span> |
---|
991 | 0924 <span class="comment">%node: uid of the element that we correct, if =0, a new element is created</span> |
---|
992 | 0925 <span class="comment">%key: key name of the element</span> |
---|
993 | 0926 <span class="comment">%value: new value of the element</span> |
---|
994 | 0927 <a name="_sub12" href="#_subfunctions" class="code">function t=set_element(t,RootUid,node,key,value)</a> |
---|
995 | 0928 <span class="comment">%create the subelement if needed</span> |
---|
996 | 0929 <span class="keyword">if</span> isequal(node,0) |
---|
997 | 0930 [t,node]= add(t,RootUid,<span class="string">'element'</span>,key); |
---|
998 | 0931 <span class="keyword">end</span> |
---|
999 | 0932 node_chardata=children(t,node); <span class="comment">%corresponding data node</span> |
---|
1000 | 0933 <span class="keyword">if</span> isempty(node_chardata)<span class="comment">%if the data does not exist in t, create it</span> |
---|
1001 | 0934 t=add(t,node,<span class="string">'chardata'</span>,value); |
---|
1002 | 0935 <span class="keyword">elseif</span> isequal(length(node_chardata),1)&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> |
---|
1003 | 0936 t=set(t,node_chardata,<span class="string">'value'</span>,value);<span class="comment">%modify existing data</span> |
---|
1004 | 0937 <span class="keyword">end</span> |
---|
1005 | 0938 attr=attributes(t,<span class="string">'get'</span>,node); |
---|
1006 | 0939 <span class="keyword">if</span> isempty(attr) |
---|
1007 | 0940 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> |
---|
1008 | 0941 <span class="keyword">end</span> |
---|
1009 | 0942 |
---|
1010 | 0943 <span class="comment">% --- Executes on selection change in element_attr_val.</span> |
---|
1011 | 0944 <a name="_sub13" href="#_subfunctions" class="code">function element_attr_val_Callback(hObject, eventdata, handles)</a> |
---|
1012 | 0945 <span class="comment">% hObject handle to element_attr_val (see GCBO)</span> |
---|
1013 | 0946 <span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span> |
---|
1014 | 0947 <span class="comment">% handles structure with handles and user data (see GUIDATA)</span> |
---|
1015 | 0948 |
---|
1016 | 0949 <span class="comment">% Hints: contents = get(hObject,'String') returns element_attr_val contents as cell array</span> |
---|
1017 | 0950 <span class="comment">% contents{get(hObject,'Value')} returns selected item from element_attr_val</span> |
---|
1018 | 0951 |
---|
1019 | 0952 |
---|
1020 | 0953 <span class="comment">% --- Executes on button press in ADD.</span> |
---|
1021 | 0954 <a name="_sub14" href="#_subfunctions" class="code">function ADD_Callback(hObject, eventdata, handles)</a> |
---|
1022 | 0955 <span class="comment">% hObject handle to ADD (see GCBO)</span> |
---|
1023 | 0956 <span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span> |
---|
1024 | 0957 <span class="comment">% handles structure with handles and user data (see GUIDATA)</span> |
---|
1025 | 0958 |
---|
1026 | 0959 <span class="comment">%----------------------------------------</span> |
---|
1027 | 0960 <span class="comment">%read an xml file without schema</span> |
---|
1028 | 0961 <a name="_sub15" href="#_subfunctions" class="code">function [Data,testsimple]=displ_xml(handles,t,root_uid,DataIn,heditxml)</a> |
---|
1029 | 0962 Data=DataIn;<span class="comment">%default</span> |
---|
1030 | 0963 <span class="keyword">if</span> ~isfield(Data,<span class="string">'CurrentUid'</span>) |
---|
1031 | 0964 Data.CurrentUid=[]; |
---|
1032 | 0965 <span class="keyword">end</span> |
---|
1033 | 0966 CurrentFile=get(handles.CurrentFile,<span class="string">'String'</span>); |
---|
1034 | 0967 |
---|
1035 | 0968 <span class="comment">%display the current element</span> |
---|
1036 | 0969 root_element=get(t,root_uid); |
---|
1037 | 0970 uidparent=root_uid; |
---|
1038 | 0971 <span class="keyword">if</span> isfield(root_element,<span class="string">'name'</span>) |
---|
1039 | 0972 CurrentElement=root_element.name; |
---|
1040 | 0973 <span class="keyword">while</span> ~isequal(uidparent,1)<span class="comment">%while the first level has not been reached</span> |
---|
1041 | 0974 uidparent=parent(t,uidparent); |
---|
1042 | 0975 dirdat=get(t,uidparent); |
---|
1043 | 0976 <span class="keyword">if</span> isfield(dirdat,<span class="string">'name'</span>) |
---|
1044 | 0977 CurrentElement=[dirdat.name <span class="string">'/'</span> CurrentElement]; |
---|
1045 | 0978 <span class="keyword">end</span> |
---|
1046 | 0979 <span class="keyword">end</span> |
---|
1047 | 0980 set(handles.CurrentElement,<span class="string">'String'</span>,CurrentElement) |
---|
1048 | 0981 <span class="keyword">end</span> |
---|
1049 | 0982 list_uid=children(t,root_uid); |
---|
1050 | 0983 <span class="comment">%case of a single element</span> |
---|
1051 | 0984 testsimple=0; |
---|
1052 | 0985 filedat=[]; |
---|
1053 | 0986 <span class="keyword">if</span> ~isempty(list_uid) |
---|
1054 | 0987 filedat=get(t,list_uid(1)) |
---|
1055 | 0988 <span class="keyword">if</span> isfield(filedat,<span class="string">'type'</span>) & isequal(filedat.type,<span class="string">'chardata'</span>) &isfield(filedat,<span class="string">'value'</span>) |
---|
1056 | 0989 testsimple=1;<span class="comment">%simple element</span> |
---|
1057 | 0990 <span class="keyword">end</span> |
---|
1058 | 0991 <span class="keyword">end</span> |
---|
1059 | 0992 |
---|
1060 | 0993 <span class="comment">%attributes of the current element</span> |
---|
1061 | 0994 nbattrib= attributes(t,<span class="string">'length'</span>,root_uid); |
---|
1062 | 0995 testopen=0; |
---|
1063 | 0996 attr_col=[]; |
---|
1064 | 0997 <span class="keyword">for</span> iattr=1:nbattrib |
---|
1065 | 0998 attr= attributes(t,<span class="string">'get'</span>,root_uid,iattr); |
---|
1066 | 0999 <span class="keyword">if</span> isequal(attr.key,<span class="string">'source'</span>)<span class="comment">% look for 'source' attribute</span> |
---|
1067 | 1000 <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> |
---|
1068 | 1001 <span class="keyword">if</span> isfield(filedat,<span class="string">'type'</span>) & isequal(filedat.type,<span class="string">'chardata'</span>) &isfield(filedat,<span class="string">'value'</span>) |
---|
1069 | 1002 cur_file=filedat.value; |
---|
1070 | 1003 uidparent=root_uid;<span class="comment">%initialization</span> |
---|
1071 | 1004 <span class="keyword">while</span> ~isequal(uidparent,1)<span class="comment">%while the first level has not been reached</span> |
---|
1072 | 1005 uidparent=parent(t,uidparent); |
---|
1073 | 1006 dirdat=get(t,uidparent); |
---|
1074 | 1007 <span class="keyword">if</span> isfield(dirdat,<span class="string">'type'</span>) & isequal(dirdat.type,<span class="string">'element'</span>) & isfield(dirdat,<span class="string">'name'</span>) |
---|
1075 | 1008 nbattrib_up= attributes(t,<span class="string">'length'</span>,uidparent); |
---|
1076 | 1009 <span class="keyword">for</span> iattr_up=1:nbattrib_up |
---|
1077 | 1010 attr= attributes(t,<span class="string">'get'</span>,uidparent,iattr_up); |
---|
1078 | 1011 <span class="comment">% if isequal(attr.key,'source')&isequal(attr.val,'directory')% look for 'source' attribute</span> |
---|
1079 | 1012 <span class="keyword">if</span> isequal(attr.key,<span class="string">'DirName'</span>) |
---|
1080 | 1013 cur_file=fullfile(attr.val,cur_file); |
---|
1081 | 1014 <span class="keyword">end</span> |
---|
1082 | 1015 <span class="keyword">end</span> |
---|
1083 | 1016 <span class="keyword">end</span> |
---|
1084 | 1017 <span class="keyword">end</span> |
---|
1085 | 1018 RootPath=fileparts(CurrentFile);<span class="comment">%path to the current .xml file</span> |
---|
1086 | 1019 cur_file=fullfile(RootPath,cur_file) |
---|
1087 | 1020 set(handles.CurrentAttributes,<span class="string">'UserData'</span>,cur_file)<span class="comment">%will be searched by uvmat</span> |
---|
1088 | 1021 [path,fil,ext]=fileparts(cur_file); |
---|
1089 | 1022 <span class="keyword">if</span> ~exist(cur_file,<span class="string">'file'</span>) |
---|
1090 | 1023 <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> |
---|
1091 | 1024 <span class="keyword">return</span> |
---|
1092 | 1025 <span class="keyword">elseif</span> isequal(ext,<span class="string">'.xml'</span>) |
---|
1093 | 1026 <span class="keyword">if</span> ~isfield(Data,<span class="string">'UpFile'</span>) |
---|
1094 | 1027 Data.UpFile={CurrentFile}; |
---|
1095 | 1028 <span class="keyword">else</span> |
---|
1096 | 1029 Data.UpFile=[{CurrentFile};Data.UpFile]; |
---|
1097 | 1030 <span class="keyword">end</span> |
---|
1098 | 1031 set(heditxml,<span class="string">'UserData'</span>,Data) |
---|
1099 | 1032 set(handles.CurrentFile,<span class="string">'String'</span>,cur_file) |
---|
1100 | 1033 <a href="#_sub7" class="code" title="subfunction CurrentFile_Callback(hObject, eventdata, handles)">CurrentFile_Callback</a>(handles.CurrentFile, [], handles) |
---|
1101 | 1034 <span class="keyword">else</span> |
---|
1102 | 1035 <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> |
---|
1103 | 1036 set(heditxml,<span class="string">'Tag'</span>,<span class="string">'idle'</span>)<span class="comment">% signal for uvmat browser</span> |
---|
1104 | 1037 <span class="keyword">else</span> |
---|
1105 | 1038 <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> |
---|
1106 | 1039 <span class="keyword">end</span> |
---|
1107 | 1040 <span class="keyword">return</span> |
---|
1108 | 1041 <span class="keyword">end</span> |
---|
1109 | 1042 <span class="keyword">end</span> |
---|
1110 | 1043 <span class="comment">%elseif isequal(attr.val,'dir') A FAIRE : check directory</span> |
---|
1111 | 1044 <span class="comment">%else A FAIRE: edit the element</span> |
---|
1112 | 1045 <span class="keyword">end</span> |
---|
1113 | 1046 <span class="keyword">end</span> |
---|
1114 | 1047 attr_col=strvcat(attr_col,[attr.key <span class="string">' = '</span> attr.val]); |
---|
1115 | 1048 <span class="keyword">end</span> |
---|
1116 | 1049 set(handles.CurrentAttributes,<span class="string">'String'</span>,attr_col) |
---|
1117 | 1050 |
---|
1118 | 1051 <span class="comment">%list subtree</span> |
---|
1119 | 1052 <span class="keyword">if</span> ~testsimple |
---|
1120 | 1053 list_element=[]; |
---|
1121 | 1054 <span class="comment">% Data.CurrentUid=[Data.CurrentUid root_uid]%record new current uid</span> |
---|
1122 | 1055 <span class="keyword">for</span> iline=1:length(list_uid) |
---|
1123 | 1056 element=get(t,list_uid(iline)); |
---|
1124 | 1057 <span class="keyword">if</span> isfield(element,<span class="string">'type'</span>)&isequal(element.type,<span class="string">'element'</span>) |
---|
1125 | 1058 list_element{iline,2}=element.name; |
---|
1126 | 1059 child_uid=children(t,list_uid(iline)); |
---|
1127 | 1060 subelem=get(t,child_uid); |
---|
1128 | 1061 <span class="keyword">if</span> isfield(subelem,<span class="string">'type'</span>)& isfield(subelem,<span class="string">'value'</span>) & isequal(subelem.type,<span class="string">'chardata'</span>) |
---|
1129 | 1062 data_read=subelem.value; |
---|
1130 | 1063 list_element{iline,3}=[<span class="string">'= '</span> data_read]; |
---|
1131 | 1064 <span class="keyword">end</span> |
---|
1132 | 1065 <span class="keyword">if</span> iscell(subelem)|(isfield(subelem,<span class="string">'type'</span>)&isequal(subelem.type,<span class="string">'element'</span>)) |
---|
1133 | 1066 list_element{iline,1}=<span class="string">'+ '</span>;<span class="comment">%sign for subtree existence</span> |
---|
1134 | 1067 <span class="keyword">else</span> |
---|
1135 | 1068 list_element{iline,1}=<span class="string">' '</span>; |
---|
1136 | 1069 <span class="keyword">end</span> |
---|
1137 | 1070 nbattr=attributes(t,<span class="string">'length'</span>,list_uid(iline)); |
---|
1138 | 1071 <span class="keyword">if</span> nbattr==1 |
---|
1139 | 1072 attr=attributes(t,<span class="string">'get'</span>,list_uid(iline)); |
---|
1140 | 1073 list_element{iline,4}=[attr.key <span class="string">'='</span>]; |
---|
1141 | 1074 list_element{iline,5}=attr.val; |
---|
1142 | 1075 <span class="keyword">elseif</span> nbattr>1 |
---|
1143 | 1076 <span class="keyword">for</span> iattr=1:nbattr |
---|
1144 | 1077 attr=attributes(t,<span class="string">'get'</span>,list_uid(iline),iattr); |
---|
1145 | 1078 list_element{iline,2+2*iattr}=[attr.key <span class="string">'='</span>]; |
---|
1146 | 1079 list_element{iline,3+2*iattr}=attr.val; |
---|
1147 | 1080 <span class="keyword">end</span> |
---|
1148 | 1081 <span class="keyword">end</span> |
---|
1149 | 1082 <span class="keyword">end</span> |
---|
1150 | 1083 <span class="keyword">end</span> |
---|
1151 | 1084 set(handles.list_element,<span class="string">'Value'</span>,1)<span class="comment">%select the first line of list_element by default</span> |
---|
1152 | 1085 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>) ) |
---|
1153 | 1086 list.uid=list_uid; |
---|
1154 | 1087 set(handles.list_element,<span class="string">'UserData'</span>,list) |
---|
1155 | 1088 <span class="keyword">end</span> |
---|
1156 | 1089 <span class="comment">%---------------------------------------------------------</span> |
---|
1157 | 1090 <span class="comment">%-------------------------------------</span> |
---|
1158 | 1091 <span class="comment">%updates the interface</span> |
---|
1159 | 1092 <a name="_sub16" href="#_subfunctions" class="code">function update_ref_list(hh,xs_element,element,node,xs_subelem,subelem)</a> |
---|
1160 | 1093 <span class="comment">%-----------------------------</span> |
---|
1161 | 1094 pref_col=<span class="string">''</span>; |
---|
1162 | 1095 key_col=<span class="string">''</span>; |
---|
1163 | 1096 equal_sign=<span class="string">''</span>; |
---|
1164 | 1097 val_col=<span class="string">''</span>; |
---|
1165 | 1098 <span class="keyword">for</span> iline=1:length(subelem) |
---|
1166 | 1099 xsindex=subelem(iline).xsindex; |
---|
1167 | 1100 indexcur=subelem(iline).index; |
---|
1168 | 1101 subuid=subelem(iline).uid; |
---|
1169 | 1102 <span class="keyword">if</span> isempty(subuid) |
---|
1170 | 1103 RefDataIn.uid(iline)=0; |
---|
1171 | 1104 <span class="keyword">else</span> |
---|
1172 | 1105 RefDataIn.uid(iline)=subuid; |
---|
1173 | 1106 <span class="keyword">end</span> |
---|
1174 | 1107 index(iline)=indexcur; |
---|
1175 | 1108 node(iline)=xs_subelem(xsindex).node; |
---|
1176 | 1109 <span class="comment">% testmanual(iline)=subelem(iline).testmanual;</span> |
---|
1177 | 1110 ikey=xs_subelem(xsindex).key; |
---|
1178 | 1111 <span class="keyword">if</span> xs_subelem(xsindex).testsub |
---|
1179 | 1112 ival=[<span class="string">' + '</span> subelem(iline).val]; |
---|
1180 | 1113 <span class="keyword">else</span> |
---|
1181 | 1114 ival=[<span class="string">' = '</span> subelem(iline).val]; |
---|
1182 | 1115 <span class="keyword">end</span> |
---|
1183 | 1116 key_col=strvcat(key_col,ikey); |
---|
1184 | 1117 val_col=strvcat(val_col,ival); |
---|
1185 | 1118 <span class="keyword">end</span> |
---|
1186 | 1119 RefDataIn.xs_uid=node; |
---|
1187 | 1120 list_element=[key_col val_col]; |
---|
1188 | 1121 siztext=size(list_element); |
---|
1189 | 1122 set(hh,<span class="string">'Value'</span>,[1:siztext(1)]) |
---|
1190 | 1123 set(hh,<span class="string">'String'</span>,list_element) |
---|
1191 | 1124 set(hh,<span class="string">'UserData'</span>,RefDataIn) |
---|
1192 | 1125 |
---|
1193 | 1126 <span class="comment">%</span> |
---|
1194 | 1127 <span class="comment">% function RefFile_Callback(hObject, eventdata, handles)</span> |
---|
1195 | 1128 <span class="comment">% global t_ref xs</span> |
---|
1196 | 1129 <span class="comment">% t_ref=xmltree(get(hObject,'String'));%open the xml file fileinput</span> |
---|
1197 | 1130 <span class="comment">% heditxml=get(hObject,'parent');</span> |
---|
1198 | 1131 <span class="comment">% DataIn=get(get(hObject,'parent'),'UserData');</span> |
---|
1199 | 1132 <span class="comment">% % set(heditxml,'Units','pixel')</span> |
---|
1200 | 1133 <span class="comment">% figpos=get(heditxml,'Position')</span> |
---|
1201 | 1134 <span class="comment">% % title_element=get(handles.element_cur,'UserDataIn');</span> |
---|
1202 | 1135 <span class="comment">% % xs_node=xsnode_index(1,ind);</span> |
---|
1203 | 1136 <span class="comment">% % index_chosen=xsnode_index(2,ind);</span> |
---|
1204 | 1137 <span class="comment">% if isfield(DataIn,'fig_ref')&ishandle(DataIn.fig_ref)</span> |
---|
1205 | 1138 <span class="comment">% figure(DataIn.fig_ref);</span> |
---|
1206 | 1139 <span class="comment">% else</span> |
---|
1207 | 1140 <span class="comment">% DataIn.fig_ref=figure;</span> |
---|
1208 | 1141 <span class="comment">% end</span> |
---|
1209 | 1142 <span class="comment">% set(DataIn.fig_ref,'Name',get(hObject,'String'))</span> |
---|
1210 | 1143 <span class="comment">% set(DataIn.fig_ref,'MenuBar','none')</span> |
---|
1211 | 1144 <span class="comment">% newfigpos=[figpos(1)+figpos(3) figpos(2)+0.4*figpos(4) 0.5*figpos(3) 0.3*figpos(4)];</span> |
---|
1212 | 1145 <span class="comment">% set(DataIn.fig_ref,'Units','normalized')</span> |
---|
1213 | 1146 <span class="comment">% set(DataIn.fig_ref,'Position',newfigpos)</span> |
---|
1214 | 1147 <span class="comment">% DataIn.h_ref=uicontrol('Style','listbox', 'Max',2,'Units','pixel','Position', [0 0 newfigpos(3) newfigpos(4)], ...</span> |
---|
1215 | 1148 <span class="comment">% 'FontName','FixedWidth','Tag','listbox');</span> |
---|
1216 | 1149 <span class="comment">% if isfield(DataIn,'xs_CurrentUid');</span> |
---|
1217 | 1150 <span class="comment">% xs_CurrentUid=DataIn.xs_CurrentUid(end);</span> |
---|
1218 | 1151 <span class="comment">% else</span> |
---|
1219 | 1152 <span class="comment">% DataIn.xs_CurrentUid=find(xs,'/xs:schema/xs:element');%uid of the root element in the schema</span> |
---|
1220 | 1153 <span class="comment">% end</span> |
---|
1221 | 1154 <span class="comment">% [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,xs_CurrentUid(end));</span> |
---|
1222 | 1155 <span class="comment">% xs_element.key</span> |
---|
1223 | 1156 <span class="comment">% tag0=find(t_ref,['/' path '/' xs_element.key]);</span> |
---|
1224 | 1157 <span class="comment">% if length(tag0)>=1</span> |
---|
1225 | 1158 <span class="comment">% CurrentRefNode=tag0(1);%chose the first occurence of the element</span> |
---|
1226 | 1159 <span class="comment">% else</span> |
---|
1227 | 1160 <span class="comment">% CurrentRefNode=0;</span> |
---|
1228 | 1161 <span class="comment">% end</span> |
---|
1229 | 1162 <span class="comment">% [ref_element,ref_subelem]=get_xml(t_ref,path,xs_element,CurrentRefNode,xs_subelem);</span> |
---|
1230 | 1163 <span class="comment">% update_ref_list(DataIn.h_ref,xs_element,ref_element,CurrentRefNode,xs_subelem,ref_subelem);</span> |
---|
1231 | 1164 <span class="comment">% siztext=size(get(DataIn.h_ref,'String'));</span> |
---|
1232 | 1165 <span class="comment">% set(DataIn.h_ref,'Value',[1:siztext(1)]); %select the whole list by default</span> |
---|
1233 | 1166 <span class="comment">% set(heditxml,'UserData',DataIn)</span> |
---|
1234 | 1167 <span class="comment">% set(handles.ref_data,'Value',siztext(1)); %select the whole list by default</span> |
---|
1235 | 1168 <span class="comment">% 'TESTimport'</span> |
---|
1236 | 1169 <span class="comment">% title_element=get(handles.element_cur,'UserDataIn')</span> |
---|
1237 | 1170 <span class="comment">% xs_node=title_element.xsnode;%uid of the element in the schema</span> |
---|
1238 | 1171 <span class="comment">% node=title_element.node;</span> |
---|
1239 | 1172 <span class="comment">% t=flush(t,node);%removes the corresponding subtree in t</span> |
---|
1240 | 1173 <span class="comment">% [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,xs_node);%scan the schema</span> |
---|
1241 | 1174 <span class="comment">% tag0=find(t_import,['/' path '/' xs_element.key])</span> |
---|
1242 | 1175 <span class="comment">% if isempty(tag)</span> |
---|
1243 | 1176 <span class="comment">% errordlg(['element /' path '/' xs_element.key ' not found in' fileinput])</span> |
---|
1244 | 1177 <span class="comment">% return</span> |
---|
1245 | 1178 <span class="comment">% end</span> |
---|
1246 | 1179 <span class="comment">% % [element_import,node_import]=get_xml(t_import,path,xs_element,1,xs_subelem);% read the corresponding xml data</span> |
---|
1247 | 1180 <span class="comment">% node2_import=children(t_import,tag0);</span> |
---|
1248 | 1181 <span class="comment">% % t_import=branch(t_import,node_import);% extract branch of the new file</span> |
---|
1249 | 1182 <span class="comment">% % %removes the corresponding subtree in t</span> |
---|
1250 | 1183 <span class="comment">% for inode=1:length(node2_import)</span> |
---|
1251 | 1184 <span class="comment">% struct=get(t_import,node2_import(inode))</span> |
---|
1252 | 1185 <span class="comment">% if isfield(struct,'type') & isfield(struct,'name')%if the node is an elmeent type</span> |
---|
1253 | 1186 <span class="comment">% node3_import=children(t_import,node2_import(inode))</span> |
---|
1254 | 1187 <span class="comment">% [t,newuid]=add(t,node,struct.type,struct.name);</span> |
---|
1255 | 1188 <span class="comment">% for inode2=1:length(node3_import)</span> |
---|
1256 | 1189 <span class="comment">% struct2=get(t_import,node3_import(inode2))</span> |
---|
1257 | 1190 <span class="comment">% if isequal(struct2.type,'chardata')</span> |
---|
1258 | 1191 <span class="comment">% t=add(t,newuid,'chardata',struct2.value);</span> |
---|
1259 | 1192 <span class="comment">% end</span> |
---|
1260 | 1193 <span class="comment">% end</span> |
---|
1261 | 1194 <span class="comment">% end</span> |
---|
1262 | 1195 <span class="comment">% end</span> |
---|
1263 | 1196 <span class="comment">% --- Executes on button press in replicate.</span> |
---|
1264 | 1197 <a name="_sub17" href="#_subfunctions" class="code">function replicate_Callback(hObject, eventdata, handles)</a> |
---|
1265 | 1198 <span class="keyword">global</span> xs t |
---|
1266 | 1199 |
---|
1267 | 1200 export_list=get(handles.export_list,<span class="string">'String'</span>); |
---|
1268 | 1201 export_val=get(handles.export_list,<span class="string">'UserData'</span>); |
---|
1269 | 1202 heditxml=get(handles.replicate,<span class="string">'parent'</span>); |
---|
1270 | 1203 Data=get(heditxml,<span class="string">'UserData'</span>) |
---|
1271 | 1204 |
---|
1272 | 1205 hdataview=findobj(allchild(0),<span class="string">'Name'</span>,<span class="string">'dataview'</span>) |
---|
1273 | 1206 <span class="keyword">if</span> isempty(hdataview) |
---|
1274 | 1207 hdataview=<a href="dataview.html" class="code" title="function varargout = dataview(varargin)">dataview</a>; |
---|
1275 | 1208 <span class="keyword">return</span> |
---|
1276 | 1209 <span class="keyword">end</span> |
---|
1277 | 1210 hhdataview=guidata(hdataview); |
---|
1278 | 1211 CurrentPath=get(hhdataview.CurrentFile,<span class="string">'String'</span>); |
---|
1279 | 1212 ListExperiments=get(hhdataview.ListExperiments,<span class="string">'String'</span>); |
---|
1280 | 1213 Value=get(hhdataview.ListExperiments,<span class="string">'Value'</span>); |
---|
1281 | 1214 <span class="keyword">if</span> ~isequal(Value,1) |
---|
1282 | 1215 ListExperiments=ListExperiments(Value); |
---|
1283 | 1216 <span class="keyword">end</span> |
---|
1284 | 1217 ListDevices=get(hhdataview.ListDevices,<span class="string">'String'</span>); |
---|
1285 | 1218 Value=get(hhdataview.ListDevices,<span class="string">'Value'</span>); |
---|
1286 | 1219 <span class="keyword">if</span> ~isequal(Value,1) |
---|
1287 | 1220 ListDevices=ListDevices(Value); |
---|
1288 | 1221 <span class="keyword">end</span> |
---|
1289 | 1222 ListRecords=get(hhdataview.ListRecords,<span class="string">'String'</span>); |
---|
1290 | 1223 Value=get(hhdataview.ListRecords,<span class="string">'Value'</span>); |
---|
1291 | 1224 <span class="keyword">if</span> ~isequal(Value,1) |
---|
1292 | 1225 ListRecords=ListRecords(Value); |
---|
1293 | 1226 <span class="keyword">end</span> |
---|
1294 | 1227 <span class="comment">% uvmat('runplus_Callback',hObject,eventdata,handleshaxes)</span> |
---|
1295 | 1228 [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); |
---|
1296 | 1229 ListXml=get(hhdataview.ListXml,<span class="string">'String'</span>); |
---|
1297 | 1230 Value=get(hhdataview.ListXml,<span class="string">'Value'</span>); |
---|
1298 | 1231 <span class="keyword">if</span> isequal(Value,1) |
---|
1299 | 1232 <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>) |
---|
1300 | 1233 <span class="keyword">return</span> |
---|
1301 | 1234 <span class="keyword">end</span> |
---|
1302 | 1235 ListXml=ListXml(Value);<span class="comment">%list of</span> |
---|
1303 | 1236 <span class="keyword">for</span> iexp=1:length(List.Experiment) |
---|
1304 | 1237 ExpName=List.Experiment{iexp}.name; |
---|
1305 | 1238 <span class="keyword">if</span> isfield(List.Experiment{iexp},<span class="string">'Device'</span>) |
---|
1306 | 1239 <span class="keyword">for</span> idevice=1:length(List.Experiment{iexp}.Device) |
---|
1307 | 1240 DeviceName=List.Experiment{iexp}.Device{idevice}.name; |
---|
1308 | 1241 <span class="keyword">if</span> isfield(List.Experiment{iexp}.Device{idevice},<span class="string">'xmlfile'</span>) |
---|
1309 | 1242 <span class="keyword">for</span> ixml=1:length(List.Experiment{iexp}.Device{idevice}.xmlfile) |
---|
1310 | 1243 FileName=List.Experiment{iexp}.Device{idevice}.xmlfile{ixml}; |
---|
1311 | 1244 <span class="keyword">for</span> ilistxml=1:length(ListXml) |
---|
1312 | 1245 <span class="keyword">if</span> isequal(FileName,ListXml{ilistxml}) |
---|
1313 | 1246 xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,FileName); |
---|
1314 | 1247 t_export=xmltree(xmlfullname); |
---|
1315 | 1248 rootelement=get(t_export,1,<span class="string">'name'</span>); |
---|
1316 | 1249 uidlist=Data.CurrentUid; |
---|
1317 | 1250 <span class="keyword">if</span> isequal(rootelement,get(t,1,<span class="string">'name'</span>)) |
---|
1318 | 1251 backupfile=xmlfullname; |
---|
1319 | 1252 testexist=2; |
---|
1320 | 1253 <span class="keyword">while</span> testexist==2 |
---|
1321 | 1254 backupfile=[backupfile <span class="string">'~'</span>]; |
---|
1322 | 1255 testexist=exist(backupfile,<span class="string">'file'</span>); |
---|
1323 | 1256 <span class="keyword">end</span> |
---|
1324 | 1257 [success,message]=copyfile(xmlfullname,backupfile);<span class="comment">%make backup</span> |
---|
1325 | 1258 <span class="keyword">if</span> ~isequal(success,1) |
---|
1326 | 1259 <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>) |
---|
1327 | 1260 <span class="keyword">return</span> |
---|
1328 | 1261 <span class="keyword">end</span> |
---|
1329 | 1262 findstr=[<span class="string">'/'</span> rootelement]; |
---|
1330 | 1263 uid_export(1)=1; |
---|
1331 | 1264 <span class="comment">% fill the root elements if absent</span> |
---|
1332 | 1265 <span class="keyword">for</span> index=2:length(uidlist) |
---|
1333 | 1266 name_t=get(t,uidlist(index),<span class="string">'name'</span>) |
---|
1334 | 1267 findstr=[findstr <span class="string">'/'</span> name_t] |
---|
1335 | 1268 uid=find(t_export,findstr) |
---|
1336 | 1269 <span class="keyword">if</span> isempty(uid) |
---|
1337 | 1270 [t_export,uid_export(index)]=add(t_export,uid_export(index-1),<span class="string">'element'</span>,name_t); |
---|
1338 | 1271 <span class="keyword">else</span> |
---|
1339 | 1272 uid_export(index)=uid; |
---|
1340 | 1273 <span class="keyword">end</span> |
---|
1341 | 1274 <span class="keyword">end</span> |
---|
1342 | 1275 <span class="comment">% chardata......</span> |
---|
1343 | 1276 <span class="keyword">end</span> |
---|
1344 | 1277 <span class="keyword">break</span> |
---|
1345 | 1278 <span class="keyword">end</span> |
---|
1346 | 1279 <span class="keyword">end</span> |
---|
1347 | 1280 <span class="comment">% [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,[],FileName,SubCampaignTest);</span> |
---|
1348 | 1281 <span class="comment">% if test</span> |
---|
1349 | 1282 <span class="comment">% [List.Experiment{iexp}.Device{idevice}.xmlfile{ixml} ' , Heading updated']</span> |
---|
1350 | 1283 <span class="comment">% end</span> |
---|
1351 | 1284 <span class="keyword">end</span> |
---|
1352 | 1285 <span class="keyword">elseif</span> isfield(List.Experiment{iexp}.Device{idevice},<span class="string">'Record'</span>) |
---|
1353 | 1286 <span class="keyword">for</span> irecord=1:length(List.Experiment{iexp}.Device{idevice}.Record) |
---|
1354 | 1287 RecordName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.name; |
---|
1355 | 1288 <span class="keyword">if</span> isfield(List.Experiment{iexp}.Device{idevice}.Record{irecord},<span class="string">'xmlfile'</span>) |
---|
1356 | 1289 <span class="keyword">for</span> ixml=1:length(List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile) |
---|
1357 | 1290 FileName=List.Experiment{iexp}.Device{idevice}.Record{irecord}.xmlfile{ixml}; |
---|
1358 | 1291 <span class="keyword">for</span> ilistxml=1:length(ListXml) |
---|
1359 | 1292 <span class="keyword">if</span> isequal(FileName,ListXml{ilistxml}) |
---|
1360 | 1293 xmlfullname=fullfile(CurrentPath,ExpName,DeviceName,RecordName,FileName) |
---|
1361 | 1294 <span class="keyword">break</span> |
---|
1362 | 1295 <span class="keyword">end</span> |
---|
1363 | 1296 <span class="keyword">end</span> |
---|
1364 | 1297 <span class="comment">% [Title,test]=check_heading(Currentpath,Campaign,ExpName,DeviceName,RecordName,FileName,SubCampaignTest);</span> |
---|
1365 | 1298 <span class="comment">% if test</span> |
---|
1366 | 1299 <span class="comment">% [FileName ' , Heading updated']</span> |
---|
1367 | 1300 <span class="comment">% end</span> |
---|
1368 | 1301 <span class="keyword">end</span> |
---|
1369 | 1302 <span class="keyword">end</span> |
---|
1370 | 1303 <span class="keyword">end</span> |
---|
1371 | 1304 <span class="keyword">end</span> |
---|
1372 | 1305 <span class="keyword">end</span> |
---|
1373 | 1306 <span class="keyword">end</span> |
---|
1374 | 1307 <span class="keyword">end</span> |
---|
1375 | 1308 <span class="keyword">return</span> |
---|
1376 | 1309 <span class="comment">%%%%%%%%%%% A REVOIR</span> |
---|
1377 | 1310 <span class="comment">% Copier la liste des elements selectionnés dans dataview</span> |
---|
1378 | 1311 <span class="comment">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</span> |
---|
1379 | 1312 <span class="comment">%ANCIEN:</span> |
---|
1380 | 1313 heditxml=get(hObject,<span class="string">'parent'</span>); |
---|
1381 | 1314 DataIn=get(heditxml,<span class="string">'UserData'</span>); |
---|
1382 | 1315 <span class="keyword">if</span> ~isfield(DataIn,<span class="string">'h_ref'</span>) |
---|
1383 | 1316 DataIn.h_ref=[]; |
---|
1384 | 1317 <span class="keyword">end</span> |
---|
1385 | 1318 <span class="keyword">if</span> ~ishandle(DataIn.h_ref) |
---|
1386 | 1319 errordlg(<span class="string">'no source file opened for import'</span>) |
---|
1387 | 1320 <span class="keyword">return</span> |
---|
1388 | 1321 <span class="keyword">end</span> |
---|
1389 | 1322 <span class="comment">%create the current root element if needed</span> |
---|
1390 | 1323 LengthElement=length(DataIn.CurrentUid); |
---|
1391 | 1324 FilledUid=find(DataIn.CurrentUid~=0); |
---|
1392 | 1325 LengthFilled=FilledUid(end); |
---|
1393 | 1326 <span class="keyword">for</span> irank=LengthFilled+1:LengthElement |
---|
1394 | 1327 attrib=attributes(xs,<span class="string">'get'</span>,DataIn.xs_CurrentUid(irank),1); |
---|
1395 | 1328 [t,DataIn.CurrentUid(irank)]=add(t,DataIn.CurrentUid(irank-1),<span class="string">'element'</span>,attrib.val); |
---|
1396 | 1329 <span class="keyword">end</span> |
---|
1397 | 1330 |
---|
1398 | 1331 <span class="comment">%copy list of subelements</span> |
---|
1399 | 1332 RefDataIn=get(DataIn.h_ref,<span class="string">'UserData'</span>); |
---|
1400 | 1333 list=get(handles.list_element,<span class="string">'UserData'</span>);<span class="comment">%=,[node;index]</span> |
---|
1401 | 1334 <span class="keyword">for</span> ilist=get(DataIn.h_ref,<span class="string">'Value'</span>) |
---|
1402 | 1335 node_content=get(xs,RefDataIn.xs_uid(ilist)); |
---|
1403 | 1336 <span class="keyword">if</span> ~isempty(node_content) & isfield(node_content,<span class="string">'attributes'</span>) |
---|
1404 | 1337 attrib=node_content.attributes; |
---|
1405 | 1338 <span class="keyword">for</span> iattr=1:length(attrib) |
---|
1406 | 1339 struct=attrib{iattr}; |
---|
1407 | 1340 <span class="keyword">if</span> isequal(struct.key,<span class="string">'name'</span>) |
---|
1408 | 1341 key=struct.val; <span class="comment">% read element key name</span> |
---|
1409 | 1342 <span class="keyword">end</span> |
---|
1410 | 1343 <span class="keyword">end</span> |
---|
1411 | 1344 <span class="keyword">end</span> |
---|
1412 | 1345 value=<span class="string">''</span>; |
---|
1413 | 1346 <span class="keyword">if</span> ~isequal(RefDataIn.uid(ilist),0) |
---|
1414 | 1347 child_uid=children(t_ref,RefDataIn.uid(ilist)); |
---|
1415 | 1348 <span class="keyword">if</span> isequal(length(child_uid),1) |
---|
1416 | 1349 content=get(t_ref,child_uid); |
---|
1417 | 1350 <span class="keyword">if</span> isfield(content,<span class="string">'type'</span>) &isfield(content,<span class="string">'value'</span>)& isequal(content.type,<span class="string">'chardata'</span>) |
---|
1418 | 1351 value=content.value; |
---|
1419 | 1352 <span class="keyword">end</span> |
---|
1420 | 1353 <span class="keyword">end</span> |
---|
1421 | 1354 <span class="keyword">end</span> |
---|
1422 | 1355 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); |
---|
1423 | 1356 <span class="keyword">end</span> |
---|
1424 | 1357 set(heditxml,<span class="string">'UserData'</span>,DataIn) |
---|
1425 | 1358 <span class="comment">%update the current listing</span> |
---|
1426 | 1359 [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)); |
---|
1427 | 1360 [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); |
---|
1428 | 1361 <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); |
---|
1429 | 1362 <span class="comment">% t=set_xml(t,xs_DataIn,subelem)</span> |
---|
1430 | 1363 <span class="comment">%edit list of subelments:</span> |
---|
1431 | 1364 |
---|
1432 | 1365 <span class="comment">%A REVOIR</span> |
---|
1433 | 1366 <span class="comment">% xsnode_index=get(handles.list_element,'UserDataIn')</span> |
---|
1434 | 1367 <span class="comment">% xs_node=xsnode_index(1,ind);</span> |
---|
1435 | 1368 <span class="comment">% RefDataIn=get(handles.ref_data,'UserDataIn');</span> |
---|
1436 | 1369 <span class="comment">% subelem=RefDataIn.subelem;</span> |
---|
1437 | 1370 <span class="comment">% xsnode_index=get(handles.list_element,'UserDataIn');%data on the xs_nodes of the subelements</span> |
---|
1438 | 1371 <span class="comment">% ref_list=get(handles.ref_data,'Value');%selected indices in the list of reference subelements</span> |
---|
1439 | 1372 <span class="comment">% xs_node=xsnode_index(1,ref_list);%xs_nodes of the selected subelements</span> |
---|
1440 | 1373 <span class="comment">% % index_chosen=xsnode_index(2,ref_list);% indices in the list of occurence for a subelement</span> |
---|
1441 | 1374 <span class="comment">% % for ilist=ref_list</span> |
---|
1442 | 1375 <span class="comment">% ilist=1;</span> |
---|
1443 | 1376 <span class="comment">% while icontinue</span> |
---|
1444 | 1377 <span class="comment">% 'TESTCOPY'</span> |
---|
1445 | 1378 <span class="comment">% [nodeup,path,xs_element,xs_subelem]=scan_schema(xs,xs_node(ilist))</span> |
---|
1446 | 1379 <span class="comment">% xs_subelem.key</span> |
---|
1447 | 1380 <span class="comment">% tsub=subelem(ilist).tsub</span> |
---|
1448 | 1381 <span class="comment">% xsnode_index(2,ilist)</span> |
---|
1449 | 1382 <span class="comment">% [ref_elem,ref_node,ref_subelem]=get_xml(tsub,'',xs_element,1,xs_subelem)</span> |
---|
1450 | 1383 <span class="comment">% ref_subelem.val</span> |
---|
1451 | 1384 <span class="comment">% testedit= ~isfield(element.attrup,'source') | isequal(element.attrup.source,'manual') %| element vide</span> |
---|
1452 | 1385 <span class="comment">%</span> |
---|
1453 | 1386 <span class="comment">%</span> |
---|
1454 | 1387 <span class="comment">% icontinue=0</span> |
---|
1455 | 1388 <span class="comment">% end</span> |
---|
1456 | 1389 <span class="comment">% function [element,node,subelem]=get_xml(t,path,xs_element,node,xs_subelem)</span> |
---|
1457 | 1390 <span class="comment">% element.attr_key='';%default</span> |
---|
1458 | 1391 <span class="comment">% element.attr_val='';%default</span> |
---|
1459 | 1392 <span class="comment">% element.val='';</span> |
---|
1460 | 1393 <span class="comment">% % element.type='';</span> |
---|
1461 | 1394 <span class="comment">% % element.testmanual=testmanual %inheritates the input manual editing flag by default</span> |
---|
1462 | 1395 <span class="comment">% subelem=[]; %default</span> |
---|
1463 | 1396 <span class="comment">% attrup=[];</span> |
---|
1464 | 1397 <span class="comment">% % node=[];</span> |
---|
1465 | 1398 <span class="comment">%</span> |
---|
1466 | 1399 <span class="comment">% % %find the element properties in the xml file</span> |
---|
1467 | 1400 <span class="comment">% if node >= 1</span> |
---|
1468 | 1401 <span class="comment">% elem_struct=get(t,node);</span> |
---|
1469 | 1402 <span class="comment">% if ~xs_element.subtest</span> |
---|
1470 | 1403 <span class="comment">% elem_contents=get(t,elem_struct.contents);</span> |
---|
1471 | 1404 <span class="comment">% if isempty(elem_contents)</span> |
---|
1472 | 1405 <span class="comment">% element.val=[];</span> |
---|
1473 | 1406 <span class="comment">% else</span> |
---|
1474 | 1407 <span class="comment">% element.val=elem_contents.value</span> |
---|
1475 | 1408 <span class="comment">% end</span> |
---|
1476 | 1409 <span class="comment">% end</span> |
---|
1477 | 1410 <span class="comment">% if isfield(elem_struct,'attributes')</span> |
---|
1478 | 1411 <span class="comment">% elem_attr=elem_struct.attributes;</span> |
---|
1479 | 1412 <span class="comment">% for iattr=1:length(elem_attr)</span> |
---|
1480 | 1413 <span class="comment">% element.attr_key{iattr}=elem_attr{iattr}.key ;</span> |
---|
1481 | 1414 <span class="comment">% element.attr_val{iattr}=elem_attr{iattr}.val;</span> |
---|
1482 | 1415 <span class="comment">% % attrup=setfield(attrup,elem_attr{iattr}.key,elem_attr{iattr}.val);</span> |
---|
1483 | 1416 <span class="comment">% breakdetect=find(elem_attr{iattr}.key=='/'| elem_attr{iattr}.key==':'| elem_attr{iattr}.key=='.');% find '/'</span> |
---|
1484 | 1417 <span class="comment">% if isempty(breakdetect)</span> |
---|
1485 | 1418 <span class="comment">% % comline=['attrup.' elem_attr{iattr}.key '=' elem_attr{iattr}.val ';']</span> |
---|
1486 | 1419 <span class="comment">% eval(['attrup.' elem_attr{iattr}.key '=''' elem_attr{iattr}.val ''';'])</span> |
---|
1487 | 1420 <span class="comment">% end</span> |
---|
1488 | 1421 <span class="comment">% end</span> |
---|
1489 | 1422 <span class="comment">% end</span> |
---|
1490 | 1423 <span class="comment">% end</span> |
---|
1491 | 1424 <span class="comment">% %get the parent node attributes</span> |
---|
1492 | 1425 <span class="comment">% up=1</span> |
---|
1493 | 1426 <span class="comment">% if node>0</span> |
---|
1494 | 1427 <span class="comment">% nodeup=node;</span> |
---|
1495 | 1428 <span class="comment">% while up==1;</span> |
---|
1496 | 1429 <span class="comment">% nodeup=get(t,nodeup,'parent');%move up to the parent in the tree</span> |
---|
1497 | 1430 <span class="comment">% if isempty(nodeup)</span> |
---|
1498 | 1431 <span class="comment">% up=0;</span> |
---|
1499 | 1432 <span class="comment">% else</span> |
---|
1500 | 1433 <span class="comment">% nodeup_content=get(t,nodeup);</span> |
---|
1501 | 1434 <span class="comment">% attrib=nodeup_content.attributes;</span> |
---|
1502 | 1435 <span class="comment">% for iattr=1:length(attrib)</span> |
---|
1503 | 1436 <span class="comment">% key=attrib{iattr}.key;</span> |
---|
1504 | 1437 <span class="comment">% breakdetect=find(key=='/'| key==':'| key=='.');% find '/'</span> |
---|
1505 | 1438 <span class="comment">% if ~isfield(attrup,key) & isempty(breakdetect)</span> |
---|
1506 | 1439 <span class="comment">% eval(['attrup.' key '=''' attrib{iattr}.val ''';'])</span> |
---|
1507 | 1440 <span class="comment">% end</span> |
---|
1508 | 1441 <span class="comment">% end</span> |
---|
1509 | 1442 <span class="comment">% end</span> |
---|
1510 | 1443 <span class="comment">% end</span> |
---|
1511 | 1444 <span class="comment">% element.attrup=attrup;</span> |
---|
1512 | 1445 <span class="comment">% end</span> |
---|
1513 | 1446 <span class="comment">% %find the subelement properties in the xml file</span> |
---|
1514 | 1447 <span class="comment">% if xs_element.subtest</span> |
---|
1515 | 1448 <span class="comment">% iline=0;</span> |
---|
1516 | 1449 <span class="comment">% for k=1:length(xs_subelem)%node2: list of subelements in the sub-sequence</span> |
---|
1517 | 1450 <span class="comment">% % attr=attributes(xs,'get',node2(i),1);%</span> |
---|
1518 | 1451 <span class="comment">% % element=attr.val;%name of the element</span> |
---|
1519 | 1452 <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> |
---|
1520 | 1453 <span class="comment">% struct_element=get(t,tag);%get the content of the element</span> |
---|
1521 | 1454 <span class="comment">% if isempty(struct_element)</span> |
---|
1522 | 1455 <span class="comment">% iline=iline+1;</span> |
---|
1523 | 1456 <span class="comment">% subelem(iline).xsindex=k;</span> |
---|
1524 | 1457 <span class="comment">% subelem(iline).index=0;</span> |
---|
1525 | 1458 <span class="comment">% % subelem(iline).testmanual=element.testmanual;% inheritates the manual editing flag by default</span> |
---|
1526 | 1459 <span class="comment">% if isequal(xs_subelem(k).minOccurs,0)</span> |
---|
1527 | 1460 <span class="comment">% subelem(iline).val='[]';%element value not mandatory in the schema</span> |
---|
1528 | 1461 <span class="comment">% else</span> |
---|
1529 | 1462 <span class="comment">% subelem(iline).val='[MISSING]';%element value mandatory in the schema</span> |
---|
1530 | 1463 <span class="comment">% end</span> |
---|
1531 | 1464 <span class="comment">% % subelem(iline).attrup=attrup; %inheritated attributes</span> |
---|
1532 | 1465 <span class="comment">% elseif isequal(length(struct_element),1)</span> |
---|
1533 | 1466 <span class="comment">% contents=get(t,struct_element.contents);</span> |
---|
1534 | 1467 <span class="comment">% iline=iline+1;</span> |
---|
1535 | 1468 <span class="comment">% subelem(iline).xsindex=k;</span> |
---|
1536 | 1469 <span class="comment">% subelem(iline).index=1;</span> |
---|
1537 | 1470 <span class="comment">% % subelem(iline).testmanual=element.testmanual;%</span> |
---|
1538 | 1471 <span class="comment">% if isfield(contents,'value') & ~isempty(contents.value)</span> |
---|
1539 | 1472 <span class="comment">% subelem(iline).val=contents.value;</span> |
---|
1540 | 1473 <span class="comment">% elseif xs_subelem(k).testsub</span> |
---|
1541 | 1474 <span class="comment">% subelem(iline).val='';</span> |
---|
1542 | 1475 <span class="comment">% elseif isequal(xs_subelem(k).minOccurs,0)</span> |
---|
1543 | 1476 <span class="comment">% subelem(iline).val='[]';%element value not mandatory in the schema</span> |
---|
1544 | 1477 <span class="comment">% else</span> |
---|
1545 | 1478 <span class="comment">% subelem(iline).val='[MISSING]';%element value mandatory in the schema</span> |
---|
1546 | 1479 <span class="comment">% end</span> |
---|
1547 | 1480 <span class="comment">% % subelem(iline).attrup=attrup; %inheritated attributes</span> |
---|
1548 | 1481 <span class="comment">% if isfield(struct_element,'attributes')</span> |
---|
1549 | 1482 <span class="comment">% element_attr=struct_element.attributes;</span> |
---|
1550 | 1483 <span class="comment">% attr_display=[];</span> |
---|
1551 | 1484 <span class="comment">% for iattr=1:length(element_attr)</span> |
---|
1552 | 1485 <span class="comment">% % attr_display{iline}=[attr_display ' , ' element_attr{iattr}.key ' = ' element_attr{iattr}.val];</span> |
---|
1553 | 1486 <span class="comment">% subelem(iline).val=[subelem(iline).val attr_display ' , ' element_attr{iattr}.key ' = ' element_attr{iattr}.val];</span> |
---|
1554 | 1487 <span class="comment">% % subelem(iline).attrup=setfield(subelem(iline).attrup,element_attr{iattr}.key,element_attr{iattr}.val);</span> |
---|
1555 | 1488 <span class="comment">% end</span> |
---|
1556 | 1489 <span class="comment">% end</span> |
---|
1557 | 1490 <span class="comment">% else%case of a multiple element</span> |
---|
1558 | 1491 <span class="comment">% for subindex=1:length(struct_element)</span> |
---|
1559 | 1492 <span class="comment">% contents=get(t,struct_element{subindex}.contents);</span> |
---|
1560 | 1493 <span class="comment">% iline=iline+1;</span> |
---|
1561 | 1494 <span class="comment">% subelem(iline).index=subindex;%index of the element</span> |
---|
1562 | 1495 <span class="comment">% subelem(iline).xsindex=k;</span> |
---|
1563 | 1496 <span class="comment">% % subelem(iline).testmanual=element.testmanual;%</span> |
---|
1564 | 1497 <span class="comment">% if isfield(contents,'value')& ~isempty(contents.value)</span> |
---|
1565 | 1498 <span class="comment">% subelem(iline).val=contents.value;</span> |
---|
1566 | 1499 <span class="comment">% elseif xs_subelem(k).testsub</span> |
---|
1567 | 1500 <span class="comment">% subelem(iline).val='';</span> |
---|
1568 | 1501 <span class="comment">% else</span> |
---|
1569 | 1502 <span class="comment">% subelem(iline).val='[]';</span> |
---|
1570 | 1503 <span class="comment">% end</span> |
---|
1571 | 1504 <span class="comment">% % subelem(iline).attrup=attrup; %inheritated attributes</span> |
---|
1572 | 1505 <span class="comment">% if isfield(struct_element{subindex},'attributes')</span> |
---|
1573 | 1506 <span class="comment">% element_attr=struct_element{subindex}.attributes;</span> |
---|
1574 | 1507 <span class="comment">% attr_display=[];</span> |
---|
1575 | 1508 <span class="comment">% for iattr=1:length(element_attr)</span> |
---|
1576 | 1509 <span class="comment">% % attr_display{iline}=[attr_display ' , ' element_attr{iattr}.key ' = ' element_attr{iattr}.val];</span> |
---|
1577 | 1510 <span class="comment">% subelem(iline).val=[subelem(iline).val attr_display ' , ' element_attr{iattr}.key ' = ' element_attr{iattr}.val];</span> |
---|
1578 | 1511 <span class="comment">% % subelem(iline).attrup=setfield(subelem(iline).attrup,element_attr{iattr}.key,element_attr{iattr}.val);</span> |
---|
1579 | 1512 <span class="comment">% end</span> |
---|
1580 | 1513 <span class="comment">% end</span> |
---|
1581 | 1514 <span class="comment">% end</span> |
---|
1582 | 1515 <span class="comment">% end</span> |
---|
1583 | 1516 <span class="comment">% end</span> |
---|
1584 | 1517 <span class="comment">% end</span> |
---|
1585 | 1518 |
---|
1586 | 1519 |
---|
1587 | 1520 <span class="comment">% --- Executes on button press in HELP.</span> |
---|
1588 | 1521 <a name="_sub18" href="#_subfunctions" class="code">function HELP_Callback(hObject, eventdata, handles)</a> |
---|
1589 | 1522 path_to_uvmat=which (<span class="string">'uvmat'</span>)<span class="comment">% check the path of uvmat</span> |
---|
1590 | 1523 pathelp=fileparts(path_to_uvmat); |
---|
1591 | 1524 helpfile=fullfile(pathelp,<span class="string">'UVMAT_DOC'</span>,<span class="string">'uvmat_doc.html'</span>); |
---|
1592 | 1525 <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>) |
---|
1593 | 1526 <span class="keyword">else</span> |
---|
1594 | 1527 web([helpfile <span class="string">'#editxml'</span>]) |
---|
1595 | 1528 <span class="keyword">end</span> |
---|
1596 | 1529 |
---|
1597 | 1530 |
---|
1598 | 1531 <span class="comment">% --- Executes on button press in Export.</span> |
---|
1599 | 1532 <a name="_sub19" href="#_subfunctions" class="code">function Export_Callback(hObject, eventdata, handles)</a> |
---|
1600 | 1533 val=get(handles.Export,<span class="string">'Value'</span>); |
---|
1601 | 1534 <span class="keyword">if</span> val |
---|
1602 | 1535 set(handles.Export,<span class="string">'BackgroundColor'</span>,[0 1 0]) |
---|
1603 | 1536 set(handles.export_list,<span class="string">'Visible'</span>,<span class="string">'on'</span>) |
---|
1604 | 1537 set(handles.replicate,<span class="string">'Visible'</span>,<span class="string">'on'</span>) |
---|
1605 | 1538 h_dataview=findobj(allchild(0),<span class="string">'name'</span>,<a href="dataview.html" class="code" title="function varargout = dataview(varargin)">dataview</a>'); |
---|
1606 | 1539 <span class="keyword">if</span> isempty(h_dataview) |
---|
1607 | 1540 <span class="comment">% CurrentFile=get(handles.CurrentFile,'String');</span> |
---|
1608 | 1541 <a href="dataview.html" class="code" title="function varargout = dataview(varargin)">dataview</a>; |
---|
1609 | 1542 <span class="keyword">end</span> |
---|
1610 | 1543 <span class="keyword">else</span> |
---|
1611 | 1544 set(handles.Export,<span class="string">'BackgroundColor'</span>,[0.7 0.7 0.7]) |
---|
1612 | 1545 set(handles.export_list,<span class="string">'Visible'</span>,<span class="string">'off'</span>) |
---|
1613 | 1546 set(handles.replicate,<span class="string">'Visible'</span>,<span class="string">'off'</span>) |
---|
1614 | 1547 <span class="keyword">end</span> |
---|
1615 | 1548 |
---|
1616 | 1549 |
---|
1617 | 1550 <span class="comment">% --- Executes on button press in pushbutton9.</span> |
---|
1618 | 1551 <a name="_sub20" href="#_subfunctions" class="code">function pushbutton9_Callback(hObject, eventdata, handles)</a> |
---|
1619 | 1552 <span class="comment">% hObject handle to pushbutton9 (see GCBO)</span> |
---|
1620 | 1553 <span class="comment">% eventdata reserved - to be defined in a future version of MATLAB</span> |
---|
1621 | 1554 <span class="comment">% handles structure with handles and user data (see GUIDATA)</span> |
---|
1622 | 1555 |
---|
1623 | 1556</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> © 2003</address> |
---|
1625 | </body> |
---|
1626 | </html> |
---|