Search code examples
javaxsltinternationalizationsaxonapache-fop

How to install or register a Saxon HE 10.3 Configuration? Configuration is not being used


I'm trying to use a custom Configuration for saxon HE 10.3.

The Configuration is not being used. Presumably the config needs to be registered or installed? But how?
Here's my code:

final Configuration config = new net.sf.saxon.Configuration();
/**/                config.setLocalizerFactory(new LocalizerFactory() {
    public Numberer getNumberer(final String language, final String country) {
        if (language.equals("de")) {
            return  Numberer_de.getInstance();
        } else {
            return  null;
        }
    }
});
net.sf.saxon.Transform.main(new String[] {
        "-s:source.xml",
        "-xsl:stylesheet.xslt",
        "-o:result.txt"
});

Solution

  • What was missing, was how to inject the Config. This worked for me:

    import net.sf.saxon.Configuration;
    import net.sf.saxon.TransformerFactoryImpl;
    import net.sf.saxon.lib.Feature;
    
    final TransformerFactoryImpl factory = (TransformerFactoryImpl) TransformerFactory.newInstance();
    factory.getProcessor().setConfigurationProperty(Feature.CONFIGURATION, config);