Home > atmlab > arts > xml > xmlStoreImpl.m

xmlStoreImpl

PURPOSE ^

Writes data to an XML file.

SYNOPSIS ^

function xmlStoreImpl(filename, comment, data, type, precision)

DESCRIPTION ^

 Writes  data to an XML file.

    This is the generic writing routine for XML files. You have to give
    the filename, the data and the type of data as a string.

    E.g. writing the vector v to file 'vect.xml':

    xmlStoreImpl ('vect.xml', 'Some comment', v, 'Vector');

    Make sure that the data you're passing has the correct type.

 FORMAT   xmlStoreImpl(filename, comment, data, type, precision)

 IN    filename   Name of output file
 IN    comment    Comment to store along with the data
 IN    data       Data
 IN    type       Data type

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

xmlStoreImpl.m

SOURCE CODE ^

0001 % Writes  data to an XML file.
0002 %
0003 %    This is the generic writing routine for XML files. You have to give
0004 %    the filename, the data and the type of data as a string.
0005 %
0006 %    E.g. writing the vector v to file 'vect.xml':
0007 %
0008 %    xmlStoreImpl ('vect.xml', 'Some comment', v, 'Vector');
0009 %
0010 %    Make sure that the data you're passing has the correct type.
0011 %
0012 % FORMAT   xmlStoreImpl(filename, comment, data, type, precision)
0013 %
0014 % IN    filename   Name of output file
0015 % IN    comment    Comment to store along with the data
0016 % IN    data       Data
0017 % IN    type       Data type
0018 
0019 % 2002-12-16  Created by Oliver Lemke.
0020 
0021 
0022 function xmlStoreImpl(filename, comment, data, type, precision)
0023 
0024 %=== Basic ckeck of input
0025 %
0026 rqre_nargin( 2, nargin );
0027 %
0028 if nargin < 5
0029   precision = 'FLOAT';
0030 end
0031 
0032 precision = upper(precision);
0033 
0034 if (~strcmp(precision, 'FLOAT')) ...
0035         && (~strcmp(precision, 'DOUBLE')) ...
0036         && (~strcmp(precision, 'BINARY'))
0037     error ('Invalid value for precision. Must be either FLOAT, DOUBLE or BINARY');
0038 end
0039 
0040 fidb = -1;
0041 if (strcmp(precision, 'BINARY'))
0042     fidb = xmlOpenBinaryOutputFile (filename);
0043 end
0044 
0045 fid = xmlOpenOutputFile (filename);
0046 xmlWriteHeader (fid, fidb);
0047 
0048 if ~isempty(comment)
0049   xmlWritecomment (fid, comment);
0050 end
0051 
0052 if length (type) > 14 && strcmp(type (1:14), 'ArrayOfArrayOf')
0053   xmlWriteArrayOfArrayOf (fid, fidb, data, type(15:length(type)), precision);
0054 elseif length (type) > 7 && strcmp(type (1:7), 'ArrayOf')
0055   xmlWriteArrayOf (fid, fidb, data, type (8:length(type)), precision);
0056 else
0057   func = str2func (['xmlWrite' type]);
0058   feval (func, fid, fidb, data, precision);
0059 end
0060 
0061 xmlWriteFooter (fid);
0062 fclose (fid);
0063 
0064 if (fidb ~= -1), fclose(fidb); end
0065

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005