Project

Profile

Help

Passing Collection in Java extension

Added by Anonymous almost 18 years ago

Legacy ID: #4106378 Legacy Poster: Libor (liborvalenta)

I have xsl:param which is instance of Collection, every time I pass this parameter into Java extension I get new instance of ArrayList, it does not use passed object. Why is that?


Replies (2)

RE: Passing Collection in Java extension - Added by Anonymous almost 18 years ago

Legacy ID: #4106489 Legacy Poster: Michael Kay (mhkay)

When you pass a Java List into XSLT, Saxon interprets it as an XPath sequence, converting each item in the list separately to an XPath node or value. This is the right thing to do in many use cases, for example when you want to pass a sequence of strings as the identifiers of objects to be processed in your query or stylesheet. Similarly, if you pass an XPath sequence from XSLT to Java, it will be converted to a Java List. If you don't want this conversion to happen, the only thing I can suggest is to wrap your List in a Java object that Saxon doesn't recognize as anything special. The rules are explained at http://www.saxonica.com/documentation/extensibility/converting-args.html and http://www.saxonica.com/documentation/extensibility/function-result.html (Note that the rules for converting an externally supplied value for xsl:param are the same as the rules for converting the result of an extension function)

RE: Passing Collection in Java extension - Added by Anonymous almost 18 years ago

Legacy ID: #4106779 Legacy Poster: Libor (liborvalenta)

Thanks, wrapping collection in custom object solves the problem.

    (1-2/2)

    Please register to reply