Hello all,
I could track the problem down to QueryProcessor.reset() not resetting the underlying Context instance. Demo:
//-------------------------------------------------------------------- import org.basex.core.Context; import org.basex.query.QueryProcessor;
public class Test2 {
public static void main(String[] args) throws Exception { final QueryProcessor qp = new QueryProcessor( "declare variable $x := 1; $x", new Context()); qp.parse(); // registers the variable $x with the Context qp.reset(); // sets 'parsed = false;' but doesn't reset the Context qp.parse(); // old definition is found, resulting in an exception }
} //--------------------------------------------------------------------
The problem appears in XQPreparedExpression because executeQuery() resets the internal QueryProcessor after the query has been parsed in the constructor.
Since I found no quick fix for this, I hope Christian or someone else with more BaseX-Fu than me can make use of my observations.
Cheers, Leo
Am 10.07.2010 23:43, schrieb Godmar Back:
The problem persists in 6.1.9.
Here's a minimal test case:
http://top.cs.vt.edu/~gback/bx/Test.java
http://top.cs.vt.edu/~gback/bx/Test.java
import javax.xml.xquery.*;
public class Test { public static void main(String av[]) throws Exception { XQConnection conn = ((XQDataSource)Class.forName("org.basex.api.xqj.BXQDataSource"). newInstance()).getConnection();
XQPreparedExpression xqp = null; String q = "declare variable $x := 1; $x"; try { xqp = conn.prepareExpression(q); xqp.executeQuery(); } catch (XQQueryException xqex) { printXQException(xqex, q); } } public static void printXQException (XQQueryException xquery, String query) { String [] lines = query.split("\n"); System.out.println(lines[Math.min(xquery.getLineNumber() - 1, lines.length - 1)]); System.out.println(" " .substring(0, xquery.getColumnNumber()) + "^"); System.out.println(xquery); }
}
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk