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
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
Hi Christian,
The XQJ driver comes with its own XQuery parser, which differs from the BaseX query parser.
Interesting. That's not what I would have been expecting. May I inquire why this is done like this?
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.
OK, I will try, but I am afraid that is not the only parser issue I am encountering, merely the one with the simplest steps to reproduce, so even if Charles is responsive, this may mean embarking on a longer journey.
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].
Yes, that's essentially the same response I got on saxon-help (use their S9API).
Unfortunately, for my use case that is less than ideal: I am developing a plug-in for Maven (unsurprisingly named xquery-maven-plugin) that does for XQuery what the xml-maven-plugin does for XSLT [1]: offer a goal to query and transform some inputs w.r.t. to a stylesheet/query.
Thus, my plug-in requires a common interface to the XQuery engines. XQJ seemed like the natural conterpart of javax.xml.transform used by the xml-maven-plugin, but I guess I really have to to write my own wrapper around Saxon's S9API and BaseX's API, if only because the XQJ integration seems to be among the least tested and most buggy parts of the XQuery engines I have tried so far.
Best wishes,
Andreas Sewe
[1] https://www.mojohaus.org/xml-maven-plugin/transform-mojo.html
Interesting. That's not what I would have been expecting. May I inquire why this is done like this?
Once again, a solution chosen by the developer… I assume this is because the same XQJ base driver was used for a range of XQuery processors (eXist-db, Sedna, Marklogic).
Thus, my plug-in requires a common interface to the XQuery engines. XQJ seemed like the natural conterpart of javax.xml.transform used by the xml-maven-plugin, but I guess I really have to to write my own wrapper around Saxon's S9API and BaseX's API, if only because the XQJ integration seems to be among the least tested and most buggy parts of the XQuery engines I have tried so far.
I guess so. A clean abstraction for the Java and XQuery world often be helpful, but XQJ was discontinued at a rather early stage. One open issue from the very beginning was that it assumed the underlying processor to behave in certain ways, which did not reflect the reality of existing processors. And around 10 years ago, we were maintaining our own XQJ implementation, but it was too much effort to keep it alive (too few developers were using it).
basex-talk@mailman.uni-konstanz.de