2014-11-06 131 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。希望这能为你解决一些问题。

相关问题