【问题标题】:Keep header with first line of next block将标题与下一个块的第一行保持一致
【发布时间】:2010-12-04 05:49:20
【问题描述】:

在页面末尾,我不想将“examClin”标签隔离开来。因此,如果有的话,标签到达页面末尾,我需要一个并且不超过一行examClin 与examClin 的@label 附加...或者两个元素都应该转到下一页。 我够清楚吗?

不同的元素...我们到达页面的末尾

 <fo:table-row>
   <fo:table-cell number-columns-spanned="5">
      <fo:block space-before="2mm">
           <xsl:value-of select="./examClin/@label"/>: </fo:inline>
       </fo:block>
   </fo:table-cell>
  </fo:table-row>
 <fo:table-row>
  <fo:table-cell number-columns-spanned="5" padding-top="2mm" padding-bottom="2mm"
                                    padding-left="1mm" padding-right="1mm">
    <fo:block white-space-collapse="false" font-style="italic" >
             <xsl:value-of select="./examClin/child::text()"/>
    </fo:block>
   </fo:table-cell>
  </fo:table-row>

【问题讨论】:

    标签: xslt xsl-fo


    【解决方案1】:

    谢谢亚伦。但是我担心如果是一个很长的文本,所有的东西都会保持在一起,而不仅仅是第一行。结果,它会在上一页留下一个长长的白块。

    我创建了以下模板:想法是查找第一行的内容:第 75 个字符,但如果我们在第 75 个字符之前找到回车,我们将在第一个回车之前获取字符串。

    <xsl:template name="elem3">
        <xsl:choose>
            <xsl:when test="child::text()">
                <xsl:variable name="test0" select="substring(child::text(),1,100000)"/> 
                <xsl:variable name="test1" select="substring(child::text(),0,75)"/> 
                <xsl:variable name="test2" select="substring(child::text(),75,100000)"/>
                <xsl:variable name="test3" select="substring-before($test2,' ')"/>
                <xsl:variable name="test4" select="concat($test1,$test3)"/>
                <xsl:variable name="test5" select="substring-after($test2,' ')"/>
                 <xsl:variable name="test6" select="substring-before($test1,'&#10;')"/>
               <xsl:variable name="test7" select="substring-after($test0,'&#10;')"/>
                <fo:table-row>
                    <fo:table-cell number-columns-spanned="5">
                        <fo:block space-before="2mm">
                            <fo:inline font-weight="bold"><xsl:value-of select="@label"/>: </fo:inline>
                        </fo:block>
                    </fo:table-cell>
                </fo:table-row>
                <xsl:choose>
                    <xsl:when test="child::text()">
                        <fo:table-row keep-with-previous="always">
                            <fo:table-cell number-columns-spanned="6" padding-top="2mm" padding-left="1mm" padding-right="1mm">
                                <fo:block white-space-collapse="false" font-style="italic" >
                                <xsl:choose>
                                    <xsl:when test="contains($test1,'&#10;')"> <xsl:value-of select="$test6"/></xsl:when>
                                    <xsl:otherwise><xsl:value-of select="$test4"/></xsl:otherwise>
                                </xsl:choose>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row>
                            <fo:table-cell number-columns-spanned="5" padding-left="1mm" padding-right="1mm">
                                <fo:block white-space-collapse="false" font-style="italic" >
                                    <xsl:choose>
                                        <xsl:when test="contains($test1,'&#10;')"><xsl:value-of select="$test7"/></xsl:when>
                                        <xsl:otherwise> <xsl:value-of select="$test5"/></xsl:otherwise>
                                        </xsl:choose>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </xsl:when>
                </xsl:choose>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    

    【讨论】:

      【解决方案2】:

      将它们放在一个块中(这意味着您必须将两个表行合并为一个)并使用keep-together

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-08-01
        • 2016-07-11
        • 2014-07-20
        • 1970-01-01
        • 2014-11-19
        • 2014-09-19
        相关资源
        最近更新 更多