Godmar,
thanks again for tracing the bug and isolating it in your Java code. As Leo annnounced, the query parsing process was reset, so that the query was parsed twice – an issue which resulted from an earlier XQJ bug fix.
It's even more surprising that the bug went unnoticed. It's not covered by the XQJ test suite either. We've fixed the bug and added some test cases; please have a look at the latest sources or the latest versions from the Maven repository:
http://www.inf.uni-konstanz.de/dbis/basex/maven/org/basex/basex/6.2/basex-6.... http://www.inf.uni-konstanz.de/dbis/basex/maven/org/basex/basex-api/6.2/base...
Best, Christian
On Sat, Jul 10, 2010 at 11:43 PM, Godmar Back godmar@gmail.com wrote:
The problem persists in 6.1.9. Here's a minimal test case: 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); } }