我正在尝试创建一个函数,允许我评估数据库受限区域的登录凭据。
这是我的代码:
declare function local:check() as xs:string {
let $login :=  request:get-parameter("username",'')
let $password :=  request:get-parameter("password",'')
let $user := doc('credentials.xml')/credenziali/utente[./user = $login]
return (
    if (not(empty($user))) then concat('staff.xq',$login,' ',$password)
    else concat('login_error.xq',$login,' ',$password)
)    
};
此函数在以下位置调用:
form name="login" method="post" action="{local:check()}"
但我不明白为什么我总是被重定向到页面''login_error''(即用户对象总是空的),尽管我输入了正确的凭据(在文件credentials.xml 中可用)。
Credentials.xml 包含:
<credenziali> 
   <utente id="1"> 
     <user>admin</user> 
     <password>admin</password> 
   </utente> 
 </credenziali>
我在屏幕的相应输入文本框中设置了 username=admin 和 password=admin