0

I have the Java method ...

public static Object parseXMLtoXLSX(File xmlFile, String path)

So I want to call the method from XSLT.

I understand, that I have to introduce the class in my XSLT File e.g. like this:

<xsl:stylesheet version="2.0" xmlns:trans="pathToMyJavaClass">

But how can I call the method?

Is this the right way?:

<xsl:value-of select="trans:parseXMLtoXLSX($xmlFIle,$path)" />

But how can I store the Java File Object, that I get back from the Method in a Variable?

Edit: I can't show the < > in this question...

1
  • Study the documentation of your used XSLT processor, for instance for Saxon 9.8 see saxonica.com/html/documentation/extensibility. If you use a different processor the conventions might be different. Commented Mar 28, 2018 at 8:46

1 Answer 1

1

The calling conventions from XSLT to other languages depend entirely on which XSLT processor you are using, so you need to provide this information.

If you're using XSLT 2.0 under Java then it's likely that the processor you are using is Saxon, in which case the calling conventions are documented at http://saxonica.com/documentation/index.html#!extensibility/functions

In cases where you're handling objects (like a Java java.util.File) that have no equivalent in the XDM data model used by XSLT, the calling conventions can be quite complicated. It's simpler if you organize things so that you only need to pass simple values like strings and integers. For example, write another method in Java that accepts a String (containing a file name) rather than a File.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.