Implementing random ordering in XSL/XSLT

黄舟
Release: 2017-03-02 17:20:13
Original
1382 people have browsed it

Like database sorting, XSL/XSLT can also implement random sorting. The principle is also very simple. The following is the code.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:msxsl="urn:schemas-microsoft-com:xslt"
  xmlns:eMeng="http://dotnet.aspx.cc/"
  version="1.0">
<msxsl:script language="javaScript" implements-PRefix="eMeng">
 function Random() {
  return Math.random();
 }
</msxsl:script>
<xsl:template match="/">
<xsl:for-each select="/*/node()">
<xsl:sort select="eMeng:Random()"/>
<xsl:value-of select="."/>
<br/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Copy after login

The above is the content of implementing random sorting in XSL/XSLT. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!