【问题标题】:XForms and restxq applicationXForms 和 restxq 应用程序
【发布时间】:2014-05-14 03:20:00
【问题描述】:

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

xformsonlydel.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>

RestXQdropdatabase.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. 错误的原因是什么以及消除错误的解决方案也会有所帮助

【问题讨论】:

    标签: rest xforms basex xsltforms


    【解决方案1】:

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

    【讨论】:

    • 这绝对有助于消除错误。非常感谢 dirkk。然而,我没有让数据库被删除。你能看出哪里有问题吗?
    • 我想我明白了...我必须将 GET 更改为 POST
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-07
    相关资源
    最近更新 更多