public void register(Declaration declaration) throws XPathException {
if (match != null) {
StylesheetModule module = declaration.getModule();
int slots = match.allocateSlots(getStaticContext(), getSlotManager(), 0);
RuleManager mgr = getPreparedStylesheet().getRuleManager();
for (int i=0; i<modeNames.length; i++) {
StructuredQName nc = modeNames[i];
Mode mode = mgr.getMode(nc, true);
if (prioritySpecified) {
mgr.setTemplateRule(match, compiledTemplate, mode,
module, priority, ixslPreventDefault, ixslEventProperty);
} else {
mgr.setTemplateRule(match, compiledTemplate, mode,
module, Double.NaN, ixslPreventDefault, ixslEventProperty);
}
mode.allocatePatternSlots(slots);
}