phillipbentonkelly
9/18/2013 - 8:16 PM

Generate a random number between 1- 10 in XSLT. @href: http://www.getsymphony.com/discuss/thread/81429/

Generate a random number between 1- 10 in XSLT.

@href: http://www.getsymphony.com/discuss/thread/81429/

<!-- Add the 'math' namespace to your XML stylesheet (so we can use 'math:random') -->
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:math="http://exslt.org/math"
    extension-element-prefixes="math">

<!-- Pick a random number between 1 - 10 and set as a variable -->
<xsl:value-of select="(floor(math:random()*10) mod 10) + 1" />