Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/main/xar-resources/data/urlrewrite/listings/listing-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
xquery version "3.1";

declare namespace exist = "http://exist.sourceforge.net/NS/exist";

declare variable $exist:path external;
declare variable $exist:resource external;
declare variable $exist:controller external;
declare variable $exist:prefix external;
declare variable $exist:root external;

<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="{$exist:controller}/modules/transform.xq">
<add-parameter name="doc" value="{$exist:resource}.xml"/>
</forward>
</dispatch>
33 changes: 14 additions & 19 deletions src/main/xar-resources/data/urlrewrite/listings/listing-10.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
if ($name eq 'acronyms.xql') then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<!-- query results are passed to XSLT servlet via request attribute -->
<set-attribute name="xquery.attribute"
value="model"/>
<view>
<forward servlet="XSLTServlet">
<set-attribute name="xslt.input"
value="model"/>
<set-attribute name="xslt.stylesheet"
value="xquery/stylesheets/acronyms.xsl"/>
</forward>
<forward servlet="XSLTServlet">
<clear-attribute name="xslt.input"/>
<set-attribute name="xslt.stylesheet"
value="stylesheets/db2html.xsl"/>
</forward>
</view>
</dispatch>
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<!-- NOTE: query results are passed to XSLT servlet via a request attribute -->
<set-attribute name="xquery.attribute" value="model"/>
<view>
<forward servlet="XSLTServlet">
<set-attribute name="xslt.input" value="model"/>
<set-attribute name="xslt.stylesheet" value="xquery/stylesheets/acronyms.xsl"/>
</forward>
<forward servlet="XSLTServlet">
<clear-attribute name="xslt.input"/>
<set-attribute name="xslt.stylesheet" value="stylesheets/db2html.xsl"/>
</forward>
</view>
</dispatch>
46 changes: 23 additions & 23 deletions src/main/xar-resources/data/urlrewrite/listings/listing-11.txt
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
if (starts-with($path, '/sandbox/execute')) then
if (starts-with($path, '/sandbox/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"/>
<!-- Errors should be passed through instead of terminating the request -->
<set-attribute name="xquery.report-errors" value="yes"/>
<!-- 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"/>
<!-- 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.xq">
<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>
<!-- 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>
</view>
</dispatch>
else if (starts-with($path, '/sandbox/results/'))
then
(: 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($path, '/sandbox/results/')) then
format of the URL will be /sandbox/results/X, where X is the number of the
item in the result set :)
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="../session.xql">
<forward url="../session.xq">
<add-parameter name="num" value="{$name}"/>
</forward>
</dispatch>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
if (starts-with($exist:path, "/libs/")) then
if (starts-with($exist:path, "/libs/"))
then
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/{substring-after($exist:path, '/libs/')}" absolute="yes"/>
</dispatch>
24 changes: 16 additions & 8 deletions src/main/xar-resources/data/urlrewrite/listings/listing-2.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
let $params := subsequence(analyze-string($exist:path, '^/?(.*)/([^/]+)$')//fn:group, 2)
return
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="/index.xql">
<add-parameter name="feed" value="{$params[1]}"/>
<add-parameter name="ref" value="{$params[2]}"/>
</forward>
</dispatch>
xquery version "3.1";

declare namespace exist = "http://exist.sourceforge.net/NS/exist";

declare variable $exist:path external;
declare variable $exist:resource external;
declare variable $exist:controller external;
declare variable $exist:prefix external;
declare variable $exist:root external;

<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
<forward url="data/{$exist:resource}.xml"/>
<view>
<forward url="{$exist:controller}/modules/transform.xq"/>
</view>
</dispatch>
Loading