Adding a Directory of Ext Functions
Added by Anonymous about 16 years ago
Legacy ID: #5623715 Legacy Poster: Alex Maskovyak (litcigar)
I am trying to wrap my head around the way in which java classes are bound to a prefix in saxon. I would like very much to have a single directory which has a number of classes where each class implements some number of extension functions. I would like to be able to call any of these extension functions using a common prefix or alternatively with no prefix. Is there a method that I can call to register the functions in these classes to the default or a explicitely specified prefix?
Replies (1)
RE: Adding a Directory of Ext Functions - Added by Anonymous about 16 years ago
Legacy ID: #5623775 Legacy Poster: Michael Kay (mhkay)
The normal mapping is that a Java class is bound to a namespace URI by name, for example com.acme.package.MyClass is bound to the namespace URI java:com.acme.package.myClass, and then a prefix is bound to the namespace URI using the normal XML/XSLT/XQuery mechanisms. You can't change the way the prefix is bound to the namespace, but you can change the way the namespace is bound to a Java class: FunctionLibrary javaFunctionLib = config.getExtensionBinder("java"); ((JavaExtensionLibrary)javaFunctionLib).declareJavaClass("http://xbrl.org/functions", MyXbrlLibrary.class); will associate the namespace URI http://xbrl.org/functions with the Java class MyXbrlLibrary. If you want to spread the methods around several classes I would suggest having one class that acts as the interface. If you really want, though, you can register your own FunctionLibrary and have it bind extension function calls in any way that it likes.
Please register to reply