[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re:[Qexo-general] Function return value,create library module
From: |
Jun Yu |
Subject: |
Re:[Qexo-general] Function return value,create library module |
Date: |
Tue, 9 Mar 2004 23:59:20 +0100 (MET) |
Dear Per,
Thanks a lot lot for your help. Now it works.
I am trying to make the authtication function as library module. There
are lots of place to need to use this function.
So I create a file named "authenticate.xq" as my library module:
/////////////////
module "myAuthenticate";
define function authenticate($username as string, $password as string) as
boolean {
let $session:=document("session.xml")/login
return
if ($session/username=$username and $session/password=$password) then
true()
else
false()
};
/////////////////
Here the namespace of module I only use a string "myAuthenticate", not a
URL string. Because I do not want an URL string.
Then, in my other XQuery files such as "update.xql", I try to use:
/////////////////
<html>
<body>
{
let $login_user:=request-parameter("username"),
$login_password:=request-parameter("password")
return
<p>
{
import module "myAuthenticate" at "authenticate.xq";
if (authenticate($login_user,$login_password)) then ( ...)
else (...)
}
</p>
}
</body></html>
//////////////////////
I am using XQuery as Servlets. All the XQuery and XML files are in
$CATALINA_HOME/webapps/dbis/.
The kawa program kawa-1.7.90.jar is placed in $CATALINA_HOME/shared/lib of
Tomcat.
when I run the XQuery "update.xql", I got these messages:
update.xql:84:18: missing expression
update.xql:84:18: missing '}' or ','
update.xql:84:37: missing '}' or ','
update.xql:84:57: missing '}' or ','
The Line 84 is just the line 'import module "myAuthenticate" at
"authenticate.xq"; '.
Is it possible to implement library module in Servlets ?
I made another experiment. I put authenticate.xq to the directory
$CATALINA_HOME/shared/lib,
and compiled it using:
java -jar kawa-1.7.90.jar --xquery -C ./authenticate.xq
The system prompts:
(compiling ./authenticate.xq)
./authenticate.xq:1:8: node test when focus is undefined
./authenticate.xq:1:23: confused by syntax error
./authenticate.xq:1:24: missing expression
./authenticate.xq:1:24: confused by syntax error
Thanks for giving directions.
Sincerely yours,
Jun Yu
- [Qexo-general] function return value, Jun Yu, 2004/03/10
- [Qexo-general] function return value, Jun Yu, 2004/03/10
- [Qexo-general] Function return value, Jun Yu, 2004/03/10
- Re: [Qexo-general] Function return value, Per Bothner, 2004/03/10
- Re:[Qexo-general] Function return value,create library module,
Jun Yu <=
- Re: [Qexo-general] Function return value,create library module, Per Bothner, 2004/03/11
- Re: [Qexo-general] Function return value,create library module, Jun Yu, 2004/03/11
- Re: [Qexo-general] Function return value,create library module, Per Bothner, 2004/03/11
- Re: [Qexo-general] Function return value,create library module, Jun Yu, 2004/03/13