comparison m-toolbox/classes/@smodel/fromDom.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 obj = fromDom(obj, node, inhists)
3
4 % Get shape
5 objShape = utils.xml.getShape(node);
6
7 if any(objShape==0)
8
9 obj = smodel.initObjectWithSize(objShape(1), objShape(2));
10
11 else
12
13 %%%%%%%%%% Call super-class
14
15 fromDom@ltpda_uoh(obj, node, inhists);
16
17 %%%%%%%%%% Get properties from the node attributes
18
19 %%%%%%%%%% Get properties from the child nodes
20
21 % Get expr
22 childNode = utils.xml.getChildByName(node, 'expr');
23 if ~isempty(childNode)
24 obj.expr = utils.xml.getString(childNode);
25 end
26
27 % Get params
28 childNode = utils.xml.getChildByName(node, 'params');
29 if ~isempty(childNode)
30 obj.params = eval(utils.xml.mchar(childNode.getTextContent()));
31 end
32
33 % Get values
34 childNode = utils.xml.getChildByName(node, 'values');
35 if ~isempty(childNode)
36 obj.values = utils.xml.getCell(childNode, inhists);
37 end
38
39 % Get trans
40 childNode = utils.xml.getChildByName(node, 'trans');
41 if ~isempty(childNode)
42 type = utils.xml.mchar(childNode.getAttribute('type'));
43 if strcmp(type, 'char')
44 obj.trans = utils.xml.getString(childNode);
45 elseif strcmp(type, 'cell')
46 obj.trans = utils.xml.getCell(childNode, inhists);
47 else
48 error('### Don''t expect the type %s for ''xvals''', type);
49 end
50 end
51
52 % Get xvar
53 childNode = utils.xml.getChildByName(node, 'xvar');
54 if ~isempty(childNode)
55 type = utils.xml.mchar(childNode.getAttribute('type'));
56 if strcmp(type, 'char')
57 obj.xvar = utils.xml.getString(childNode);
58 elseif strcmp(type, 'cellstr')
59 obj.xvar = eval(utils.xml.mchar(childNode.getTextContent()));
60 else
61 error('### Don''t expect the type %s for ''xvals''', type);
62 end
63 end
64
65 % Get xvals
66 childNode = utils.xml.getChildByName(node, 'xvals');
67 if ~isempty(childNode)
68 type = utils.xml.mchar(childNode.getAttribute('type'));
69 if strcmp(type, 'cell')
70 obj.xvals = utils.xml.getCell(childNode, inhists);
71 elseif strcmp(type, 'double')
72 obj.xvals = utils.xml.getNumber(childNode);
73 else
74 error('### Don''t expect the type %s for ''xvals''', type);
75 end
76 end
77
78 % Get xunits
79 childNode = utils.xml.getChildByName(node, 'xunits');
80 if ~isempty(childNode)
81 obj.xunits = unit(childNode, inhists);
82 end
83
84 % Get yunits
85 childNode = utils.xml.getChildByName(node, 'yunits');
86 if ~isempty(childNode)
87 obj.yunits = unit(childNode, inhists);
88 end
89
90 % Get aliasNames
91 childNode = utils.xml.getChildByName(node, 'aliasNames');
92 if ~isempty(childNode)
93 obj.aliasNames = utils.xml.getCell(childNode, inhists);
94 end
95
96 % Get aliasValues
97 childNode = utils.xml.getChildByName(node, 'aliasValues');
98 if ~isempty(childNode)
99 obj.aliasValues = utils.xml.getCell(childNode, inhists);
100 end
101
102 end
103
104 end