Changes

Jump to navigation Jump to search
38 bytes added ,  13:14, 9 July 2021
* The namespace of the function name identifies the Java class.
* The local part of the name, which is rewritten to camel case, identifies a variable or function of that class.
* The middle dot character <code>[https://www.fileformat.info/info/unicode/char/b7/index.htm ·]</code> (<code>&amp;#xB7;</code>, a valid character in XQuery names, but not in Java) can be used to append exact Java parameter types to the function name. Class types must be referenced by their full path. Since {{Version|9.6}}, three adjacent dots can be used to address an array argument.
{| class="wikitable"
|- valign="top"
! TypeAddressed code
! XQuery
! Java
| Variable
| <code>Q{java.lang.Integer}MIN_VALUE()</code>
| <code>[https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html#MAX_VALUE Integer.MIN_VALUE]</code>
|- valign="top"
| Function
| <code>Q{java.lang.Object}hash-code($object)</code>
| <code>[https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode() object.hashCode()]</code>
|- valign="top"
| Function with typesargument
| <code>Q{java.lang.String}split·java.lang.String·int($string, ';', xs:int(3))</code>
| <code>[https://docsstring.oracle.com/javase/8/docs/apisplit(";", 3)</code>|- valign="top"| Function with array argument| <code>Q{java/.lang/.String}new·byte.html#split-java.lang.(xs:hexBinary('414243'))</code>| <code>new String-int- string.split(";"new byte[] { 41, 42, 343 })]</code>
|}
As XQuery and Java have different type systems, XQuery arguments are must be converted to equivalent Java values, and the result of a Java function is converted back to an XQuery value (see [[#Data Types|Data Types]]).
If the Java function you want to address is not detected, you may need to cast your values to the target type. For example, if a Java function expects a primitive {{Code|int}} value, you will need to convert your XQuery integers to {{Code|xs:int}}.
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu