MATHML2ARRAY Parses a MathML vector or array into a Matlab array.
0001 function array = mathml2array( mathml ) 0002 %MATHML2ARRAY Parses a MathML vector or array into a Matlab array. 0003 0004 % Author: Ivan E. Cao-Berg (icaoberg@cmu.edu) 0005 % Created: May 8, 2007 0006 % Last Update: March 4, 2008 0007 % 0008 % Copyright (C) 2008 Center for Bioimage Informatics/Murphy Lab 0009 % Carnegie Mellon University 0010 % 0011 % This program is free software; you can redistribute it and/or modify 0012 % it under the terms of the GNU General Public License as published 0013 % by the Free Software Foundation; either version 2 of the License, 0014 % or (at your option) any later version. 0015 % 0016 % This program is distributed in the hope that it will be useful, but 0017 % WITHOUT ANY WARRANTY; without even the implied warranty of 0018 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0019 % General Public License for more details. 0020 % 0021 % You should have received a copy of the GNU General Public License 0022 % along with this program; if not, write to the Free Software 0023 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 0024 % 02110-1301, USA. 0025 % 0026 % For additional information visit http://murphylab.web.cmu.edu or 0027 % send email to murphy@cmu.edu 0028 0029 if( nargin ~= 1 ) 0030 error( 'CellOrganizer: Wrong number of input arguments' ); 0031 else 0032 mathml = checkInputArguments( mathml ); 0033 0034 if( strfind( mathml{1}, 'vector' ) ) 0035 array = vector( mathml ); 0036 elseif( strfind( mathml{1}, 'array' )) 0037 array = matrix( mathml ); 0038 else 0039 error( ['CellOrganizer: The information in the cell array is ' ... 0040 'not a supported MathML code.'] ); 0041 end 0042 end 0043 end%mathml2array 0044 0045 %-------------------------------------------------------------------------- 0046 % HELPER METHODS 0047 function mathml = checkInputArguments( mathml ) 0048 % CHECKINPUTARGUMENTS Checks the validity of the arguments of the main function 0049 if( ~isa( mathml, 'cell' ) ) 0050 if( exist( mathml, 'file' )) 0051 mathml = textread( mathml, '%s', 'delimiter', '\n' ); 0052 else 0053 error( 'CellOrganizer: Input must me a cell array or an XML file.' ); 0054 end 0055 end 0056 end%checkInputArguments