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 ristenutil="http://www.risten.no/shared/util" at "../xquery/ristenutil.xqm"; (: Assemble the query string :) declare function local:build-query($nodeid as xs:string, $entrylang as xs:string, $collID as xs:string) as xs:string { let $docname := request:get-parameter("doc", ""), $doc := ristenutil:get-doc-path($collID, $docname) return (: util:node-by-id($docnode, $nodeid) :) concat("let $r := util:node-by-id(document('", $doc, "'), '", $nodeid, "') return $r") }; (: Modify the query results before display: :) declare function local:display($collID as xs:string, $hits as node()+) as element() { let $entry := item-at($hits, 1), $content := $entry/* return {$content} }; (: Main function - retrieves some request attributes, forks further processing to other defined functions depending on the retrieved values :) declare function local:main() as element()+ { let $nodeid := request:get-parameter("record", ""), $entrylang := request:get-parameter("entrylang", ""), $collection := request:get-parameter("collection", "") return if(string-length($nodeid) = 0) then

WARNING: There was an error with this request! Please check with the webmaster. Cause: No request record value.

else let $query := local:build-query($nodeid, $entrylang, $collection), $hits := util:eval( $query ) return if (empty($hits)) then (

ERROR! Record {$nodeid} not found!

,

Your language: {$entrylang}

,

Your collection: {$collection}

,

Your request: {$nodeid}

,

Your search query:

) else ( (:

Your search query:

, :) local:display($collection, $hits) ) };