I have a simple xml file:
<headlines>
<headline>
...
</headline>
<headline>
...
</headline>
<headline>
...
</headline>
</headlines>
All I want to do is shuffle the order in which headlines appear. I've been fooling around how this template should look, but I can't get it working.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/headline">
<xsl:for-each select="headline">
__not sure what to do here? rand() isn't a thing?__
One way to do this would be to use the function generate-id() as a sorting criterion. Suppose you have the following input:
With this XSLT you can "randomize" the output:
The result is
Three things should be noted: