function msxsl(in,xsl,out)

% msxsl - apply xsl transformation to xml file
% --------------------------------------------
%
% msxsl(in,style,out)
%
% Input:
% ------
%  in - input xml file
%  xsl - xsl transformation file
%  out - output file

%--------------------------------
% Author: Harold Figueroa
%--------------------------------
% $Date: 2004-12-02 15:58:47 -0500 (Thu, 02 Dec 2004) $
% $Revision: 132 $
%--------------------------------

%-----------------------------------
% HANDLE INPUT
%-----------------------------------

%--
% check for proper input
%--

if (nargin < 3)
	disp(' ');
	error('Function requires three inputs.');
end

%--
% check for existence of input file
%--

if (~exist(in,'file'))
	disp(' ');
	error(['Unable to find input file ''' in ''', file does not exist.']);
end

%--
% get location of msxsl application using function position
%--

root = which('msxsl'); 

ix = findstr(root,filesep);

root = root(1:ix(end));

%--
% check for existence of transformation file
%--

% 
% % see if transformation file is given in explicit form
% 
% flag = exist(xsl,'file');
% 
% if (~flag)
	
	% try to get transformation from local transformation directory by name
	
	xsl_local = [root 'XSLT' filesep xsl '.xsl'];
	
	flag = exist(xsl_local,'file');
	
	if (~flag)
		disp(' ');
		error(['Unable to find input file ''' xsl ''', file does not exist.']);
	end
	
	xsl = xsl_local;
	
% end
	
%-----------------------------------
% PERFORM TRANSFORMATION
%-----------------------------------

%--
% create command string
%--

str = ['!' root 'msxsl "' in '" "' xsl '" -xw -t -o "' out '"'];

%--
% evaluate transformation command
%--

disp(' '); eval(str); disp(' ');