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.
Asked
Active
Viewed 8,771 times
-2
-
Possible duplicate of https://stackoverflow.com/questions/2359134/random-items-in-xslt – potame May 06 '15 at 07:21
-
See: https://stackoverflow.com/questions/25867727/generate-random-number-in-rss-viewer-webpart/25869149#25869149 – michael.hor257k May 06 '15 at 08:13
-
See: http://stackoverflow.com/a/2360489/36305 – Dimitre Novatchev May 08 '15 at 04:08
1 Answers
2
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>

Shivaji Varma
- 690
- 13
- 24