dynamic web application, XQJ, BaseX

Thursday, 17 January 2013 · 6 messages · last reply 22 Jan 2013
MF
marco fregonese17 Jan 2013 12:56 #
Hi there, I'm developing a Java dynamic web application in Eclipse Juno using XQJ and BaseX (OS Ubuntu 12.04). I'm using an XQuery main module importing a library module in my Java-XQJ code to query BaseX, something like this: .... String xqueryString = // import library module and point the processor to the file containing the library module "import module namespace lib=\" http://www.example.com/mylibrary_module\" at \"mylibrary_module.xq\";" + "lib:myfunction()"; XQResultSequence rs = xqe.executeQuery(xqueryString); ... Two questions: 1. Why does the processor looks for "mylibrary_module.xq" in ~/basex/bin? 2. Is there any way to change this path? Thanks.
MF
marco fregonese20 Jan 2013 23:04 #
Question 1. BaseX 7.3 processor looks for "mylibrary_module.xq" in ~/basex/bin BaseX 7.5 processor looks for "mylibrary_module.xq" in ~/ 2013/1/17 marco fregonese <marcofregonese at gmail.com>
Quoted text · marco fregonese · 24 lines
> Hi there, > > I'm developing a Java dynamic web application in Eclipse Juno using XQJ > and BaseX (OS Ubuntu 12.04). > I'm using an XQuery main module importing a library module in my Java-XQJ > code to query BaseX, something like this: > > .... > String xqueryString = > // import library module and point the processor to the > file containing the library module > "import module namespace lib=\" > http://www.example.com/mylibrary_module\" at \"mylibrary_module.xq\";" + > "lib:myfunction()"; > > XQResultSequence rs = xqe.executeQuery(xqueryString); > ... > > Two questions: > 1. Why does the processor looks for "mylibrary_module.xq" in ~/basex/bin? > 2. Is there any way to change this path? > > Thanks. >
CG
Christian Grün21 Jan 2013 00:51 #
Hi Marco, sorry for the late feedback. Can you reproduce the issues in the BaseX GUI or on command line? Best, Christian
Quoted text · marco fregonese · 34 lines
> 2013/1/17 marco fregonese <marcofregonese at gmail.com> >> >> Hi there, >> >> I'm developing a Java dynamic web application in Eclipse Juno using XQJ >> and BaseX (OS Ubuntu 12.04). >> I'm using an XQuery main module importing a library module in my Java-XQJ >> code to query BaseX, something like this: >> >> .... >> String xqueryString = >> // import library module and point the processor to the >> file containing the library module >> "import module namespace >> lib=\"http://www.example.com/mylibrary_module\" at \"mylibrary_module.xq\";" >> + >> "lib:myfunction()"; >> >> XQResultSequence rs = xqe.executeQuery(xqueryString); >> ... >> >> Two questions: >> 1. Why does the processor looks for "mylibrary_module.xq" in ~/basex/bin? >> 2. Is there any way to change this path? >> >> Thanks. > > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
MF
marco fregonese22 Jan 2013 00:37 #
---------- Forwarded message ----------
Quoted text · marco fregonese · 72 lines
From: marco fregonese <marcofregonese at gmail.com> Date: 2013/1/21 Subject: Re: [basex-talk] dynamic web application, XQJ, BaseX To: Christian Grün <christian.gruen at gmail.com> There is a class in my Java web application that has a method that, after connecting to my BaseX database, execute a query on it. This query (associated to the "xquerystring" variable), after importing a library module and pointing the processor to the file containing the library module("library_module.xq"), uses the function "lib:getparts()". Now, after executing this method, I noticed that: with BaseX 7.3 the Xquery processor (o whatever it is, I don't know) looks for "library_module.xq" in the filesystem $HOME/basex/bin, while with BaseX 7.5 the processor looks for "library_module.xq" in $HOME. My question basically is: what is that makes the processor (or whatever it is) look for the file "library_module.xq" in $HOME/basex/bin (with BaseX 7.3) and in $HOME (with BaseX 7.5)? Hope I've been clear. Thanks PS: in BaseX GUI everything works fine: the XQuery processor looks for the file containing the library module in the same folder where the main module is. Example of main module: import module namespace lib="http://www.example.com/my_library_module" at "library_module.xq"; lib:getparts() The following is the code of the class I've talked about: package xqu; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.PrintStream; import javax.xml.namespace.QName; import javax.xml.xquery.XQConnection; import javax.xml.xquery.XQException; import javax.xml.xquery.XQExpression; import javax.xml.xquery.XQResultSequence; import con.Connection; public class Query { public static void getAllParts(String a, String sc) throws XQException, FileNotFoundException { File file = new File(sc); FileOutputStream fos = new FileOutputStream(file); PrintStream ps = new PrintStream(fos); System.setOut(ps); XQConnection con = Connection.getConnection(); XQExpression xqe = con.createExpression(); xqe.bindString(new QName("b"), a, null); String xqueryString = // using backslash for escaping " "import module namespace lib=\" http://www.example.com/library_module\"" + "at \"library_module.xq\";" + "declare variable $b external; " + "lib:getparts($b)"; XQResultSequence rs = xqe.executeQuery(xqueryString); String b = rs.getSequenceAsString(null); con.close(); System.out.println(b); } } 2013/1/20 Christian Grün <christian.gruen at gmail.com> > Hi Marco, > > sorry for the late feedback. Can you reproduce the issues in the BaseX > GUI or on command line? > > Best, > Christian > ___________________________________ > >
CG
Christian Grün22 Jan 2013 10:06 #
Marco, thanks for the example. The reason for the error message is that your query will be executed server-side, and the server has no information on the working directory the client was started from. Two possible solutions for that: – if you place your modules in the module repository of your BaseX server, there will be no need to specify the exact location [1] – you could try to use the absolute path to your file (I agree this is probably not the approach that’s most desirable) I’ll be passing this question on to Charles Foster, the architect of our XQJ implementation: what’s your experience with expressions that import other modules? Best, Christian [1] http://docs.basex.org/wiki/Repository
Quoted text · marco fregonese · 103 lines
> ---------- Forwarded message ---------- > From: marco fregonese <marcofregonese at gmail.com> > Date: 2013/1/21 > Subject: Re: [basex-talk] dynamic web application, XQJ, BaseX > To: Christian Grün <christian.gruen at gmail.com> > > > There is a class in my Java web application that has a method that, after > connecting to my BaseX database, execute a query on it. > This query (associated to the "xquerystring" variable), after importing a > library module and pointing the processor to the file containing the library > module("library_module.xq"), uses the function "lib:getparts()". > Now, after executing this method, I noticed that: > with BaseX 7.3 the Xquery processor (o whatever it is, I don't know) looks > for "library_module.xq" in the filesystem $HOME/basex/bin, > while with BaseX 7.5 the processor looks for "library_module.xq" in $HOME. > My question basically is: what is that makes the processor (or whatever it > is) look for the file "library_module.xq" in $HOME/basex/bin (with BaseX > 7.3) and in $HOME (with BaseX 7.5)? > > Hope I've been clear. > > Thanks > > PS: in BaseX GUI everything works fine: the XQuery processor looks for the > file containing the library module in the same folder where the main module > is. > Example of main module: > > import module namespace lib="http://www.example.com/my_library_module" at > "library_module.xq"; > > lib:getparts() > > The following is the code of the class I've talked about: > > package xqu; > > import java.io.File; > import java.io.FileNotFoundException; > import java.io.FileOutputStream; > import java.io.PrintStream; > > import javax.xml.namespace.QName; > import javax.xml.xquery.XQConnection; > import javax.xml.xquery.XQException; > import javax.xml.xquery.XQExpression; > import javax.xml.xquery.XQResultSequence; > > import con.Connection; > > public class Query { > > public static void getAllParts(String a, String sc) throws XQException, > FileNotFoundException > { > File file = new File(sc); > FileOutputStream fos = new FileOutputStream(file); > PrintStream ps = new PrintStream(fos); > System.setOut(ps); > > XQConnection con = Connection.getConnection(); > XQExpression xqe = con.createExpression(); > > xqe.bindString(new QName("b"), a, null); > > String xqueryString = > // using backslash for escaping " > "import module namespace > lib=\"http://www.example.com/library_module\"" + > "at \"library_module.xq\";" + > "declare variable $b external; " + > "lib:getparts($b)"; > > XQResultSequence rs = xqe.executeQuery(xqueryString); > > String b = rs.getSequenceAsString(null); > > con.close(); > > System.out.println(b); > > > } > } > > 2013/1/20 Christian Grün <christian.gruen at gmail.com> >> >> Hi Marco, >> >> sorry for the late feedback. Can you reproduce the issues in the BaseX >> GUI or on command line? >> >> Best, >> Christian >> ___________________________________ >> > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
MF
marco fregonese22 Jan 2013 12:37 #
Hi Christian, thank you for answering. Sorry, but I didn't read http://docs.basex.org/wiki/Repository I did "REPO INSTALL path/to/mymodule.xqm" and I solved all the problems. Now everything is OK. Thanks again. ---------- Forwarded message ----------
Quoted text · Christian Grün · 126 lines
From: Christian Grün <christian.gruen at gmail.com> Date: 2013/1/22 Subject: Re: [basex-talk] Fwd: dynamic web application, XQJ, BaseX To: marco fregonese <marcofregonese at gmail.com>, Charles Foster < charles at cfoster.net> Cc: BaseX <basex-talk at mailman.uni-konstanz.de> Marco, thanks for the example. The reason for the error message is that your query will be executed server-side, and the server has no information on the working directory the client was started from. Two possible solutions for that: – if you place your modules in the module repository of your BaseX server, there will be no need to specify the exact location [1] – you could try to use the absolute path to your file (I agree this is probably not the approach that’s most desirable) I’ll be passing this question on to Charles Foster, the architect of our XQJ implementation: what’s your experience with expressions that import other modules? Best, Christian [1] http://docs.basex.org/wiki/Repository > ---------- Forwarded message ---------- > From: marco fregonese <marcofregonese at gmail.com> > Date: 2013/1/21 > Subject: Re: [basex-talk] dynamic web application, XQJ, BaseX > To: Christian Grün <christian.gruen at gmail.com> > > > There is a class in my Java web application that has a method that, after > connecting to my BaseX database, execute a query on it. > This query (associated to the "xquerystring" variable), after importing a > library module and pointing the processor to the file containing the library > module("library_module.xq"), uses the function "lib:getparts()". > Now, after executing this method, I noticed that: > with BaseX 7.3 the Xquery processor (o whatever it is, I don't know) looks > for "library_module.xq" in the filesystem $HOME/basex/bin, > while with BaseX 7.5 the processor looks for "library_module.xq" in $HOME. > My question basically is: what is that makes the processor (or whatever it > is) look for the file "library_module.xq" in $HOME/basex/bin (with BaseX > 7.3) and in $HOME (with BaseX 7.5)? > > Hope I've been clear. > > Thanks > > PS: in BaseX GUI everything works fine: the XQuery processor looks for the > file containing the library module in the same folder where the main module > is. > Example of main module: > > import module namespace lib="http://www.example.com/my_library_module" at > "library_module.xq"; > > lib:getparts() > > The following is the code of the class I've talked about: > > package xqu; > > import java.io.File; > import java.io.FileNotFoundException; > import java.io.FileOutputStream; > import java.io.PrintStream; > > import javax.xml.namespace.QName; > import javax.xml.xquery.XQConnection; > import javax.xml.xquery.XQException; > import javax.xml.xquery.XQExpression; > import javax.xml.xquery.XQResultSequence; > > import con.Connection; > > public class Query { > > public static void getAllParts(String a, String sc) throws XQException, > FileNotFoundException > { > File file = new File(sc); > FileOutputStream fos = new FileOutputStream(file); > PrintStream ps = new PrintStream(fos); > System.setOut(ps); > > XQConnection con = Connection.getConnection(); > XQExpression xqe = con.createExpression(); > > xqe.bindString(new QName("b"), a, null); > > String xqueryString = > // using backslash for escaping " > "import module namespace > lib=\"http://www.example.com/library_module\"" + > "at \"library_module.xq\";" + > "declare variable $b external; " + > "lib:getparts($b)"; > > XQResultSequence rs = xqe.executeQuery(xqueryString); > > String b = rs.getSequenceAsString(null); > > con.close(); > > System.out.println(b); > > > } > } > > 2013/1/20 Christian Grün <christian.gruen at gmail.com> >> >> Hi Marco, >> >> sorry for the late feedback. Can you reproduce the issues in the BaseX >> GUI or on command line? >> >> Best, >> Christian >> ___________________________________ >> > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >

⚡Generated with XQuery