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";
import module namespace save="http://www.risten.no/edit/save" at "saveroutines.xqm";
import module namespace ristenutil="http://www.risten.no/shared/util"
at "../xquery/ristenutil.xqm";
(: Assemble the query string :)
declare function fn:build-query($record as xs:string, $entrylang as xs:string)
as xs:string
{
let $expr := ristenutil:id-filter($record),
$doc := ristenutil:get-doc($entrylang)
return
concat("for $r in document('", $doc, "')//entry[",
$expr, "] return $r")
};
(: Check for the existence of the new entry: :)
declare function fn:ID-exists($entry as xs:string, $entrylang as xs:string)
as xs:boolean
{
let $query := fn:build-query($entry, $entrylang),
$hits := util:eval( $query ),
$count := count($hits)
return if ( $count = 0 ) then
false()
else
true()
};
(: Modify the query results before display: :)
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,
$id := $entry/@id
return
WARNING: There was an error with this request! Please check with the webmaster. Cause: No request record value.
else if ( ( $exists ) and ($record != $newid) ) thenWARNING: You can not change the entry to an existing entry. Please copy the information to the existing entry.
else let $updatedid := if ($record != $newid) then save:updateID($record, $newid) else $record let $saveresult := save:saveentry($updatedid), $query := fn:build-query($updatedid, $entrylang), $hits := util:eval( $query ) return if (empty($hits)) then (ERROR! Record {$updatedid} not found!
,Your language: {$entrylang}
,Your request: {$updatedid}
,Your entry: {$entry}
,Your search query:
Your search query:
The input type: {$inputtype}
,The save result: {$saveresult}
, :) fn:display($entrylang, $hits) ) };Søket tok { seconds-from-duration(current-time()-$start) } sekund.
) }