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 shrutin <sh...@mastek.com> on 2009/09/29 11:58:56 UTC

Page Break in FOP

Hello All,
I am new to FOP and have started my first assignment. i need to know how can
i insert a page break on the basis of a  condition.
Scenario:
I have a list and based on the value in the list i need to break pages.
i.e my XML data is
<data>
   <record>
     <date>01/01/2009</date>
     <srno>A</srno>
     <name>AA</name>
    </record>
   <record>
     <date>01/01/2009</date>
     <srno>A</srno>
     <name>AA</name>
    </record>
   <record>
     <date>02/01/2009</date>
     <srno>A</srno>
     <name>AA</name>
    </record>
</data>
Now my XSL has a <xsl:for-each> statement for iterating the list into a
table. But what i need is that the as the date changes a page break should
be inserted. 
i.e. In the above example the first 2 records should be on page 1 and then a
page break should be inserted enabling the 3rd record to be on another page.
How could i do this?

Awaiting replies.

Thanks
Shruti
-- 
View this message in context: http://www.nabble.com/Page-Break-in-FOP-tp25660112p25660112.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Page Break in FOP

Posted by Venkat Reddy <va...@googlemail.com>.
Hi,

I hope you will find someway using the following xslt in order to get 
page breaks based on the date condition...

<?xml version="1.0"?>
<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:fo="http://www.w3.org/1999/XSL/Format">
  <xsl:template match='data'>
    <fo:root>
      <fo:layout-master-set>
        <fo:simple-page-master master-name="my-page">
          <fo:region-body margin="1in"/>
        </fo:simple-page-master>
      </fo:layout-master-set>
      <fo:page-sequence master-reference="my-page">
        <fo:flow flow-name="xsl-region-body">
           <xsl:for-each select="*">
          <xsl:variable name="currentdate"><xsl:value-of 
select="date"/></xsl:variable>
          <xsl:variable name="previousdate"><xsl:value-of 
select="preceding-sibling::record/date"/></xsl:variable>
          <xsl:if test="$currentdate!=$previousdate">
        <fo:block break-after="page"/>
          </xsl:if>
          <fo:block>
        <xsl:value-of select="$currentdate"/>
        <xsl:value-of select="$previousdate"/>
          </fo:block>
          <fo:block>
        <xsl:value-of select="name"/>
          </fo:block>
            </xsl:for-each>
        </fo:flow>
      </fo:page-sequence>
    </fo:root>
  </xsl:template>
</xsl:stylesheet>

I don't know this may be the ideal solution or not?

Cheers,
Venkat.

shrutin wrote:
> Hello All,
> I am new to FOP and have started my first assignment. i need to know how can
> i insert a page break on the basis of a  condition.
> Scenario:
> I have a list and based on the value in the list i need to break pages.
> i.e my XML data is
> <data>
>    <record>
>      <date>01/01/2009</date>
>      <srno>A</srno>
>      <name>AA</name>
>     </record>
>    <record>
>      <date>01/01/2009</date>
>      <srno>A</srno>
>      <name>AA</name>
>     </record>
>    <record>
>      <date>02/01/2009</date>
>      <srno>A</srno>
>      <name>AA</name>
>     </record>
> </data>
> Now my XSL has a <xsl:for-each> statement for iterating the list into a
> table. But what i need is that the as the date changes a page break should
> be inserted. 
> i.e. In the above example the first 2 records should be on page 1 and then a
> page break should be inserted enabling the 3rd record to be on another page.
> How could i do this?
>
> Awaiting replies.
>
> Thanks
> Shruti
>   


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


Re: Page Break in FOP

Posted by shrutin <sh...@mastek.com>.
To resolve this issue i did not change the XSL file instead i changed the XML
file.
Here i grouped the data with the same date together.
Then in XSL file i wrote 2 nested <xsl:for-each> (one for date grouping and
one for data within the grouped dates) and then  on the outer most for each
loop gave a break-before="page")


shrutin wrote:
> 
> Hello All,
> I am new to FOP and have started my first assignment. i need to know how
> can i insert a page break on the basis of a  condition.
> Scenario:
> I have a list and based on the value in the list i need to break pages.
> i.e my XML data is
> <data>
>    <record>
>      <date>01/01/2009</date>
>      <srno>A</srno>
>      <name>AA</name>
>     </record>
>    <record>
>      <date>01/01/2009</date>
>      <srno>A</srno>
>      <name>AA</name>
>     </record>
>    <record>
>      <date>02/01/2009</date>
>      <srno>A</srno>
>      <name>AA</name>
>     </record>
> </data>
> Now my XSL has a <xsl:for-each> statement for iterating the list into a
> table. But what i need is that the as the date changes a page break should
> be inserted. 
> i.e. In the above example the first 2 records should be on page 1 and then
> a page break should be inserted enabling the 3rd record to be on another
> page.
> How could i do this?
> 
> Awaiting replies.
> 
> Thanks
> Shruti
> 

-- 
View this message in context: http://www.nabble.com/Page-Break-in-FOP-tp25660112p25676331.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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