Hi Mark,
ByteArrayOutputStream stream = new ByteArrayOutputStream(); String inQuery = "collection()/event/@in/string()"; XQuery inputQuery = new XQuery(inQuery); inputQuery.execute(_context,stream); String input = stream.toString();
Just a hint.. The following code might do the same:
String inQuery = "/event/@in/string()"; XQuery inputQuery = new XQuery(inQuery); String input = inputQuery.execute(_context);
QueryProcessor processor = new QueryProcessor(processQuery, _context); Iter iterator = processor.iter(); Item item; while ((item=iterator.next())!=null) { [...] } [...] Exception in thread "main" java.lang.RuntimeException: Possible bug? Feedback is welcome: basex-talk@mailman.uni-konstanz.de
You should be very careful when executing nested queries incl. update operations, as the inner update operation might change parts of the database, which you are addressing by the outer QueryProcessor instance. I would recommend to...
a) do it all in just one XQuery expression, or b) sequentially run all query operations (nested read-only operations won't cause any troubles)
If the exception still occurs after rewriting your code, it would be great if you could create a little example that allows us to reproduce the issue.
The first issue I have is that it seemed a bit inefficient to use an XQuery to match a regular expression. [...] My question now is, can I call the BaseX 'matches()' function directly? Because I think that would be much more efficient.
Our XQuery functions are not designated to be run stand-alone; next, we're internally working with byte arrays instead of strings. I'd recommend to first benchmark the evaluation of your regular XQuery expressions, as I don't believe they are the major bottleneck here (instead, I believe that you might save execution time by avoiding the use of DOM (BXNode) instances).
Christian