Passing Collection in Java extension

Libor
2007-01-16
2012-10-08
  • Libor
    Libor
    2007-01-16

    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?

     
    • Michael Kay
      Michael Kay
      2007-01-16

      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)

       
      • Libor
        Libor
        2007-01-17

        Thanks, wrapping collection in custom object solves the problem.