Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support setting a Saxon initializer when invoking Calabash #335

Open
dwcramer opened this issue May 6, 2022 · 6 comments
Open

Support setting a Saxon initializer when invoking Calabash #335

dwcramer opened this issue May 6, 2022 · 6 comments

Comments

@dwcramer
Copy link

dwcramer commented May 6, 2022

Beginning in Saxon 9.3 you can pass in a class that implements the interface net.sf.saxon.lib.Initializer to register extension functions. On the command line, you would use the -init option. It would be great if Calabash provided a way to supply an initializer for Saxon to use.

@nkutsche
Copy link

Hi,

I had shortly a similar issue. I found in Calabash the com.xmlcalabash.config.XProcConfigurer interface. You can provide your configurer class by the Calabash config file:

<xproc-config xmlns="http://xmlcalabash.com/ns/configuration">
    <xproc-configurer class-name="full.classname.of.your.ConfigureClass"/>
</xproc-config>

or by system property:

-Dcom.xmlcalabash.xproc-configurer=full.classname.of.your.ConfigureClass

An implementation of an configurer could look like this:

import com.xmlcalabash.config.JaxpConfigurer;
import com.xmlcalabash.config.JingConfigurer;
import com.xmlcalabash.config.XMLCalabashConfigurer;
import com.xmlcalabash.core.XProcRuntime;
import com.xmlcalabash.util.DefaultJaxpConfigurer;
import com.xmlcalabash.util.DefaultJingConfigurer;
import com.xmlcalabash.util.DefaultSaxonConfigurer;
import com.xmlcalabash.util.DefaultXMLCalabashConfigurer;
import net.sf.saxon.Configuration;

public class XProcConfigurer implements com.xmlcalabash.config.XProcConfigurer {

    private final XProcRuntime runtime;

    public XProcConfigurer(XProcRuntime runtime){
        this.runtime = runtime;
    }

    @Override
    public XMLCalabashConfigurer getXMLCalabashConfigurer() {
        return new DefaultXMLCalabashConfigurer(runtime);
    }

    @Override
    public SaxonConfigurer getSaxonConfigurer() {
        return new SaxonConfigurer() ;
    }

    @Override
    public JingConfigurer getJingConfigurer() {
        return new DefaultJingConfigurer();
    }

    @Override
    public JaxpConfigurer getJaxpConfigurer() {
        return new DefaultJaxpConfigurer();
    }

    private class SaxonConfigurer extends DefaultSaxonConfigurer {
        @Override
        public void configXSLT(Configuration config) {
            //do what ever you wanted to do in the Saxon initializer 
        }
    }
}

Hope it helps!

@ndw
Copy link
Owner

ndw commented Sep 13, 2023

This is probably a case where a configuration option or command line flag is justified. I'll see what I can do.

@wendellpiez
Copy link

@ndw any update on this? We are now at the point of wanting iXML support inside Saxon, i.e. CoffeeSacks etc., inside XML Calabash. Everything but the Calabash part seems to be working nicely. Thanks!

@nkutsche
Copy link

@wendellpiez: is there a reason why you don't use an XProcConfigurer as I proposed above? On my point of view, this is not a workaround. It is just another configuration layer. You can re-use your existing Saxon initializer by just calling it by your SaxonConfigurer. That's how I did it.

@wendellpiez
Copy link

If @aj-stein-nist is promising to help with the Java aspects, I might just do this, thanks @nkutsche (and for the link as well).

@aj-stein-nist
Copy link

aj-stein-nist commented Jan 19, 2024

If @aj-stein-nist is promising to help with the Java aspects, I might just do this, thanks @nkutsche (and for the link as well).

The implication of my thumbs up is be me looking into it, trying to work with it in our project, and report back here. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants