
大家都知道,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的函数。