Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any possibility to generate random numbers using XQuery? [closed]

Tags:

xquery

I have to generate a series of random numbers using XQuery.I found a set of libraries but those are paid.If anyone can give me a direction it would be much appreciated(preferably code).

like image 898
Charles Avatar asked Aug 23 '12 06:08

Charles


People also ask

How do I generate a random number in Livecode?

Use the random function to pick a random member of a set, or to generate a random number. If the upperLimit is a positive integer, the random function returns an integer between 1 and the upperLimit.

How do you use random in c3?

To generate random numbers in C#, use the Next(minValue, MaxValue) method. The parameters are used to set the minimum and maximum values. Next(100,200); We have set the above method under Random() object.


1 Answers

The standard XQuery languages provides no random function, but many implementations do. Some examples for open source implementations:

  • BaseX provides a Random Module
  • Zorba has a Random Module, too
  • eXist-db has some suitable functions in the Util Module
  • MarkLogic provides the xdmp:random() function

As an alternative, most Java implementations of XQuery (such as BaseX, Saxon or Qizx) provide so-called Java bindings in order to evaluate Java code:

declare namespace math = 'java:java.lang.Math';
math:random()

If the implementation support the latest XQuery 3.0 specification, this can also be written as a one-liner:

Q{java:java.lang.Math}random()
like image 141
Christian Grün Avatar answered Sep 29 '22 06:09

Christian Grün