protected SortKeyDefinition[] makeSortKeys(Declaration decl) throws XPathException {
// handle sort keys if any
int numberOfSortKeys = 0;
AxisIterator kids = iterateAxis(Axis.CHILD);
while (true) {
Item child = kids.next();
if (child == null) {
break;
}
if (child instanceof XSLSort) {
((XSLSort)child).compile(getExecutable(), decl);
if (numberOfSortKeys != 0 && ((XSLSort)child).getStable() != null) {
compileError("stable attribute may appear only on the first xsl:sort element", "XTSE1017");
}
numberOfSortKeys++;
}
}
if (numberOfSortKeys > 0) {
SortKeyDefinition[] keys = new SortKeyDefinition[numberOfSortKeys];
kids = iterateAxis(Axis.CHILD);
int k = 0;
while (true) {
NodeInfo child = (NodeInfo)kids.next();
if (child == null) {
break;
}
if (child instanceof XSLSort) {
keys[k++] = ((XSLSort)child).getSortKeyDefinition().simplify(makeExpressionVisitor());