Hi, My question is how do you create a new database in restxq?When trying to create a db I get the error msg:HTTP Error 400[XUST0001] element constructor: no updating expression allowed.Some digging around and I learned that I might need the "updating" annotation though even after the change it gives the same error.My file looks like this now:=========== File start ================ declare %rest:path("/start") %updating %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:hello() as element(Q{http://www.w3.org/1999/xhtml%7Dhtml) { <html xmlns="http://www.w3.org/1999/xhtml"> <title>Good day Sir!</title> <link rel="stylesheet" href="static/w3.css"/> <time>The current time is: { current-time() }</time> <body class="w3-container"> <ul class="w3-navbar w3-green"> <li><a href="#">Home</a></li> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <ul>{ for $result in db:open('factbook')//continent/@name return <li>{ data($result) }</li> }</ul> <li> { db:create("test") } </li> </body> </html> =========== File End ================
Just some general comments on the HTML that you are trying to generate:
- You are using XHTML. XHTML as quite strict.
- You forgot a head element;
- The time element is HTML5, and won't "work" as such under any other (X)HTML declaration. Additionally, it is forbidden to have such content outside the body tag;
- You also have a list item (li) outside a ul. This is not valid either.
- Note that you wrote factbook instead of facebook, if that was what you were trying to do
Edited code below. Hope it helps!
declare
%rest:path("/start")
%updating
%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:hello()
as element(Q{http://www.w3.org/1999/xhtml%7Dhtml)
{
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Good day Sir!</title>
<link rel="stylesheet" href="static/w3.css"/>
</head>
<body class="w3-container">
<div class="time">The current time is: { current-time() }</div>
<ul class="w3-navbar w3-green">
<li><a href="#">Home</a></li>
<li><a href="#">Link 1</a></li>
<li><a href="#">Link 2</a></li>
<li><a href="#">Link 3</a></li>
</ul>
<ul>{
for $result in db:open('factbook')//continent/@name
return <li>{ data($result) }</li>
}</ul>
<div>
{ db:create("test") }
</div>
</body>
</html>
Van: basex-talk-bounces@mailman.uni-konstanz.de [mailto:basex-talk-bounces@mailman.uni-konstanz.de] Namens Henning Phan Verzonden: zaterdag 21 mei 2016 19:03 Aan: basex-talk@mailman.uni-konstanz.de Onderwerp: [basex-talk] Creating db in restxq interface
Hi,
My question is how do you create a new database in restxq?
When trying to create a db I get the error msg:
HTTP Error 400 [XUST0001] element constructor: no updating expression allowed.
Some digging around and I learned that I might need the "updating" annotation though even after the change it gives the same error.
My file looks like this now:
=========== File start ================
declare %rest:path("/start") %updating %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 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd") function page:hello() as element(Q{http://www.w3.org/1999/xhtml%7Dhtml) { <html xmlns=" <http://www.w3.org/1999/xhtml> http://www.w3.org/1999/xhtml"> <title>Good day Sir!</title> <link rel="stylesheet" href="static/w3.css"/> <time>The current time is: { current-time() }</time> <body class="w3-container"> <ul class="w3-navbar w3-green"> <li><a href="#">Home</a></li> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <ul>{ for $result in db:open('factbook')//continent/@name return <li>{ data($result) }</li> }</ul> <li> { db:create("test") } </li> </body> </html>
=========== File End ================
Hi Henning,
The XQuery Update specification does not allow users to mix updating expressions and return data at the same time. The slides of Arve and Sabine (see [1]) will give you some hints how updates are usually performed in RESTXQ contexts. The slides are from 2013, and some convenience functions have been added since then, but the basic principle is the same as before. In a nutshell:
* Use db:output() to both return data and do updates [2]; * use web:redirect() to redirect to another success page [3]; * alternatively, activate the MIXUPDATES option in web.xml to disable the XQuery Update restriction [4].
Hope this helps, Christian
[1] http://files.basex.org/publications/xmlprague/2013.html [2] http://docs.basex.org/wiki/Database_Module#db:output [3] http://docs.basex.org/wiki/Web_Module#web:redirect [4] http://docs.basex.org/wiki/XQuery_Update#Returning_Results
declare %rest:path("/start") %updating %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:hello() as element(Q{http://www.w3.org/1999/xhtml%7Dhtml) {
<html xmlns="http://www.w3.org/1999/xhtml"> <title>Good day Sir!</title> <link rel="stylesheet" href="static/w3.css"/> <time>The current time is: { current-time() }</time> <body class="w3-container"> <ul class="w3-navbar w3-green"> <li><a href="#">Home</a></li> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <ul>{ for $result in db:open('factbook')//continent/@name return <li>{ data($result) }</li> }</ul> <li> { db:create("test") } </li> </body> </html>
=========== File End ================
Hi,Thank you very much the example code was excellent and I was sort of able to solve the problem. Maybe its okay to continue here though the problem statement has changed. In restxq, creating a database locally with 'db:create("test", "5GB.xml")' results in a crash. It uses more than 1 GB in memory, I changed the http server memory to 1024MB, and takes more than 20 minutes as the job never finished. Doing the same thing but with basexGUI takes 5 minutes and uses 500 MB memory and finishes. My question are:what is the difference between basexgui and restxq to give such discrepency, are they not using the same function?Am I maybe creating the database incorrectly? Is there another db:create function I missed? (Sorry if I sent two mails to Christian Grun)
From: christian.gruen@gmail.com Date: Sun, 22 May 2016 12:32:17 +0200 Subject: Re: [basex-talk] Creating db in restxq interface To: henningphan@hotmail.com CC: basex-talk@mailman.uni-konstanz.de
Hi Henning,
The XQuery Update specification does not allow users to mix updating expressions and return data at the same time. The slides of Arve and Sabine (see [1]) will give you some hints how updates are usually performed in RESTXQ contexts. The slides are from 2013, and some convenience functions have been added since then, but the basic principle is the same as before. In a nutshell:
- Use db:output() to both return data and do updates [2];
- use web:redirect() to redirect to another success page [3];
- alternatively, activate the MIXUPDATES option in web.xml to disable
the XQuery Update restriction [4].
Hope this helps, Christian
[1] http://files.basex.org/publications/xmlprague/2013.html [2] http://docs.basex.org/wiki/Database_Module#db:output [3] http://docs.basex.org/wiki/Web_Module#web:redirect [4] http://docs.basex.org/wiki/XQuery_Update#Returning_Results
declare %rest:path("/start") %updating %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:hello() as element(Q{http://www.w3.org/1999/xhtml%7Dhtml) {
<html xmlns="http://www.w3.org/1999/xhtml"> <title>Good day Sir!</title> <link rel="stylesheet" href="static/w3.css"/> <time>The current time is: { current-time() }</time> <body class="w3-container"> <ul class="w3-navbar w3-green"> <li><a href="#">Home</a></li> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <ul>{ for $result in db:open('factbook')//continent/@name return <li>{ data($result) }</li> }</ul> <li> { db:create("test") } </li> </body> </html>
=========== File End ================
Hi Henning,
db:create("test", "5GB.xml")
You could try to set the ADDCACHE option:
db:create('test', '5GB.xml', (), map { 'addcache': true() })
The CREATE command will probably be faster, because we can ignore some of the XQuery Update semantics on command level.
Hope this helps, Christian
results in a crash. It uses more than 1 GB in memory, I changed the http server memory to 1024MB, and takes more than 20 minutes as the job never finished. Doing the same thing but with basexGUI takes 5 minutes and uses 500 MB memory and finishes.
My question are: what is the difference between basexgui and restxq to give such discrepency, are they not using the same function? Am I maybe creating the database incorrectly? Is there another db:create function I missed?
(Sorry if I sent two mails to Christian Grun)
From: christian.gruen@gmail.com Date: Sun, 22 May 2016 12:32:17 +0200 Subject: Re: [basex-talk] Creating db in restxq interface To: henningphan@hotmail.com CC: basex-talk@mailman.uni-konstanz.de
Hi Henning,
The XQuery Update specification does not allow users to mix updating expressions and return data at the same time. The slides of Arve and Sabine (see [1]) will give you some hints how updates are usually performed in RESTXQ contexts. The slides are from 2013, and some convenience functions have been added since then, but the basic principle is the same as before. In a nutshell:
- Use db:output() to both return data and do updates [2];
- use web:redirect() to redirect to another success page [3];
- alternatively, activate the MIXUPDATES option in web.xml to disable
the XQuery Update restriction [4].
Hope this helps, Christian
[1] http://files.basex.org/publications/xmlprague/2013.html [2] http://docs.basex.org/wiki/Database_Module#db:output [3] http://docs.basex.org/wiki/Web_Module#web:redirect [4] http://docs.basex.org/wiki/XQuery_Update#Returning_Results
declare %rest:path("/start") %updating %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:hello() as element(Q{http://www.w3.org/1999/xhtml%7Dhtml) {
<html xmlns="http://www.w3.org/1999/xhtml"> <title>Good day Sir!</title> <link rel="stylesheet" href="static/w3.css"/> <time>The current time is: { current-time() }</time> <body class="w3-container"> <ul class="w3-navbar w3-green"> <li><a href="#">Home</a></li> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <ul>{ for $result in db:open('factbook')//continent/@name return <li>{ data($result) }</li> }</ul> <li> { db:create("test") } </li> </body> </html>
=========== File End ================
Hi Christian,Just wanted to give you feedback. The job did finish it took approximately 30 minutes and around 900 MB memory. As basexgui does the same thing in 5 minutes I rather recommend my users to load the data in basexgui instead.
From: christian.gruen@gmail.com Date: Mon, 23 May 2016 14:24:34 +0200 Subject: Re: [basex-talk] Creating db in restxq interface To: henningphan@hotmail.com CC: basex-talk@mailman.uni-konstanz.de
Hi Henning,
db:create("test", "5GB.xml")
You could try to set the ADDCACHE option:
db:create('test', '5GB.xml', (), map { 'addcache': true() })
The CREATE command will probably be faster, because we can ignore some of the XQuery Update semantics on command level.
Hope this helps, Christian
results in a crash. It uses more than 1 GB in memory, I changed the http server memory to 1024MB, and takes more than 20 minutes as the job never finished. Doing the same thing but with basexGUI takes 5 minutes and uses 500 MB memory and finishes.
My question are: what is the difference between basexgui and restxq to give such discrepency, are they not using the same function? Am I maybe creating the database incorrectly? Is there another db:create function I missed?
(Sorry if I sent two mails to Christian Grun)
From: christian.gruen@gmail.com Date: Sun, 22 May 2016 12:32:17 +0200 Subject: Re: [basex-talk] Creating db in restxq interface To: henningphan@hotmail.com CC: basex-talk@mailman.uni-konstanz.de
Hi Henning,
The XQuery Update specification does not allow users to mix updating expressions and return data at the same time. The slides of Arve and Sabine (see [1]) will give you some hints how updates are usually performed in RESTXQ contexts. The slides are from 2013, and some convenience functions have been added since then, but the basic principle is the same as before. In a nutshell:
- Use db:output() to both return data and do updates [2];
- use web:redirect() to redirect to another success page [3];
- alternatively, activate the MIXUPDATES option in web.xml to disable
the XQuery Update restriction [4].
Hope this helps, Christian
[1] http://files.basex.org/publications/xmlprague/2013.html [2] http://docs.basex.org/wiki/Database_Module#db:output [3] http://docs.basex.org/wiki/Web_Module#web:redirect [4] http://docs.basex.org/wiki/XQuery_Update#Returning_Results
declare %rest:path("/start") %updating %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:hello() as element(Q{http://www.w3.org/1999/xhtml%7Dhtml) {
<html xmlns="http://www.w3.org/1999/xhtml"> <title>Good day Sir!</title> <link rel="stylesheet" href="static/w3.css"/> <time>The current time is: { current-time() }</time> <body class="w3-container"> <ul class="w3-navbar w3-green"> <li><a href="#">Home</a></li> <li><a href="#">Link 1</a></li> <li><a href="#">Link 2</a></li> <li><a href="#">Link 3</a></li> </ul> <ul>{ for $result in db:open('factbook')//continent/@name return <li>{ data($result) }</li> }</ul> <li> { db:create("test") } </li> </body> </html>
=========== File End ================
basex-talk@mailman.uni-konstanz.de