mojohaus/xml-maven-plugin

Is it possible to register custom saxon extensions?

sirinsevinc opened this issue · 1 comments

Hi,
I'm using xml-maven-plugin to do XSLT 2.0 transformations with SaxonHE version.10

As per Saxon HE documentation, it is possible to register custom Saxon extensions. https://www.saxonica.com/html/documentation/extensibility/integratedfunctions.

However, I need to be able to register the custom extension to net.sf.saxon.s9api.Processor.
I wonder if it is possible to do that using the xml-maven-pluin with transformationSet configuration?

My pom looks like below :

<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>xml-maven-plugin</artifactId> <version>1.0.2</version> <executions> <execution> <phase>generate-sources</phase> <goals> <goal>transform</goal> </goals> </execution> </executions> <configuration> <transformationSets> <transformationSet> <dir>sourceFile</dir> <stylesheet>mystylesheet.xsl</stylesheet> <outputDir>outputDir</outputDir> </transformationSet> </transformationSets> </configuration> </plugin

Hi again,

I solved this by adding a custom transformerFactory in the xml-maven-plugin configuration as described here : http://www.mojohaus.org/xml-maven-plugin/transform-mojo.html#transformerFactory

Below is a simple CustomFactory code

public class CustomTransformerFactory extends TransformerFactoryImpl { public CustomTransformerFactory() { super(); net.sf.saxon.Configuration saxonConfig = this.getConfiguration(); Processor processor = (Processor) saxonConfig.getProcessor(); ExtensionFunction test = new Test(); processor.registerExtensionFunction(test); } }
Test is an extension function as implemented in this thread : https://stackoverflow.com/a/33502184/344931