问题
I am using RSS viewer webpart with the following references:
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
xmlns:rssaggwrt="http://schemas.microsoft.com/WebParts/v3/rssagg/runtime"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:rssFeed="urn:schemas-microsoft-com:sharepoint:RSSAggregatorWebPart"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:rss1="http://purl.org/rss/1.0/" xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"
xmlns:atom2="http://purl.org/atom/ns#"
Could anyone please suggest me how to generate random number in xsl ?
I tried the following code :
xsl:value-of select="(floor(math:random()*10) mod 10) + 1"
with the following references:
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="http://exslt.org/math"
The above references are throwing error. Please help for the same.
回答1:
If your processor does not support the EXSLT math:random() function, then you can:
- check the documentation to see if the processor provides extension functions under a different namespace;
- write your own extension function using the extension mechanism provided by your processor;
- supply a random number to the stylesheet as a parameter at runtime;
- derive a random number from the current date/time (if your processor can generate those, or if you can pass them to the stylesheet at runtime) or from some other non-constant data, for example the length of the processed document (knowing the purpose would be helpful here);
- get a random number from a web service.
来源:https://stackoverflow.com/questions/25867727/generate-random-number-in-rss-viewer-webpart