xquery version "1.0";
declare namespace request="http://exist-db.org/xquery/request";
declare namespace util="http://exist-db.org/xquery/util";
declare namespace i18n="http://apache.org/cocoon/i18n/2.1";
import module namespace save="http://www.risten.no/edit/save" at "xquery/saveroutines.xqm";
import module namespace ristenutil="http://www.risten.no/shared/util"
at "../xquery/ristenutil.xqm";
(: This function updates the ID of an entry, and all references to it :)
declare function local:updateID($oldID as xs:string, $newID as xs:string) as xs:string
{
let $lang := request:get-parameter("lang", ""),
$user := session:get-attribute("user"),
$cntr := "termcenter.xml",
$doc := ristenutil:get-doc($lang),
$cntdoc := concat($coll,'/',$cntr)
(: Need to use ' since $oldcenterref is used as part of an attribute already containing '' :)
(: Also, it has to be ' and not ", since it should match a string containing '' :)
let $oldcenterref := concat("terms-", $lang, ".xml",
"#xpointer(//entry[@id='",
$oldID,
"'])" ),
$newcenterref := concat("terms-", $lang, ".xml",
"#xpointer(//entry[@id='",
$newID,
"'])" )
(: Update the ID of the entry itself: :)
let $mainupdate :=
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 manually to the existing entry.
else let $updatedid := if ($record != $newid) then local:updateID($record, $newid) else $record let $saveresult := save:saveentry($updatedid), $query := local: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}
, :) ristenutil:display($entrylang, $hits) ) };