Delivers a sequence of random numbers between zero and one.
random-sequence($count as xs:integer, $seed as xs:double) ➔ xs:double*
The number of items required
Random number seed
Links to specifications
Requires Saxon-PE or Saxon-EE. Available for Java and C/C++ only (not .NET).
Notes on the Saxon implementation
The implementation is deterministic: if called twice with the same seed, it will deliver
the same sequence. This property can be useful or a nuisance; if you want a different
sequence each time, use something like
seconds-from-dateTime() as a seed. The
numbers are computed on demand, so there is no harm in setting the first argument to a
very high number. It can be useful to use the function in conjunction with
xsl:iterate, since this allows early exit.
Saxon also offers the EXSLT math:random() function to compute a single random number, but this is not very useful because it will often be optimized out of a loop, resulting in the same number being chosen each time.