Hi Andreas,
The XQJ driver comes with its own XQuery parser, which differs from the BaseX query parser. It has been a closed-source development from Charles Foster [1]; you may need to directly contact him to see if there is a chance to get this fixed.
As there haven’t been any considerable updates for a long time now, and as more recent features of XQuery are not supported by XQJ, we usually recommend users to work with our own APIs [2].
If you need a quick workaround, I noticed you can rewrite your query to:
<html{ (.) }</html>
if I read https://github.com/BaseXdb/basex/issues/new correctly, then I should post here first.
Exactly; thanks.
Christian
[1] http://xqj.net [2] http://docs.basex.org/wiki/Developing
On Mon, Jan 27, 2020 at 5:42 PM Andreas Sewe sewe@st.informatik.tu-darmstadt.de wrote:
Hi,
I get a weird NPE/parse error when interfacing with BaseX 9.3.1 via XQJ and even occurs for the following minimal query:
<html>{.}</html>
In other words, I just want to interpolate the context item.
The gist of the XQJ calls is the following:
XQPreparedExpression expression = connection.prepareExpression("<html>{.}</html>"); expression.bindDocument(XQConstants.CONTEXT_ITEM, "<context/>", null, null); XQResultSequence results = expression.executeQuery(); results.writeSequence(System.out, null);
This results in the following message
XQJQS001 - Invalid XQuery syntax, syntax does not pass static validation.
and a long and unfortunately obfuscated stack trace:
java.lang.NullPointerException at net.xqj.basex.bin.bz.a(Unknown Source) at net.xqj.basex.bin.bv.c(Unknown Source) at net.xqj.basex.bin.bC.bE(Unknown Source) at net.xqj.basex.bin.bC.by(Unknown Source) at net.xqj.basex.bin.bC.bu(Unknown Source) at net.xqj.basex.bin.bC.bj(Unknown Source) at net.xqj.basex.bin.bC.bi(Unknown Source) at net.xqj.basex.bin.bC.bh(Unknown Source) at net.xqj.basex.bin.bC.aY(Unknown Source) at net.xqj.basex.bin.bC.aX(Unknown Source) at net.xqj.basex.bin.bC.aW(Unknown Source) at net.xqj.basex.bin.bC.aV(Unknown Source) at net.xqj.basex.bin.bC.aU(Unknown Source) at net.xqj.basex.bin.bC.aT(Unknown Source) at net.xqj.basex.bin.bC.aS(Unknown Source) at net.xqj.basex.bin.bC.aR(Unknown Source) at net.xqj.basex.bin.bC.aQ(Unknown Source) at net.xqj.basex.bin.bC.aP(Unknown Source) at net.xqj.basex.bin.bC.aO(Unknown Source) at net.xqj.basex.bin.bC.aN(Unknown Source) at net.xqj.basex.bin.bC.aM(Unknown Source) at net.xqj.basex.bin.bC.aL(Unknown Source) at net.xqj.basex.bin.bC.aK(Unknown Source) at net.xqj.basex.bin.bC.R(Unknown Source) at net.xqj.basex.bin.bC.Q(Unknown Source) at net.xqj.basex.bin.bC.N(Unknown Source) at net.xqj.basex.bin.bC.bS(Unknown Source) at net.xqj.basex.bin.bC.bR(Unknown Source) at net.xqj.basex.bin.bC.bM(Unknown Source) at net.xqj.basex.bin.bC.bL(Unknown Source) at net.xqj.basex.bin.bC.bK(Unknown Source) at net.xqj.basex.bin.bC.by(Unknown Source) at net.xqj.basex.bin.bC.bu(Unknown Source) at net.xqj.basex.bin.bC.bj(Unknown Source) at net.xqj.basex.bin.bC.bi(Unknown Source) at net.xqj.basex.bin.bC.bh(Unknown Source) at net.xqj.basex.bin.bC.aY(Unknown Source) at net.xqj.basex.bin.bC.aX(Unknown Source) at net.xqj.basex.bin.bC.aW(Unknown Source) at net.xqj.basex.bin.bC.aV(Unknown Source) at net.xqj.basex.bin.bC.aU(Unknown Source) at net.xqj.basex.bin.bC.aT(Unknown Source) at net.xqj.basex.bin.bC.aS(Unknown Source) at net.xqj.basex.bin.bC.aR(Unknown Source) at net.xqj.basex.bin.bC.aQ(Unknown Source) at net.xqj.basex.bin.bC.aP(Unknown Source) at net.xqj.basex.bin.bC.aO(Unknown Source) at net.xqj.basex.bin.bC.aN(Unknown Source) at net.xqj.basex.bin.bC.aM(Unknown Source) at net.xqj.basex.bin.bC.aL(Unknown Source) at net.xqj.basex.bin.bC.aK(Unknown Source) at net.xqj.basex.bin.bC.R(Unknown Source) at net.xqj.basex.bin.bC.Q(Unknown Source) at net.xqj.basex.bin.bC.P(Unknown Source) at net.xqj.basex.bin.bC.d(Unknown Source) at net.xqj.basex.bin.bC.b(Unknown Source) at net.xqj.basex.bin.bC.a(Unknown Source) at net.xqj.basex.bin.bC.a(Unknown Source) at net.xqj.basex.bin.bJ.<init>(Unknown Source) at net.xqj.basex.bin.bd.a(Unknown Source) at net.xqj.basex.bin.H.<init>(Unknown Source) at net.xqj.basex.bin.H.a(Unknown Source) at net.xqj.basex.bin.u.a(Unknown Source) at net.xqj.basex.bin.u.a(Unknown Source) at net.xqj.basex.bin.w.prepareExpression(Unknown Source) at net.xqj.basex.bin.w.prepareExpression(Unknown Source)
Executing the same query using "bin/basex -i context.xml query.xq" outputs the expected result:
<html> <context/> </html>
I have a minimal (Maven-based) test project, in case you want to reproduce the bug. I can also file the issue on GitHub, if that's the preferred method, but if I read https://github.com/BaseXdb/basex/issues/new correctly, then I should post here first.
Best wishes,
Andreas