[ 
https://issues.apache.org/jira/browse/CAMEL-9591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15142875#comment-15142875
 ] 

ASF GitHub Bot commented on CAMEL-9591:
---------------------------------------

GitHub user lburgazzoli opened a pull request:

    https://github.com/apache/camel/pull/836

    CAMEL-9591 - Support Saxon integrated extension functions

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/lburgazzoli/apache-camel CAMEL-9591

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/camel/pull/836.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #836
    
----
commit 82abd905cb4110090184c19a750ed2aac25c175c
Author: lburgazzoli <[email protected]>
Date:   2016-02-11T15:23:23Z

    CAMEL-9591 - Support Saxon integrated extension functions

----


> 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
>
> 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)

Reply via email to