The standard XQuery languages ββdo not provide random functions, but many implementations are executed. Some examples of open source implementations:
Alternatively, most Java XQuery implementations (such as BaseX, Saxon, or Qizx) provide what are called Java bindings for evaluating Java code:
declare namespace math = 'java:java.lang.Math'; math:random()
If the implementation supports the latest XQuery 3.0 specification, this can also be written as single-line:
Q{java:java.lang.Math}random()
source share