Re: [xsl] Random number seed generation

Subject: Re: [xsl] Random number seed generation
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 09 Dec 2010 15:37:14 +0000
On 09/12/2010 14:04, Michel Hendriksen wrote:
Hi all,

I'm using Saxon9he processor XSLT 2.0, and I am trying to get some
random numbers. I'm currently using fxsl/random for this. The problem
is that it needs a seed.
I tried using current time stuff but that doesn't change during the
transfomation using the stylesheet.. So I tried an extension function
to cal to Java but that doesn't seem to work. Examples are probably
XSLT 1.0 but should be ok.

You need to organize your code so that all the random numbers come from a single sequence from a single seed; or alternatively, generate one random sequence and use the numbers from this as seeds for subsidiary random sequences.

Can't tell you how to do that without knowing more about your code. It can be tricky - it may involve turning iterative code into recursive code.

Michael Kay

Current Thread