The 'restxq.xqm' was edited as below:
(:~ : 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() as element(bookstore) { <bookstore> { let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title[contains(text(),'Everyday Italian')]/parent::* return $x } </bookstore> };
The server response:
HTTP ERROR 400
Problem accessing /. Reason: Stopped at /path/to/webapp/restxq.xqm, 58/10: [BASX0003] Variable $x is not specified as argument.
Powered by Jetty://
What is my mistake for the declaration:
... function page:bookstore() as element(bookstore) { ...
What is my mistake for the declaration:
function page:bookstore() as element(bookstore) {
The error message may serve as inspiration:
[BASX0003] Variable $x is not specified as argument.
The examples in our documentation may be helpful, too:
On 15/01/2014, Christian Grün christian.gruen@gmail.com wrote:
What is my mistake for the declaration:
function page:bookstore() as element(bookstore) {
The error message may serve as inspiration:
[BASX0003] Variable $x is not specified as argument.
I don't understand.
The examples in our documentation may be helpful, too:
The query component is the xquery function below, correct? :
let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title[contains(text(),'Everyday Italian')]/parent::*
The result of this query is selection of all the sibling elements for this book title element.
In the documentation example:
declare %rest:path("/params") %rest:query-param("id", "{$id}") %rest:query-param("add", "{$add}", 42, 43, 44) function page:params($value as xs:string?, $answer as xs:integer+) { <result id="{ $id }" sum="{ sum($add) }"/> };
It is not seen where '$value' and '$answer' originate. In my example, I have only one variable, '$x'.
This should help:
function page:bookstore($x)
The error message may serve as inspiration:
[BASX0003] Variable $x is not specified as argument.
I don't understand.
The examples in our documentation may be helpful, too:
The query component is the xquery function below, correct? :
let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title[contains(text(),'Everyday Italian')]/parent::*
The result of this query is selection of all the sibling elements for this book title element.
In the documentation example:
declare %rest:path("/params") %rest:query-param("id", "{$id}") %rest:query-param("add", "{$add}", 42, 43, 44) function page:params($value as xs:string?, $answer as xs:integer+) {
<result id="{ $id }" sum="{ sum($add) }"/> };
It is not seen where '$value' and '$answer' originate. In my example, I have only one variable, '$x'.
On 15/01/2014, Christian Grün christian.gruen@gmail.com wrote:
This should help:
function page:bookstore($x)
I tried:
... function page:bookstore($x) as element(bookstore) { <bookstore> { let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title[contains(text(),'Everyday Italian')]/parent::* return $x } </bookstore> };
The result:
HTTP ERROR 404
Problem accessing /. Reason: No function found that matches the request.
Powered by Jetty://
Then I tried:
... function page:bookstore($x) {...
which produces the same error result shown above. Then tried:
... function page:bookstore($x) <bookstore> { let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title[contains(text(),'Everyday Italian')]/parent::* return $x } </bookstore>
The result:
HTTP ERROR 400
Problem accessing /. Reason: Stopped at /path/to/webapp/restxq.xqm, 59/2: [XPST0003] Expecting '{', found '<'.
Powered by Jetty://
What next must I try, please?
Problem accessing /. Reason: No function found that matches the request.
404 indicates that your XQuery code is correct, but that no mapping for your URL is found. What are the values for..
- your URL? - your %rest:path argument? - your RESTXQ url-pattern in web.xml?
Usually, the easiest way is to start off with the given examples (in the BaseX zip/exe distribution or the ones shown in the Wiki) and modify them to your needs.
Powered by Jetty://
Then I tried:
... function page:bookstore($x) {...
which produces the same error result shown above. Then tried:
... function page:bookstore($x) <bookstore> { let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title[contains(text(),'Everyday Italian')]/parent::* return $x } </bookstore>
The result:
HTTP ERROR 400
Problem accessing /. Reason: Stopped at /path/to/webapp/restxq.xqm, 59/2: [XPST0003] Expecting '{', found '<'.
Powered by Jetty://
What next must I try, please?
On 15/01/2014, Christian Grün christian.gruen@gmail.com wrote:
Problem accessing /. Reason: No function found that matches the request.
404 indicates that your XQuery code is correct, but that no mapping for your URL is found. What are the values for..
- your URL?
The xml database file is stored in '/path/to/webapp' and the url is stated in the xqm file as:
... %rest:path("xmldatabasefile.xml/bookstore/book") ...
- your %rest:path argument?
As above, is correct?
- your RESTXQ url-pattern in web.xml?
/path/to/webapp/WEB-INF/web.xml: line77 <url-pattern>/*</url-pattern> 97 <url-pattern>/rest/*</url-pattern> 117 <url-pattern>/webdav/*</url-pattern> 130 <url-pattern>/static/*</url-pattern>
Usually, the easiest way is to start off with the given examples (in the BaseX zip/exe distribution or the ones shown in the Wiki) and modify them to your needs.
I've tried using the wiki page suggested, without any success in understanding (!)
- your URL?
The xml database file is stored in '/path/to/webapp' and the url is stated in the xqm file as:
But which URL causes the 404 error?
%rest:path("xmldatabasefile.xml/bookstore/book")
/path/to/webapp/WEB-INF/web.xml: line77 <url-pattern>/*</url-pattern>
So your URL should probably look sth like..
http://localhost:8984/xmldatabasefile.xml/bookstore/book
I've tried using the wiki page suggested, without any success in understanding (!)
What are the problems? Christian
On 15/01/2014, Christian Grün christian.gruen@gmail.com wrote:
So your URL should probably look sth like..
I had to enclosedthe url in quotation marks:
... declare %rest:GET %rest:path("http://localhost:8984/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> };
The result:
HTTP ERROR 404
Problem accessing /. Reason: No function found that matches the request.
Powered by Jetty://
With the quotation marks removed around the url, the server result:
HTTP ERROR 400
Problem accessing /. Reason: Stopped at /path/to/webapp/restxq.xqm, 54/12: [XPST0003] Literal expected after annotation.
Powered by Jetty://
I've tried using the wiki page suggested, without any success in understanding (!)
What are the problems?
It is incomplete, to my usage scenario. For example, the wiki page does not show an example with the localhost as part of the url.
Hello,
It is incomplete, to my usage scenario. For example, the wiki page does not show an example with the localhost as part of the url.
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.
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).
Cheers, Dirk
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>
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>
On 16/01/2014, Dirk Kirsten dk@basex.org wrote:
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
The urls were enclosed in quotation marks:
... %rest:path("http://localhost:8984/test") ... %rest:path("http://localhost:8984/xmldatabasefile.xml/bookstore/book") ...
The server response:
HTTP ERROR 400
Problem accessing /. Reason: Stopped at /path/to/webapp/restxq.xqm, 17/10: [BASX0003] Variable $x is not assigned by the annotations.
Powered by Jetty://
What are these annotations please?
No, you don't want to change your %rest:path() annotation. You _never_ put anything like http://localhost into your %rest:path() annotation. The URLs I have given are the URLs you have to enter in your browser to access this functions.
On 16/01/14 11:46, e-letter wrote:
On 16/01/2014, Dirk Kirsten dk@basex.org wrote:
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
The urls were enclosed in quotation marks:
... %rest:path("http://localhost:8984/test") ... %rest:path("http://localhost:8984/xmldatabasefile.xml/bookstore/book") ...
The server response:
HTTP ERROR 400
Problem accessing /. Reason: Stopped at /path/to/webapp/restxq.xqm, 17/10: [BASX0003] Variable $x is not assigned by the annotations.
Powered by Jetty://
What are these annotations please?
On 16/01/2014, Dirk Kirsten dk@basex.org wrote:
No, you don't want to change your %rest:path() annotation. You _never_ put anything like http://localhost into your %rest:path() annotation. The URLs I have given are the URLs you have to enter in your browser to access this functions.
The result of the url 'http://localhost:8984/test' in the web browser is a web page with the html form. Finally, I have made a millimetre of progress! :)
The result of 'http://localhost:8984/xmldatabasefile.xml/bookstore/book' is:
HTTP ERROR 404
Problem accessing /xmldatabasefile.xml/bookstore/book. Reason: No function found that matches the request.
Powered by Jetty://
On 16/01/14 12:03, e-letter wrote:
On 16/01/2014, Dirk Kirsten dk@basex.org wrote:
No, you don't want to change your %rest:path() annotation. You _never_ put anything like http://localhost into your %rest:path() annotation. The URLs I have given are the URLs you have to enter in your browser to access this functions.
The result of the url 'http://localhost:8984/test' in the web browser is a web page with the html form. Finally, I have made a millimetre of progress! :)
We are very happy to hear that!
The result of 'http://localhost:8984/xmldatabasefile.xml/bookstore/book' is:
HTTP ERROR 404
Problem accessing /xmldatabasefile.xml/bookstore/book. Reason: No function found that matches the request.
Powered by Jetty://
Could you please send the whole function + annotations once again? However, it should work if your path annotation is:
%rest:path("xmldatabasefile.xml/bookstore/book")
On 16/01/2014, Dirk Kirsten dk@basex.org wrote:
On 16/01/14 12:03, e-letter wrote:
On 16/01/2014, Dirk Kirsten dk@basex.org wrote:
No, you don't want to change your %rest:path() annotation. You _never_ put anything like http://localhost into your %rest:path() annotation. The URLs I have given are the URLs you have to enter in your browser to access this functions.
The result of the url 'http://localhost:8984/test' in the web browser is a web page with the html form. Finally, I have made a millimetre of progress! :)
We are very happy to hear that!
The result of 'http://localhost:8984/xmldatabasefile.xml/bookstore/book' is:
HTTP ERROR 404
Problem accessing /xmldatabasefile.xml/bookstore/book. Reason: No function found that matches the request.
Powered by Jetty://
Could you please send the whole function + annotations once again?
Not necessary, I found my mistake, which to use the http domain.
However, it should work if your path annotation is:
%rest:path("xmldatabasefile.xml/bookstore/book")
With this applied, and the url 'http://localhost:8984/xmldatabasefile.xml/bookstore/book' loaded into the web browser, I finally have a desirable result!
Giada De Laurentiis 2005 30.00
However, it is noticed that the web browser window title has changed to:
'Everyday Italian - Opera'
What has caused this behaviour?
Also for the web browser url 'http://localhost:8984/test', the html form is visible, but submitting the 'get' request does not return the result of the query.
However, it should work if your path annotation is:
%rest:path("xmldatabasefile.xml/bookstore/book")
With this applied, and the url 'http://localhost:8984/xmldatabasefile.xml/bookstore/book' loaded into the web browser, I finally have a desirable result!
Giada De Laurentiis 2005 30.00
However, it is noticed that the web browser window title has changed to:
'Everyday Italian - Opera'
What has caused this behaviour?
We can't control this, this is done by your browser. Quite likely it handles the <title /> node the same it would normally handle the <title /> node within an HTML head element.
Also for the web browser url 'http://localhost:8984/test', the html form is visible, but submitting the 'get' request does not return the result of the query.
Your <form /> element needs an action attribute, otherwise it sends it to the some URL. So it should be <form method='get' name='databasequeryform' action="xmldatabasefile.xml/bookstore/book" >
Please be also aware that this has nothing to do with BaseX, XQuery or XPath, but is standard HTML. So your question might be more appropriate at other places, e.g. StackOverflow. There are also great debugging tools integrated into modern browsers (Firebug for Firefox, Developer toolbar for Chrome, ...) where you can see all your requests and you could immediately spot that your request is going to the wrong address.
Cheers, Dirk
On 16/01/2014, Dirk Kirsten dk@basex.org wrote:
We can't control this, this is done by your browser. Quite likely it handles the <title /> node the same it would normally handle the <title /> node within an HTML head element.
OK, thanks; will test in another browser.
Hi,
based on your recent questions I would really recommend that you try to understand RESTXQ in more detail. Apart from our documentation at https://docs.basex.org/wiki/RESTXQ (which Chrisdtian already pointed out), there was also a Talk given by Arve and Sabine named "How to develop RESTXQ-based web applications with BaseX", you can find the slides and the example code at https://files.basex.org/publications/xmlprague2013/.
All the details are given in the Spec at http://exquery.github.io/exquery/exquery-restxq-specification/restxq-1.0-spe...
You are using an annotation %rest:path("{$x}")
This means, your URL can be basically be any atomic type (see http://exquery.github.io/exquery/exquery-restxq-specification/restxq-1.0-spe...) and this value will be bound to the variable $x. This is also the reason why you have to declare $x as argument of the function. Within your function you never actually use this value, so probably you don't really intend to use a template in your path, so you might simply want to remove this. Of course, this is mostly guessing as we don't know what you actually want to do.
Cheers, Dirk
On 15/01/14 21:23, e-letter wrote:
On 15/01/2014, Christian Grün christian.gruen@gmail.com wrote:
This should help:
function page:bookstore($x)
I tried:
... function page:bookstore($x) as element(bookstore) {
<bookstore> { let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title[contains(text(),'Everyday Italian')]/parent::* return $x } </bookstore> };
The result:
HTTP ERROR 404
Problem accessing /. Reason: No function found that matches the request.
Powered by Jetty://
Then I tried:
... function page:bookstore($x) {...
which produces the same error result shown above. Then tried:
... function page:bookstore($x)
<bookstore> { let $x := fn:doc("xmldatabasefile.xml")/bookstore/book/title[contains(text(),'Everyday Italian')]/parent::* return $x } </bookstore>
The result:
HTTP ERROR 400
Problem accessing /. Reason: Stopped at /path/to/webapp/restxq.xqm, 59/2: [XPST0003] Expecting '{', found '<'.
Powered by Jetty://
What next must I try, please?
On 15/01/2014, Dirk Kirsten dk@basex.org wrote:
Hi,
based on your recent questions I would really recommend that you try to understand RESTXQ in more detail. Apart from our documentation at https://docs.basex.org/wiki/RESTXQ (which Chrisdtian already pointed out), there was also a Talk given by Arve and Sabine named "How to develop RESTXQ-based web applications with BaseX", you can find the slides and the example code at https://files.basex.org/publications/xmlprague2013/.
This presentation does seem connected to my set up. For example it states that webapp must be run using maven via port 9876, but I am using 'basexhttp' which I access via a web browser and url 'localhost:8984'.
All the details are given in the Spec at http://exquery.github.io/exquery/exquery-restxq-specification/restxq-1.0-spe...
You are using an annotation %rest:path("{$x}")
This means, your URL can be basically be any atomic type (see http://exquery.github.io/exquery/exquery-restxq-specification/restxq-1.0-spe...) and this value will be bound to the variable $x. This is also the reason why you have to declare $x as argument of the function. Within your function you never actually use this value, so probably you don't really intend to use a template in your path, so you might simply want to remove this. Of course, this is mostly guessing as we don't know what you actually want to do.
The objective is to use basex to query an xml database using and html select form and return the result in a web page (see: http://www.mail-archive.com/basex-talk@mailman.uni-konstanz.de/msg03469.html).
When the list item 'every day italian' is selected, a new web page should be created which displays the 'title', 'author', 'year', 'price' elements of the parent element 'book'.
basex-talk@mailman.uni-konstanz.de