55634

Does Saxon 9 supports java varargs in extension functions?

Question:

Can Saxon map the following extension function call the java static method with varargs below?

<strong>XSLT:</strong>

<xsl:value-of select="mylib:fun('a', 'b', 'c')"/>

<strong>Java</strong>

public static String fun(String arg1, String... args) { ... }

I would expect that saxon supports varargs but, I get

<blockquote>

The namespace URI and local name are recognized, but the number of arguments is wrong

</blockquote>

Am I doing something wrong?

It seems it's able to recognize a sequence () but I want to implement a function with zero or more arguments like those that are in the standard XPath function library.

Thank you

Answer1:

I think you've answered your own question: SAXON does not support it.

Moreover, <em>it makes sense</em> that SAXON does not support it. Java varargs are implemented in the compiler; they are not represented in class files or bytecode. All SAXON sees is a method accepting two arguments (a String and a String[]) and returning a String.

I'm not familiar with all the details of SAXON's type mapping, but perhaps you could achieve your objective by passing a list as the second function argument:

<xsl:value-of select="mylib:fun('a', ('b', 'c'))"/>

Recommend

  • How can I find all elements in an XML Schema whose value is specified as a QName?
  • Unexpected namespace prefix “xmlns” found for tag fragment
  • Can you define a custom collation using a function in XSLT?
  • Referencing a CDI Bean in a non managed CDI Bean
  • How to avoid the use of Spring annotations in my java beans and use them only in the configuration c
  • finding maximum depth of chapter
  • Can you set a background imaged to a PdfPTable when using iText
  • Parse an XML fragment stored in a string into nodes in XSLT with SAXON for Java
  • How to fail Phing without triggering backtrace
  • Does SmartGit support git-svn?
  • On which thread JavaFX change listeners are executed ?
  • custom string delimiters stringtemplate-4
  • How dotnet build chooses the output name
  • SIP API media codecs
  • Wrong row deleted from custom listview with spinner
  • hide missing dates from x-axis ggplot2
  • Eloquent paginate function in Slim 3 project using twig
  • How to Cache Real-time Data?
  • Is there a javascript serializer for JSON.Net?
  • Spring Data JPA custom method causing PropertyReferenceException
  • Illegal mix of collations for operation for date/time comparison
  • Launch Runnable Jar from Web Start
  • Resize panoramic image to fixed size
  • Possible to stop flickering java tooltip in heavyweight mode?
  • MySQL WHERE-condition in procedure ignored
  • Where to put my custom functions in Wordpress?
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Buffer size for converting unsigned long to string
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • apache spark aggregate function using min value
  • Bitwise OR returns boolean when one of operands is nil
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • Checking variable from a different class in C#
  • Sorting a 2D array using the second column C++
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?