Sunday, January 21, 2018

An unexpected error occured, message = Evaluation of the XPath expression

XSLT 2.0 functions such as the 'replace' function could produce the above error.

In WSO2 ESB this was fixed simply by enabling XSLT 2.0 by uncomment the following in 'conf/synapse.properties'

synapse.xpath.dom.failover.enabled=true


But in EI this could cause the following error:

javax.xml.transform.TransformerException: DOM Synapse XPATH variable resolution failed

This could be resolved by adding the following to integrator.sh:
-Djavax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom=net.sf.saxon.xpath.XPathFactoryImpl

Ref: https://wso2.org/jira/browse/ESBJAVA-5118


Still in the integrator profile this could result in the following:

Fatal error occurred in stylesheet parsing : javax.xml.transform.TransformerException: Could not find function: replace


This can be solved by doing the following:

Remove(rename to _bkp) the following jars:
/opt/wso2/wso2ei-6.1.1/wso2/lib/endorsed/xalan-2.7.2.wso2v2.jar
/opt/wso2/wso2ei-6.1.1/wso2/components/plugins/saxon.he_9.4.0.wso2v1.jar
/opt/wso2/wso2ei-6.1.1/wso2/components/plugins/saxon.bps_9.0.0.x-wso2v1.jar

(EI version: 6.1.1)

Ref: http://shriwithjava.blogspot.com.au/2015/11/how-to-use-xslt-20-in-wso2-esb-403.html