comparison m-toolbox/classes/@unit/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 % There exist two possibilities.
5 %
6 % first (only one unit object):
7 % <parent exps="1" shape="1x1" strs="{'Hz'}" vals="1"/>
8 %
9 % second:
10 % <parent>
11 % <unit exps="1" shape="1x2" strs="{'Hz'}" vals="1"/>
12 % <unit exps="1" shape="1x2" strs="{'m'}" vals="1000"/>
13 % </parent>
14
15
16 if node.hasAttribute('shape')
17
18 %%%% first possibility
19 % Get shape
20 objShape = utils.xml.getShape(node);
21
22 if any(objShape==0)
23
24 obj = unit.initObjectWithSize(objShape(1), objShape(2));
25
26 else
27
28 %%%%%%%%%% Call super-class
29
30 fromDom@ltpda_nuo(obj, node, inhists);
31
32 %%%%%%%%%% Get properties from the node attributes
33
34 % Add strs
35 obj.strs = eval(utils.xml.mchar(node.getAttribute('strs')));
36
37 % Add exps
38 obj.exps = eval(utils.xml.mchar(node.getAttribute('exps')));
39
40 % Add vals
41 obj.vals = eval(utils.xml.mchar(node.getAttribute('vals')));
42
43 end
44
45 else
46
47 %%%% second possibility
48 % If the parent don't have the attribute 'shape' then are the unit
49 % objects in the child nodes.
50
51 %%%%%%%%%% Get units from child nodes
52 obj = utils.xml.getObject(node, inhists);
53
54 end
55
56 end