2014-05-09 42 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>