Mercurial > hg > mpdl-group
diff software/eXist/webapp/mpdl/_stuff/testDev/controller.xql @ 7:5589d865af7a
Erstellung XQL/XSL Applikation
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 08 Feb 2011 15:16:46 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/software/eXist/webapp/mpdl/_stuff/testDev/controller.xql Tue Feb 08 15:16:46 2011 +0100 @@ -0,0 +1,64 @@ +xquery version "1.0"; + +(: Controller XQuery for the mpdl application. :) + +let $id := "blabla" + +return +if ($exist:path eq '/test.xql') +then + <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> + <forward url="test2.xql"> + <add-parameter name="id" value="{$exist:resource}"/> + </forward> + </dispatch> +else if (starts-with($exist:path, '/ir/')) then + <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> + <forward url="/test"> + <add-parameter name="doc" value="{$exist:resource}"/> + </forward> + </dispatch> +else if ($exist:resource eq 'execute') then + let $query := request:get-parameter("qu", ()) + let $startTime := util:system-time() + return + <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> + <!-- Query is executed by XQueryServlet --> + <forward servlet="XQueryServlet"> + <!-- Query is passed via the attribute 'xquery.source' --> + <set-attribute name="xquery.source" value="{$query}"/> + <!-- Results should be written into attribute 'results' --> + <set-attribute name="xquery.attribute" value="results"/> + <clear-attribute name="results"/> + <!-- Errors should be passed through instead of terminating the request --> + <set-attribute name="xquery.report-errors" value="yes"/> + </forward> + <view> + <!-- Post process the result: store it into the HTTP session + and return the number of hits only. --> + <forward url="session.xql"> + <clear-attribute name="xquery.source"/> + <clear-attribute name="xquery.attribute"/> + <set-attribute name="elapsed" + value="{string(seconds-from-duration(util:system-time() - $startTime))}"/> + </forward> + </view> + </dispatch> +(: Retrieve an item from the query results stored in the HTTP session. The + format of the URL will be /sandbox/results/X, where X is the number of the + item in the result set :) +else if (starts-with($exist:path, '/results/')) then + <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> + <forward url="../session.xql"> + <add-parameter name="num" value="{$exist:resource}"/> + </forward> + </dispatch> +else if (starts-with($exist:path, '/scripts/yui')) then + <dispatch xmlns="http://exist.sourceforge.net/NS/exist"> + <forward url="/{replace($exist:path, '(/scripts/yui/.*)$', '$1')}"/> + </dispatch> +else + (: everything else is passed through :) + <ignore xmlns="http://exist.sourceforge.net/NS/exist"> + <cache-control cache="yes"/> + </ignore>