tags:

views:

109

answers:

2

At the end of the page, I dont want to have the label of 'examClin' isolated. So if ever, the label arrives at the end of the page, I need ONE and no more than one line of examClin to be attached with the @label of examClin... Or both elements should go to next page. Am i clear enough?

different elements... we arrive at the end of the page

 <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>
A: 

Put them into a single block (that means you must merge the two table rows into one) and use keep-together.

Aaron Digulla
A: 

Thank you Aaron. But then I am afraid that if is a very long text, everything will keep together and not just the first line. As a result, it can leave a long white block on previous page.

I created the following template: the idea is to find what the first line will be: either the 75 first characters but if we find a return carriage before the 75 first characters, we will take the string before the first return carriage.

<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>
Mathieu