文章詳情頁
在 XSL/XSLT 中實(shí)現(xiàn)隨機(jī)排序
瀏覽:103日期:2022-06-03 13:32:03
和數(shù)據(jù)庫(kù)排序一樣,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. asp讀取xml文件和記數(shù)2. PHP實(shí)現(xiàn)基本留言板功能原理與步驟詳解3. 每日六道java新手入門面試題,通往自由的道路第二天4. vue 驗(yàn)證兩次輸入的密碼是否一致的方法示例5. python利用opencv實(shí)現(xiàn)顏色檢測(cè)6. CSS自定義滾動(dòng)條樣式案例詳解7. 讓你的PHP同時(shí)支持GIF、png、JPEG8. 多個(gè)SpringBoot項(xiàng)目采用redis實(shí)現(xiàn)Session共享功能9. 簡(jiǎn)體中文轉(zhuǎn)換為繁體中文的PHP函數(shù)10. JavaScript快速實(shí)現(xiàn)一個(gè)顏色選擇器
排行榜
