Calling QuiP from Java - Cannot get Input from Java variable


I want to execute an XML Query using Quip on an XML document object
that is in a variable in a java program of my own. I thought of
defining a java function that would be called during the execution of
the XML Query. (In a way similar to the “document” function that gets
a document into the Quip XML query engine from a remote or local

I looked at the examples in QuiP/examples/javaCalls and wrote the
program below that should work, but it doesn’t.

I modified the in the following way:

public class JniTestProg {
static public Element e;

public static void setElement(Element elem){
e = elem;
public static Element getElement(){
return e;

The function getElement will be used to input the XML doc into QuiP.

The relevant portion of my Java Program that calls Quip:

// …
Connection qc = …

// Create an XML “Element” - this will be different every time
// I call the query (here is just an example)
String TESTDOC1 = “Begin civil
twilight19:04 on preceding

Element e = parseStringAsXml(TESTDOC1);

// The Element is actually SET in JniTestProg

// the query including the XML Query function that encapsulates
// getElement that should get my doc into QuiP
String query = “define function getDocument(){
javaFunctionElement(“JniTestProg1.getElement”)} let $x :=
(getDocument()) return $x//SunData”;

// Although it was set above, when the query is executed the
// Element “e” in JniTestProg IS NOT SET = > QUIP ERROR
QueryResult qr = qc.executeQuery(query);

Misteriuosly, the element that should have been set by calling
JniTestProg.setElement(e) it is NOT available to QuiP when the query
is executed. This is the error QuiP gives:

quip:message<![CDATA[Error (0,0): Exception occured within Java
execution: Exception in gcJniCallObjectMethod

Is there any way to pass an XML document stored in a java variable to
the QuiP query engine?

Thank you,

Jose Luis