Search code examples
xsltpdf-generationxsl-foapache-fop

WARNING: Content of the region-body on page 2 overflows the available area in block-progression dimension


I am generating a pdf with fop 0.95 version, the problem is that on exception code, I should capture the code, but I am getting the exception described in the title, and the pdf is not generated correctly, page 2 is not showing complete, as it should take steps 4 and 5, and the page looks broken, see the screenshot. Please check the code where the comment "Exceptions if any" starts, the issue is somewhere there, as when the test fails, that code is called to print in the pdf report, the message and stacktrace of failure, if all tests pass this code is not called and pdf is created correctly. enter image description here

I already checked these questions, but i am not able to understand what is needed to fix the issue.

Main Page - from here teststepdetails is called, where i think the issue is

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version= '2.0'>
  <xsl:import href="./testrunsummary.xsl"/>  
  <xsl:import href="./suitesummary.xsl"/>  
  <xsl:import href="./summary.xsl" />
   <xsl:import href="./testsummary.xsl"/> 
   <xsl:import href="./teststeps.xsl"/> 
   <xsl:import href="./teststepdetails.xsl"/>
   <xsl:import href="./logreport.xsl"/>
<!-- <xsl:import href="./suitehistory.xsl"/>
  <xsl:import href="./history.xsl"/>--> 
    <xsl:import href="./suitedetails.xsl"/> 

<xsl:template match="test-run-result">  
    <fo:root >
        <xsl:call-template name="master-set-layout"/>
        <xsl:call-template name="page-sequence"/>
    </fo:root>
</xsl:template>

<xsl:template name="master-set-layout">
    <fo:layout-master-set>
        <fo:simple-page-master master-name="Test Report"
            margin-top="0.5cm" margin-bottom="0.5cm" margin-left="1cm"
            margin-right="1cm">
            <fo:region-body margin-top="0.5cm" margin-bottom="0.5cm" />
        </fo:simple-page-master>
    </fo:layout-master-set>
</xsl:template>

<xsl:template name="page-sequence">

    <fo:page-sequence master-reference="Test Report">
            <fo:flow flow-name="xsl-region-body">                   
                <!-- Report title -->                   
                <fo:block font-size="10px" text-align="center" font-family="sans-serif" color="#000080" font-weight="400">Test Run Report</fo:block>
                <!--  Include run summary if more than one suite is present in results -->
                <xsl:if test="count(./suite) &gt; 1">
                    <xsl:call-template name="testrunsummary"/>      
                </xsl:if>
                <!-- Suite Summary -->
                <xsl:for-each select="./suite">
                <xsl:variable name="verbosityType"  select="@verbosity" />
                        <xsl:if test="contains($verbosityType,'-1-')">
                        <xsl:call-template name="suitesummary"/>
                    <!--    <xsl:call-template name="suitehistory"/>    -->
                        </xsl:if>
                        <xsl:for-each select="./test">
                            <!-- <fo:block page-break-before="always"> -->
                            <xsl:if test="contains($verbosityType,'-2-')">
                                <xsl:call-template name="testsummary"/>
                            </xsl:if>
                            <xsl:if test="contains($verbosityType,'-4-')">
                                <xsl:call-template name="teststeps"/>
                            </xsl:if>
                            <xsl:if test="contains($verbosityType,'-8-') or contains($verbosityType,'-32-') or contains($verbosityType,'-64-')">
                                <xsl:call-template name="teststepdetails">
                                <xsl:with-param name="reportDetailLevel" select="$verbosityType" /> 
                                <xsl:with-param name="testStatus" select="@status" />                                                                                                       
                                </xsl:call-template>
                            </xsl:if>                                   
                            
                        </xsl:for-each> 
                        <xsl:if test="contains($verbosityType,'-16-')">
                        <xsl:call-template name="logreport"/>   
                        </xsl:if>                                                           
                </xsl:for-each>
            </fo:flow>
        </fo:page-sequence>
</xsl:template>
  </xsl:stylesheet>

And this is the teststepdetails, please check the block with the comment "Exceptions (if any)"

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version= '2.0'>

<xsl:template name="teststepdetails">
    <xsl:param name="testStatus" />
    <xsl:param name="reportDetailLevel" />
    <fo:block margin-top="10pt" font-size="10px"
        font-family="sans-serif" text-align="center" font-weight="bold">Test Details
    </fo:block>
    <fo:block font-size="8px" margin-top="5pt">
        <xsl:variable name="verbosityType1">
            <xsl:value-of select="../../@verbosity" />
        </xsl:variable>
        <fo:table table-layout="fixed" width="100%"
            border="0.8pt solid black" border-collapse="collapse">

            <fo:table-column column-width="20px" />
            <fo:table-column
                column-width="proportional-column-width(1)" />
            <fo:table-column column-width="120px" />
            <fo:table-column column-width="60px" />
            <fo:table-column column-width="60px" />
            <fo:table-column column-width="70px" />
            <fo:table-column column-width="40px" />


            <fo:table-header>
                <fo:table-row font-weight="bold"
                    border-bottom-style="none"    >
                    <fo:table-cell border="0.1pt solid gray"
                        text-align="center" padding-top="2pt" padding-bottom="1pt"
                        background-color="lightgray">
                        <fo:block>#</fo:block>
                    </fo:table-cell>
                    <fo:table-cell border="0.1pt solid gray"
                          text-align="center"
                        padding-left="5pt" padding-top="2pt" padding-bottom="1pt"
                        background-color="lightgray">
                        <fo:block>Test Step</fo:block>
                    </fo:table-cell>
                    <fo:table-cell border="0.1pt solid gray"
                          text-align="center"
                        padding-left="5pt" padding-top="2pt" padding-bottom="1pt"
                        background-color="lightgray">
                        <fo:block>Test Class</fo:block>
                    </fo:table-cell>
                    <fo:table-cell border="0.1pt solid gray"
                          text-align="center"
                        padding-top="2pt" padding-bottom="1pt"
                        background-color="lightgray">
                        <fo:block>Started</fo:block>
                    </fo:table-cell>
                    <fo:table-cell border="0.1pt solid gray"
                          text-align="center"
                        padding-top="2pt" padding-bottom="1pt"
                        background-color="lightgray">
                        <fo:block>Finished</fo:block>
                    </fo:table-cell>
                    <fo:table-cell border="0.1pt solid gray"
                          text-align="center"
                        padding-top="2pt" padding-bottom="1pt"
                        background-color="lightgray">
                        <fo:block>Duration (sec)</fo:block>
                    </fo:table-cell>
                    <fo:table-cell border="0.1pt solid gray"
                           
                        text-align="center" padding-top="2pt" padding-bottom="1pt"
                        background-color="lightgray">
                        <fo:block>Status</fo:block>
                    </fo:table-cell>
                </fo:table-row>
            </fo:table-header>

            <fo:table-body>

                <xsl:for-each select="./test-method">
                    <xsl:variable name="startDate" select="@started-at" />
                    <xsl:variable name="verbosityType">
                        <xsl:value-of select="../../@verbosity" />
                    </xsl:variable>

                    <xsl:if test="contains($verbosityType,'-8-')">
                        <fo:table-row keep-with-previous="always" >
                            <fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
                                padding-left="5pt" padding-top="1pt" padding-bottom="1pt">
                                <fo:block>
                                    <xsl:value-of select="@sequence" />
                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
                                 text-align="left"
                                padding-left="5pt" padding-top="1pt" padding-bottom="1pt">
                                <fo:block font-weight="bold">
                                    <xsl:call-template name="zero_width_space_1">
                                        <xsl:with-param name="data" select="@name" />
                                    </xsl:call-template>
                                    <!-- <xsl:value-of select="@name" /> -->
                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
                                 text-align="left"
                                padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                <fo:block>
                                    <xsl:call-template name="zero_width_space_1">
                                        <xsl:with-param name="data" select="@class" />
                                    </xsl:call-template>
                                    <!-- <xsl:text></xsl:text> <xsl:value-of select="substring(@class,string-length(@class) 
                                        - 40)" /> -->
                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
                                 text-align="left"
                                padding-left="1pt" padding-top="1pt" padding-bottom="1pt">
                                <fo:block>
                                    <xsl:value-of select="@started-at" />
                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
                                 text-align="left"
                                padding-left="1pt" padding-top="1pt" padding-bottom="1pt">
                                <fo:block>
                                    <xsl:value-of select="@finished-at" />
                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
                                 text-align="right"
                                padding-right="5pt" padding-top="1pt" padding-bottom="1pt">
                                <fo:block>
                                    <xsl:value-of
                                        select="format-number(@duration-ms div 1000, '###,###.0')" />
                                </fo:block>
                            </fo:table-cell>
                            <fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
                                  
                                text-align="left" padding-left="5pt" padding-top="1pt"
                                padding-bottom="1pt">
                                <fo:block>
                                    <xsl:choose>
                                        <xsl:when test="@status = 'PASS'">
                                            <fo:block color="green">PASS</fo:block>
                                        </xsl:when>
                                        <xsl:when test="@status = 'SKIP'">
                                            <fo:block color="gray">SKIP</fo:block>
                                        </xsl:when>
                                        <xsl:when test="@status = 'FAIL'">
                                            <fo:block color="red">FAIL</fo:block>
                                        </xsl:when>
                                    </xsl:choose>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <!-- ALM Documentation -->
                        <xsl:if test="./@step">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">
                                        Description
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border="0.1pt solid gray"
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block>
                                        Step :
                                        <xsl:value-of select="./@step" />
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="4"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block>
                                        Expected:
                                        <xsl:value-of select="./@expected" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>
                        <!-- Reason for Failure Message for Leonardo -->
                        <xsl:if test="./@failureMessage">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">
                                        Reason for Failure
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="6"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block color="gray">
                                        <xsl:value-of select="./@failureMessage" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>
                        <!--Performance -->
                        <xsl:if test="./@docLoadTime">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">
                                        Performance: Document Complete
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border="0.1pt solid gray"
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block color="gray">
                                        Time:
                                        <xsl:value-of select="./@docLoadTime" />
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray" padding-left="2pt" padding-top="1pt"
                                    padding-bottom="1pt">
                                    <fo:block color="gray">
                                        Requests:
                                        <xsl:value-of select="./@docRequests" />
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block color="gray">
                                        Bytes In:
                                        <xsl:value-of select="./@docBytesIn" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>
                        <xsl:if test="./@fullLoadTime">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">
                                        Performance: Fully Loaded
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border="0.1pt solid gray"
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block color="gray">
                                        Time:
                                        <xsl:value-of select="./@fullLoadTime" />
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray" padding-left="2pt" padding-top="1pt"
                                    padding-bottom="1pt">
                                    <fo:block color="gray">
                                        Requests:
                                        <xsl:value-of select="./@fullRequests" />
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block color="gray">
                                        Bytes In:
                                        <xsl:value-of select="./@fullBytesIn" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>
                        <xsl:if test="./@PerformanceVisuallyComplete">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">
                                        Visually Complete
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="5"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block color="gray">
                                        <xsl:value-of
                                            select="./@PerformanceVisuallyComplete" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>
                        <xsl:if test="./@PerformanceScore">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">
                                        Performance Score - Speed Index
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="1"
                                    border="0.1pt solid gray" padding-left="2pt" padding-top="1pt"
                                    padding-bottom="1pt">
                                    <fo:block color="gray">
                                        <xsl:value-of select="./@PerformanceScore" />
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray" padding-left="2pt" padding-top="1pt"
                                    padding-bottom="1pt">
                                    <fo:block font-style="italic">
                                        Transaction Name
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block color="gray">
                                        <xsl:value-of select="./@TransactionName" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>
                        <xsl:if test="./@Performancedetails">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">
                                        Performance Details
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="5"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block color="gray">
                                        <xsl:value-of select="./@Performancedetails" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>
                        <xsl:if test="./URL">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">
                                        Description
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell border="0.1pt solid gray"
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block color="gray">
                                        Step :
                                        <xsl:value-of select="./@step" />
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="4"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block color="gray">
                                        Expected:
                                        <xsl:value-of select="./@expected" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>
                        <!-- Parameters (if any) -->
                        <xsl:if test="./parameters">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">Parameters</fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="5"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block>
                                        <xsl:for-each select="./parameters">
                                            <xsl:for-each select="./parameter">
                                                <xsl:value-of select="./value" />
                                                <xsl:text>  </xsl:text>
                                            </xsl:for-each>
                                        </xsl:for-each>
                                        <xsl:value-of select="./@testaddedparameter" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>

                        <!-- Request -->
                        <xsl:if test="./@request">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">Request</fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="5"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block>
                                        <xsl:value-of select="./@request" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>

                        <!-- Response Status -->
                        <xsl:if test="./@responseStatus">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">
                                        Response Status
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="5"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block>
                                        <xsl:value-of select="./@responseStatus" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>

                        <!-- Response -->
                        <xsl:if test="./@response">
                            <fo:table-row keep-with-previous="always"  >
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray" border-bottom="solid black" 
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">
                                        Response
                                    </fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="5"
                                    border="0.1pt solid gray"  border-bottom="solid black"
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block>
                                        <xsl:value-of select="./@response" />
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>


                        <!-- Reporter output (if any) -->
                        <xsl:if test="./reporter-output">
                            <fo:table-row keep-with-previous="always">
                                <fo:table-cell number-columns-spanned="2"
                                    border="0.1pt solid gray"  
                                    text-align="right" padding-left="2pt" padding-right="5pt"
                                    padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-style="italic">Output</fo:block>
                                </fo:table-cell>
                                <fo:table-cell number-columns-spanned="5"
                                    border="0.1pt solid gray"  
                                    padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                    <fo:block font-size="8px">
                                        <fo:table table-layout="fixed" width="100%"
                                            margin="0pt">
                                            <fo:table-column
                                                column-width="proportional-column-width(1)" />
                                            <fo:table-body>
                                                <xsl:for-each select="./reporter-output/line">
                                                    <fo:table-row keep-with-previous="always">
                                                        <fo:table-cell border="none"
                                                            padding-left="2pt" padding-top="1pt">
                                                            <fo:block>
                                                                <xsl:value-of select="." />
                                                            </fo:block>
                                                        </fo:table-cell>
                                                    </fo:table-row>
                                                </xsl:for-each>
                                            </fo:table-body>
                                        </fo:table>
                                    </fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                        </xsl:if>

                        <!-- Exceptions (if any) -->
                        <xsl:if test="./exception">
                            <xsl:for-each select="./exception">
                                <fo:table-row keep-with-previous="always">
                                    <fo:table-cell number-columns-spanned="2"
                                        border="0.1pt solid gray"  
                                        text-align="right" padding-left="2pt" padding-right="5pt"
                                        padding-top="1pt" padding-bottom="1pt">
                                        <fo:block font-style="italic">Message</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell number-columns-spanned="5"
                                        border="0.1pt solid gray"  
                                        padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                        <fo:block>
                                            <xsl:value-of select="./message" />
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                                <fo:table-row keep-with-previous="always">
                                    <fo:table-cell number-columns-spanned="2"
                                        border="0.1pt solid gray"  
                                        text-align="right" padding-left="2pt" padding-right="5pt"
                                        padding-top="1pt" padding-bottom="1pt">
                                        <fo:block font-style="italic">Stack Trace</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell number-columns-spanned="5"
                                        border="0.1pt solid gray"  
                                        padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
                                        <fo:block linefeed-treatment="preserve">
                                            <xsl:value-of select="./full-stacktrace" />
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </xsl:for-each>
                        </xsl:if>
                    </xsl:if>
                    <!-- Screenshots (if any) -->


                    <xsl:if test="contains($verbosityType,'-32-') or contains($verbosityType,'-64-')">
                        <xsl:choose>
                            <xsl:when test="@screenshot">
                                <xsl:variable name="screenshot-path"
                                    select="@screenshot" />
                                <fo:table-row keep-with-previous="always">
                                    <fo:table-cell number-columns-spanned="2"
                                        border="0.1pt solid gray"  
                                        text-align="right" padding-left="2pt" padding-right="5pt"
                                        padding-top="1pt" padding-bottom="1pt">
                                        <fo:block font-style="italic">Screenshot</fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell number-columns-spanned="5"
                                        border="0.1pt solid gray"  
                                        padding="5pt">
                                         <fo:block>
                                            <fo:external-graphic 
                                            display-align="center"
                                            content-width="338px"
                                            content-height="290px"
                                            src="url(file:/{$screenshot-path})">
                                            </fo:external-graphic>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </xsl:when>
                            <xsl:otherwise>
                                <fo:table-row keep-with-previous="always">
                                    <fo:table-cell number-columns-spanned="2">
                                        <fo:block> <!-- <xsl:value-of select="$testStatus" /> -->
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell number-columns-spanned="5">
                                        <fo:block></fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </xsl:otherwise>
                        </xsl:choose>

                    </xsl:if>

                </xsl:for-each>

            </fo:table-body>
        </fo:table>
        <xsl:if
            test="contains($testStatus,'PASS') and not(contains($reportDetailLevel,'-8-')) and not(contains($reportDetailLevel,'-64-'))">
            <fo:table>
                <fo:table-column column-width="75mm" />
                <fo:table-header>
                    <fo:table-cell>
                        <fo:block font-weight="bold">Screen Detail Not Available
                        </fo:block>
                    </fo:table-cell>
                </fo:table-header>

                <fo:table-body>
                    <fo:table-row>
                        <fo:table-cell>
                            <fo:block></fo:block>
                        </fo:table-cell>
                    </fo:table-row>
                </fo:table-body>

            </fo:table>
        </xsl:if>
    </fo:block>

</xsl:template>

<xsl:template name="zero_width_space_1">
    <xsl:param name="data" />
    <xsl:param name="counter" select="0" />
    <xsl:choose>
        <xsl:when test="$counter &lt;= string-length($data)">
            <xsl:value-of
                select='concat(substring($data,$counter,1),"&#8203;")' />
            <xsl:call-template name="zero_width_space_2">
                <xsl:with-param name="data" select="$data" />
                <xsl:with-param name="counter" select="$counter+1" />
            </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template name="zero_width_space_2">
    <xsl:param name="data" />
    <xsl:param name="counter" />
    <xsl:value-of
        select='concat(substring($data,$counter,1),"&#8203;")' />
    <xsl:call-template name="zero_width_space_1">
        <xsl:with-param name="data" select="$data" />
        <xsl:with-param name="counter" select="$counter+1" />
    </xsl:call-template>
</xsl:template>
 </xsl:stylesheet>

Solution

  • You are limiting the formatter's ability to break across a page because of the many <fo:table-row keep-with-previous="always">.

    If you remove some of the keep-with-previous="always", you should get a different result, though I can't tell if that would completely solve your problem.

    (And, as @mzjn implies, you might get a different (better) result with the latest FOP version.)