You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Danny <da...@gainergroup.com> on 2005/11/02 21:40:54 UTC

control number of records per page

I have a problem with determining the number of detail records that should
be displayed on the first page of a report.

 

The report consists of a title, a summary table (that can be one to many
rows) ** this is the root of my problem **

then a detail for each record (2 rows per record) there can be 1000's of
records.

 

The first version of this xsl that I coded processed everything within one
page-sequence, so that worked as far as layout is concerned,

but the performance was terrible.

 

So the current version of the xsl has the first page in one page-sequence
(title, summary table, n # of records)

then each page after the first contains a known number of records, each
within it's own page-sequence.

If the summary table was a fixed size, everything would work fine, but it
can be different sizes so the number of records that

should appear on the first page varies.  Right now the xsl is code as 11
records on the first page and 21 on every other, which works 

fine if the summary table contains only one row, but if it contains 4 rows
(or 15 for that matter) everything is thrown off.

 

So I cannot figure out how to determine how many records to place on the
first page dynamically?

Also I don't like the logic in the RECORD template below, although if the
size of the components on the first page is static, it seems to work just
fine.

 

Any help is greatly appreciated.

 

relevant XSL

 

fo:layout-master-set>

                <fo:simple-page-master

                    master-name="page" page-width="11in"
page-height="8.5in">

                    <fo:region-body region-name="body" margin-top="0.5in"
margin-bottom="1in" 

                        margin-left="0.5in" margin-right="0.5in">

                    </fo:region-body>

                    <fo:region-after region-name="footer" extent=".75in">

                    </fo:region-after>  

                </fo:simple-page-master>

                <fo:simple-page-master

                                    master-name="contentpage"
page-width="11in" page-height="8.5in">

                                    <fo:region-body
region-name="contentbody" margin-top="0.5in" margin-bottom="1in" 

                                    margin-left="0.5in"
margin-right="0.5in">

                                </fo:region-body>

                                <fo:region-after region-name="footer"
extent=".75in">

                                </fo:region-after>  

                </fo:simple-page-master>

 </fo:layout-master-set>  

 

<fo:page-sequence master-reference="page">

    <fo:flow>

       . xsl to produce title, summary table, detail heading

            <xsl:call-template name="RECORD">                           

                                <xsl:with-param
name="pagegroup">11</xsl:with-param>

            </xsl:call-template>

     </fo:flow>

</fo:page-sequence>

<xsl:if test="count(FILE/RECORDS/RECORD) &gt; 11">

                <fo:page-sequence master-reference="contentpage"> 

                    <fo:static-content flow-name="footer"
xsl:use-attribute-sets="base">

                        <fo:block text-align="center"> Page

                            <fo:page-number/>

                            </fo:block>

                        </fo:static-content>    

                        <fo:flow flow-name="contentbody">    

                        <xsl:call-template name="RECORD">


                            <xsl:with-param
name="pagegroup">21</xsl:with-param>

                        </xsl:call-template>

                        </fo:flow>    

                    </fo:page-sequence> 

                </xsl:if>

        </fo:root>

    </xsl:template>

 

 

<xsl:template name="RECORD"> 

        <xsl:param name="pagegroup"/>

        <xsl:for-each
select="FILE/RECORDS/RECORD|following-sibling::RECORD[position() &lt;
$pagegroup]">

                <xsl:if test="$pagegroup = 21">

                <xsl:if test="position() &gt; 11">

                            <xsl:call-template name="DETAIL"/>

                        </xsl:if>

                </xsl:if>

            <xsl:if test="$pagegroup = 11">

                <xsl:if test="position() &lt; 12">

                            <xsl:call-template name="DETAIL"/>

                        </xsl:if>

                </xsl:if>

         </xsl:for-each>   

     </xsl:template>

 

<xsl:template name="DETAIL">

   .. produces tht detail records (2 rows each)

</xsl:template>

 

Danny Gallagher

The Gainer Group

6525 The Corners Parkway

Suite 215

Norcross Ga, 30092

 

 

 


Re: control number of records per page

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Danny, you can greatly improve the chance that someone will help you if
you attach (or better post a link to) a complete FO file that shows your
problem. That way, people can quickly set up your document and help
track down the problem. Otherwise, people spend a lot of time
second-guessing what exactly happens on your machine.

Anyway, I think you shouldn't try to determine the height of the content
so you can split between page-sequences. The performance problems
probably come from a different source. Check things like
forward-references or try to find easier split points for new
page-sequences.

On 02.11.2005 21:40:54 Danny wrote:
> I have a problem with determining the number of detail records that should
> be displayed on the first page of a report.
> 
>  
> 
> The report consists of a title, a summary table (that can be one to many
> rows) ** this is the root of my problem **
> 
> then a detail for each record (2 rows per record) there can be 1000's of
> records.
> 
>  
> 
> The first version of this xsl that I coded processed everything within one
> page-sequence, so that worked as far as layout is concerned,
> 
> but the performance was terrible.
> 
>  
> 
> So the current version of the xsl has the first page in one page-sequence
> (title, summary table, n # of records)
> 
> then each page after the first contains a known number of records, each
> within it's own page-sequence.
> 
> If the summary table was a fixed size, everything would work fine, but it
> can be different sizes so the number of records that
> 
> should appear on the first page varies.  Right now the xsl is code as 11
> records on the first page and 21 on every other, which works 
> 
> fine if the summary table contains only one row, but if it contains 4 rows
> (or 15 for that matter) everything is thrown off.
> 
>  
> 
> So I cannot figure out how to determine how many records to place on the
> first page dynamically?
> 
> Also I don't like the logic in the RECORD template below, although if the
> size of the components on the first page is static, it seems to work just
> fine.
> 
>  
> 
> Any help is greatly appreciated.
> 
>  
> 
> relevant XSL
> 
>  
> 
> fo:layout-master-set>
> 
>                 <fo:simple-page-master
> 
>                     master-name="page" page-width="11in"
> page-height="8.5in">
> 
>                     <fo:region-body region-name="body" margin-top="0.5in"
> margin-bottom="1in" 
> 
>                         margin-left="0.5in" margin-right="0.5in">
> 
>                     </fo:region-body>
> 
>                     <fo:region-after region-name="footer" extent=".75in">
> 
>                     </fo:region-after>  
> 
>                 </fo:simple-page-master>
> 
>                 <fo:simple-page-master
> 
>                                     master-name="contentpage"
> page-width="11in" page-height="8.5in">
> 
>                                     <fo:region-body
> region-name="contentbody" margin-top="0.5in" margin-bottom="1in" 
> 
>                                     margin-left="0.5in"
> margin-right="0.5in">
> 
>                                 </fo:region-body>
> 
>                                 <fo:region-after region-name="footer"
> extent=".75in">
> 
>                                 </fo:region-after>  
> 
>                 </fo:simple-page-master>
> 
>  </fo:layout-master-set>  
> 
>  
> 
> <fo:page-sequence master-reference="page">
> 
>     <fo:flow>
> 
>        . xsl to produce title, summary table, detail heading
> 
>             <xsl:call-template name="RECORD">                           
> 
>                                 <xsl:with-param
> name="pagegroup">11</xsl:with-param>
> 
>             </xsl:call-template>
> 
>      </fo:flow>
> 
> </fo:page-sequence>
> 
> <xsl:if test="count(FILE/RECORDS/RECORD) &gt; 11">
> 
>                 <fo:page-sequence master-reference="contentpage"> 
> 
>                     <fo:static-content flow-name="footer"
> xsl:use-attribute-sets="base">
> 
>                         <fo:block text-align="center"> Page
> 
>                             <fo:page-number/>
> 
>                             </fo:block>
> 
>                         </fo:static-content>    
> 
>                         <fo:flow flow-name="contentbody">    
> 
>                         <xsl:call-template name="RECORD">
> 
> 
>                             <xsl:with-param
> name="pagegroup">21</xsl:with-param>
> 
>                         </xsl:call-template>
> 
>                         </fo:flow>    
> 
>                     </fo:page-sequence> 
> 
>                 </xsl:if>
> 
>         </fo:root>
> 
>     </xsl:template>
> 
>  
> 
>  
> 
> <xsl:template name="RECORD"> 
> 
>         <xsl:param name="pagegroup"/>
> 
>         <xsl:for-each
> select="FILE/RECORDS/RECORD|following-sibling::RECORD[position() &lt;
> $pagegroup]">
> 
>                 <xsl:if test="$pagegroup = 21">
> 
>                 <xsl:if test="position() &gt; 11">
> 
>                             <xsl:call-template name="DETAIL"/>
> 
>                         </xsl:if>
> 
>                 </xsl:if>
> 
>             <xsl:if test="$pagegroup = 11">
> 
>                 <xsl:if test="position() &lt; 12">
> 
>                             <xsl:call-template name="DETAIL"/>
> 
>                         </xsl:if>
> 
>                 </xsl:if>
> 
>          </xsl:for-each>   
> 
>      </xsl:template>
> 
>  
> 
> <xsl:template name="DETAIL">
> 
>    .. produces tht detail records (2 rows each)
> 
> </xsl:template>
> 
>  



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org