0

On my website (driven by eXist-db 4.4) I have a search page:

http://localhost:8081/exist/apps/deheresi/search

This contains a simple form that submits a search request like:

http://localhost:8081/exist/apps/deheresi/search?keyword=someword

The page is served up through templates in eXist-db which are triggered by controller.xqlreceiving the request:

 else if (starts-with(lower-case($exist:path), "/search")) then
    <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
        <forward url="{$exist:controller}/search.html"/>
        <view>
            <forward url="{$exist:controller}/modules/view.xql">
                <add-parameter name="searchterm" value="{$exist:resource}"/>
                <add-parameter name="pagetype" value="search"/>
            </forward>
        </view>
    </dispatch>

In this context, I would assume that $exist:resource would contain the some string which includes ?keyword=somewordor something to that effect (so that I can further parse the request). But nothing is being output to the parameter. I have a feeling I'm not understanding exactly how to get the query string from an http request in the eXist controller.

Many thanks in advance for any advice.

jbrehr
  • 775
  • 6
  • 19

1 Answers1

0

Just after I posted this I discovered https://exist-db.org/exist/apps/fundocs/view.html?uri=http://exist-db.org/xquery/request where

 request:get-parameter($name as xs:string, $default-value as item()*) as xs:string*

Does exactly as needed, like this:

else if (starts-with(lower-case($exist:path), "/search")) then
  <dispatch xmlns="http://exist.sourceforge.net/NS/exist">
    <forward url="{$exist:controller}/search.html"/>
    <view>
        <forward url="{$exist:controller}/modules/view.xql">
            <add-parameter name="searchterm" value="{request:get-parameter("keyword","")}"/>
            <add-parameter name="pagetype" value="search"/>
        </forward>
    </view>
 </dispatch>
jbrehr
  • 775
  • 6
  • 19