Home > classes > @ao > private > xml_read_data.m

xml_read_data

PURPOSE ^

XML_READ_DATA read a data object from the given node of an XML DOM

SYNOPSIS ^

function data = xml_read_data(node)

DESCRIPTION ^

 XML_READ_DATA read a data object from the given node of an XML DOM
 object.
 
 M Hewitson 14-02-07
 
 $Id: xml_read_data.html,v 1.1 2007/06/08 14:15:04 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function data = xml_read_data(node)
0002 
0003 % XML_READ_DATA read a data object from the given node of an XML DOM
0004 % object.
0005 %
0006 % M Hewitson 14-02-07
0007 %
0008 % $Id: xml_read_data.html,v 1.1 2007/06/08 14:15:04 hewitson Exp $
0009 %
0010 
0011 
0012 disp('-- reading data');
0013 children = node.getChildNodes;
0014 
0015 % defaults
0016 t0     = '';
0017 navs   = [];
0018 enbw   = [];
0019 fs     = [];
0020 xunits = '';
0021 yunits = '';
0022 dType  = '';
0023 
0024 % Go through to get type etc
0025 for j=1:children.getLength
0026   ch = children.item(j-1);  
0027   nodeName = char(ch.getNodeName);
0028   switch nodeName
0029     case 'Type'
0030       type =  char(ch.getTextContent);
0031     case 'Name'
0032       name = char(ch.getTextContent);
0033     case 'Created'
0034       created = char(ch.getTextContent);
0035     case 'Xunits'
0036       xunits = char(ch.getTextContent);
0037     case 'Yunits'
0038       yunits = char(ch.getTextContent);
0039     case 'Shape'
0040       shape = str2num(char(ch.getTextContent));
0041     case 'Fs'
0042       fs = str2num(char(ch.getTextContent));
0043     case 'ENBW'
0044       enbw = str2num(char(ch.getTextContent));
0045     case 'Navs'
0046       navs = str2num(char(ch.getTextContent));
0047     case 'Version'
0048       version = char(ch.getTextContent);   
0049     case 'dType'
0050       dType = char(ch.getTextContent);   
0051     case 'Data'
0052       data = xml_read_datasamples(ch, dType);
0053     otherwise
0054 %       warning(['!!! unknown data field: ' nodeName]);
0055   end
0056 end
0057 
0058 % Build output data object
0059 if strcmp(type, 'fsdata')
0060   data = fsdata(data.x, data.y, fs);
0061   data = set(data, 'enbw', enbw);
0062   data = set(data, 'navs', navs);
0063   
0064 elseif strcmp(type, 'cdata')
0065   
0066   data = cdata(reshape(data.y, shape));
0067   
0068 elseif strcmp(type, 'tsdata')
0069   
0070   data = tsdata(data.y, fs);
0071 
0072   elseif strcmp(type, 'xydata')
0073   
0074   data = xydata(data.x, data.y);
0075 
0076 else
0077   error(['### unknown data type: ' type]);
0078 end
0079 
0080 data = set(data, 'name', name);
0081 data = set(data, 'version', version);
0082 data = set(data, 'created', created);
0083 data = set(data, 'xunits', xunits);
0084 data = set(data, 'yunits', yunits);
0085 
0086 
0087 
0088 
0089 % END
0090

Generated on Fri 08-Jun-2007 16:09:11 by m2html © 2003