XSLT专业站 - 提供xslt和xml相关的资料书籍和教程  
XSLT专业站 - 提供xslt和xml相关的资料书籍和教程
网站地图  收藏本站
首页 | 热门文章 | 精彩实例 | 经典教程 | XSLT语法详解 | 资料下载 | 休闲天地 | 交流论坛
  当前位置:首页>XSLT语法详解>文章内容
xsl:choose, xsl:when 和 xsl:otherwise
来源:XSLT.org.cn 作者:XSLT专业站 发布时间:2007-08-04  
xsl:choose, xsl:when 和 xsl:otherwise

xsl:if语法没有else的属性。如果我们要进行多项选择,那么就要使用xsl:choose / xsl:when / xsl:otherwise系列流程控制语法了。具体的使用请看下面的XSL文件例子:


<xsl:template match="PEOPLE">

<xsl:choose>

<xsl:when test="@name = 'ajie'">

<B><xsl:value-of select="@name"/></B>

</xsl:when>

<xsl:when test="@name">

<I><xsl:value-of select="@name"/></I>

</xsl:when>

<xsl:otherwise>

No name available

</xsl:otherwise>

<xsl:choose>

</xsl:template>


说明:首先在PEOPLE节点下寻找<name>属性值为ajie的元素,如果找到,将ajie用粗体输出;如果没有发现值为ajie的<name>元素,则将所有的<name>元素的值都用斜体输出;如果没有发现任何<name>元素,则显示"No name available"。



标题: xsl:choose, xsl:when 和 xsl:otherwise
关键字:xsl:choose, xsl:when xsl:otherwise XSLT 语法
上一篇:xsl:if 语法   下一篇:xsl:sort 语法
  XSLT语法详解热点文章
·XSLT 语法详解:xsl:apply-impor
·xsl:for-each 语法
·xsl:sort 语法
·XSLT 语法详解: xsl:apply-templ
·XSLT 语法详解: xsl:attribute
·XSLT 语法详解: xsl:attribute-s
·xsl:template 和 xsl:apply-temp
·xsl:value-of 语法
·xsl:if 语法
  XSLT语法详解相关文章
·xsl:if 语法
·xsl:sort 语法
·xsl:for-each 语法
·XSLT 语法详解:xsl:apply-impor
·xsl:value-of 语法
·XSLT 语法详解: xsl:apply-templ
·xsl:template 和 xsl:apply-temp
·XSLT 语法详解: xsl:attribute
·XSLT 语法详解: xsl:attribute-s
Copyright© 2007 xslt.org.cn All rights reserved.