xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Khan, Atique \(IT\)" <Atiqur.K...@MorganStanley.com>
Subject Multi page pdf using fop-one page for each person tag
Date Fri, 04 Apr 2008 10:33:15 GMT
Hi All,
I need to convert my xml data using xsl-fo template into pdf using fop.
My XML data looks like
<resultset>
  <employee>
    <row>
      <data_description>Payment Company</data_description>
      <data_value>ABC UK Ltd</data_value>
      <data_display_type>1</data_display_type>
      <display_order>10</display_order>
    </row>
    <row>
      <data_description>Employee Name</data_description>
      <data_value>Mr A Lastname</data_value>
      <data_display_type>2</data_display_type>
      <display_order>10</display_order>
    </row>
    ...
    </employee>
    <employee>
    ...
    </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">
            <!-- defines page layout -->
            <fo:layout-master-set>
                <!-- layout for the first page -->
                <fo:simple-page-master margin-bottom="0cm"
margin-left="0cm" margin-right="0cm" margin-top="0cm" master-name="ukA4"
page-height="29.704cm" page-width="20.990cm">
                    <fo:region-body background-repeat="no-repeat"
margin-bottom="0cm" margin-left="0cm" margin-right="0cm"
margin-top="0cm"/>
                    <fo:region-before extent="2cm" precedence="true"/>
                    <fo:region-after extent="0cm" precedence="true"/>
                    <fo:region-start extent="0cm"/>
                    <fo:region-end extent="0cm"/>
                </fo:simple-page-master>
                <fo:page-sequence-master master-name="simpleDoc" >
                    <fo:repeatable-page-master-alternatives>
                        <fo:conditional-page-master-reference
master-reference="ukA4"/>
                    </fo:repeatable-page-master-alternatives>
                </fo:page-sequence-master>
            </fo:layout-master-set>
            <!-- end: defines page layout -->
            <!-- actual layout -->
            <!-- <fo:page-sequence master-reference="simpleDoc">-->
            
            <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="resultset">
        <xsl:for-each select="employee">
            <xsl:flow flow-name="xsl-region-body">
                <xsl:apply-templates />
            </xsl:flow>
        </xsl:for-each>
    </xsl:template>-->
    
    <xsl:template match="employee">
        <fo:block-container height="29.704cm" left="0cm"
position="absolute" top="0cm" width="0.404cm">
            <fo:block/>
        </fo:block-container>
        <fo:block-container height="1.97cm" left="0cm"
position="absolute" top="0cm" width="29.704cm">
            <fo:block/>
        </fo:block-container>
        <fo:block-container height="29.704cm" left="20.65cm"
position="absolute" top="0cm" width="0.404cm">
            <fo:block/>
        </fo:block-container>
        
        <!-- Payslip footer -->
        <fo:block-container height="1.834cm" left="0.515cm"
position="absolute" top="27.8342cm" width="5.5cm"
background-color="#FFFFFF" padding-left="0cm">
            <fo:block>
                <fo:external-graphic
src="url(file:///webapp/images/Logo_Black.jpg)" height="1.24cm"
width="5.29cm"/>
            </fo:block>
        </fo:block-container>
        <fo:block-container height="1.834cm" left="15.145cm"
position="absolute" top="28.4242cm" width="5.5cm"
background-color="#FFFFFF" padding-left="0cm">
            <fo:block font-family="Arial" font-weight="normal"
font-size="10.00pt" color="#000000" text-align="end"> PRIVATE AND
CONFIDENTIAL
            </fo:block>
        </fo:block-container>
        
        <!-- Payslip main header -->
        <fo:block-container height="0.53cm" left="0.7cm"
position="absolute" top="1.2cm" width="13.33cm" border-width="0.5pt"
border-style="solid" border-color="#000000" padding-top="0.11cm"
padding-bottom="0.07cm" padding-left="0.125cm">
            <fo:block font-family="Arial" font-weight="normal"
font-size="9pt" line-height="0.5pt" text-align="start" color="#000000"
padding="0.25cm">
                <xsl:for-each select="row">
                    <xsl:choose>
                        <xsl:when test="data_display_type=1">
                            <xsl:value-of select="data_value"/>
                        </xsl:when>
                    </xsl:choose>
                </xsl:for-each>
            </fo:block>
        </fo:block-container>
        
        <!-- Paydate -->
        <fo:block-container height="0.53cm" left="14.6087cm"
position="absolute" top="1.2cm" width="5.875cm" border-width="0.5pt"
border-style="solid" border-color="#000000" padding-top="0.11cm"
padding-bottom="0.07cm" padding-left="0.125cm">
            <fo:block font-size="11pt" text-align="left">
                <fo:table table-layout="fixed" height="0.4808cm">
                    <fo:table-column column-width="2.2cm"/>
                    <fo:table-column column-width="0.750cm"/>
                    <fo:table-column column-width="2.75cm"/>
                    <fo:table-body font-size="11pt" color="#000000">
                        <fo:table-row color="#000000" height="0.4808cm">
                            <fo:table-cell font-family="ArialBold"
font-weight="bold" font-size="10pt" color="#000000"
vertical-align="middle">
                                <fo:block text-align="left"
vertical-align="middle"> Paydate </fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block/>
                            </fo:table-cell>
                            <fo:table-cell font-family="Arial"
font-weight="normal" font-size="9pt" color="#000000">
                                <fo:block text-align="start"
vertical-align="middle">
                                    <xsl:for-each select="row">
                                        <xsl:choose>
                                            <xsl:when
test="data_display_type=3">
                                                <xsl:value-of
select="data_value"/>
                                            </xsl:when>
                                        </xsl:choose>
                                    </xsl:for-each>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
            </fo:block>
        </fo:block-container>
        
        <!-- Employee details on payslip -->
        <fo:block-container height="1.7974cm" left="0.7cm"
position="absolute" top="2.46955cm" width="13.30cm" border-width="0.5pt"
border-style="solid" border-color="#000000" padding-top="0.13cm"
padding-left="0.125cm">
            <fo:block font-family="ArialBold" font-weight="bold"
font-size="11.00pt" line-height="11.00pt" text-align="center">
                <fo:table table-layout="fixed" border-width="2pt"
border-color="#000000" height="1.7724cm">
                    <fo:table-column column-width="3.2cm"/>
                    <fo:table-column column-width="0.750cm"/>
                    <fo:table-column column-width="7.6cm"/>
                    <fo:table-body font-size="11pt" color="#000000">
                        <fo:table-row color="#000000" line-height="11pt"
height="0.5908cm">
                            <fo:table-cell font-family="ArialBold"
font-weight="bold" font-size="10pt" color="#000000"
vertical-align="bottom">
                                <fo:block text-align="left"
vertical-align="middle"> Employee Name </fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block/>
                            </fo:table-cell>
                            <fo:table-cell font-family="Arial"
font-weight="normal" font-size="9pt" color="#000000">
                                <fo:block text-align="start"
vertical-align="middle">
                                    <xsl:for-each select="row">
                                        <xsl:choose>
                                            <xsl:when
test="data_display_type=2 and display_order=10">
                                                <xsl:value-of
select="data_value"/>
                                            </xsl:when>
                                        </xsl:choose>
                                    </xsl:for-each>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row color="#000000" line-height="11pt"
height="0.5908cm">
                            <fo:table-cell font-family="ArialBold"
font-weight="bold" font-size="10pt" color="#000000"
vertical-align="bottom">
                                <fo:block text-align="left"
vertical-align="middle"> Employee Number </fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block/>
                            </fo:table-cell>
                            <fo:table-cell font-family="Arial"
font-weight="normal" font-size="9pt" color="#000000">
                                <fo:block text-align="start"
vertical-align="middle">
                                    <xsl:for-each select="row">
                                        <xsl:choose>
                                            <xsl:when
test="data_display_type=2 and display_order=20">
                                                <xsl:value-of
select="data_value"/>
                                            </xsl:when>
                                        </xsl:choose>
                                    </xsl:for-each>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                        <fo:table-row color="#000000" line-height="11pt"
height="0.5908cm">
                            <fo:table-cell font-family="ArialBold"
font-weight="bold" font-size="10pt" color="#000000"
vertical-align="middle">
                                <fo:block text-align="left"
vertical-align="middle"> Payment Method </fo:block>
                            </fo:table-cell>
                            <fo:table-cell>
                                <fo:block/>
                            </fo:table-cell>
                            <fo:table-cell font-family="Arial"
font-weight="normal" font-size="9pt" color="#000000">
                                <fo:block text-align="start"
vertical-align="middle">
                                    <xsl:for-each select="row">
                                        <xsl:choose>
                                            <xsl:when
test="data_display_type=2 and display_order=30">
                                                <xsl:value-of
select="data_value"/>
                                            </xsl:when>
                                        </xsl:choose>
                                    </xsl:for-each>
                                </fo:block>
                            </fo:table-cell>
                        </fo:table-row>
                    </fo:table-body>
                </fo:table>
            </fo:block>
        </fo:block-container>
        .
        .
        .
    </xsl:template>
</xsl:stylesheet>

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 somebody please point out the mistake in
my xsl template.

Thanks
Atique
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to
waive confidentiality or privilege. Use of this email is prohibited when received in error.

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


Mime
View raw message