Page 1 of 1

Is it possible to register a "simple interface" Java extension function

Posted: Sat Nov 02, 2019 12:48 am
by trevordavidlawrence
To be clear, I'm using the terminology in Saxon's documentation. The "simple interface" refers to implementations of "net.sf.saxon.s9api.ExtensionFunction" and "full interface" to implementations of "net.sf.saxon.lib.ExtensionFunctionDefinition".

I have a number of extension functions implemented using Saxon's simple interface for defining Java-based extension functions. I'd like to make these available when executing stylesheets that make use of them with Oxygen. I see that by packaging an implementation of the "full interface" with some SPI voodoo and setting the JAR as an extension in the transformation scenario works.

I tried to use a Saxon initializer ("net.sf.saxon.lib.Initializer") to register the functions. However, I suspect that either Oxygen does not use s9api internally or it does not expose the underlying API instance (whatever type it is), since the getProcessor() method of the Configuration object that was given to my initializer returns null.

Is there a way to use simple interface implementations in Oxygen?

More generally, is there a way to use s9api to configure how Saxon runs within Oxygen?

Re: Is it possible to register a "simple interface" Java extension function

Posted: Wed Nov 06, 2019 10:27 am
by alex_jitianu
Hello,

Yes, I managed to reproduce this issue myself. As far as I can tell, when wee create Saxon's transformer factories, we supply the configuration to the factory and, when doing so, Saxon's doesn't set the processor. Maybe it expects the configuration to be somehow already initialized... I don't know. I will add an issue to figure it out how to approach this: either Saxon should set the processor in this case too, or we can do it ourselves.

Meanwhile, as far as I understand, you still have the possibility to pack the extensions inside a JAR file as described in our documentation topic, right?

Best regards,
Alex

Re: Is it possible to register a "simple interface" Java extension function

Posted: Wed Feb 19, 2020 12:53 pm
by alex_jitianu
Hi,

This issue was fixed in the latestet Oxygen release, version 22. From a net.sf.saxon.lib.Initializer you will be able to access the API instance by using Configuration .getProcessor().

I hope it helps!

Best regards,
Alex