// prepare a result handler (StAX)
Writer writer = new StringWriter();
XMLOutputFactory factory = XMLOutputFactory.newInstance();
XMLStreamWriter streamWriter = factory.createXMLStreamWriter(writer);
XQEventReceiver handler = new StAXSerializer(streamWriter);
// #2 execute the compiled expression using ``push'' mode
// In push mode, the result is directed to the events.
proc.execute(module, handler);