public void compileStylesheet() throws XPathException {
try {
PreparedStylesheet pss = getPreparedStylesheet();
// If any XQuery functions were imported, fix up all function calls
// registered against these functions.
try {
//queryFunctions.bindUnboundFunctionCalls();
Iterator qf = queryFunctions.getFunctionDefinitions();
while (qf.hasNext()) {
XQueryFunction f = (XQueryFunction) qf.next();
f.fixupReferences(getStaticContext());
}
} catch (XPathException e) {
compileError(e);
}
// Call compile method for each top-level object in the stylesheet
for (int i = 0; i < topLevel.size(); i++) {
NodeInfo node = (NodeInfo) topLevel.get(i);
if (node instanceof StyleElement) {
StyleElement snode = (StyleElement) node;
//int module = putModuleNumber(snode.getSystemId());
Expression inst = snode.compile(exec);
if (inst != null) {
inst.setLocationId(allocateLocationId(getSystemId(), snode.getLineNumber()));
}
}
}
// Call optimize method for each top-level object in the stylesheet
for (int i = 0; i < topLevel.size(); i++) {
NodeInfo node = (NodeInfo) topLevel.get(i);
if (node instanceof StylesheetProcedure) {
((StylesheetProcedure) node).optimize();
}
}
// Fix up references to the default default decimal format
if (pss.getDecimalFormatManager() != null) {
try {
pss.getDecimalFormatManager().fixupDefaultDefault();
} catch (XPathException err) {
compileError(err.getMessage(), err.getErrorCodeQName());
}
}