Project

Profile

Help

Support #5722

closed

Cannot use Java functions in XSLT transformation.

Added by Harish Annamalai over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
High
Assignee:
Category:
JAXP Java API
Sprint/Milestone:
-
Start date:
2022-10-26
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:
Java

Description

Hi,

We have ab enterprise licence for Saxon.

This is with regards to camel-xslt-saxon.

We are using saxon with camel and during our migration we are trying to invoke java functions from XSLT transformation.

We are hit with following exception: Fatal error parsing XSLT file: Cannot find a 1-argument function named Q{java:java.lang.String}new()

The Corresponding XSLT is simple:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:template match="/" xmlns:str="java:java.lang.String">
        <xsl:value-of select="str:new('Test')"/>
    </xsl:template>
</xsl:stylesheet>

We are using the camel Saxon URI as below

xslt-saxon:mapping/XSLTMapping1.xsl?transformerFactory=#saxoneeTransformer&amp;output=bytes&amp;saxonExtensionFunctions=#xsltExtensionsV11

While this works with in Camel 2.x this fails in Camel 3.x

We are passing an instance of EnterpriseTransformerFactory to camel.

We are not sure why the XSLT transformation fails.

Stack Trace:

2022 10 26 11:25:11#+00#ERROR#org.apache.camel.component.xslt.XsltErrorListener##anonymous#1666783509958-XSLTMapping_Worker-1####na#na#na#na#Fatal error parsing XSLT file: Cannot find a 1-argument function named Q{java:java.lang.String}new(). For diagnostics on calls to Java methods, use the -TJ command line option or set the Configuration property FeatureKeys.TRACE_EXTERNAL_FUNCTIONS; SystemID: classpath:mapping/XSLTMapping1.xsl; Line\#: 4|
2022 10 26 11:25:11#+00#ERROR#org.apache.camel.processor.errorhandler.DefaultErrorHandler##anonymous#1666783509958-XSLTMapping_Worker-1####na#na#na#na#Failed delivery for (MessageId: B86228E138F42E1-0000000000000001 on ExchangeId: B86228E138F42E1-0000000000000001). Exhausted after delivery attempt: 1 caught: net.sf.saxon.trans.XPathException: Errors were reported during stylesheet compilation

Message History (complete message history is disabled)
---------------------------------------------------------------------------------------------------------------------------------------
RouteId              ProcessorId          Processor                                                                        Elapsed (ms)
[route17           ] [route17           ] [from[quartz://XSLTMappingTimerEventDefinition5693451?trigger.repeatCount=0&tri] [       148]
	...
[Process_1         ] [CallActivity_4_216] [xslt-saxon:mapping/XSLTMapping1.xsl?transformerFactory=\#saxoneeTransformer&out] [         0]

Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
net.sf.saxon.trans.XPathException: Errors were reported during stylesheet compilation
	at net.sf.saxon.style.XSLTemplate.jitCompile(XSLTemplate.java:819)
	at com.saxonica.ee.trans.TemplateRuleInitializer.init(TemplateRuleInitializer.java:52)
	at com.saxonica.ee.trans.TemplateRuleEE.initialize(TemplateRuleEE.java:85)
	at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:509)
	at net.sf.saxon.trans.XsltController.applyTemplates(XsltController.java:746)
	at net.sf.saxon.s9api.AbstractXsltTransformer.applyTemplatesToSource(AbstractXsltTransformer.java:347)
	at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:349)
	at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:71)
	at org.apache.camel.component.xslt.XsltBuilder.process(XsltBuilder.java:123)
	at org.apache.camel.support.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:93)

We are using a simple String::new to test, even this fails.

We executed the method: getProductTitle() of Configuration class, and get a response as

Saxon-EE 9.9.1.6J from Saxonica

Therefore we believe the licence features are activated.

We created a small java program and executed the XSLT transformation, this works as a standalone application, but not in camel 3.x

We are looking for possible reasons as to why the XSLT transformation fails, possible reasons for failure and how to check whether the License features are activated.

Please register to edit this issue

Also available in: Atom PDF