xquery version "1.0";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace fn="http://exist-db.org/local-functions";
declare namespace i18n="http://apache.org/cocoon/i18n/2.1";
(: Assemble the query string :)
declare function fn:build-query($record as xs:string, $entrylang as xs:string)
as xs:string
{
let $doc := concat('/db/ordbase/terms/SD-terms/terms-',$entrylang,'.xml')
return
concat("for $r in document('", $doc, "')",
$record," return $r")
};
(: Modify the query results before display - in this case just add the
language of the entry: :)
declare function fn:display($entrylang as xs:string, $hits as node()+)
as element()
{
let $entry := item-at($hits, 1),
$common := $entry/common,
$senses := $entry/senses,
$changes := $entry/changes,
$id := $entry/@id
return
WARNING: There was an error with this request! Please check with the webmaster. Cause: No request record value.
else let $query := fn:build-query($request, $entrylang), $hits := util:eval( $query ) return if (empty($hits)) then (ERROR! Record {$request} not found!
,Your language: {$entrylang}
,Your request: {$request}
,Your search query: