}
public Expression compile(Executable exec, Declaration decl) throws XPathException {
SortKeyDefinition[] sortKeys = makeSortKeys(decl);
if (select != null) {
return new SortExpression(select, sortKeys);
} else {
Expression body = compileSequenceConstructor(exec, decl, iterateAxis(Axis.CHILD));
if (body == null) {
body = Literal.makeEmptySequence();
}
try {
return new SortExpression(makeExpressionVisitor().simplify(body), sortKeys);
} catch (XPathException e) {
compileError(e);
return null;
}
}