We have a use-case where we have to call instance methods from Xlst template. We are using Saxon-HE 9.6 version. Went though this stack-overflow post. We tried psssing XML transformer with Java object as parameter and then updated the template to call that instance method. But it's giving javax.xml.transform.TransformerConfigurationException.
Can some-one please help if we can call instance method from XSLT template using Saxon HE ?
Java Object :
public Double getValue(String s1, String s2, Double d1) {
// perform some operation and call other service to fetch data.
Double response = 2.0;
return response;
}
Xlst template : Added :
xmlns:util="java:com.test.utils.TestUtils"
<!--<xsl:value-of select="util:getValue($utils, $country1, $country2, $value)"/>
Code to pass this util object to xlst
Transformer transformer = factory.newTransformer(xsltTemplate);
transformer.setParameter("utils", util);