xmlcalabash1
                                
                                
                                
                                    xmlcalabash1 copied to clipboard
                            
                            
                            
                        Support setting a Saxon initializer when invoking Calabash
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.
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!
This is probably a case where a configuration option or command line flag is justified. I'll see what I can do.
@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!
@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.
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).
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. :-)