for (int i = 0; i< elements.size(); i++) {
ElementSymbol elemSymbol = (ElementSymbol) elements.get(i);
String nodeName = planEnv.getGlobalMetadata().getFullName(elemSymbol.getMetadataID()).toUpperCase();
MappingNode elementNode = MappingNode.findNode(planEnv.mappingDoc, nodeName);
// make sure that the name in source is defined for this node, so that it can be used
// in the orderby. static nodes do not qualify for ordering.
if (elementNode.getNameInSource() == null){
Object[] params = new Object[] {elementNode, orderBy};
String msg = QueryPlugin.Util.getString("XMLPlanner.The_XML_document_element_{0}_is_not_mapped_to_data_and_cannot_be_used_in_the_ORDER_BY_clause__{1}_1", params); //$NON-NLS-1$
throw new QueryPlannerException(msg);
}
MappingSourceNode sourceNode = elementNode.getSourceNode();
ResultSetInfo rs = sourceNode.getResultSetInfo();
OrderBy by = rs.getOrderBy();
if (by == null) {
by = new OrderBy();
}
ElementSymbol mappedSymbol = (ElementSymbol)sourceNode.getSymbolMap().get(new ElementSymbol(elementNode.getNameInSource()));
by.addVariable((ElementSymbol)mappedSymbol.clone(), ((Boolean)types.get(i)).booleanValue());
rs.setOrderBy(by);
}
}