Converting Method Arguments - General Rules
Having decided which method to call, Saxon has to convert the supplied XPath argument values to the Java objects required by this method.
If the expected type is
Object, the supplied value must either be a singleton, or an empty sequence.
If it is an empty sequence, null will be passed. If it is a singleton node, an instance of
will be passed. If it is a wrapped Java object, that Java object will be passed.
If it is a singleton atomic value, the value will be converted to the nearest equivalent Java object: for example
and so on. An untyped atomic value is treated as a string. An
xs:integer (even if it belongs to a subtype such as
xs:short) is converted to a Java
BigInteger. The more specialized XML Schema primitive types such as
xs:duration are passed in their native Saxon representation (a subclass of
If the expected type is one of the Saxon-specific classes (
SequenceExtent), then the value is passed unchanged. An error occurs if the supplied value contains
more than one item and the expected type does not allow this.
If the expected type implements
java.util.Collection, Saxon attempts to convert each value in the supplied sequence
to the most appropriate Java class, following the same rules as when converting a singleton to
This process takes no account of parameterized collection types (such as
List<String>). If the required
collection type accepts an
java.util.ArrayList, Saxon will create an
ArrayList to hold the values; otherwise
it will attempt to instantiate the required type of collection, which will only work if it is a concrete class with a zero-argument
public constructor (so it will fail, for example, if the required type is
java.util.Set). If an empty sequence is
supplied as the argument value, this is converted to an empty Collection.
If the required type is an array, Saxon will attempt to create an array of the required type. This will not always succeed,
for example if the array has type
X where X is an interface rather than a concrete class. If it is an array of items
or nodes, the nodes in the supplied sequence will be inserted into the array directly; if it is an array of a type such as integer or
double, the sequence will first be atomized.