Home > classes > @param > private > fromxml.m

fromxml

PURPOSE ^

FROMXML read from part of an XML tree and create a param object.

SYNOPSIS ^

function p = fromxml(xml)

DESCRIPTION ^

 FROMXML read from part of an XML tree and create a param object.

 M Hewitson 28-08-07

 $Id: fromxml.html,v 1.6 2008/02/12 12:18:01 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function p = fromxml(xml)
0002 
0003 % FROMXML read from part of an XML tree and create a param object.
0004 %
0005 % M Hewitson 28-08-07
0006 %
0007 % $Id: fromxml.html,v 1.6 2008/02/12 12:18:01 hewitson Exp $
0008 %
0009 
0010 % disp('---------------- param ------------------')
0011 % xml.getNodeName
0012 % disp('---------------- param ------------------')
0013 
0014 p = param();
0015 sch = xml.getChildNodes;
0016 for c=1:sch.getLength
0017   x = sch.item(c-1);
0018   switch char(x.getNodeName)
0019     case 'name'
0020       p.name = char(x.getTextContent);
0021     case 'created'
0022       xch = x.getChildNodes;
0023       p = set(p, 'created', time(xch.item(1)));
0024     case 'version'
0025       p = set(p, 'version', char(x.getTextContent));
0026     case 'key'
0027       p = set(p, 'key', char(x.getTextContent));
0028     case 'value'
0029       % if this has children then there is probably an object
0030       % below this
0031       mych = x.getChildNodes;
0032       if mych.getLength > 1
0033         % get the object
0034         vobj = x.item(1);
0035         switch char(vobj.getNodeName)
0036           case 'specwin'
0037             p = set(p, 'val', specwin(vobj));
0038           case 'miir'
0039             p = set(p, 'val', miir(vobj));
0040           case 'mfir'
0041             p = set(p, 'val', mfir(vobj));
0042           case 'pole'
0043             p = set(p, 'val', pole(vobj));
0044           case 'zero'
0045             p = set(p, 'val', zero(vobj));
0046           case 'pzmodel'
0047             p = set(p, 'val', pzmodel(vobj));
0048           case 'time'
0049             p = set(p, 'val', time(vobj));
0050           case 'timespan'
0051             p = set(p, 'val', timespan(vobj));
0052           otherwise
0053             error('### Unknown object in parameter value.');
0054         end
0055       else
0056         % we have numeric or char parameter
0057         valstr = char(x.getTextContent);
0058         if ~isempty(str2num(valstr))
0059           p = set(p, 'val', str2num(valstr));
0060         else
0061           if strcmp(valstr, 'logical value: true')
0062             p = set(p, 'val', true);
0063           elseif strcmp(valstr, 'logical value: false')
0064             p = set(p, 'val', false);
0065           elseif length(valstr) >= 5 && strcmp(valstr(1:5), 'CELL:')
0066             p = set(p, 'val', ltpda_str2cells(valstr(6:end)));
0067           else
0068             p = set(p, 'val', valstr);
0069           end
0070         end
0071       end
0072     otherwise
0073   end
0074 end
0075 
0076 % build plist
0077 
0078 % END

Generated on Tue 12-Feb-2008 13:12:45 by m2html © 2003