Re: [xsl] Multi page pdf using fop-one page for each person tag

Subject: Re: [xsl] Multi page pdf using fop-one page for each person tag
From: Tony Graham <Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 04 Apr 2008 13:24:32 +0100
On Fri, Apr 04 2008 11:56:59 +0100, Atiqur.Khan@xxxxxxxxxxxxxxxxx wrote:
> I was able to proceed with this and got stuck as its overwriting on the
> first page only. Each of the employee tags need to go into a separate
> page in the pdf. When I am creating the pdf its writing on the first
> page only without advancing to the next page. Can you please point out
> the mistake in my xsl template. A sample xml & xsl is below:
>
> <resultset>
>   <employee>
...
> </resultset>
>
> My xsl template is as follows:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:fo="http://www.w3.org/1999/XSL/Format";
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>     <xsl:template match="resultset">
>         <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format";>
...
>             <fo:page-sequence master-reference="simpleDoc"
> initial-page-number="1" force-page-count="odd">
>                 <!-- usage of page layout -->
>                 <!-- header -->
>                 <fo:static-content flow-name="xsl-region-start"/>
>                 <!-- Body -->
>                 <fo:flow flow-name="xsl-region-body">
>                     <xsl:apply-templates/>
>                 </fo:flow>
>             </fo:page-sequence>
>             
>         </fo:root>
>     </xsl:template>
...
>     <xsl:template match="employee">
>         <fo:block-container height="29.704cm" left="0cm"
> position="absolute" top="0cm" width="0.404cm">
...
>         </fo:block-container>
>         .
>         .
>         .
>     </xsl:template>
> </xsl:stylesheet>
...
> -----Original Message-----
> From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx] 
...
>><xsl:template match="/">
>><root font-family="Times" font-size="20pt">
>>
>>   <layout-master-set>
>>     <simple-page-master master-name="frame"
>>                         page-height="297mm" page-width="210mm"
>>                         margin-top="15mm" margin-bottom="15mm"
>>                         margin-left="15mm" margin-right="15mm">
>>       <region-body region-name="frame-body"/>
>>     </simple-page-master>
>>   </layout-master-set>
>>   <xsl:apply-templates/>
>></root>
>></xsl:template>
>>
>><xsl:template match="person">
>>   <page-sequence master-reference="frame">
>>     <flow flow-name="frame-body">
>>       <block>This is a person</block>
>>     </flow>
>>   </page-sequence>
>></xsl:template>

You didn't really follow Ken's advice.

Ken used <person> where you use <employee>.  He is generating one
fo:page-sequence for each employee, whereas you are generating one
fo:page-sequence for <resultset>, with each employee generating a bunch
of absolutely positioned fo:block-container.

The end of the first template and the beginning of the second should be
like:

------------------------------------------------------------
      <!-- end: defines page layout -->
      <!-- actual layout -->
      <xsl:apply-templates/>
    </fo:root>
  </xsl:template>

  <xsl:template match="employee">
    <fo:page-sequence master-reference="simpleDoc"
		      initial-page-number="1" force-page-count="odd">
      <!-- usage of page layout -->
      <!-- header -->
      <fo:static-content flow-name="xsl-region-start"/>
      <!-- Body -->
      <fo:flow flow-name="xsl-region-body">
	<fo:block-container height="29.704cm" left="0cm"
			    position="absolute" top="0cm" width="0.404cm">
------------------------------------------------------------

(and I'll leave it to you to sort out the end-tags).

Regards,


Tony Graham.
======================================================================
Tony.Graham@xxxxxxxxxxxxxxxxxxxxxx   http://www.menteithconsulting.com

Menteith Consulting Ltd             Registered in Ireland - No. 428599
Registered Office: 13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
----------------------------------------------------------------------
Menteith Consulting -- Understanding how markup works
======================================================================

Current Thread