Hello,

writing a RESTXQ application, I have the following code in a module:

module namespace page = 'http://localhost/web-page';

declare %rest:path("/list/{$category}")
  %rest:GET
  %rest:query-param("page:category", "{$category}")
  %output:method("xhtml")
  %output:omit-xml-declaration("no")
  %output:doctype-public("-//W3C//DTD XHTML 1.0 Transitional//EN")
  
%output:doctype-system("http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";)
  function page:list($page:category as xs:string) { () };

I get: 

  [basex:restxq] Variable $category is not specified as argument.

If I replace *every* '$category' with '$page:category' I get:

  [basex:restxq] Variable $page:category is specified more than once. 

But the only place I use '$page:category' in this module is at this point.

The rules are, as far as I have understood:

1. In a module, only one namespace can be used for the functions and variables 
defined therein,
   foreign namespaces can be sourced via module imports only.
2. This namespace can not be in the 
{http://www.w3.org/2005/xquery-local-functions} namespace,
   but must go into my own namespace, here {http://localhost/web-page}.
3. All variables must be in the relevant namespaces *(global or local only?)*.

I now have tried several approaches. As I see in the XQM modules in the BaseX 
DBA application, 
it seems, that neither the '%rest:query-param' is needed nor is it needed to 
prefix variable/parameter
names, that are local to that function. This can be found, for example, in 
'dba/common.xqm':


  module namespace dba = 'dba/common';
  (:~
   : Shows a "page not found" error.
   : @param  $path  path to unknown page
   : @return page
   :)
  declare
    %rest:path("/dba/{$path}")
    %output:method("html")
  function dba:unknown(
    $path  as xs:string
  ) as element(html) {
    html:wrap(
      <tr>
        <td>
          <h2>Page not found:</h2>
          <ul>
            <li>Page: dba/{ $path }</li>
            <li>Method: { Request:method() }</li>
          </ul>
        </td>
      </tr>
    )
  };


So, I am disturbed by now. What am I doing wrong here?

-- 
Goody Bye, Minden jót, Mit freundlichen Grüßen,
Andreas Mixich

Reply via email to