March 10, 2004

random:random-sequence() at large

Ok, I've implemented EXSLT Random module, which consists of the only function random:random-sequence() for EXSLT.NET library. Here is how it looks now:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:random="http://exslt.org/random" exclude-result-prefixes="random">
    <xsl:template match="/">
    	10 random numbers: 
    		<xsl:for-each select="random:random-sequence(10)">
    		<xsl:value-of select="format-number(., '##0.000')"/>
    		<xsl:if test="position() != last()">, 
    		</xsl:if>
    	</xsl:for-each>
    </xsl:template>
</xsl:stylesheet>
The result is
10 random numbers: 
    0.311, 
    0.398, 
    0.698, 
    0.929, 
    0.418, 
    0.523, 
    0.667, 
    0.215, 
    0.915, 
    0.007
The function accepts optional number of random numbers to generate and optional seed (DateTime.Now.Ticks by default) and returns nideset of <random> elements, containing generated random numbers.

EXSLT.NET team members are encouraged to review inplementation in the projects's source repository and if nobody objects we can release EXSLT.NET 1.1 version.

March 10, 2004 08:37 PM | TrackBack |
Comments
Post a comment









Remember personal info?