An XPath extension for use under XMLProbe must implement org.jaxen.Function (http://jaxen.org/apidocs/org/jaxen/Function.html).
The method Function#call() should for best results return a node-set, represented by a java.util.List.
Extension functions with a default/no-arg constructor can be loaded from the XML configuration file using this syntax:
<probe:addIn xmlns:probe='http://xmlprobe.com/200312'> <probe:name>com.xmlprobe.QAHandler</probe:name> <probe:feature> <probe:name>http://xmlprobe.com/features/xpath-extension-function</probe:name> <probe:value>[classname of function to be loaded]</probe:value> <probe:alias>[name of XPath function]</probe:alias> </probe:feature> <!--...more features here...--> </probe:config> </probe:addIn>
The element <probe:alias> is not required. If omitted, the classname specified in <probe:value> is used as the registered name of the extension function.
Extension functions whose constructor takes arguments must be loaded from a subclass of com.xmlprobe.QAHandler. To do this, create an instance of the function and register it with the current com.xmlprobe.XPathEvaluator, accessible via QAHandler#functionContext(), e.g.:
MyExtensionFunction f = new MyExtensionFunction( arg1, arg2 ); //constructor takes args getEvaluator().registerFunction( namespaceURI, "my-ext-func", f );
In order for custom extension functions to be loaded by XMLProbe at runtime, they must be present in the same directory as xmlprobe.jar, either as binary (.class) files, or as part of a JAR archive.