<?vsp 
--  
--  $Id$
--  
--  This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
--  project.
--  
--  Copyright (C) 1998-2024 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
--  
--  

  declare body, qry varchar;
  if ({?'file'} is not null)
    {
      select XT_TEXT into body from XML_TEXT2 where XT_FILE = {?'file'};
      declare ses any;
      ses := string_output ();
      http ('<html><body>');
      http_value (body, 'pre', ses);
      http (string_output_string (ses));
      http ('</body></html>');
      return;
    }
  if ({?'exec'} is not null)
      qry := get_keyword ('qry', params, '');
    else
      qry := 'Sample';

?>
<html>
<head><link rel="stylesheet" type="text/css" href="../demo.css"></head>
<body>
<table class="tableentry">
<form method="post" action="xs_s_4_sample_1.vsp">
<tr>
 <td>1. Enter the search text</td>
 <td><input type="text" name="qry" value="<?=qry?>"></td>
</tr>
<tr>
 <td>2. Look up titles</td>
 <td><input type="submit" name="exec" value="Execute"></td>
</tr>
</form>
</table>
<table class="tableresult">
<?vsp
  if ({?'exec'} is not null)
    {
?>
<th>Title</th><th>File name</th>
<?vsp
     qry := get_keyword ('qry', params, '');
      for select XT_FILE, cast (p as varchar) descr from XML_TEXT2 where xcontains (XT_TEXT, sprintf ('//title [.like''%%%s%%'' ]', qry), p) do {
?>
        <tr><td><?=descr?></td><td><a href="xs_s_4_sample_1.vsp?file=<?=XT_FILE?>"><?=XT_FILE?></a></td></tr>
<?vsp
      }
    }
?>
</table>
</body>
</html>
