Skip to content

Commit 3198f17

Browse files
committed
[refactor] Minor tidy up and some consistency improvements
1 parent 58feeef commit 3198f17

File tree

6 files changed

+374
-216
lines changed

6 files changed

+374
-216
lines changed

src/main/xar-resources/data/urlrewrite/listings/listing-1.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
xquery version "3.1";
22

3+
declare namespace exist = "http://exist.sourceforge.net/NS/exist";
4+
35
declare variable $exist:path external;
46
declare variable $exist:resource external;
57
declare variable $exist:controller external;
Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
if ($name eq 'acronyms.xql') then
2-
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
3-
<!-- query results are passed to XSLT servlet via request attribute -->
4-
<set-attribute name="xquery.attribute"
5-
value="model"/>
6-
<view>
7-
<forward servlet="XSLTServlet">
8-
<set-attribute name="xslt.input"
9-
value="model"/>
10-
<set-attribute name="xslt.stylesheet"
11-
value="xquery/stylesheets/acronyms.xsl"/>
12-
</forward>
13-
<forward servlet="XSLTServlet">
14-
<clear-attribute name="xslt.input"/>
15-
<set-attribute name="xslt.stylesheet"
16-
value="stylesheets/db2html.xsl"/>
17-
</forward>
18-
</view>
19-
</dispatch>
1+
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
2+
<!-- NOTE: query results are passed to XSLT servlet via a request attribute -->
3+
<set-attribute name="xquery.attribute" value="model"/>
4+
<view>
5+
<forward servlet="XSLTServlet">
6+
<set-attribute name="xslt.input" value="model"/>
7+
<set-attribute name="xslt.stylesheet" value="xquery/stylesheets/acronyms.xsl"/>
8+
</forward>
9+
<forward servlet="XSLTServlet">
10+
<clear-attribute name="xslt.input"/>
11+
<set-attribute name="xslt.stylesheet" value="stylesheets/db2html.xsl"/>
12+
</forward>
13+
</view>
14+
</dispatch>

src/main/xar-resources/data/urlrewrite/listings/listing-11.txt

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
if (starts-with($path, '/sandbox/execute')) then
1+
if (starts-with($path, '/sandbox/execute'))
2+
then
23
let $query := request:get-parameter("qu", ())
34
let $startTime := util:system-time()
45
return
56
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
6-
<!-- Query is executed by XQueryServlet -->
7-
<forward servlet="XQueryServlet">
8-
<!-- Query is passed via the attribute 'xquery.source' -->
9-
<set-attribute name="xquery.source" value="{$query}"/>
10-
<!-- Results should be written into attribute 'results' -->
11-
<set-attribute name="xquery.attribute" value="results"/>
12-
<!-- Errors should be passed through instead of terminating the request -->
13-
<set-attribute name="xquery.report-errors" value="yes"/>
7+
<!-- Query is executed by XQueryServlet -->
8+
<forward servlet="XQueryServlet">
9+
<!-- Query is passed via the attribute 'xquery.source' -->
10+
<set-attribute name="xquery.source" value="{$query}"/>
11+
<!-- Results should be written into attribute 'results' -->
12+
<set-attribute name="xquery.attribute" value="results"/>
13+
<!-- Errors should be passed through instead of terminating the request -->
14+
<set-attribute name="xquery.report-errors" value="yes"/>
15+
</forward>
16+
<view>
17+
<!-- Post process the result: store it into the HTTP session and return the number of hits only. -->
18+
<forward url="session.xq">
19+
<clear-attribute name="xquery.source"/>
20+
<clear-attribute name="xquery.attribute"/>
21+
<set-attribute name="elapsed" value="{string(seconds-from-duration(util:system-time() - $startTime))}"/>
1422
</forward>
15-
<view>
16-
<!-- Post process the result: store it into the HTTP session
17-
and return the number of hits only. -->
18-
<forward url="session.xq">
19-
<clear-attribute name="xquery.source"/>
20-
<clear-attribute name="xquery.attribute"/>
21-
<set-attribute name="elapsed"
22-
value="{string(seconds-from-duration(util:system-time() - $startTime))}"/>
23-
</forward>
24-
</view>
23+
</view>
2524
</dispatch>
25+
else if (starts-with($path, '/sandbox/results/'))
26+
then
2627
(: Retrieve an item from the query results stored in the HTTP session. The
27-
format of the URL will be /sandbox/results/X, where X is the number of the
28-
item in the result set :)
29-
else if (starts-with($path, '/sandbox/results/')) then
28+
format of the URL will be /sandbox/results/X, where X is the number of the
29+
item in the result set :)
3030
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
3131
<forward url="../session.xq">
3232
<add-parameter name="num" value="{$name}"/>
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
if (starts-with($exist:path, "/libs/")) then
1+
if (starts-with($exist:path, "/libs/"))
2+
then
23
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
34
<forward url="/{substring-after($exist:path, '/libs/')}" absolute="yes"/>
45
</dispatch>

src/main/xar-resources/data/urlrewrite/listings/listing-2.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
xquery version "3.1";
22

3+
declare namespace exist = "http://exist.sourceforge.net/NS/exist";
4+
35
declare variable $exist:path external;
46
declare variable $exist:resource external;
57
declare variable $exist:controller external;

0 commit comments

Comments
 (0)