xquery version "1.0"; declare option exist:serialize "expand-xincludes=no"; declare namespace session="http://exist-db.org/xquery/session"; 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"; declare namespace xi="http://www.w3.org/2001/XInclude"; import module namespace ristenutil="http://www.risten.no/shared/util" at "../xquery/ristenutil.xqm"; (: Local function to build XIncludes for all collections: :) declare function local:make-xincludes-for-all() as element()+ { for $searchcoll in ristenutil:get-all-public-collections() return }; (: Local function to build XIncludes for all collections: :) declare function local:make-xincludes( $colls as xs:string+) as element()+ { for $searchcoll in $colls return (: if public then - this should really be tested as a safeguard against hacking, but the list returned does only include public collections in the first place :) }; (: Main function - retrieves a request parameter and calls one of two functions to build a list of XInclude elements to be sent back to the sitemap for individual processing. :) declare function local:main() as element()+ { let $searchcoll := request:get-parameter("coll","all") return if ($searchcoll = "all") then local:make-xincludes-for-all() else local:make-xincludes( $searchcoll ) };
{ let $start := util:system-time() return ( local:main(),

{ round-half-to-even( seconds-from-duration( util:system-time()-$start) , 3)}

) }