问题
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).
回答1:
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()
来源:https://stackoverflow.com/questions/12086038/is-there-any-possibility-to-generate-random-numbers-using-xquery