参数的exist-db基数 [英] exist-db cardinality for parameter
问题描述
我是exist-db和XQuery的新手。
I am new in exist-db and XQuery.
在exist-db中,我有以下站点地图:目录 registranten包含目录 data(带有xml文件)和两个文件 regBasic.xql和 regSearch.xql。
In exist-db I have this site map: The catalog "registranten" contains the catalog "data" (with xml-files) and the two files "regBasic.xql" and "regSearch.xql".
我正在尝试使用脚本regSearch在xml文件中进行搜索.xql:
I am trying to search in the xml-files using the script regSearch.xql:
xquery version "3.0";
declare option exist:serialize "method=xhtml media-type=text/html";
declare variable $pageTitle := "Resultat";
declare variable $searchphrase := request:get-parameter("searchphrase", ());
<html>
<head>
<meta HTTP-EQUIV="Content-Type" content="text/html; charset=UTF-8"/>
<title>{$pageTitle}</title>
</head>
<body>
<h1>{$pageTitle}</h1>
<p>Søgestreng eller søgeord: "{$searchphrase}"</p>
<ul>
{
for $p in collection("/db/registranten/data")//grundtvig/indholdsregest/p[ft:query(., $searchphrase)]
return
<li>
from: {string(root($p)/grundtvig/filnavn)}<br/>
<i>$p</i>
</li>
}
</ul>
</body>
</html>
当我评估脚本时,出现以下错误: exerr:ERROR XPTY0004:参数的实际基数2与函数签名中声明的基数不匹配:ft:query($ nodes作为node(),$ query作为item())node()。预期的基数:正好为1,得到0。 [在第17行,第100列,来源:/db/apps/registranten/regSearch.xql]
When I evaluate the script I get this error: "exerr:ERROR XPTY0004: The actual cardinality for parameter 2 does not match the cardinality declared in the function's signature: ft:query($nodes as node(), $query as item()) node(). Expected cardinality: exactly one, got 0. [at line 17, column 100, source: /db/apps/registranten/regSearch.xql]"
这是什么意思,脚本有什么问题?
What does that mean and what is wrong with the script?
推荐答案
您的 $ searchphrase
变量为空序列,这可能表明您没有使用 request:get-parameter()
设置要查询的请求参数。
Your $searchphrase
variable is an empty sequence, which likely suggests that you did not set the request parameter which you are asking for with request:get-parameter()
.
这篇关于参数的exist-db基数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!