comparison m-toolbox/classes/+utils/@xml/attachCellToDom.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 = attachCellToDom(objs, dom, parent, collectedHist)
3
4 % Store the cell shape in the parent node
5 parent.setAttribute('cellShape', sprintf('%dx%d', size(objs)));
6 parent.setAttribute('type', class(objs));
7
8 if isempty(objs)
9
10 % Create cell node
11 cellNode = dom.createElement('cell');
12 cellNode.setAttribute('cellShape', sprintf('%dx%d', size(objs)));
13 cellNode.setAttribute('shape', sprintf('%dx%d', size(objs)));
14 cellNode.setAttribute('type', 'empty-cell');
15
16 % Add to parent node
17 parent.appendChild(cellNode);
18
19 else
20
21 for oo = 1:numel(objs)
22 obj = objs{oo};
23
24 % Create cell node
25 cellNode = dom.createElement('cell');
26
27 % It is necessary to add 'cellShape' to a cell node because
28 % attachNumberToDom overwrites the attribute 'shape' (in some cases)
29 cellNode.setAttribute('cellShape', sprintf('%dx%d', size(objs)));
30 cellNode.setAttribute('shape', sprintf('%dx%d', size(obj)));
31 cellNode.setAttribute('type', class(obj));
32
33 if isnumeric(obj)
34
35 utils.xml.attachNumberToDom(obj, dom, cellNode);
36
37 elseif islogical(obj)
38 content = dom.createTextNode(utils.xml.mat2str(obj));
39 cellNode.appendChild(content);
40
41 elseif isa(obj, 'sym')
42 utils.xml.attachSymToDom(obj, dom, cellNode);
43
44 elseif ischar(obj)
45 utils.xml.attachCharToDom(obj, dom, cellNode);
46
47 elseif isa(obj, 'ltpda_obj')
48 collectedHist = obj.attachToDom(dom, cellNode, collectedHist);
49
50 elseif iscell(obj)
51 collectedHist = utils.xml.attachCellToDom(obj, dom, cellNode, collectedHist);
52
53 elseif isstruct(obj)
54 collectedHist = utils.xml.attachStructToDom(obj, dom, cellNode, collectedHist);
55
56 elseif isjava(obj)
57 if strcmp(class(obj), 'sun.util.calendar.ZoneInfo')
58 content = dom.createTextNode(char(obj.getID));
59 cellNode.appendChild(content);
60 else
61 error('### Unknown JAVA class. Can not attach the java class %s to DOM.', class(obj));
62 end
63
64 else
65 error('!!! Please code me up for the class [%s]', class(obj));
66 end
67
68 % Add to parent node
69 parent.appendChild(cellNode);
70
71 end
72
73 end
74
75 end