} else if (value instanceof Source) {
// Saxon extension to the XQJ specification
Builder b = new TinyBuilder();
PipelineConfiguration pipe = config.makePipelineConfiguration();
b.setPipelineConfiguration(pipe);
new Sender(pipe).send((Source)value, b);
return b.getCurrentRoot();
} else if (value instanceof XMLStreamReader) {
// Saxon extension to the XQJ specification
StaxBridge bridge = new StaxBridge();
bridge.setXMLStreamReader((XMLStreamReader)value);
Builder b = new TinyBuilder();
PipelineConfiguration pipe = config.makePipelineConfiguration();
b.setPipelineConfiguration(pipe);
new Sender(pipe).send(new PullSource(bridge), b);
return b.getCurrentRoot();
} else {
throw new XPathException("Java object cannot be converted to an XQuery value");
}
} catch (XPathException e) {