Godmar Back asks: I'm still curious what XML interface I'm missing.
While I agree that published interfaces should work properly, I think a
simple point is being completely missed. Both XML and XQuery are, by their
nature, human readable text, regardless of their complexity. That means that
queries can be sent simply as text strings, and results of any size can also
be returned in that way and then parsed as XML fragments in any number of
myriad ways, including parsing to an in-memory DOM. I successfully use this
approach to query an XML database representing close to 200,000 pages of
text and to retrieve pretty large XML fragments (actually documents with a
single root element) quickly. This may be a simple approach but there is no
loss of generality by using it - in other words, using a more complex
interface will not let you do some XQuery processing that cannot be done
with this approach.
You can use the following code to access BaseX for example (in this case to
a local server using default permissions). I am prefixing text to make the
result string an XML document but your code may not need it:
package [...];
import java.io.*;
import java.util.*;
import org.basex.server.ClientSession;
public class QueryText {
public String doQuery(String xquery) {
ClientSession session;
String result;
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
session=null;
result="NO RESULT";
try {
session = new ClientSession("localhost", 1984, "admin", "admin");
session.execute(xquery, buffer);
result="<?xml version='1.0' encoding='UTF-8'?>"+buffer.toString("UTF-8");
} catch(Exception e) {
...
} finally {
try {
session.close();
} catch(Exception e) {
...
}
}
}
}