actually with this saxon-ee lib , we are trying to call external jar methods by specifying jar in xslt file like this :
<xsl:stylesheet version="2.0"
xmlns:fib="java:com.company.Main" >
<xsl:template match="/">
test value: <xsl:value-of select="fib:testMethod()"/>
</xsl:template>
</xsl:stylesheet>
this is the jar class imp:
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
}
public static void testMethod() {
System.out.println("testMethod Main");
}
}
but after running all this code :
Processor processor = new Processor(true);
processor.setConfigurationProperty(Feature.LICENSE_FILE_LOCATION,"C:/Users/shchaudhary/Downloads/saxon-license.lic");
processor.setConfigurationProperty(Feature.ALLOW_EXTERNAL_FUNCTIONS,true);
processor.setConfigurationProperty(Feature.TRACE_EXTERNAL_FUNCTIONS, true);
XsltCompiler compiler = processor.newXsltCompiler();
XsltExecutable stylesheet = compiler.compile(new StreamSource(new File("C:/Users/shchaudhary/Downloads/org.microsoft.functions.xslt/Artifacts/MapWithXslt20Function.xslt")));
StringWriter writer = new StringWriter();
Serializer out = processor.newSerializer(writer);
out.setOutputProperty(Serializer.Property.METHOD, "xml");
out.setOutputProperty(Serializer.Property.INDENT, "yes");
Xslt30Transformer transformer = stylesheet.load30();
transformer.transform(new StreamSource(new File("C:/Users/shchaudhary/Downloads/org.microsoft.functions.xslt/Artifacts/MapWithXslt20FunctionInput.xml")), out);
I am getting this error:
[2021-12-02T04:07:27.865Z] The class com.company.Main could not be loaded: com.company.Main
[2021-12-02T04:07:27.865Z] Error in {fib:testMethod()} at char 0 in xsl:value-of/@select on line 35 column 58 of MapWithXslt20Function.xslt:
[2021-12-02T04:07:27.865Z] XPST0017 Cannot find a 0-argument function named Q{java:com.company.Main}testMethod().
[2021-12-02T04:07:27.865Z] Cannot load Java class java:com.company.Main. For diagnostics on calls to Java methods,
[2021-12-02T04:07:27.866Z] use the -TJ command line option or set the Configuration property
[2021-12-02T04:07:27.866Z] FeatureKeys.TRACE_EXTERNAL_FUNCTIONS