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 |
xs:string |
StringValue, String, CharSequence |
xs:boolean |
BooleanValue, Boolean |
xs:float |
FloatValue, Float, Double |
xs:double |
DoubleValue, Double |
xs:decimal |
DecimalValue, BigDecimal, Double, Float |
xs:integer |
IntegerValue, BigInteger, BigDecimal, Long, Integer, Short, Byte, Double, Float |
xs:date, xs:gDay, xs:gMonthDay, xs:gMonth, xs:gYearMonth, xs: gYear |
DateValue, Date |
xs:dateTime |
DateTimeValue, Date |
xs:time |
TimeValue |
xs:duration, xs:yearMonthDuration, xs:dayTimeDuration |
DurationValue |
xs:hexBinary |
HexBinaryValue |
xs:base64Binary |
Base64BinaryValue |
xs:anyURI |
AnyURIValue, java.net.URI, java.net.URL, String, CharSequence |
xs: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.