comparison 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
comparison
equal deleted inserted replaced
6:2396a569e446 7:5589d865af7a
1 xquery version "1.0";
2
3 (: Controller XQuery for the mpdl application. :)
4
5 let $id := "blabla"
6
7 return
8 if ($exist:path eq '/test.xql')
9 then
10 <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
11 <forward url="test2.xql">
12 <add-parameter name="id" value="{$exist:resource}"/>
13 </forward>
14 </dispatch>
15 else if (starts-with($exist:path, '/ir/')) then
16 <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
17 <forward url="/test">
18 <add-parameter name="doc" value="{$exist:resource}"/>
19 </forward>
20 </dispatch>
21 else if ($exist:resource eq 'execute') then
22 let $query := request:get-parameter("qu", ())
23 let $startTime := util:system-time()
24 return
25 <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
26 <!-- Query is executed by XQueryServlet -->
27 <forward servlet="XQueryServlet">
28 <!-- Query is passed via the attribute 'xquery.source' -->
29 <set-attribute name="xquery.source" value="{$query}"/>
30 <!-- Results should be written into attribute 'results' -->
31 <set-attribute name="xquery.attribute" value="results"/>
32 <clear-attribute name="results"/>
33 <!-- Errors should be passed through instead of terminating the request -->
34 <set-attribute name="xquery.report-errors" value="yes"/>
35 </forward>
36 <view>
37 <!-- Post process the result: store it into the HTTP session
38 and return the number of hits only. -->
39 <forward url="session.xql">
40 <clear-attribute name="xquery.source"/>
41 <clear-attribute name="xquery.attribute"/>
42 <set-attribute name="elapsed"
43 value="{string(seconds-from-duration(util:system-time() - $startTime))}"/>
44 </forward>
45 </view>
46 </dispatch>
47 (: Retrieve an item from the query results stored in the HTTP session. The
48 format of the URL will be /sandbox/results/X, where X is the number of the
49 item in the result set :)
50 else if (starts-with($exist:path, '/results/')) then
51 <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
52 <forward url="../session.xql">
53 <add-parameter name="num" value="{$exist:resource}"/>
54 </forward>
55 </dispatch>
56 else if (starts-with($exist:path, '/scripts/yui')) then
57 <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
58 <forward url="/{replace($exist:path, '(/scripts/yui/.*)$', '$1')}"/>
59 </dispatch>
60 else
61 (: everything else is passed through :)
62 <ignore xmlns="http://exist.sourceforge.net/NS/exist">
63 <cache-control cache="yes"/>
64 </ignore>