comparison m-toolbox/classes/@smodel/attachToDom.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1
2 function collectedHist = attachToDom(objs, dom, parent, collectedHist)
3
4 if isempty(objs)
5
6 % Create empty smodel node with the attribute 'shape'
7 utils.xml.attachEmptyObjectNode(objs, dom, parent);
8
9 else
10 for oo = 1:numel(objs)
11 obj = objs(oo);
12
13 % Create object node
14 smodelNode = dom.createElement('smodel');
15 smodelNode.setAttribute('shape', sprintf('%dx%d', size(objs)));
16
17 % Call superclass
18 collectedHist = attachToDom@ltpda_uoh(obj, dom, smodelNode, collectedHist);
19
20 % Add expression
21 if ~isempty(obj.expr)
22 exprNode = dom.createElement('expr');
23 utils.xml.attachCharToDom(obj.expr.s, dom, exprNode);
24 smodelNode.appendChild(exprNode);
25 end
26
27 % Add parameters
28 content = dom.createTextNode(utils.xml.cellstr2str(obj.params));
29 paramsNode = dom.createElement('params');
30 paramsNode.appendChild(content);
31 smodelNode.appendChild(paramsNode);
32
33 % Add default values for the parameters
34 valuesNode = dom.createElement('values');
35 collectedHist = utils.xml.attachCellToDom(obj.values, dom, valuesNode, collectedHist);
36 smodelNode.appendChild(valuesNode);
37
38 % Add default trans for the parameters
39 transNode = dom.createElement('trans');
40 if ischar(obj.trans) || isnumeric(obj.trans)
41 utils.xml.attachCharToDom(num2str(obj.trans), dom, transNode);
42 transNode.setAttribute('type', 'char');
43 elseif iscell(obj.trans)
44 transNode = dom.createElement('trans');
45 collectedHist = utils.xml.attachCellToDom(obj.trans, dom, transNode, collectedHist);
46 transNode.setAttribute('type', 'cell');
47 end
48 smodelNode.appendChild(transNode);
49
50 % Add x-variable
51 xvarNode = dom.createElement('xvar');
52 if ischar(obj.xvar)
53 utils.xml.attachCharToDom(obj.xvar, dom, xvarNode);
54 xvarNode.setAttribute('type', 'char');
55 elseif iscellstr(obj.xvar)
56 content = dom.createTextNode(utils.xml.cellstr2str(obj.xvar));
57 xvarNode.appendChild(content);
58 xvarNode.setAttribute('type', 'cellstr');
59 else
60 error('### Unexpected values in xvar. %s', class(obj.xvar));
61 end
62 smodelNode.appendChild(xvarNode);
63
64 % Add values for the x-variable
65 if ~isempty(obj.xvals)
66 xvalsNode = dom.createElement('xvals');
67 collectedHist = utils.xml.attachCellToDom(obj.xvals, dom, xvalsNode, collectedHist);
68 smodelNode.appendChild(xvalsNode);
69 end
70
71 % Add units of the x-axis
72 if isa(obj.xunits, 'unit')
73 xunitsNode = dom.createElement('xunits');
74 collectedHist = obj.xunits.attachToDom(dom, xunitsNode, collectedHist);
75 smodelNode.appendChild(xunitsNode);
76 end
77
78 % Add units of the y-axis
79 if isa(obj.yunits, 'unit')
80 yunitsNode = dom.createElement('yunits');
81 collectedHist = obj.yunits.attachToDom(dom, yunitsNode, collectedHist);
82 smodelNode.appendChild(yunitsNode);
83 end
84
85 % Add aliasNames
86 if ~isempty(obj.aliasNames)
87 aliasNamesNode = dom.createElement('aliasNames');
88 collectedHist = utils.xml.attachCellToDom(obj.aliasNames, dom, aliasNamesNode, collectedHist);
89 smodelNode.appendChild(aliasNamesNode);
90 end
91
92 % Add aliasValues
93 if ~isempty(obj.aliasValues)
94 aliasValuesNode = dom.createElement('aliasValues');
95 collectedHist = utils.xml.attachCellToDom(obj.aliasValues, dom, aliasValuesNode, collectedHist);
96 smodelNode.appendChild(aliasValuesNode);
97 end
98
99 % Add to parent node
100 parent.appendChild(smodelNode);
101
102 end
103 end
104
105 end