文章詳情頁
在 XSL/XSLT 中實(shí)現(xiàn)隨機(jī)排序
瀏覽:104日期:2022-06-03 13:32:03
和數(shù)據(jù)庫排序一樣,XSL/XSLT也可以實(shí)現(xiàn)隨機(jī)排序,原理也很簡(jiǎn)單,下面就是代碼。
<?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>
標(biāo)簽:
XML/RSS
相關(guān)文章:
1. idea設(shè)置自動(dòng)導(dǎo)入依賴的方法步驟2. IntelliJ IDEA設(shè)置編碼格式的方法3. XML入門精解之結(jié)構(gòu)與語法4. ASP基礎(chǔ)入門第八篇(ASP內(nèi)建對(duì)象Application和Session)5. idea重置默認(rèn)配置的方法步驟6. idea設(shè)置代碼格式化的方法步驟7. IntelliJ IDEA設(shè)置默認(rèn)瀏覽器的方法8. IntelliJ IDEA設(shè)置條件斷點(diǎn)的方法步驟9. idea刪除項(xiàng)目的操作方法10. idea自定義快捷鍵的方法步驟
排行榜
