xslt语法之---If Else

时间:2023-03-09 07:52:51
xslt语法之---If Else

大家都知道,XSL中是没有if else的,那么要想实现if else该怎么办呢?

其实很简单

<xsl:choose>
<xsl:when test="position()=1">
</xsl:when> <xsl:otherwise>
</xsl:otherwise>
</xsl:choose>

上面when相当于if,otherwise相当于else。外面的<xsl:choose>一定不能少,when标签里的test是加条件的地方,返回值是boolean类型。position()是XSLT的函数。