Question

I am trying to create a simple interface, that will use XForms to display a button that say "Drop a Database". I then want to be able to invoke a RestXQ document called dropdatabase.xqm which is called when the button on the form is clicked. I am using BaseX. I saved my XForm in a file called onlydel.xml in the basex/webapp/static folder. I created my RestXQ program called dropdatabase.xqm and saved it to my basex/webapp folder. I have created a database called patients.

xforms: The contents of onlydel.xml is:

<?xml-stylesheet href="xsltforms/xsltforms.xsl" type="text/xsl"?>
<?xsltforms-options debug="yes"?>
<html xmlns="http://www.w3.org/1999/xhtml" 
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">     
<head>
<title>XFORMS IN XHTML</title>       
<model xmlns="http://www.w3.org/2002/xforms" id="order-model">
<instance>
<soap xmlns="">
</soap>
</instance>
<submission action="/dropdatabase" method="post" id="s06"/>

</model>
</head>

<body>
<h2>DATABASE</h2>
<div style="float:center;">
<fieldset style="width:50%">
<xf:submit submission="s06"><xf:label>Drop A Database</xf:label></xf:submit>
</fieldset></div>
</body>
</html>

RestXQ :The contents of dropdatabase.xqm is:

module namespace _ = 'http://exquery.org/ns/restxq';
(:~
 : Deletes the blog database and redirects the user to the main page.
 :)
declare 
%restxq:path("/dropdatabase")
%restxq:GET
function _:dropdatabase()
{
   (db:drop("patients"))
};

When I run this I get the following error:

 Stopped at /home/ubuntu/basex/webapp/dropdatabase.xqm, 10/13:
[XUST0001] StaticFunc expression: no updating expression allowed.

The help I need is:

  1. Can I do something like this with the code I have written.
  2. What is the reason for the error and a solution to eliminate the error too would be helpful
Was it helpful?

Solution

The error message seems quite clear to me: db:drop() is an updating expression and is hence not allowed at this point. You have to mark the function as an updating function by using the %updating annotation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top