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 ---------- From: Christian Grün christian.gruen@gmail.com Date: 2013/1/22 Subject: Re: [basex-talk] Fwd: dynamic web application, XQJ, BaseX To: marco fregonese marcofregonese@gmail.com, Charles Foster < charles@cfoster.net> Cc: BaseX basex-talk@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@gmail.com Date: 2013/1/21 Subject: Re: [basex-talk] dynamic web application, XQJ, BaseX To: Christian Grün christian.gruen@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%5C"" + "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@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@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk