[
https://issues.apache.org/jira/browse/CAMEL-9591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15144538#comment-15144538
]
Claus Ibsen commented on CAMEL-9591:
------------------------------------
Oh it would also be good to add a line about this in the 2.17 release notes
http://camel.apache.org/camel-2170-release.html
> Support Saxon integrated extension functions
> ---------------------------------------------
>
> Key: CAMEL-9591
> URL: https://issues.apache.org/jira/browse/CAMEL-9591
> Project: Camel
> Issue Type: New Feature
> Components: camel-xslt
> Reporter: Luca Burgazzoli
> Assignee: Luca Burgazzoli
> Priority: Minor
> Fix For: 2.17.0
>
>
> Since Saxon 9.2, writing extension functions has been supplemented by a new
> mechanism, referred to as [integrated extension
> functions|http://www.saxonica.com/html/documentation/extensibility/integratedfunctions].
>
> To use such an extension function, user writes a custom class which extends
> net.sf.saxon.lib.ExtensionFunctionDefinition an registers it in the Saxon
> transformer factory. It works fine. Only problem is that there's no
> convenient support in Camel to pass such an extension function reference to
> camel-xslt.
> Current way:
> {code:java}
> // Define my extension functions (note: Saxon requires a class for each
> function)
> List<ExtensionFunctionDefinition> extensionFunctions = new
> ArrayList<ExtensionFunctionDefinition>();
> extensionFunctions.add(new MyExtensionFunction1());
> extensionFunctions.add(new MyExtensionFunction2());
>
> // Register extension functions
> TransformerFactoryImpl extendedSaxonTransformerFactory = new
> TransformerFactoryImpl();
> Configuration configuration =
> extendedSaxonTransformerFactory.getConfiguration();
> for ( ExtensionFunctionDefinition func : extensionFunctions ) {
> configuration.registerExtensionFunction(func);
> }
> // Enable secure processing (note: secure processing allows use of Saxon
> integrated extension functions as opposed to reflective extension functions)
>
> extendedSaxonTransformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,
> true);
> // Register transformer factory on Camel
> SimpleRegistry registry = new SimpleRegistry();
> registry.put("extendedSaxonTransformerFactory",
> extendedSaxonTransformerFactory);
> CamelContext context = new DefaultCamelContext(registry);
> // Define Route
> context.addRoutes(new RouteBuilder() {
> @Override
> public void configure() throws Exception {
> from("direct:start")
>
> .to("xslt:transformation/myStyleSheet.xslt?transformerFactory=#extendedSaxonTransformerFactory");
> }
> });
> {code}
> Proposed way:
> {code:java}
> // Define my extension functions (note: Saxon requires a class for each
> function)
> List<ExtensionFunctionDefinition> extensionFunctions = new
> ArrayList<ExtensionFunctionDefinition>();
> extensionFunctions.add(new MyExtensionFunction1());
> extensionFunctions.add(new MyExtensionFunction2());
> // Register extension functions with Camel
> SimpleRegistry registry = new SimpleRegistry();
> registry.put("extensionFunctions", extensionFunctions);
> CamelContext context = new DefaultCamelContext(registry);
> // Define Route
> context.addRoutes(new RouteBuilder() {
> @Override
> public void configure() throws Exception {
> from("direct:start")
>
> .to("xslt:transformation/myStyleSheet.xslt?saxon=true&saxonExtensionFunctions=#extensionFunctions&secureProcessing=true");
> }
> });
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)