xslt
2012-11-20 103 views 1 likes 
1

我想知道下面是否可能。我想檢查是否有任何這些條件回來是爲了打印聲明。xslt當多個或條件選擇

想知道寫這個的最好方法是什麼。謝謝

<li> 
    <xsl:choose> 
     <xsl:when test="overdraftmoreaffordable/option [@id='yes']='selected' or businessmoreaffordable/option [@id='yes']='selected' or farmermoreaffordable/option [@id='yes']='selected' or loanprimiummoreaffordable/option [@id='yes']='selected' or loanmoreaffordable/option [@id='yes']='selected' or baseloanmoreaffordable/option [@id='yes']='selected' or termloanprimiummoreaffordable/option [@id='yes']='selected' or termmoreaffordable/option [@id='yes']='selected' or variablemoreaffordable/option [@id='yes']='selected' or fixedloanmoreaffordable/option [@id='yes']='selected'">Statement One</xsl:when> 
     <xsl:otherwise>Statement Two</xsl:otherwise> 
    </xsl:choose> 
</li> 

還是更好地做單獨的時候,即使我只是想確定是否是條件是打印語句。

感謝

增加:

這似乎正是我需要的,但我的代碼被分隔成很多獨立的,如果這樣的頁面,我不認爲,如果是在一個選擇,他們可以溝通了解其他

<xsl:if test="overdraft &gt; 0"> 
     <div style="margin-top: 0cm; margin-bottom: 0cm;"> 
      <br/> 
      <b>Overdraft</b><br/> 
      An Overdraft allows your current account to go into an overdrawn position up to an agreed limit.<br/> 
     </div> 

     <xsl:for-each select="overdrafts/overdraftdata"> 

      <div style="margin-top: 0cm; margin-bottom: 0cm;"> 
       <br/> 
       This product is suitable because; 
       <ul> 
        <li>You are seeking a lending product for the purpose of <xsl:value-of select="overdraftpurpose"/></li> 
        <li>You are seeking a total amount of credit of EUR <xsl:value-of select="overdraftamount"/></li> 
        <li><xsl:choose> 
          <xsl:when test="*[substring(local-name(), string-length(local-name()) - 9) = 'affordable']/option[@id='yes']='selected'"> 
           Repayment of the debt has been structured in a manner that is more affordable given your current circumstances 
          </xsl:when> 
          <xsl:otherwise> 
           You are likely to be able to repay the debt in the manner required under the credit agreement 
          </xsl:otherwise> 
         </xsl:choose> 
        </li> 
        <li>It is available for the term you require</li> 
       </ul> 
      </div> 

     </xsl:for-each> 

    </xsl:if> 

    <xsl:if test="businesscreditline &gt; 0"> 

     <div style="margin-top: 0cm; margin-bottom: 0cm;"> 
      <br/> 
      <b>Business Credit Line</b><br/> 
      A Business Credit Line provides you with the convenience and flexibility of a pre-arranged line of 
      credit. It will facilitate improved budgeting and will give you greater choice in meeting your working 
      capital and short term funding needs<br/> 
     </div> 

     <xsl:for-each select="businesscreditlines/businesscreditlinedata"> 

      <div style="margin-top: 0cm; margin-bottom: 0cm;"> 
       <br/> 
       This product is suitable because; 
       <ul> 
        <li>You are seeking a lending product for the purpose of <xsl:value-of select="businesspurpose"/></li> 
        <li>You are seeking a total amount of credit of EUR <xsl:value-of select="businessamount"/></li> 
        <li><xsl:choose><xsl:when test="*[substring(local-name(), string-length(local-name()) - 9) = 'affordable']/option[@id='yes']='selected'">Repayment of the debt has been structured in a manner that is more affordable given your current circumstances</xsl:when><xsl:otherwise>You are likely to be able to repay the debt in the manner required under the credit agreement</xsl:otherwise></xsl:choose></li> 
        <li>It is available for the term you require</li> 
       </ul> 
      </div> 

     </xsl:for-each> 

    </xsl:if>' 
+0

我相信我需要回到主要貸款節點,例如,我有內部透支,所以顯然它只能看到這個內部的YES。有沒有一種方法可以在每個內部進行覆蓋,以掃描所有貸款節點? – topcat3

+0

好的,我正在學習。這個簡單的解決方案,我把//infront。

這將檢查當前元素的所有子元素。

如果你想更具體,只檢查其名稱中「買得起」的結束元素,你可以做到這一點,而不是

<xsl:when test=" 
    *[substring(local-name(), string-length(local-name()) - 9) = 'affordable'] 
    /option[@id='yes']='selected'"> 
    Statement One 
</xsl:when> 

這是假設XSLT1.0。在XSLT2.0中,您可以通過使用'ends-with'功能來簡化此操作。

<xsl:when test=" 
    *[ends-with(local-name(),'affordable')]/option [@id='yes']='selected'"> 
    Statement One 
</xsl:when> 
1

您可以通過說出

(overdraftmoreaffordable | businessmoreaffordable | farmermoreaffordable | 
    loanprimiummoreaffordable | loanmoreaffordable| baseloanmoreaffordable | 
    termloanprimiummoreaffordable | termmoreaffordable | variablemoreaffordable | 
    fixedloanmoreaffordable)/option[@id='yes']='selected' 

採取的事實,即設置一個節點和一個字符串之間的=比較爲真壓縮有點如果在節點的節點的任何 set的值等於給定的字符串。另外,如果你在做的是枚舉所有可能的元素名稱包含子字符串「moreaffordable」那麼你可以逃脫

*[contains(local-name(), 'moreaffordable')]/option[@id='yes'] = 'selected' 
相關問題