<?vsp 
--  
--  $Id$
--  
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--  
--  Copyright (C) 1998-2018 OpenLink Software
--  
--  This project is free software; you can redistribute it and/or modify it
--  under the terms of the GNU General Public License as published by the
--  Free Software Foundation; only version 2 of the License, dated June 1991.
--  
--  This program is distributed in the hope that it will be useful, but
--  WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
--  General Public License for more details.
--  
--  You should have received a copy of the GNU General Public License along
--  with this program; if not, write to the Free Software Foundation, Inc.,
--  51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--  
--  
?>
<html>
<head><link rel="stylesheet" type="text/css" href="../demo.css"></head>
<body>

<?vsp
 declare result any;
 declare err, msg, delim, hdelim, sdelim varchar;
 err := '';
 msg := '';
 delim := '/';
 if (sys_stat ('st_build_opsys_id') = 'Win32')
   delim := '\\';
 sdelim := '';
 hdelim := '';
 if (aref (server_root (), length (server_root()) -1) <> aref (delim, 0))
  sdelim := delim;
 if (aref (http_root (), length (http_root()) -1) <> aref (delim, 0))
  hdelim := delim;

 if ({?'exec'} is not null)
   {
     whenever sqlstate '42000' goto set_err;
     whenever sqlstate '39000' goto set_err;
     whenever sqlstate 'XS*' goto set_err2;
     whenever sqlstate '22*' goto set_err2;
     declare ses, xper, ses1 any;
     declare st varchar;
     err := {?'if'};
     ses := file_to_string_output ({?'if'});
     xper := xml_persistent (ses);
     err := {?'sf'};
     st := {?'sf'};
     result := xslt (sprintf ('file://%s', st), xper);
     ses1 := string_output ();
     http_value (result, null, ses1);
     err := {?'of'};
     string_to_file ({?'of'}, ses1, 0);
     err := '';
     msg := 'Transformation completed successfully, the result has been stored in ' || server_root () || sdelim || {?'of'};
   }
if (0)
  {
set_err:
    err := 'Can not open file ' || err;
  }
if (0)
  {
set_err2:
    err := '[' || __SQL_STATE || '] ' || __SQL_MESSAGE;
  }
?>

<div class="error"> <?= err ?> </div>
<div class="message"> <?= msg ?> </div>
<form action="xs_l_1_sample_1.vsp" method="post">
<table class="tableentry">

<tr>
<td>
1. Enter the source XML filename
</td>
<td>
<?= server_root () ?><?= sdelim ?><input type="text" name="if" size="50%">
</td>
</tr>

<tr>
<td>
2. Enter the destination file
</td>
<td>
<?= server_root () ?><?= sdelim ?><input type="text" name="of" size="50%">
</td>
</tr>

<tr>
<td>
3. Enter the XSLT style sheet for transformation
</td>
<td>
<?= http_root () ?><?= hdelim ?><input type="text" name="sf" size="50%">
</td>
</tr>

<tr>
<td>
4. Transform the document
</td>
<td>
<input type="submit" name="exec" value="Execute">
</td>
</tr>

</table>
</form>
</body>
</html>
