xsltteamsiteinterwoven

Is a way to generate random number using XSLT 1.0 [Teamsite CMS]


I'm trying to generate random number using XSLT 1.0 (in Teamsite). Every time I generate a page a new random number should be generated as well.


Solution

  • Here is the solution:

    Teamsite XSLT uses xalan-j processor, it allows you to use Java library functions and below code will helps you creating random number everytime you generate a page.

        <?xml version="1.0" encoding="UTF-8"?>
        <xsl:stylesheet version="1.0" exclude-result-prefixes="xalan math"
                      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                      xmlns:xalan="http://xml.apache.org/xalan"
                      xmlns:math="xalan://java.lang.Math">
           <xsl:template match="/">
               <xsl:value-of select="math:random()"/>
            </xsl:template>
    
        </xsl:stylesheet>