public XQPreparedExpression prepareExpression(InputStream xquery, XQStaticContext properties) throws XQException {
checkNotClosed();
try {
SaxonXQStaticContext xqStaticContext = ((SaxonXQStaticContext)properties);
StaticQueryContext sqc = xqStaticContext.getSaxonStaticQueryContext();
XQueryExpression exp = sqc.compileQuery(xquery, null);
DynamicQueryContext dqc = new DynamicQueryContext(config);
return new SaxonXQPreparedExpression(this, exp, xqStaticContext, dqc);
} catch (XPathException e) {
throw newXQException(e);
} catch (IOException e) {