Bugzilla – Bug 20573
Random generator in XPath
Last modified: 2013-01-08 16:22:39 UTC
A random generator is present in almost every programming language. I was surprised that XPath does not have one.
fn:random() as xs:double
returns a random number from the interval [0,1]
fn:random($l as xs:double, $u as xs:double) as xs:double
returns a random number from the interval [$l,$u]
The main reason for the omission, I think, is the difficulty of doing it with deterministic functional semantics.
See also bug #13494 and bug #13747.
The EXSLT library attempts to tackle the requirement with a deterministic function that generates a number that is a pseudo-random function of a supplied seed:
Moving this to the 3.1 category as it's too late to be considered for 3.0.