2014-05-09 40 views
0

你可以请指教是下面的xsl标签实现是正确的,因为我怀疑我使用xsl的方式:if ()里面的xsl:否则是不正确的,我们应该有使用的xsl:for第二条件时也..使用xsl:如果里面xslt:否则我xslt 1.0

<xsl:template name="swaption_notional_template_nd_currency"> 
     <xsl:param name="abcVar"/> 
     <xsl:choose> 
      <xsl:when test="$ert">    

      </xsl:when> 
      <xsl:otherwise> 
       <xsl:if test="$abcValue">   

       </xsl:if> 
      </xsl:otherwise> 
     </xsl:choose> 
</xsl:template> 

回答

1

在语法上,它是精细放置<xsl:if></xsl:if>一个<otherwise></otherwise>块内。然而,正如你已经认为这是一个更好的选择(并更容易阅读)使用另一个<xsl:when></xsl:when>块。

如果<otherwise></otherwise>块包含依赖于测试在测试的你的<xsl:choose></xsl:choose>块但独立的<xsl:if></xsl:if>块部分,例如你的解决方案可能是必要的:

<xsl:choose> 
    <xsl:when test="$ert">    

    </xsl:when> 

    <xsl:otherwise> 

    <!-- SOMETHING happens here --> 

    <xsl:if test="$abcValue">   

    </xsl:if> 

    <!-- and/or SOMETHING happens here --> 

    </xsl:otherwise> 

</xsl:choose> 
0
You can use <xsl:if> inside the <xsl:otherwise> block below is example 

<xsl:template name="check"> 
     <xsl:param name="id"/> 
     <xsl:choose> 
     <xsl:when test="Response/Specification/Section/Item/Property[id=$id]/Boolean1=1"> 
      <xsl:text>Y</xsl:text> 
     </xsl:when> 
     <xsl:otherwise> 
      <xsl:if test="Response/Specification/Section/Item/Property[id=$id]/Boolean`enter code here`1=0"> 
       <xsl:text>N</xsl:text> 
      </xsl:if> 
     </xsl:otherwise> 
     </xsl:choose> 
    </xsl:template>