declareVariables(context);
if(compiled == null)
try {
compiled = xquery.compile(context, source);
} catch (final IOException e) {
throw new EXistException("An exception occurred while compiling the query: " + e.getMessage());
}
Sequence resultSeq = null;
try {
resultSeq = xquery.execute(compiled, null);
} finally {
pool.returnCompiledXQuery(source, compiled);
}
if (!(resultSeq.isEmpty() || Type.subTypeOf(resultSeq.getItemType(), Type.NODE)))
{throw new EXistException("select expression should evaluate to a node-set; got " +
Type.getTypeName(resultSeq.getItemType()));}
if (LOG.isDebugEnabled())
{LOG.debug("found " + resultSeq.getItemCount() + " for select: " + selectStmt);}
return (NodeList)resultSeq.toNodeSet();
}