亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

目錄 搜尋
XSLT 基礎(chǔ)教程 XSL 語言 XSLT 簡介 XSLT 瀏覽器 XSLT - 轉(zhuǎn)換 XSLT <xsl:template> 元素 XSLT <xsl:value-of> 元素 XSLT <xsl:for-each> 元素 XSLT <xsl:sort> 元素 XSLT <xsl:if> 元素 XSLT <xsl:choose> 元素 XSLT <xsl:apply-templates> 元素 XSLT - 在客戶端 XSLT - 在服務(wù)器端 XSLT - 編輯 XML XML 編輯器 XSLT 元素參考手冊 XSLT <xsl:apply-imports> 元素 XSLT <xsl:apply-templates> 元素 XSLT <xsl:attribute> 元素 XSLT <xsl:attribute-set> 元素 XSLT <xsl:call-template> 元素 XSLT <xsl:choose> 元素 XSLT <xsl:comment> 元素 XSLT <xsl:copy> 元素 XSLT <xsl:copy-of> 元素 XSLT <xsl:decimal-format> 元素 XSLT <xsl:element> 元素 XSLT <xsl:fallback> 元素 XSLT <xsl:for-each> 元素 XSLT <xsl:if> 元素 XSLT <xsl:import> 元素 XSLT <xsl:include> 元素 XSLT <xsl:key> 元素 XSLT <xsl:message> 元素 XSLT <xsl:namespace-alias> 元素 XSLT <xsl:number> 元素 XSLT <xsl:otherwise> 元素 XSLT <xsl:output> 元素 XSLT <xsl:param> 元素 XSLT <xsl:preserve-space> 和 <xsl:strip-space> 元素 XSLT <xsl:processing-instruction> 元素 XSLT <xsl:sort> 元素 XSLT <xsl:stylesheet> 和 <xsl:transform> 元素 XSLT <xsl:template> 元素 XSLT <xsl:text> 元素 XSLT <xsl:value-of> 元素 XSLT <xsl:value-of> 元素 XSLT <xsl:variable> 元素 XSLT <xsl:when> 元素 XSLT <xsl:with-param> 元素 XSLT 函數(shù) XSLT current() 函數(shù) XSLT document() 函數(shù) XSLT element-available() 函數(shù) XSLT format-number() 函數(shù) XSLT function-available() 函數(shù) XSLT generate-id() 函數(shù) XSLT key() 函數(shù) XSLT system-property() 函數(shù) XSLT unparsed-entity-uri() 函數(shù)
文字

XSLT <xsl:choose> 元素



定義和用法

<xsl:choose> 元素與 <xsl:when> 以及 <xsl:otherwise> 協(xié)同使用,來表達(dá)多重條件測試。

如果沒有 <xsl:when> 是 true,則處理 <xsl:otherwise> 的內(nèi)容。

如果沒有 <xsl:when> 是 true,且不存在 <xsl:otherwise> 元素,則不創(chuàng)建任何內(nèi)容。

提示:對于簡單的條件測試,請使用 <xsl:if> 元素取而代之。


語法

<xsl:choose>
<!-- Content:(xsl:when+,xsl:otherwise?) -->
</xsl:choose>

屬性


實(shí)例

下面的代碼會(huì)在 CD 的價(jià)格高于 10 時(shí),向 artist 列添加粉色的背景色。

實(shí)例

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<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 test="price &gt; 10">
<td bgcolor="#ff00ff">
<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>
 

聲明名為 "color" 的變量。把這個(gè)變量的值賦值到當(dāng)前元素的 color 屬性。如果當(dāng)前元素沒有 color 屬性,則 "color" 的值是 "green":

<xsl:variable name="color">
<xsl:choose>
<xsl:when test="@color">
<xsl:value-of select="@color"/>
</xsl:when>
<xsl:otherwise>green</xsl:otherwise>
</xsl:choose>
</xsl:variable>

上一篇: 下一篇: