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

Deadly 提交于 2019-12-22 09:40:08

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!