0

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);
Michael Kay
  • 156,231
  • 11
  • 92
  • 164
Amit Kumar
  • 377
  • 4
  • 17

1 Answers1

0

No, this capability is not available in Saxon-HE. There are alternatives: see the section "Extensibility" in the documentation at www.saxonica.com.

Note also that 9.6 is a rather old release. Since Saxon tracked the draft XSLT 2.0 and 3.0 specs as they were developed, it's best to avoid old versions of the product, because the specs were in flux at the time of the product release.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164