The Saxon XQuery implementation allows you to call Java methods as external functions.
The function does not need to be declared. Use a namespace declaration such as
declare namespace math=java:java.lang.Math,
and invoke the method as math:sqrt(2).
More details of this mechanism are found in
Writing Extension Functions; note however
that for XQuery the only form of namespace URI accepted is java:full.class.Name.