xquery version "1.0"; declare namespace util="http://exist-db.org/xquery/util"; declare namespace dc="http://purl.org/dc/elements/1.1/"; declare namespace i18n="http://apache.org/cocoon/i18n/2.1"; (: Create filter expression from query term, field and mode :) declare function local:filter-expr($record as xs:string) as xs:string { let $t := concat("'", $record, "'") return concat("@id &= ", $t) }; (: Assemble the query string :) declare function local:build-query($record as xs:string) as xs:string { let $expr := local:filter-expr($record), $docs := "'/db/ordbase/terms/SD-terms/termcenter.xml'" return concat("for $r in document(", $docs, ")//entry[", $expr, "] return $r") }; (: 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 $record := request:request-parameter("record", "") return if(string-length($record) = 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($record), $hits := util:eval( $query ) return if (empty($hits)) then

ERROR! Record {$record} not found!

else ( (:

Your search query:

, :) $hits ) };
{ let $start := util:system-time() return ( local:main(),

Søket tok { seconds-from-duration(util:system-time()-$start) } sekund.

) }