1

我正在尝试创建一个简单的界面,它将使用 XForms 来显示一个按钮,上面写着“删除数据库”。然后,我希望能够调用一个名为 RestXQ 的文档dropdatabase.xqm,当单击表单上的按钮时调用该文档。我正在使用 BaseX。我将 XForm 保存在文件夹中onlydel.xml的一个文件中basex/webapp/static。我创建了名为 dropdatabase.xqm 的 RestXQ 程序并将其保存到我的basex/webapp文件夹中。我创建了一个名为patients.

xforms:内容onlydel.xml为:

<?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:内容dropdatabase.xqm为:

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"))
};

当我运行它时,我收到以下错误:

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

我需要的帮助是:

  1. 我可以用我写的代码做这样的事情吗?
  2. 错误的原因是什么以及消除错误的解决方案也会有所帮助
4

1 回答 1

1

错误消息对我来说似乎很清楚:db:drop()是一个更新表达式,因此此时不允许。%updating您必须使用注释将函数标记为更新函数。

于 2014-04-02T17:39:45.540 回答