xsl-list
[Top] [All Lists]

[xsl] dynamic page break for tables

2011-07-18 06:50:19
Dear all,

I am experiencing an problem with keep-together.within-page. I work
with FOP Apache Version 0.95.
A short intro of my plan: I use xsl-fo as a style sheet for generating
reports out of Matlab. I'd like to have only one style sheet for 2
different types of reports. The main difference between both reports
are the layout of tables. The first report uses tables which fit to a
single page. The other report contains tables which can cause an
overflow. But thats not the problem. The crux is the following: The
table does not use <xsl:table> because FOP Apache does not support
captions of tables. To keep title, data and caption on a single page,
I use blocks and keep-together.within-page="always". But this does not
work in the second report because of an overflow. This is pretty clear
to me because of keep-together.within-page="always". Now, I am
searching for a method which combines both aspects. I would like to
avoid another template .. What I tried so far: Upgrade to version 1.0
to use integers for keep-together.within-page; avoid
keep-together.within-page and use keep-with-next with integers; ....
But it does not work ...

<xsl:template match="table">
                
                
        <fo:block span="all" space-before="1.5cm" space-after="1.5cm"
keep-together.within-page="always" start-indent="4%">


                <fo:block font-size="10pt" space-after="3mm">
                        <xsl:text>Table </xsl:text>
                        <xsl:value-of select="1 + count(preceding::chapter)" />
                        <xsl:text>.</xsl:text>

                        
                        <xsl:if test="parent::chapter">
                                <xsl:value-of 
select="count(preceding-sibling::table)
                                        + 
count(preceding-sibling::section/descendant::table)
                                        - 
count(preceding-sibling::section/descendant::elementrow/table)
                                        +1" />  
                                                
                        </xsl:if>

                        <xsl:if test="parent::section">
                                <xsl:value-of 
select="count(preceding-sibling::table)
                                        + 
count(preceding-sibling::subesction/descendant::table)
                                        - 
count(preceding-sibling::subesction/descendant::elementrow/table)
                                        + 
count(parent::*/preceding-sibling::table)     
                                        + 
count(parent::*/preceding-sibling::section/descendant::table)
                                        - 
count(parent::*/preceding-sibling::section/descendant::elementrow/table)
                                        + 1" />
                        </xsl:if>

                        <xsl:if test="parent::subsection">
                                <xsl:value-of 
select="count(preceding-sibling::table)
                                        + 
count(parent::*/preceding-sibling::table)
                                        + 
count(parent::*/preceding-sibling::subsection/descendant::table)
                                        - 
count(parent::*/preceding-sibling::subsection/descendant::elementrow/table)
                                        + 
count(parent::*/parent::*/preceding-sibling::table)
                                        + 
count(parent::*/parent::*/preceding-sibling::section/descendant::table)
                                        - 
count(parent::*/parent::*/preceding-sibling::section/descendant::elementrow/table)
                                        +1" />
                        </xsl:if>       

                        <xsl:text>: </xsl:text>
                        <xsl:value-of select="@title" />
                </fo:block>
                
        <fo:block>
                        
                        <fo:block>
                                <fo:table table-layout="fixed" 
space-after="3mm">
                                        <xsl:attribute name="width">
                                                <xsl:choose>
                                                        <xsl:when 
test="count(./tabledataset[1]/@*)=2">60%</xsl:when>
                                                        <xsl:when 
test="count(./tabledataset[1]/@*)=3">70%</xsl:when>
                                                        <xsl:when 
test="count(./tabledataset[1]/@*)=4">80%</xsl:when>
                                                        <xsl:when 
test="count(./tabledataset[1]/@*)=5">90%</xsl:when>
                                                        
<xsl:otherwise>96%</xsl:otherwise>
                                                </xsl:choose>
                                        </xsl:attribute>
                                        <fo:table-column 
column-width="proportional-column-width(1)">
                                                <xsl:attribute 
name="number-columns-repeated">
                                                        <xsl:value-of 
select="count(./tabledataset[1]/@*)" />
                                                </xsl:attribute>
                                        </fo:table-column>
                                        <fo:table-header start-indent="0%">
                                                <xsl:apply-templates 
select="tableheader" />
                                        </fo:table-header>
                                        <fo:table-body start-indent="0%">
                                                <xsl:apply-templates 
select="tabledataset" />
                                        </fo:table-body>
                                </fo:table>
                        </fo:block>
                        
                        <fo:block-container start-indent="2%">
                                <xsl:attribute name="width">
                                                <xsl:choose>
                                                        <xsl:when 
test="count(./tabledataset[1]/@*)=2">68%</xsl:when>
                                                        <xsl:when 
test="count(./tabledataset[1]/@*)=3">78%</xsl:when>
                                                        <xsl:when 
test="count(./tabledataset[1]/@*)=4">88%</xsl:when>
                                                        <xsl:when 
test="count(./tabledataset[1]/@*)=5">100%</xsl:when>
                                                        
<xsl:otherwise>100%</xsl:otherwise>
                                                </xsl:choose>
                                </xsl:attribute>
                                <fo:block font-size="8pt" text-align="justify" 
end-indent='7%'
wrap-option="wrap">
                                        <xsl:value-of select="@caption" />
                                </fo:block>
                        </fo:block-container>
                </fo:block>
        
        
        </fo:block>
        </xsl:template>


Thanks and kind regards,
Mathis

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] dynamic page break for tables, Mathis Mörke <=