Once again, the error message "No function found that matches the request." is quite helpful. There simply is no RESTXQ path, that matches your URL.
You have two paths defined: %rest:path("{$x}") %rest:path("xmldatabasefile.xml/bookstore/book")
Given your configuration, you can access these functions using the following URLs: - For %rest:path("{$x}") it can be anything like http://localhost:8984/test or http://localhost:8984/test2 and test (or test2) will be bound to the variable $x - For %rest:path("xmldatabasefile.xml/bookstore/book") it will be http://localhost:8984/xmldatabasefile.xml/bookstore/book
On 16/01/14 11:11, e-letter wrote:
On 16/01/2014, Dirk Kirsten dk@basex.org wrote:
It is not incomplete, such a construct simply does not exist and it can not be executed this way (hence, we do not have an example for that...). It also does not make much sense: Imagine, you would write something like "ftp://....." as your path - RestXQ can not, of course, magically change the protocol. This is done on a different layer, i.e. the server.
If such a construct does not exist, does this mean I cannot test with a local installation?
Let suppose you want your final URL (which you use to access the page in the browser) to be http://localhost:8984/xmldatabasefile.xml/bookstore/book
This consists of two parts: The first one is the server url mapping, where all RESTXQ URIs are bound to. In this case, this would be http://localhost:8984/
The second part is the path given as RESTXQ annotation, in this case xmldatabasefile.xml/bookstore/book
So you should instead use the annotation %rest:path("xmldatabasefile.xml/bookstore/book")
to access your ressource at the URL given above, assuming you are binding RESTXQ execution to the root of your server, which is running on localhost:8984 (this is the default).
I changed the restxq.xqm:
(:~ : This module contains some basic examples for RESTXQ annotations : @author BaseX Team :) module namespace page = 'http://basex.org/modules/web-page';
(:~ : This function generates the welcome page. : @return HTML page :) declare %rest:path("{$x}") %output:method("xhtml") %output:omit-xml-declaration("no") %output:doctype-public("-//W3C//DTD XHTML Basic 1.1//EN") %output:doctype-system("http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd") function page:start($x) as element(Q{http://www.w3.org/1999/xhtml%7Dhtml) {
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>BaseX HTTP Services</title> <link rel="stylesheet" type="text/css" href="static/style.css"/> </head> <body> <h3>Example 2</h3> <p>The next example presents how form data is processed via RESTXQ and the POST method:</p> <form method='get' name='databasequeryform' > <p> <select name='booktitle' > <option> Everyday Italian </option> <option> Harry Potter </option> </select> <input type="submit" value='send' /> </p> </form> </body> </html> }; declare %rest:GET %rest:path("xmldatabasefile.xml/bookstore/book") %rest:form-param("booktitle","{$x}") %rest:produces("text/html") %output:method("xhtml") function page:bookstore($x) { <bookstore> { let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title[contains(text(),'Everyday Italian')]/parent::* return $x } </bookstore> };
I started the server from the command terminal (pwd=./bin) ./basexhttp
Then I open a new web browser (opera) window and enter the url
The response is:
HTTP ERROR 404
Problem accessing /. Reason: No function found that matches the request.
Powered by Jetty://
I close this web browser window. Then I stop the server entering the following command in a separate terminal window:
./basehttp stop
The command terminal (where the server was started) response:
$ ./basexhttp BaseX 7.7.2 [Server] Server was started (port: 1984) HTTP Server was started (port: 8984) Server was stopped (port: 1984) HTTP Server was stopped (port: 8984)
The restxq file is edited:
... %rest:path(http://localhost:8984/xmldatabasefile.xml/bookstore/book) ...
The web server is re-started as described previously and the server response:
HTTP ERROR 400
Problem accessing /. Reason: Stopped at /path/to/webapp/restxq.xqm, 54/12: [XPST0003] Literal expected after annotation.
Powered by Jetty://
Where is my mistake please?
The xml file:
<?xml version="1.0" encoding="utf-8"?>
<!-- Edited by XMLSpy®, taken from http://www.w3schools.com <?xml-stylesheet type='text/xsl" href="xstylesheetexample.xslt" ?>-->
<bookstore> <book category="COOKING"> <title lang="en" > Everyday Italian </title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="CHILDREN" > <title lang="en" > Harry Potter </title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="WEB" > <title lang="en" > XQuery Kick Start </title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle</author> <author>James Linn</author> <author>Vaidyanathan Nagarajan</author> <year>2003</year> <price>49.99</price> </book> <book category="WEB" > <title lang="en" > Learning XML </title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore>