我不确定Xquery在服务器上是如何工作的。我知道语法,但不确定如何在我的网站上实现它。
例如。我有一个网站,存储在XML文件中的用户名和密码。现在我要验证用于登录或注册的用户名和密码。
我该怎么做呢?我是否只需要编写一个Xquery文件并上传到服务器,然后调用它?
发布于 2013-02-04 00:25:40
请在下面找到一个在Sausalito上运行的基本身份验证模块的示例。
module namespace auth = "[project logical uri]lib/auth";
import module namespace base64 = "http://www.zorba-xquery.com/modules/converters/base64";
import module namespace req = "http://www.28msec.com/modules/http/request";
import module namespace res = "http://www.28msec.com/modules/http/response";
declare variable $auth:login := "login";
declare variable $auth:password := "password";
declare function auth:authorize() as empty-sequence()
{
let $auth := "Basic " || string(base64:encode($html:login || ":" || $html:password)) eq req:header-value("Authorization")
return
if(not($auth) and not($unprotected)) then
error($res:unauthorized);
else
();
};https://stackoverflow.com/questions/14665108
复制相似问题