我正在尝试在我的exist-db应用程序中使用RESTXQ - 让我们称之为“superapp”。 我将restxq触发器添加到/db/apps/superapp/collection.xconf:
<collection xmlns="http://exist-db.org/collection-config/1.0">
<index xmlns:xs="http://www.w3.org/2001/XMLSchema">
<fulltext default="none" attributes="false"/>
</index>
<triggers>
<trigger class="org.exist.extensions.exquery.restxq.impl.RestXqTrigger"/>
</triggers>
</collection>
然后我将文件“restxq-test.xql”添加到文件夹/db/apps/superapp/modules:
xquery version "3.0";
module namespace test="http://exist-db.org/apps/restxq/test";
declare namespace rest="http://exquery.org/ns/restxq";
declare namespace output="http://www.w3.org/2010/xslt-xquery-serialization";
declare
%rest:GET
%rest:path("/super")
%output:media-type("text/html")
%output:method("html5")
%rest:query-param("user", "{$user}", "Guest")
function test:hello($user as xs:string*) {
let $title := 'Hello '
return
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{$title}</title>
</head>
<body>
<h1>{$title , $user}</h1>
</body>
</html>
};
但是我如何让restxq“知道”这个新模块的存在?显然它不会自动这样做。如果我调用“xyz.com:8080/exist/restxq/super?user=John”我会得到
HTTP ERROR 405
Problem accessing /exist/restxq/super. Reason:
HTTP method GET is not supported by this URL
我重新启动了 eXist 并检查了/var/www/exist/webapp/WEB-INF/logs/restxq.log 但那里没有条目...我很确定函数和属性映射是正确的。如果我将相同的函数添加到“/db/apps/demo/examples/templated/restxq-demo.xql”(显然已注册),它的效果就完美了。所以我猜新模块只是没有注册。我怎样才能做到这一点?
最佳答案
我想发表评论,但我没有足够的积分。我不确定这是否会解决您使用 RESTXQ 的整个问题,因为我没有在我的应用程序中使用它,但您似乎已经放置了 collection.xconf
文件位于错误的集合中。
它应该放在系统集合中:/db/system/config
。这意味着您的配置文件应该位于 /db/system/config/db/apps/superapp
中收藏。
有关触发器的更多信息,请访问 Exist-db 网站的文档页面:Configuring Database Triggers
关于exist-db - 如何在eXist-db中注册RESTXQ模块?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47224351/