1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
<?vsp
--
-- $Id: text.vsp,v 1.2 2006/08/15 19:30:35 source Exp $
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2006 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><?vsp http(XQ..GET_SCRIPT()); ?> </head>
<body>
<h3>Text search using 'contains' predicate in "http://local.virt/DAV/feeds/" collection:</h3>
<?vsp
declare _q , _sid, _realm, _sid_arg varchar;
_sid := coalesce ({?'sid'}, '');
_realm := coalesce ({?'realm'}, '');
if ({?'sid'} is not null)
_sid_arg := '?sid=' || _sid || '&realm=' || _realm;
_q := coalesce ({?'q'}, '');
?>
<form method="GET" action="text.vsp">
<input name="sid" type="hidden" value="<?=_sid?>"/>
<input name="realm" type="hidden" value="<?=_realm?>"/>
<input name="q" type="text" value="<?= _q ?>" />
<input name="submit" type="submit" value="Search" />
</form>
<a href="search.vsp?sid=<?= _sid ?>&realm=<?= _realm ?>"> XPath Search </a>
<?vsp
if (_q <> '') {
declare _res any;
_res := xquery_eval ('
<ul> {
for \044d in collection ("http://local.virt/DAV/feeds/", ., 1, 2)
for \044item in \044d//item[contains (descendant::*,"' || _q || '")]
let \044link := \044item/link/string()
let \044title := \044item/title/string()
return
<li>
{
if (\044link and \044title) then
<a href="{\044link}" target="_blank">{\044title}</a>
else if (\044link) then
<a href="{\044link}" target="_blank">~empty title~</a>
else if (\044title) then
<div>{\044title}</div>
else
<div>~empty title~</div>
}
</li>
} </ul>', xtree_doc ('<stub/>'));
http ('<br/>');
declare _num int;
_num := 0;
if (isentity (_res))
_num := cast (xpath_eval ('count(/ul/li)', _res) as int);
if (_num = 0)
http ('No results found');
else
http (sprintf ('[%d] results found:<br/>', _num));
http (serialize_to_UTF8_xml (_res));
}
?>
</body>
</html>
|