Project

Profile

Help

Java extension using Spring Integration?

Added by Anonymous over 14 years ago

Legacy ID: #7727535 Legacy Poster: speedtrial (speedtrial)

Saxon works fine as XSLT and XPath engine inside Spring Integration 1.0.3. But I can not include Java extensions sucessfully. The extensions <xsl:value-of select="double:MAX_VALUE()" xmlns:double="java:java.lang.Double"/> <xsl:value-of select="math:sqrt($arg)" xmlns:math="java:java.lang.Math"/> work fine inside XMLSpy. But these error messages are shown using Spring Integration/Saxon EE Error at xsl:value-of on line 31 column 84 XPST0017: XPath syntax error at char 18 on line 31 in {double:MAX_VALUE()}: Cannot find a matching 0-argument function named {java:java.lang.Double}MAX_ VALUE() Error at xsl:value-of on line 32 column 77 XPST0017: XPath syntax error at char 15 on line 32 in {math:sqrt($arg)}: Cannot find a matching 1-argument function named {java:java.lang.Math}sqrt() The enviroment is: javax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl javax.xml.xpath.XPathFactory=net.sf.saxon.xpath.XPathFactoryImpl javax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl org.w3c.dom.DOMImplementationSourceList=org.apache.xerces.dom.DOMImplementationS ourceImpl The spring integration object is <spi-xml:xslt-transformer id="testtrans" xsl-resource="testtrans.xslt"/> What am I doing wrong?


Replies (4)

Please register to reply

RE: Java extension using Spring Integration? - Added by Anonymous over 14 years ago

Legacy ID: #7727560 Legacy Poster: Michael Kay (mhkay)

Hard to tell without further diagnostics. Essentially there are four possible "top-level" reasons: Saxon isn't searching for reflexive extension functions, it is searching but isn't finding the class, it finds the class but can't load it, or it loads the class and can't find the right method. Running with the search tracing enabled should give a clue: from the command line this is the -TJ flag, from the API it's Configuration.traceExternalFunctions(true).

RE: Java extension using Spring Integration? - Added by Anonymous over 14 years ago

Legacy ID: #7729040 Legacy Poster: speedtrial (speedtrial)

A futher review of the log file shows that the saxon xslt and xpath classes are used by spring integration. But I could not get Configuration to change any output to log file or stdout/stderr. Do I have to load Configuration from an XPathContext or is there a global Configuration? There is no access to XPathContext using Spring Integration beans. I reverted from saxon ee to saxon sa by replacing the jar archives and now it works. Is there a difference between sa and ee loading external classes?

RE: Java extension using Spring Integration? - Added by Anonymous over 14 years ago

Legacy ID: #7729101 Legacy Poster: Michael Kay (mhkay)

The Configuration object is created automatically to underpin the TransformerFactory or XPathFactory. I suspect the issue might be that you are using net.sf.saxon.TransformerFactoryImpl rather than com.saxonica.config.EnterpriseTransformerFactory. This means that your Configuration will be a (basic, home edition) Configuration rather than an EnterpriseConfiguration, which means it does not have the capability to load dynamic extension functions. The change here since 9.1 is that the basic Configuration no longer supports dynamic extension functions. However, I think I will introduce a bug fix here. Most interfaces in Saxon 9.2 are designed so that if you have the Saxon-EE software and a working license file, then you get the Saxon-EE capabilities automatically without asking for them. Instantiating a TransformerFactoryImpl seems to be an exception to this rule. I will change it so that the basic TransformerFactoryImpl loads an EnterpriseConfiguration if it can. Meanwhile, however, please replace your Java system property so it requests com.saxonica.config.EnterpriseTransformerFactory.

RE: Java extension using Spring Integration? - Added by Anonymous over 14 years ago

Legacy ID: #7729382 Legacy Poster: speedtrial (speedtrial)

I used net.sf.saxon.TransformerFactoryImpl. I changed it to com.saxonica.config.EnterpriseTransformerFactory and now it works. I would like to see a replacement of EnterpriseTransformerFactory to TransformerFactoryImpl. Thanks for your help, Rainer

    (1-4/4)

    Please register to reply