exist-db cardinality for parameter

情到浓时终转凉″ 提交于 2019-12-24 00:37:21

问题


I am new in exist-db and XQuery.

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

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>

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?


回答1:


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().



来源:https://stackoverflow.com/questions/47953378/exist-db-cardinality-for-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!