Skip to content

Commit 3288c97

Browse files
committed
doc(url-rewrite): actioned feedback
- corrected query names to `.xq` from `xql` in examples - Updated date - renumbered examples for consistency - Reworded Example 1
1 parent 20955cb commit 3288c97

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ declare variable $exist:prefix external;
77
declare variable $exist:root external;
88

99
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
10-
<forward url="{$exist:controller}/modules/transform.xql">
10+
<forward url="{$exist:controller}/modules/transform.xq">
1111
<add-parameter name="doc" value="{$exist:resource}.xml"/>
1212
</forward>
1313
</dispatch>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ if (starts-with($path, '/sandbox/execute')) then
1515
<view>
1616
<!-- Post process the result: store it into the HTTP session
1717
and return the number of hits only. -->
18-
<forward url="session.xql">
18+
<forward url="session.xq">
1919
<clear-attribute name="xquery.source"/>
2020
<clear-attribute name="xquery.attribute"/>
2121
<set-attribute name="elapsed"
@@ -28,7 +28,7 @@ if (starts-with($path, '/sandbox/execute')) then
2828
item in the result set :)
2929
else if (starts-with($path, '/sandbox/results/')) then
3030
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
31-
<forward url="../session.xql">
31+
<forward url="../session.xq">
3232
<add-parameter name="num" value="{$name}"/>
3333
</forward>
3434
</dispatch>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ declare variable $exist:root external;
99
<dispatch xmlns="http://exist.sourceforge.net/NS/exist">
1010
<forward url="data/{$exist:resource}.xml"/>
1111
<view>
12-
<forward url="{$exist:controller}/modules/transform.xql"/>
12+
<forward url="{$exist:controller}/modules/transform.xq"/>
1313
</view>
1414
</dispatch>

src/main/xar-resources/data/urlrewrite/urlrewrite.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml-model href="http://docbook.org/xml/5.0/rng/docbook.rng" schematypens="http://relaxng.org/ns/structure/1.0"?><?xml-model href="http://docbook.org/xml/5.0/rng/docbook.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?><article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
22
<info>
33
<title>URL Rewriting</title>
4-
<date>2Q19</date>
4+
<date>2022-02</date>
55
<keywordset>
66
<keyword>application-development</keyword>
77
</keywordset>
@@ -30,13 +30,13 @@
3030
</listitem>
3131
</orderedlist>
3232
<sect2 xml:id="eg1">
33-
<title>Example I: A Simple Implementation</title>
34-
<para>Consider the document you are currently reading; a direct URL pointing to the source data might be <code>/exist/apps/doc/data/urlrewrite.xml</code>. But accessing this URI would only show a user the raw XML: instead users should get a properly formatted HTML version of the text, accessible through a simple URL like <code>/exist/apps/doc/urlrewrite</code>.</para>
33+
<title>Example 1: A Simple Implementation</title>
34+
<para>Consider a document similar to the one you are currently reading; a direct URL pointing to the source data might be <code>/exist/apps/doc/data/urlrewrite.xml</code>. But accessing this URI would only show a user the raw XML: instead users should get a properly formatted HTML version of the text, accessible through a simple URL like <code>/exist/apps/doc/urlrewrite</code>.</para>
3535
<para>To achieve this we need a mechanism to map or rewrite a given URL to an application specific endpoint. So in the simplest case, calling <code>/exist/apps/doc/urlrewrite</code> would locate the source document, transform it into HTML and return the result.</para>
3636
<para><literal>controller.xq</literal> is invoked for all URL paths targeting the collection in which it resides. It has access to a number of <xref linkend="variables"/> pre-filled with details about the request, including <literal>$exist:resource</literal>, containing the name of the resource (without path components) the request tries to access; also the <literal>$exist:controller</literal> variable which points to the collection the <literal>controller.xq</literal> is located in.</para>
3737
<para>For example, one may want to direct all requests to <literal>/exist/apps/doc/{resource}</literal> to an XQuery, <literal>transform.xq</literal>, which is responsible for converting the XML content into HTML:</para>
3838
<programlisting language="xquery" xlink:href="listings/listing-1.txt"/>
39-
<para>This example controller returns a simple <tag>dispatch</tag> fragment which will be passed back to the URL rewriting framework. The <tag>forward</tag> element instructs the framework to call the URL <literal>modules/transform.xq</literal> relative to the collection in which the controller resides. It adds a request parameter, named <literal>doc</literal>, which translates the requested resource into an actual document path to be transformed.</para>
39+
<para>This example controller returns a simple <tag>dispatch</tag> fragment which will be passed back to the URL rewriting framework. The <tag>forward</tag> element instructs the framework to call the URL <literal>modules/transform.xq</literal> relative to the collection in which the controller resides. It adds a request parameter, named <literal>doc</literal>, which indicates the resource to be transformed. The receiving query could access this parameter using <code>request:get-parameter("doc", ())</code> in order to retrieve the requested article.</para>
4040
</sect2>
4141
<sect2 xml:id="eg2">
4242
<title>Example 2: Defining a Pipeline</title>
@@ -119,7 +119,7 @@
119119
</varlistentry>
120120
</variablelist>
121121
<programlisting language="xml">&lt;dispatch xmlns="http://exist.sourceforge.net/NS/exist"&gt;
122-
&lt;forward url="{$exist:controller}/modules/transform.xql"&gt;
122+
&lt;forward url="{$exist:controller}/modules/transform.xq"&gt;
123123
&lt;add-parameter name="doc" value="{$exist:resource}.xml"/&gt;
124124
&lt;/forward&gt;
125125
&lt;/dispatch&gt;</programlisting>

0 commit comments

Comments
 (0)