Expression sortedSequence = select;
if (sortKeys != null) {
sortedSequence = new SortExpression(select, sortKeys);
}
compileSequenceConstructor(exec, iterateAxis(Axis.CHILD), true);
ApplyTemplates app = new ApplyTemplates(
sortedSequence,
useCurrentMode,
useTailRecursion,
mode,
backwardsCompatibleModeIsEnabled(),
implicitSelect);
app.setActualParameters(getWithParamInstructions(exec, false, app),
getWithParamInstructions(exec, true, app));
return app;
}