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

Here should go questions about transforming XML with XSLT and FOP.
trevordavidlawrence
Posts: 1
Joined: Thu Oct 17, 2019 11:08 pm

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

Post by trevordavidlawrence » Sat Nov 02, 2019 12:48 am

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?

alex_jitianu
Posts: 770
Joined: Wed Nov 16, 2005 11:11 am

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

Post by alex_jitianu » Wed Nov 06, 2019 10:27 am

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

alex_jitianu
Posts: 770
Joined: Wed Nov 16, 2005 11:11 am

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

Post by alex_jitianu » Wed Feb 19, 2020 12:53 pm

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

Post Reply