FunctionContext (final XmlFile xmlFile, Void p) { final FunctionContext base = Xslt2FunctionContext.getInstance(); return new FunctionContext() { @Override public Map<Pair<QName, Integer>, Function> getFunctions() { return ContainerUtil.union(base.getFunctions(), getCustomFunctions(xmlFile)); } @Override public boolean allowsExtensions() { return base.allowsExtensions(); } @Override public Function resolve(QName name, int argCount) { final Function f = base.resolve(name, argCount); if (f == null) { return resolveCustomFunction(xmlFile, name, argCount); } return f; } }; }