hello all,
I wrote some xqueries and I declared some function for it.
I made seprated xq file for those functions.
I tried and run it in stylus studio it's all set.
But now I want to Implement it in java through  XQJ.
but when I try to load that xq file I am getting some error.
please guide me to solve those errors.
here is my xq file
module namespace m1 = 'http://m1.org';

declare function m1:getMsg() as xs:string *{

let $msg := 'Hello World'
return $msg

here is java file


static void main(String args[])


SaxonXQConnection con= (SaxonXQConnection) XQueryConnection.getConnection();


String filepath=


SaxonXQPreparedExpression exp = (SaxonXQPreparedExpression)con.prepareExpression(

new FileInputStream(filepath));

XQSequence result=exp.executeQuery();


catch(Exception e){




I am getting following errors

Error on line 1 column 0

XPST0003: XQuery syntax error in #module namespace m1#:

Module declaration must not be used in a main module

Error on line 3 column 18

XPST0081: XQuery static error in #... declare function m1:getMsg()#:

Prefix m1 has not been declared

Error on line 8 column 3

XPST0003: XQuery syntax error in #... 'Hello World' return $msg };#:

Unexpected token "<eof>" in path expression




Kunal Chauhan