Permalink
Browse files

Merge pull request #62 from argv-minus-one/saxon94

Support Saxon 9.4's ExtensionFunction interface for extension functions
  • Loading branch information...
ndw committed Jan 28, 2013
2 parents d2be7c3 + ab1ca0e commit 2877dacdf163afc32141ec2daa5b0d6b081cb3ce
Showing with 8 additions and 2 deletions.
  1. +8 −2 src/com/xmlcalabash/core/XProcRuntime.java
@@ -34,6 +34,7 @@
import com.xmlcalabash.util.StepErrorListener;
import net.sf.saxon.Configuration;
import net.sf.saxon.lib.ExtensionFunctionDefinition;
+import net.sf.saxon.s9api.ExtensionFunction;
import net.sf.saxon.s9api.Processor;
import net.sf.saxon.s9api.QName;
import net.sf.saxon.s9api.XdmNode;
@@ -168,9 +169,14 @@ public XProcRuntime(XProcConfiguration config) {
for (String className : config.extensionFunctions) {
try {
- ExtensionFunctionDefinition def = (ExtensionFunctionDefinition) Class.forName(className).newInstance();
+ Object def = Class.forName(className).newInstance();
finer(null, null, "Instantiated: " + className);
- processor.registerExtensionFunction(def);
+ if (def instanceof ExtensionFunctionDefinition)
+ processor.registerExtensionFunction((ExtensionFunctionDefinition) def);
+ else if (def instanceof ExtensionFunction)
+ processor.registerExtensionFunction((ExtensionFunction) def);
+ else
+ finer(null, null, "Failed to instantiate extension function " + className + " because that class implements neither ExtensionFunction nor ExtensionFunctionDefinition.");
} catch (NoClassDefFoundError ncdfe) {
finer(null, null, "Failed to instantiate extension function: " + className);
} catch (Exception e) {

0 comments on commit 2877dac

Please sign in to comment.