forked from pulibrary/TownTopics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.xql
70 lines (59 loc) · 2.53 KB
/
controller.xql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
xquery version "1.0";
(:~ --------------------------------------------------
Daily Prince QC controller
-------------------------------------------------- :)
import module namespace util="http://exist-db.org/xquery/util";
declare namespace exist="http://exist.sourceforge.net/NS/exist";
declare namespace request="http://exist-db.org/xquery/request";
(: These external declarations are not required but make the code
dependency clear. :)
declare variable $exist:root external;
declare variable $exist:prefix external;
declare variable $exist:path external;
declare variable $exist:resource external;
declare variable $exist:controller external;
let $uri:= request:get-uri()
let $context := request:get-context-path()
return
if (request:get-parameter("echo",())) then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="echo.xql">
<add-parameter name="root" value="{$exist:root}"/>
<add-parameter name="prefix" value="{$exist:prefix}"/>
<add-parameter name="resource" value="{$exist:resource}"/>
<add-parameter name="controller" value="{$exist:controller}"/>
<add-parameter name="context" value="{$context}"/>
<add-parameter name="path" value="{$exist:path}"/>
<add-parameter name="pathtokens" value="{tokenize($exist:path, '/')}"/>
<add-parameter name="url" value="{request:get-url()}"/>
<add-parameter name="uri" value="{request:get-uri()}"/>
</forward>
</dispatch>
else if ($exist:path eq '/') then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{concat($exist:controller, '/index.xql')}" />
</dispatch>
else if ($exist:path eq '/headline-sample') then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{concat($exist:controller, '/headline-sample.xql')}">
<set-attribute name="xquery.attribute" value="result"/>
</forward>
<view>
<forward servlet ="XSLTServlet">
<set-attribute name="xslt.stylesheet" value = "{concat($exist:controller,'/display.xsl')}"/>
<set-attribute name="xslt.input" value="result"/>
</forward>
</view>
<cache-control cache="no"/>
</dispatch>
else if ($exist:path eq '/headline-sample-raw') then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{concat($exist:controller, '/headline-sample.xql')}">
</forward>
<cache-control cache="no"/>
</dispatch>
else
(: <ignore xmlns="http://exist.sourceforge.net/NS/exist"/> :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<cache-control cache="no"/>
</dispatch>