Reputation: 159
I am using Fuse 6.1 and camel 2.12 version for my project and facing following problem. I am trying to pass java.util.HashMap to my xslt and accessing map to retrieve bunch of values in my XSLT. For this i am constructing a map and placing it the in header in a bean and accessing it XSLT. I created a test case to run this route and everything is working fine, able to access map in XSLT, XSLT is compiling fine and generating expected XML if i had net.sf.saxon/saxon/8.9.0.4 in my class path but if i try to deploy same route in fuse 6.1 which has camel-saxon feature, its failing with following error. Later i realized and replaced net.sf.saxon jar file with camel-saxon dependency in pom file and test case for the same route is failing. Question is how can i make it run using camel-saxon feature.
Here is my route
<route id="newCustomerMapToXmlTransformationRoute">
<from uri="direct:newCustomerMapToXmlTransformation" />
<to uri="customerIdGenerationProcessor" />
<to uri="xslt:xslt/flatFileToCustomer.xsl?transformerFactory=tFactory&failOnNullBody=false" />
<removeHeader headerName="customerProfileMap" />
</route>
XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:Map="java.util.HashMap" exclude-result-prefixes="Map"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0">
<xsl:variable name="sourceName" select="Map:get($customerProfileMap,'aaaa')"/>
</xsl:stylesheet>
Getting following error:
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
[ main] XsltErrorListener ERROR Cannot find a matching 2-argument function named {java.util.HashMap}get(). Note that direct calls to Java methods are not available under Saxon-HE;
net.sf.saxon.trans.XPathException: Cannot find a matching 2-argument function named {java.util.HashMap}get(). Note that direct calls to Java methods are not available under Saxon-HE
I spent lot of time to find a solution and could not find any. Can any one help me solve this issue? Does it make sense to uninstall camel-saxon feature from fuse and use net.sf.saxon jar?
Upvotes: 1
Views: 2262
Reputation: 163625
From Saxon 9.2 (released in August 2009) the product was repackaged; the free version Saxon-HE does not support calls to Java extension functions (hence the error message which fully explains what is going on). The last open-source version to support this feature was Saxon-B 9.1, which of course you are welcome to continue using if you wish.
The reasons for the repackaging were primarily commercial: we felt that we could only continue to invest in development of the open source version if we could get a larger proportion of the user base to move over to paid versions, and this strategy proved successful, which is why the open source version continues to be developed today.
Upvotes: 2
Reputation: 55540
Fuse 6.1 comes with Saxon-HE (9.5.1.2_1) which is a free library that has a limited support for XSTL.
You can read about the other versions of Saxon which you need to pay $$$ to get at: http://saxon.sourceforge.net/
The older version of Saxon 8.9, may have more functionality, which they removed in 9.x and only offer in the paid $$$ versions.
You can instead likely set those headers in the Camel message first, and then access those from the xslt file, as documented here, at the section Getting Parameters into the XSLT to work with
Upvotes: 0