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

xdoc2ao

PURPOSE ^

XDOC2AO converts a DOM object to an AO.

SYNOPSIS ^

function aout = xdoc2ao(xdoc)

DESCRIPTION ^

 XDOC2AO converts a DOM object to an AO.
 
 M Hewitson 16-05-07
 
 $Id: xdoc2ao.m,v 1.1 2007/05/16 12:59:33 hewitson Exp $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function aout = xdoc2ao(xdoc)
0002 
0003 % XDOC2AO converts a DOM object to an AO.
0004 %
0005 % M Hewitson 16-05-07
0006 %
0007 % $Id: xdoc2ao.m,v 1.1 2007/05/16 12:59:33 hewitson Exp $
0008 %
0009 
0010 ain = xdoc.getElementsByTagName('a');
0011 a = ain.item(0);
0012 
0013 children = a.getChildNodes;
0014 
0015 tag        = -1;
0016 name       = '';
0017 prov       = [];
0018 comment    = '';
0019 mfile      = '';
0020 mfname     = '';
0021 mdlfile    = '';
0022 mdlfname   = '';
0023 hist       = [];
0024 data       = [];
0025 
0026 % Go through children of AO object
0027 for j=1:children.getLength
0028   
0029   ch = children.item(j-1);
0030   
0031   nodeName = char(ch.getNodeName);
0032   if ischar(nodeName)
0033     switch nodeName
0034       case 'Tag'
0035         tag = str2num(char(ch.getTextContent));
0036       case 'Name'
0037         name = char(ch.getTextContent);
0038       case 'Provenance'
0039         prov = xml_read_provenance(ch);
0040       case 'Comment'
0041         comment = char(ch.getTextContent);
0042       case 'M-file'
0043         mfile = char(ch.getTextContent);
0044       case 'Mfilename'
0045         mfname = char(ch.getTextContent);
0046       case 'Mdl-file'
0047         mdlfile = char(ch.getTextContent);
0048       case 'Mdlfilename'
0049         mdlfname = char(ch.getTextContent);
0050       case 'hist'    
0051         hist = xml_read_hist(ch);
0052       case 'Data'
0053         data = xml_read_data(ch);
0054       otherwise
0055 %         warning(['!!! unknown child node: ' nodeName]);
0056     end
0057   end 
0058 end
0059 
0060 % Now build AO
0061 aout.tag         = tag;
0062 aout.name        = name;
0063 aout.data        = data;
0064 aout.hist        = hist;
0065 aout.provenance  = prov;
0066 aout.comment     = comment;
0067 aout.mfile       = mfile;
0068 aout.mfilename   = mfname;
0069 aout.mdlfile     = mdlfile;
0070 aout.mdlfilename = mdlfname;
0071 aout = class(aout, 'ao');
0072 
0073

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003