2014-11-06 61 views
0

爲什麼表格單元在沒有照片存在時會消失? 我正在使用下面的代碼不工作。如果我想生成一個空白表單元格,如果沒有現成的照片生成,我需要更改哪些內容?如何在XSL中生成空白表格單元格?

<xsl:for-each select="..............."> 
    <xsl:choose> 
     <xsl:when test="*"> 
      <xsl:if test="....."> 
       <xsl:if test="......."> 
        <fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1"> 
         <fo:block> 
          <fo:external-graphic src="url('{concat($FILEPATH,.....'])}')" 
           inline-progression-dimension.maximum="4.1cm" block-progression-dimension.maximum="4cm" 
           content-width="scale-to-fit" content-height= "scale-to-fit" scaling="uniform"/> 
         </fo:block> 
        </fo:table-cell> 
       </xsl:if> 
      </xsl:if> 
     </xsl:when> 
     <xsl:otherwise> 
      <fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1"> 
       <fo:block> 
        <fo:leader/> 
       </fo:block> 
      </fo:table-cell> 
     </xsl:otherwise> 
    </xsl:choose> 
</xsl:for-each> 

回答

0

你有<的xsl:當測試= 「*」 > ...是該節點是空的?如果這是您的外部測試並通過,但其他IF(您未顯示)未通過測試,則您的模板不會產生任何結果。

打破下來與評論:

<xsl:when test="*"> 
     <xsl:if test="....."> 
      <!-- If this does not pass, you get nothing --> 
      <xsl:if test="......."> 
       <!-- If this does not pass, you get nothing --> 
       <fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1"> 
        <fo:block> 
         <fo:external-graphic src="url('{concat($FILEPATH,.....'])}')" 
          inline-progression-dimension.maximum="4.1cm" block-progression-dimension.maximum="4cm" 
          content-width="scale-to-fit" content-height= "scale-to-fit" scaling="uniform"/> 
        </fo:block> 
       </fo:table-cell> 
      </xsl:if> 
     </xsl:if> 
    </xsl:when> 
    <xsl:otherwise> 
     <fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1"> 
      <fo:block> 
       <fo:leader/> 
      </fo:block> 
     </fo:table-cell> 
    </xsl:otherwise> 
0

凱文是正確的,因爲你的榜樣,你當條款則可能滿意,但如果你的if語句評估爲假,你會得到一個空表,小區中的一個。我的建議是你的if語句的條件,增加了在使用邏輯運算符,如條款AND/OR,例如,說在您的模板,其中這樣的條件...

<xsl:when test="$node = 'A'"> 
     <xsl:if test="$node/child = 'B'"> 
      <xsl:if test="not(contains($node/child,'C'))"> 
       <fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1"> 
        ... 
       </fo:table-cell> 
      </xsl:if> 
     </xsl:if> 
    </xsl:when> 
    <xsl:otherwise> 
     <fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1"> 
      <fo:block> 
       <fo:leader/> 
      </fo:block> 
     </fo:table-cell> 
    </xsl:otherwise> 
</xsl:choose> 

可以表示爲

<xsl:when test="$node = 'A' AND $node/child = 'B' AND not(contains($node/child,'C'))"> 
       <fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1"> 
        ... 
       </fo:table-cell> 
    </xsl:when> 
    <xsl:otherwise> 
     <fo:table-cell border="solid" text-align="center" font-weight="bold" number-columns-spanned="1"> 
      <fo:block> 
       <fo:leader/> 
      </fo:block> 
     </fo:table-cell> 
    </xsl:otherwise> 
</xsl:choose> 

並在這樣做,你將確保如果任何這三個邏輯條件得不到滿足,那你的塊,否則將被調用,領導者應該保持細胞坍塌,而不是當聲明被調用,儘管事實上你的邏輯條件在技術上並不滿足,而且會被一個空單元結束,而這個單元將會崩潰d默認爲FOP。希望這能爲你解決一些問題。

相關問題