日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

XSL簡明教程(7)XSL 的控制語句_Xml教程

編輯Tag賺U幣
教程Tag:暫無Tag,歡迎添加,賺取U幣!

推薦:網(wǎng)頁編程必看:XML文法分析
在進行XML文法分析之前,首先有必要了解XML語法的基本規(guī)則: 詞法特征:1)XML區(qū)分大小寫,如元素名在打開和關(guān)閉標(biāo)記中應(yīng)保持大小寫一致<mytag>…</mytag>,XML的保留詞

原著:Jan Egil Refsnes 翻譯:阿捷
七. XSL 的控制語句

1.條件語句if...then

XSL同樣還有條件語句(呵呵~~好厲害吧,象程序語言一樣)。具體的語法是增加一個xsl:if元素,類似這樣

<xsl:if match=".[ARTIST='Bob Dylan']">
... some output ...
</xsl:if>

上面的例子改寫成為:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="2" bgcolor="yellow">
<tr>
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="CATALOG/CD">
<xsl:if match=".[ARTIST='Bob Dylan']">
<tr>
<td><xsl:value-of select="TITLE"/></td>
<td><xsl:value-of select="ARTIST"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

2. XSL 的Choose

choose的用途是出現(xiàn)多個條件,給出不同顯示結(jié)果。具體的語法是增加一組xsl:choose,xsl:when,xsl:otherwise元素:

<xsl:choose>
<xsl:when match=".[ARTIST='Bob Dylan']">
... some code ...
</xsl:when>
<xsl:otherwise>
... some code ....
</xsl:otherwise>
</xsl:choose>

上面的例子改寫成為:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<body>
<table border="2" bgcolor="yellow">
<tr>
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="CATALOG/CD">
<tr>
<td><xsl:value-of select="TITLE"/></td>
<xsl:choose>
<xsl:when match=".[ARTIST='Bob Dylan']">
<td bgcolor="#ff0000"><xsl:value-of select="ARTIST"/></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="ARTIST"/></td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

分享:高手簡論:說說標(biāo)簽切換應(yīng)用原則
在國內(nèi)的主流網(wǎng)站中,自從網(wǎng)易首頁率先采用Tab標(biāo)簽切換以后,標(biāo)簽切換的應(yīng)用“忽如一夜春風(fēng)來,千樹萬樹梨花開”到處都是了。 標(biāo)簽切換的應(yīng)用原則: 在頁面中有限的重要位置里,

來源:模板無憂//所屬分類:Xml教程/更新時間:2008-08-22
相關(guān)Xml教程