Converting Atomic Values

This section describes the conversions that occur when calling a method that expects an atomic value, such as a String or a boolean.

If the supplied value is a node, then it is atomized.

If the supplied value contains more than item and only a single item is expected, an error is reported. There is no implicit extraction of the first value (as happened in earlier Saxon releases).

If the supplied value is an empty sequence, then a null value is passed. However, if the required type is a primitive Java type such as int or bool, then passing an empty sequence will result in a type error.

In other cases, the supported conversions are as follows. Italicized names are Saxon-specific classes in package net.sf.saxon.value.

Supplied type

Required type

boolean

BooleanValue, Boolean

dateTime

DateTimeValue, Date

date

DateValue, Date

decimal

DecimalValue, BigDecimal, Double, Float

double

DoubleValue, Double

duration

DurationValue

float

FloatValue, Float, Double

integer, long, int

IntegerValue, BigInteger, BigDecimal, Long, Integer, Double, Float

short

IntegerValue, BigInteger, BigDecimal, Long, Integer, Short, Double, Float

byte

IntegerValue, BigInteger, BigDecimal, Long, Integer, Short, Byte, Double, Float

string

StringValue, (String, CharSequence)

anyURI

AnyURIValue, java.net.URI, java.net.URL, (String, CharSequence)

QName

QNameValue, javax.xml.namespace.QName

A required type of one of the Java primitive types such as int or bool is treated as equivalent to the corresponding boxed type (Integer or Boolean), except that with the boxed types, an empty sequence can be supplied in the function call and is translated to a Java null value as the actual argument.