XSL-FO, Group items to tables - xslt

XML:
<?xml version="1.0" encoding="utf-8"?>
<NewDataSet>
<inc_incident>
<inc_traumatriagecriteria>
<TTC_ID>1 </TTC_ID>
<TraumaTriageCriteria>(M)echanism: Ejection</TraumaTriageCriteria>
</inc_traumatriagecriteria>
<inc_traumatriagecriteria>
<TTC_ID>2 </TTC_ID>
<TraumaTriageCriteria>(M)echanism: Fatality</TraumaTriageCriteria>
</inc_traumatriagecriteria>
<inc_traumatriagecriteria>
<TTC_ID>3 </TTC_ID>
<TraumaTriageCriteria>(P)hysiologic: GCS</TraumaTriageCriteria>
</inc_traumatriagecriteria>
<inc_traumatriagecriteria>
<TTC_ID>4 </TTC_ID>
<TraumaTriageCriteria>(A)natomic: Crushed</TraumaTriageCriteria>
</inc_traumatriagecriteria>
</inc_incident>
</NewDataSet>
XSL:
<fo:table-body>
<xsl:for-each select="inc_traumatriagecriteria">
<fo:table-row>
<fo:table-cell>
<fo:block>
<xsl:if test="contains(TraumaTriageCriteria, '(M)')">
<xsl:value-of select="text()"> </xsl:value-of>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:block>
<xsl:if test="contains(TraumaTriageCriteria, '(A)')">
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:block>
<xsl:if test="contains(TraumaTriageCriteria, '(P)')">
</xsl:if>
</fo:block>
</fo:table-cell>
with xsl:if test="contains(TraumaTriageCriteria, '(A)')" I get result like this:
| MOI | AI | PC |
===============================================================
|(M)echanism: Ejection | | |
------------------------------------------------------------------
|(M)echanism: Fatality | | |
-----------------------------------------------------------------
| |(A)natomic: Crushed |(P)hysiologic: GCS |
-------------------------------------------------------------------
but would like my table to look like this:
| MOI | AI | PC |
=================================================
|(M)echanism: Ejection |(A)natomic: Crushed |(P)hysiologic: GCS|
-------------------------------------------------
Any suggestion?

Well without looking, I see you XSL is wrong (see the comments in the following copy of your document):
</fo:block>
</fo:table-cell>
<fo:block> <-- You are inserting a block with no table cell -->
<xsl:if test="contains(TraumaTriageCriteria, '(A)')">
</xsl:if> <-- No content in this if -->
</fo:block>
</fo:table-cell> <!-- No table cell created before this end table-cell -->
<fo:block> <!-- again no table-cell here -->
<xsl:if test="contains(TraumaTriageCriteria, '(P)')">
</xsl:if> <!-- There is no content in this if -->
</fo:block>
</fo:table-cell> <!-- again no starting table-cell before this end -->
You should output your FO to a nice, parsing conforming XML editor and look at all the mistakes and correct them.

<!--TRAUMA TRIAGE-->
<xsl:if test="inc_incident/inc_situation/InjuryPresent = "Yes"">
<xsl:for-each select="inc_incident">
<fo:table start-indent="((8.5in - 0.5in - 0.5in) - 520pt) div 2" end-indent="((8.5in - 0.5in - 0.5in) - 520pt) div 2" background-color="silver" border-spacing="0" padding="0" text-align="center" width="520pt" table-layout="fixed" space-before.optimum="1pt" space-after.optimum="2pt">
<fo:table-column />
<fo:table-column />
<fo:table-column />
<fo:table-header>
<fo:table-row>
<fo:table-cell background-color="#5454A5" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" number-columns-spanned="3" text-align="center" display-align="center">
<fo:block>
<fo:inline color="white" font-family="Verdana, Arial, sans-serif" font-size="8pt" font-weight="bold">Trauma Triage</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell background-color="#eeeeee" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="center">
<fo:block>
<fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt" font-weight="bold">(M)echanism Of Injury</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell background-color="#eeeeee" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="center">
<fo:block>
<fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt" font-weight="bold">(A)natomic Injury(ies)</fo:inline>
</fo:block>
</fo:table-cell>
<fo:table-cell background-color="#eeeeee" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="center">
<fo:block>
<fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt" font-weight="bold">(P)hysiologic Criteria</fo:inline>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:for-each select="inc_traumatriagecriteria">
<fo:table-row>
<fo:table-cell background-color="white" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="start">
<fo:block>
<xsl:if test="contains(TraumaTriageCriteria, '(M)')">
<xsl:for-each select="TraumaTriageCriteria">
<fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt">
<xsl:apply-templates />
</fo:inline>
</xsl:for-each>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell background-color="white" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="start">
<fo:block>
<xsl:if test="contains(TraumaTriageCriteria, '(A)')">
<xsl:for-each select="TraumaTriageCriteria">
<fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt">
<xsl:apply-templates />
</fo:inline>
</xsl:for-each>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell background-color="white" border-style="solid" border-width="1pt" border-color="silver" padding-start="0pt" padding-end="0pt" padding-before="0pt" padding-after="0pt" display-align="center" text-align="start">
<fo:block>
<xsl:if test="contains(TraumaTriageCriteria, '(P)')">
<xsl:for-each select="TraumaTriageCriteria">
<fo:inline font-family="Verdana, Arial, sans-serif" font-size="8pt">
<xsl:apply-templates />
</fo:inline>
</xsl:for-each>
</xsl:if>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</xsl:for-each>
</xsl:if>

Related

WARNING: Content of the region-body on page 2 overflows the available area in block-progression dimension

I am generating a pdf with fop 0.95 version, the problem is that on exception code, I should capture the code, but I am getting the exception described in the title, and the pdf is not generated correctly, page 2 is not showing complete, as it should take steps 4 and 5, and the page looks broken, see the screenshot.
Please check the code where the comment "Exceptions if any" starts, the issue is somewhere there, as when the test fails, that code is called to print in the pdf report, the message and stacktrace of failure, if all tests pass this code is not called and pdf is created correctly.
I already checked these questions, but i am not able to understand what is needed to fix the issue.
Only one page is generated with XSL-FO Page-Break Problem?
Why overflow in block-progression?
Main Page - from here teststepdetails is called, where i think the issue is
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version= '2.0'>
<xsl:import href="./testrunsummary.xsl"/>
<xsl:import href="./suitesummary.xsl"/>
<xsl:import href="./summary.xsl" />
<xsl:import href="./testsummary.xsl"/>
<xsl:import href="./teststeps.xsl"/>
<xsl:import href="./teststepdetails.xsl"/>
<xsl:import href="./logreport.xsl"/>
<!-- <xsl:import href="./suitehistory.xsl"/>
<xsl:import href="./history.xsl"/>-->
<xsl:import href="./suitedetails.xsl"/>
<xsl:template match="test-run-result">
<fo:root >
<xsl:call-template name="master-set-layout"/>
<xsl:call-template name="page-sequence"/>
</fo:root>
</xsl:template>
<xsl:template name="master-set-layout">
<fo:layout-master-set>
<fo:simple-page-master master-name="Test Report"
margin-top="0.5cm" margin-bottom="0.5cm" margin-left="1cm"
margin-right="1cm">
<fo:region-body margin-top="0.5cm" margin-bottom="0.5cm" />
</fo:simple-page-master>
</fo:layout-master-set>
</xsl:template>
<xsl:template name="page-sequence">
<fo:page-sequence master-reference="Test Report">
<fo:flow flow-name="xsl-region-body">
<!-- Report title -->
<fo:block font-size="10px" text-align="center" font-family="sans-serif" color="#000080" font-weight="400">Test Run Report</fo:block>
<!-- Include run summary if more than one suite is present in results -->
<xsl:if test="count(./suite) > 1">
<xsl:call-template name="testrunsummary"/>
</xsl:if>
<!-- Suite Summary -->
<xsl:for-each select="./suite">
<xsl:variable name="verbosityType" select="#verbosity" />
<xsl:if test="contains($verbosityType,'-1-')">
<xsl:call-template name="suitesummary"/>
<!-- <xsl:call-template name="suitehistory"/> -->
</xsl:if>
<xsl:for-each select="./test">
<!-- <fo:block page-break-before="always"> -->
<xsl:if test="contains($verbosityType,'-2-')">
<xsl:call-template name="testsummary"/>
</xsl:if>
<xsl:if test="contains($verbosityType,'-4-')">
<xsl:call-template name="teststeps"/>
</xsl:if>
<xsl:if test="contains($verbosityType,'-8-') or contains($verbosityType,'-32-') or contains($verbosityType,'-64-')">
<xsl:call-template name="teststepdetails">
<xsl:with-param name="reportDetailLevel" select="$verbosityType" />
<xsl:with-param name="testStatus" select="#status" />
</xsl:call-template>
</xsl:if>
</xsl:for-each>
<xsl:if test="contains($verbosityType,'-16-')">
<xsl:call-template name="logreport"/>
</xsl:if>
</xsl:for-each>
</fo:flow>
</fo:page-sequence>
</xsl:template>
</xsl:stylesheet>
And this is the teststepdetails, please check the block with the comment "Exceptions (if any)"
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version= '2.0'>
<xsl:template name="teststepdetails">
<xsl:param name="testStatus" />
<xsl:param name="reportDetailLevel" />
<fo:block margin-top="10pt" font-size="10px"
font-family="sans-serif" text-align="center" font-weight="bold">Test Details
</fo:block>
<fo:block font-size="8px" margin-top="5pt">
<xsl:variable name="verbosityType1">
<xsl:value-of select="../../#verbosity" />
</xsl:variable>
<fo:table table-layout="fixed" width="100%"
border="0.8pt solid black" border-collapse="collapse">
<fo:table-column column-width="20px" />
<fo:table-column
column-width="proportional-column-width(1)" />
<fo:table-column column-width="120px" />
<fo:table-column column-width="60px" />
<fo:table-column column-width="60px" />
<fo:table-column column-width="70px" />
<fo:table-column column-width="40px" />
<fo:table-header>
<fo:table-row font-weight="bold"
border-bottom-style="none" >
<fo:table-cell border="0.1pt solid gray"
text-align="center" padding-top="2pt" padding-bottom="1pt"
background-color="lightgray">
<fo:block>#</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray"
text-align="center"
padding-left="5pt" padding-top="2pt" padding-bottom="1pt"
background-color="lightgray">
<fo:block>Test Step</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray"
text-align="center"
padding-left="5pt" padding-top="2pt" padding-bottom="1pt"
background-color="lightgray">
<fo:block>Test Class</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray"
text-align="center"
padding-top="2pt" padding-bottom="1pt"
background-color="lightgray">
<fo:block>Started</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray"
text-align="center"
padding-top="2pt" padding-bottom="1pt"
background-color="lightgray">
<fo:block>Finished</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray"
text-align="center"
padding-top="2pt" padding-bottom="1pt"
background-color="lightgray">
<fo:block>Duration (sec)</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray"
text-align="center" padding-top="2pt" padding-bottom="1pt"
background-color="lightgray">
<fo:block>Status</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:for-each select="./test-method">
<xsl:variable name="startDate" select="#started-at" />
<xsl:variable name="verbosityType">
<xsl:value-of select="../../#verbosity" />
</xsl:variable>
<xsl:if test="contains($verbosityType,'-8-')">
<fo:table-row keep-with-previous="always" >
<fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
padding-left="5pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
<xsl:value-of select="#sequence" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
text-align="left"
padding-left="5pt" padding-top="1pt" padding-bottom="1pt">
<fo:block font-weight="bold">
<xsl:call-template name="zero_width_space_1">
<xsl:with-param name="data" select="#name" />
</xsl:call-template>
<!-- <xsl:value-of select="#name" /> -->
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
text-align="left"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
<xsl:call-template name="zero_width_space_1">
<xsl:with-param name="data" select="#class" />
</xsl:call-template>
<!-- <xsl:text></xsl:text> <xsl:value-of select="substring(#class,string-length(#class)
- 40)" /> -->
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
text-align="left"
padding-left="1pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
<xsl:value-of select="#started-at" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
text-align="left"
padding-left="1pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
<xsl:value-of select="#finished-at" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
text-align="right"
padding-right="5pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
<xsl:value-of
select="format-number(#duration-ms div 1000, '###,###.0')" />
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray" border-top="0.4pt solid black"
text-align="left" padding-left="5pt" padding-top="1pt"
padding-bottom="1pt">
<fo:block>
<xsl:choose>
<xsl:when test="#status = 'PASS'">
<fo:block color="green">PASS</fo:block>
</xsl:when>
<xsl:when test="#status = 'SKIP'">
<fo:block color="gray">SKIP</fo:block>
</xsl:when>
<xsl:when test="#status = 'FAIL'">
<fo:block color="red">FAIL</fo:block>
</xsl:when>
</xsl:choose>
</fo:block>
</fo:table-cell>
</fo:table-row>
<!-- ALM Documentation -->
<xsl:if test="./#step">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">
Description
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
Step :
<xsl:value-of select="./#step" />
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="4"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
Expected:
<xsl:value-of select="./#expected" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<!-- Reason for Failure Message for Leonardo -->
<xsl:if test="./#failureMessage">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">
Reason for Failure
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="6"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block color="gray">
<xsl:value-of select="./#failureMessage" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<!--Performance -->
<xsl:if test="./#docLoadTime">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">
Performance: Document Complete
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block color="gray">
Time:
<xsl:value-of select="./#docLoadTime" />
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray" padding-left="2pt" padding-top="1pt"
padding-bottom="1pt">
<fo:block color="gray">
Requests:
<xsl:value-of select="./#docRequests" />
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block color="gray">
Bytes In:
<xsl:value-of select="./#docBytesIn" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<xsl:if test="./#fullLoadTime">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">
Performance: Fully Loaded
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block color="gray">
Time:
<xsl:value-of select="./#fullLoadTime" />
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray" padding-left="2pt" padding-top="1pt"
padding-bottom="1pt">
<fo:block color="gray">
Requests:
<xsl:value-of select="./#fullRequests" />
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block color="gray">
Bytes In:
<xsl:value-of select="./#fullBytesIn" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<xsl:if test="./#PerformanceVisuallyComplete">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">
Visually Complete
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="5"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block color="gray">
<xsl:value-of
select="./#PerformanceVisuallyComplete" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<xsl:if test="./#PerformanceScore">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">
Performance Score - Speed Index
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="1"
border="0.1pt solid gray" padding-left="2pt" padding-top="1pt"
padding-bottom="1pt">
<fo:block color="gray">
<xsl:value-of select="./#PerformanceScore" />
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray" padding-left="2pt" padding-top="1pt"
padding-bottom="1pt">
<fo:block font-style="italic">
Transaction Name
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block color="gray">
<xsl:value-of select="./#TransactionName" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<xsl:if test="./#Performancedetails">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">
Performance Details
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="5"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block color="gray">
<xsl:value-of select="./#Performancedetails" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<xsl:if test="./URL">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">
Description
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block color="gray">
Step :
<xsl:value-of select="./#step" />
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="4"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block color="gray">
Expected:
<xsl:value-of select="./#expected" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<!-- Parameters (if any) -->
<xsl:if test="./parameters">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">Parameters</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="5"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
<xsl:for-each select="./parameters">
<xsl:for-each select="./parameter">
<xsl:value-of select="./value" />
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:for-each>
<xsl:value-of select="./#testaddedparameter" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<!-- Request -->
<xsl:if test="./#request">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">Request</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="5"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
<xsl:value-of select="./#request" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<!-- Response Status -->
<xsl:if test="./#responseStatus">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">
Response Status
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="5"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
<xsl:value-of select="./#responseStatus" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<!-- Response -->
<xsl:if test="./#response">
<fo:table-row keep-with-previous="always" >
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray" border-bottom="solid black"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">
Response
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="5"
border="0.1pt solid gray" border-bottom="solid black"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
<xsl:value-of select="./#response" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<!-- Reporter output (if any) -->
<xsl:if test="./reporter-output">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">Output</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="5"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block font-size="8px">
<fo:table table-layout="fixed" width="100%"
margin="0pt">
<fo:table-column
column-width="proportional-column-width(1)" />
<fo:table-body>
<xsl:for-each select="./reporter-output/line">
<fo:table-row keep-with-previous="always">
<fo:table-cell border="none"
padding-left="2pt" padding-top="1pt">
<fo:block>
<xsl:value-of select="." />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<!-- Exceptions (if any) -->
<xsl:if test="./exception">
<xsl:for-each select="./exception">
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">Message</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="5"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block>
<xsl:value-of select="./message" />
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">Stack Trace</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="5"
border="0.1pt solid gray"
padding-left="2pt" padding-top="1pt" padding-bottom="1pt">
<fo:block linefeed-treatment="preserve">
<xsl:value-of select="./full-stacktrace" />
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</xsl:if>
</xsl:if>
<!-- Screenshots (if any) -->
<xsl:if test="contains($verbosityType,'-32-') or contains($verbosityType,'-64-')">
<xsl:choose>
<xsl:when test="#screenshot">
<xsl:variable name="screenshot-path"
select="#screenshot" />
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2"
border="0.1pt solid gray"
text-align="right" padding-left="2pt" padding-right="5pt"
padding-top="1pt" padding-bottom="1pt">
<fo:block font-style="italic">Screenshot</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="5"
border="0.1pt solid gray"
padding="5pt">
<fo:block>
<fo:external-graphic
display-align="center"
content-width="338px"
content-height="290px"
src="url(file:/{$screenshot-path})">
</fo:external-graphic>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:when>
<xsl:otherwise>
<fo:table-row keep-with-previous="always">
<fo:table-cell number-columns-spanned="2">
<fo:block> <!-- <xsl:value-of select="$testStatus" /> -->
</fo:block>
</fo:table-cell>
<fo:table-cell number-columns-spanned="5">
<fo:block></fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</fo:table-body>
</fo:table>
<xsl:if
test="contains($testStatus,'PASS') and not(contains($reportDetailLevel,'-8-')) and not(contains($reportDetailLevel,'-64-'))">
<fo:table>
<fo:table-column column-width="75mm" />
<fo:table-header>
<fo:table-cell>
<fo:block font-weight="bold">Screen Detail Not Available
</fo:block>
</fo:table-cell>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:if>
</fo:block>
</xsl:template>
<xsl:template name="zero_width_space_1">
<xsl:param name="data" />
<xsl:param name="counter" select="0" />
<xsl:choose>
<xsl:when test="$counter <= string-length($data)">
<xsl:value-of
select='concat(substring($data,$counter,1),"​")' />
<xsl:call-template name="zero_width_space_2">
<xsl:with-param name="data" select="$data" />
<xsl:with-param name="counter" select="$counter+1" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="zero_width_space_2">
<xsl:param name="data" />
<xsl:param name="counter" />
<xsl:value-of
select='concat(substring($data,$counter,1),"​")' />
<xsl:call-template name="zero_width_space_1">
<xsl:with-param name="data" select="$data" />
<xsl:with-param name="counter" select="$counter+1" />
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>
You are limiting the formatter's ability to break across a page because of the many <fo:table-row keep-with-previous="always">.
If you remove some of the keep-with-previous="always", you should get a different result, though I can't tell if that would completely solve your problem.
(And, as #mzjn implies, you might get a different (better) result with the latest FOP version.)
That did the trick!!! Remove the "keep-with-always" tag and also add margings "bottom,top,left,right" instead of padding

xsl:choose find the first position of elements but not the second

I would like to code an XSLT to convert an XML document to an XML-FO document, in order to generate a PDF.
This Image shows the current Output
So my Table has 3 columns. In the first 4 lines the second and third columns are merged.
My XML document looks like this:
<WS-Standards>
<tags>
<tag category = "parameters" > <!-- WS_Beer_Type -->
<tag_name>WS_Beer_TypeX</tag_name> <!-- browsename -->
<tag_number>30004</tag_number>
<datatype>Unsigned32</datatype>
<accessrights>RW</accessrights>
<names>
<name language="DE">Biersorte</name>
<name language="EN">Beer Type</name>
</names>
</tag>
</tags>
</WS-Standards>
My current XSLT document:
<?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:output method="xml" version="1.0" indent="yes"/>
<xsl:template match="WS-Standards">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master page-height="297mm" page-width="210mm"
margin="5mm 25mm 5mm 25mm" master-name="PageMaster">
<fo:region-body margin="20mm 0mm 20mm 0mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="PageMaster">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<xsl:apply-templates select="tags"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
<xsl:template match="tags">
<fo:block>
<xsl:apply-templates select="tag"/>
</fo:block>
</xsl:template>
<xsl:template match="tag">
<fo:block space-before="6pt" border-top="3pt solid green">
<fo:table>
<fo:table-column column-number="1" column-width="20%" border-style="solid"
border-width="1pt"/>
<fo:table-column column-number="2" column-width="10%" border-style="solid"
border-width="1pt"/>
<fo:table-column column-number="3" column-width="70%" border-style="solid"
border-width="1pt"/>
<fo:table-body>
<xsl:apply-templates/>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>
<xsl:template match="tag_name">
<fo:table-row>
<fo:table-cell column-number="1" border="1pt solid black">
<fo:block> Tag Name </fo:block>
</fo:table-cell>
<fo:table-cell column-number="2" number-columns-spanned="2" border="1pt solid black">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="tag_number">
<fo:table-row>
<fo:table-cell column-number="1" border="1pt solid black">
<fo:block> Tag-Nummer </fo:block>
</fo:table-cell>
<fo:table-cell column-number="2" number-columns-spanned="2" border="1pt solid black">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="datatype">
<fo:table-row>
<fo:table-cell column-number="1" border="1pt solid black">
<fo:block> Datentyp </fo:block>
</fo:table-cell>
<fo:table-cell column-number="2" number-columns-spanned="2" border="1pt solid black">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="accessrights">
<fo:table-row>
<fo:table-cell column-number="1" border="1pt solid black">
<fo:block> Zugriffsrechte </fo:block>
</fo:table-cell>
<fo:table-cell column-number="2" number-columns-spanned="2" border="1pt solid black">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
<xsl:template match="names">
<xsl:choose>
<xsl:when test="number(./name/position()) = 1">
<fo:table-row>
<fo:table-cell column-number="1" border="1pt solid black">
<fo:block> Name </fo:block>
</fo:table-cell>
<fo:table-cell column-number="2" border="1pt solid black">
<fo:block>
<xsl:value-of select="./name/#language"/>
</fo:block>
</fo:table-cell>
<fo:table-cell column-number="3" border="1pt solid black">
<fo:block>
<xsl:value-of select="./name"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:when>
<xsl:otherwise>
<fo:table-row>
<fo:table-cell column-number="1" border="1pt solid black">
<fo:block> NameXXX </fo:block>
</fo:table-cell>
<fo:table-cell column-number="2" border="1pt solid black">
<fo:block>
<xsl:value-of select="./name/#language"/>
</fo:block>
</fo:table-cell>
<fo:table-cell column-number="3" border="1pt solid black">
<fo:block>
<xsl:value-of select="./name"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="p">
<fo:block>
<xsl:apply-templates/>
</fo:block>
</xsl:template>
<xsl:template match="b">
<fo:inline font-weight="bold">
<xsl:apply-templates/>
</fo:inline>
</xsl:template>
</xsl:stylesheet>
My question is about the names element for different languages.
So the first Line in the table of the names element looks like this:
-----------------------------
|Name | DE | Biersorte |
-----------------------------
But I`m missing the second line:
-----------------------------
| | EN | beer type |
-----------------------------
What am I doing wrong with the xsl:choose->when->otherwise function?
I would be happy about a tip.
The relevant code is in a template matching names, but there is only one such element in your XSLT and so it will only be called once.
The expression number(./name/position()) = 1 in this context is simply asking "For this names element, is there a name element in position 1", which is true, and so the xsl:when gets executed.
Your code really needs to be in a block where name is selected. Try this XSLT (which also removes the code duplication).
<xsl:template match="names">
<xsl:for-each select="name">
<fo:table-row>
<fo:table-cell column-number="1" border="1pt solid black">
<fo:block>
<xsl:if test="position() = 1">Name</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell column-number="2" border="1pt solid black">
<fo:block>
<xsl:value-of select="#language"/>
</fo:block>
</fo:table-cell>
<fo:table-cell column-number="3" border="1pt solid black">
<fo:block>
<xsl:value-of select="."/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</xsl:template>

Is it possible to get a running total to display in XSLT/XSL FO?

I am trying to format a report and I have tables that will span multiple pages with various items/fees, and what i would like to do ideally is to display a running total for each page in the table footer, basically i want the sum of the values in my table from the current page back to the first page to display at the bottom. Is there any way to achieve this?
<fo:table width="100%" border-style="groove" border-width="2pt" background-repeat="repeat">
<fo:table-column column-width="5%" />
<fo:table-column column-width="60%" />
<fo:table-column column-width="5%" />
<fo:table-column column-width="7.5%" />
<fo:table-column column-width="7.5%" />
<fo:table-column column-width="7.5%" />
<fo:table-column column-width="7.5%" />
<fo:table-footer border-top-style="dashed" border-bottom-style="dashed">
<fo:table-cell display-align="center">
</fo:table-cell>
<fo:table-cell display-align="center">
<fo:block text-align="center">
Page <fo:page-number/>
<xsl:text> OF </xsl:text>
<fo:page-number-citation ref-id="end" />
</fo:block>
</fo:table-cell>
<fo:table-cell display-align="center">
</fo:table-cell>
<fo:table-cell display-align="center">
</fo:table-cell>
<fo:table-cell display-align="center">
</fo:table-cell>
<fo:table-cell display-align="center">
<fo:block text-align="end">
Page Total:
</fo:block>
</fo:table-cell>
<fo:table-cell display-align="center">
</fo:table-cell>
</fo:table-footer>
<fo:table-body>
<xsl:for-each select="/receipt_invoice/details/product_lot">
<xsl:variable name="untitled" select="." />
<fo:table-row>
<fo:table-cell border-style="solid" border-width="1pt" border-color="black" padding="2pt" background-repeat="repeat" display-align="center">
<fo:block text-align="right">
<fo:block>
<xsl:value-of select="lot/quantity" />
</fo:block>
</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" border-width="1pt" border-color="black" padding="2pt" background-repeat="repeat" display-align="center">
<fo:block>
<fo:table width="100%" border-style="none" border-width="2pt" background-repeat="repeat">
<fo:table-column/>
<fo:table-column/>
<fo:table-body>
<fo:table-row>
<fo:table-cell border-style="none" border-width="2pt" padding="2pt" background-repeat="repeat" display-align="before">
<fo:block>
<fo:block>
<xsl:value-of select="product/code" />
</fo:block>
<fo:block>
Lot Qty:
<xsl:value-of select="lot/quantity" />
</fo:block>
<fo:block>
<xsl:text>
 
</xsl:text>
</fo:block>
<fo:block>
<xsl:value-of select="lot/identifier" />
</fo:block>
<fo:block>
<xsl:value-of select="lot/lot_components/component/label" />
</fo:block>
<fo:block>
<xsl:value-of select="lot/lot_components/component/value" />
</fo:block>
</fo:block>
</fo:table-cell>
<fo:table-cell border-style="none" border-width="2pt" padding="2pt" background-repeat="repeat" display-align="before">
<fo:block>
<fo:block>
<xsl:value-of select="product/first_description" />
</fo:block>
<fo:block>
<xsl:value-of select="lot/csd/csd_line" />
</fo:block>
<fo:block>
<xsl:value-of select="lot/csd/set_description" />
</fo:block>
<fo:block>
<xsl:value-of select="lot/lot_components/component/label" />
</fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
Line Number:
<xsl:value-of select="line_number" />
</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" border-width="1pt" border-color="black" padding="2pt" background-repeat="repeat" display-align="center">
<fo:block text-align="center">
<fo:block>
<xsl:value-of select="product/unit_of_measure" />
</fo:block>
</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" border-width="1pt" border-color="black" padding="2pt" background-repeat="repeat" display-align="center">
<fo:block text-align="center">
<fo:block>
<xsl:value-of select="stock_charges/storage_rate" />
</fo:block>
</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" border-width="1pt" border-color="black" padding="2pt" background-repeat="repeat" display-align="center">
<fo:block text-align="center">
<fo:block>
<xsl:value-of select="stock_charges/storage_amount" />
</fo:block>
</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" border-width="1pt" border-color="black" padding="2pt" background-repeat="repeat" display-align="center">
<fo:block text-align="center">
<fo:block>
<xsl:value-of select="stock_charges/handling_rate" />
</fo:block>
</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" border-width="1pt" border-color="black" padding="2pt" background-repeat="repeat" display-align="center">
<fo:block text-align="center">
<fo:block>
<xsl:value-of select="stock_charges/handling_amount" />
</fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
Revision:
So I have decided to use a page footer to display the subtotal on each page, and have set up a marker in my table that simply returns the grand total just to test it out, but now what i was think was that i could try to somehow get the position in my xml file the node was taken from and use something like...
<xsl:value-of select="sum(preceding::value[the_position]"/>
Where value would actually be the name of the charge being totaled up, is this something that could work? If have been trying different things but I am uncertain of the syntax and how to return the position.
For completeness, posting the description of the solution as an answer.
If your rows are of pretty regular height, you can use sum() function over all previous nodes in your table structure as you output rows and put that running subtotal as a table/table row inside a marker for the footer of the page as a single row table. Retrieve the marker into the page footer (not the table-footer with retrieve-table-marker) using the last one on the page, then clear the marker. Careful sizing and you can get it to look just like it is a table footer and you can clear that marker at the end of the table so that it does not appear on other pages. For the table end, just output the totals.
It may not work with complex tables, especially where there are multi-line rows and keeps on those rows as the table may not reach the footer.
This overcomes two issues (1) you do not need table-markers as many FO engines do not support them (actually there are good reasons for this as they are much more problematic than you think if the content being retrieved could have a large, variable height). And (2) using table-markers can run into issues at the end of the table inside that footer where you may not want it (although you can clear the marker at the last row).

xsl fo page size / orientation

I am designing an xsl that will give a pdf output. My pdf output is in landscape format.
I can't get the landscape formatted output even i change the simple page master as follows,
Still my pdf output's height is greater than the width.
Hi mzjn, i dont have any link. attached the expected and resulted pdf outputs, also need to know how to use the border image. tried as background image for region body and failed.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
exclude-result-prefixes="fo">
<xsl:output method="xml" version="1.0" omit-xml-declaration="no"
indent="yes" />
<xsl:param name="versionParam" select="'1.0'" />
<xsl:template match="#*|node()">
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<!-- Start of page layout -->
<fo:layout-master-set>
<fo:simple-page-master master-name="A4"
page-width="8.27in" page-height="11.69in" margin-top="5mm"
margin-bottom="5mm" margin-left="5mm" margin-right="5mm"
reference-orientation="90">
<fo:region-body margin-top=".5cm" margin-bottom=".5cm"
margin-left=".5cm" margin-right=".5cm">
<xsl:if test="isPreview='true'">
<xsl:attribute name="background-image">file:///<xsl:value-of
select="pdfimagepath" />Preview Only1.JPG</xsl:attribute>
</xsl:if>
</fo:region-body>
<fo:region-before extent="0mm" />
<fo:region-after extent="0mm" />
</fo:simple-page-master>
</fo:layout-master-set>
<!-- End of page layout -->
<fo:page-sequence master-reference="A4">
<fo:static-content flow-name="xsl-region-before">
<fo:block>
<fo:leader></fo:leader>
</fo:block>
<fo:block text-align="right" font-size="9pt" font-weight="bold">
<xsl:value-of select="num" />
</fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after">
<fo:block font-size="9pt" font-family="times" text-align="left">
<xsl:value-of select="xxx" />
</fo:block>
</fo:static-content>
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:table table-layout="fixed" width="100%">
<fo:table-header>
<fo:table-row>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell width="100%">
<fo:block text-align="center" padding-top="2pt">
<fo:external-graphic content-height="85%"
content-width="65%" scaling="uniform">
<xsl:attribute name="src">
<xsl:value-of select="pdfimagepath" />LogoCert.jpg
</xsl:attribute>
</fo:external-graphic>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell width="100%">
<fo:block text-align="center">
<fo:external-graphic content-height="45%"
content-width="55%" scaling="non-uniform">
<xsl:attribute name="src">
<xsl:value-of select="pdfimagepath" />title.jpg
</xsl:attribute>
</fo:external-graphic>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell width="100%">
<fo:block font-size="15.5pt" font-family="Arial"
color="Black" text-align="center" padding-before="5pt"
start-indent="10pt">
</fo:block>
<fo:block font-size="15.5pt" font-family="Arial"
color="Black" text-align="center" start-indent="5pt">xxxxxx:
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell width="100%">
<fo:block font-size="16.5pt" font-family="Arial"
color="red" text-align="center" padding-before="8pt">
<xsl:value-of select="custname" />
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell width="100%">
<fo:block font-size="13.5pt" font-family="Arial"
color="black" text-align="center" padding-before="10pt"
start-indent="10pt">
<fo:inline background-color="yellow">xxxx</fo:inline>xxxx
</fo:block>
<fo:block font-size="13.5pt" font-family="Arial"
color="black" text-align="center" start-indent="10pt"> xxxx
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding-start="140pt" padding-end="140pt">
<fo:block font-size="10pt" font-family="Arial" color="black"
text-align="center" border-bottom="solid">
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell display-align="after"
padding-after="12pt" padding-before="2pt">
<fo:block font-size="15.5pt" font-family="Arial"
color="black" text-align="center"> xxxx
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding-start="160pt" padding-end="160pt">
<fo:block font-size="10pt" font-family="Arial" color="black"
text-align="center" border-bottom="solid">
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding-before="2pt"
display-align="before">
<fo:block font-size="15.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding-before="10pt">
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center"> xxxx
</fo:block>
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
<fo:block font-size="8.5pt" font-family="Arial"
color="black" text-align="center">
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell padding-before="5pt"
padding-start="60pt" padding-end="60pt">
<fo:block font-size="20pt" font-family="Arial" color="black"
text-align="center" border-bottom="solid">
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table table-layout="fixed" width="100%">
<fo:table-column column-width="40%" />
<fo:table-column column-width="60%" />
<fo:table-header>
<fo:table-row>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell padding-before="5pt">
<fo:block font-size="9.5pt" text-align="left"
font-weight="normal">
</fo:block>
</fo:table-cell>
<fo:table-cell padding-before="5pt">
<fo:block font-size="9.5pt" text-align="center">
</fo:block>
<fo:block font-size="9.5pt" text-align="center"
end-indent="10pt">
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<fo:table table-layout="fixed" width="100%">
<fo:table-column column-width="50%" />
<fo:table-column column-width="50%" />
<fo:table-header>
<fo:table-row>
<fo:table-cell>
<fo:block></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell padding-before="5pt"
display-align="after" border="">
<fo:block font-size="10pt" text-align="left"
font-weight="normal">
</fo:block>
<fo:block font-size="13.5pt" text-align="center"
font-weight="normal">
</fo:block>
</fo:table-cell>
<fo:table-cell padding-before="5pt"
display-align="after" border="">
<fo:block text-align="center">
<fo:external-graphic content-height="60%"
content-width="40%" scaling="uniform">
<xsl:attribute name="src">
<xsl:value-of select="pdfimagepath" />sign.jpg
</xsl:attribute>
</fo:external-graphic>
</fo:block>
<fo:block padding-bottom="1pt" font-size="15pt"
text-align="center" font-weight="bold">
_____________________________
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell display-align="after" border="">
<fo:block font-size="8pt" text-align="left"
font-weight="normal">
</fo:block>
</fo:table-cell>
<fo:table-cell display-align="after" border=""
padding-before="1pt">
<fo:block font-size="8.5pt" text-align="center"
font-weight="normal">xxxxx
</fo:block>
<fo:block font-size="8.5pt" text-align="center"
font-weight="normal">yyyyy
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
code sample attached
I am using Apache FOP 1.1.First you should define layout of landscape(A2).For Example
<fo:layout-master-set>
<fo:simple-page-master master-name="A2"
page-height="594mm" page-width="420mm" margin-left="0.2cm"
margin-right="0.2cm">
<fo:region-body margin-top="0.5cm" />
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A2">
<fo:flow flow-name="xsl-region-body">
**//your design and logic**
</fo:flow>
</fo:page-sequence>
Thank you.
I'm not sure how to set the background, but below is how I was able to change the page width and height to result in landscape orientation.
I'm editing xsl files for PDF2 that came with the DITA open toolkit. I'm not sure if the filename will be the same, but I found the below chunk of code in layout-masters-attr.xsl. Notice I switched the page-width and page-height variables.
<xsl-attribute-set name="simple-page-master">
<xsl-attribute name="page-width">
<xsl:value-of select="$page-height"/>
</xsl:attribute>
<xsl:attribute name="page-height">
<xsl:value-of select="$page-width"/>
</xsl:attribute>
</xsl:attribute-set>
This will set the entire PDF document to landscape mode. Also, you can find where the variables are defined and change them to other values, if desired.

xsl:for-each Split Records

I'm not sure if this is even possible but here we go.
I have an xml file:
<ROOT>
<MEM-STMT>
<COUNTRY>co</COUNTRY>
<CURRENCY>cu</CURRENCY>
<STMT>
<ST-NO>1</ST-NO>
<ST-DATE>21-JUL-11</ST-DATE>
<CC>21</CC>
<YY>11</YY>
<MM>07</MM>
<DD>21</DD>
</STMT>
<MEM-DET>
<MEM-NO>9</MEM-NO>
<MEM-PROD-LEV>24</MEM-PROD-LEV>
<MEM-OPTION>option</MEM-OPTION>
<MEM-EMP-NO/>
<MEM-EMP-NAME>name</MEM-EMP-NAME>
</MEM-DET>
<MEM-ADDR>
<MEM-NAME>name</MEM-NAME>
<MEM-ADDR1> Addr1</MEM-ADDR1>
<MEM-ADDR2> Addr2</MEM-ADDR2>
<MEM-ADDR3> Addr3</MEM-ADDR3>
<MEM-SUB> Sub</MEM-SUB>
<MEM-CITY> +2</MEM-CITY>
<MEM-REG> Employer:reg</MEM-REG>
<MEM-CNTRY/>
<MEM-PCODE/>
<MEM-EMPCODE/>
</MEM-ADDR>
<ACC>
<PROV>
<PR-NO>1</PR-NO>
<PR-NAME> pr</PR-NAME>
<REF-NO>1</REF-NO>
<CLM>
<REF>1</REF>
<CL-DEP-NO>04</CL-DEP-NO>
<CL-DEP-NAME>dep</CL-DEP-NAME>
<CL-DOS>10-APR-11</CL-DOS>
<CC>21</CC>
<YY>11</YY>
<MM>04</MM>
<DD>10</DD>
<CL-TAR-DRUG-CD>1 </CL-TAR-DRUG-CD>
<CL-TAR-DRUG-DESC>desc </CL-TAR-DRUG-DESC>
<CL-NO>1</CL-NO>
<CL-LINE>2</CL-LINE>
<CL-AMT>16.8</CL-AMT>
<CL-TAR-AMT>16.8</CL-TAR-AMT>
<CL-PAID-PROV>16.8</CL-PAID-PROV>
<CL-PAID-MEM>0</CL-PAID-MEM>
<CL-RSN/>
</CLM>
<CLM>
<REF>1</REF>
<CL-DEP-NO>04</CL-DEP-NO>
<CL-DEP-NAME>dep </CL-DEP-NAME>
<CL-DOS>20-APR-11</CL-DOS>
<CC>21</CC>
<YY>11</YY>
<MM>04</MM>
<DD>20</DD>
<CL-TAR-DRUG-CD>1 </CL-TAR-DRUG-CD>
<CL-TAR-DRUG-DESC>desc </CL-TAR-DRUG-DESC>
<CL-NO>1</CL-NO>
<CL-LINE>2</CL-LINE>
<CL-AMT>50.4</CL-AMT>
<CL-TAR-AMT>50.4</CL-TAR-AMT>
<CL-PAID-PROV>50.4</CL-PAID-PROV>
<CL-PAID-MEM>0</CL-PAID-MEM>
<CL-RSN/>
</CLM>
<TOTALS>
<TOT-AMT>67.2</TOT-AMT>
<TOT-TAR-AMT>67.2</TOT-TAR-AMT>
<TOT-PAID-PROV>67.2</TOT-PAID-PROV>
<TOT-PAID-MEM>0</TOT-PAID-MEM>
</TOTALS>
</PROV>
<PROV>
<PR-NO>2</PR-NO>
<PR-NAME> pr</PR-NAME>
<REF-NO>1</REF-NO>
<CLM>
<REF>1</REF>
<CL-DEP-NO>04</CL-DEP-NO>
<CL-DEP-NAME>dep</CL-DEP-NAME>
<CL-DOS>10-APR-11</CL-DOS>
<CC>21</CC>
<YY>11</YY>
<MM>04</MM>
<DD>10</DD>
<CL-TAR-DRUG-CD>1</CL-TAR-DRUG-CD>
<CL-TAR-DRUG-DESC>desc </CL-TAR-DRUG-DESC>
<CL-NO>1</CL-NO>
<CL-LINE>2</CL-LINE>
<CL-AMT>15</CL-AMT>
<CL-TAR-AMT>0</CL-TAR-AMT>
<CL-PAID-PROV>15</CL-PAID-PROV>
<CL-PAID-MEM>0</CL-PAID-MEM>
<CL-RSN/>
</CLM>
<TOTALS>
<TOT-AMT>15</TOT-AMT>
<TOT-TAR-AMT>0</TOT-TAR-AMT>
<TOT-PAID-PROV>15</TOT-PAID-PROV>
<TOT-PAID-MEM>0</TOT-PAID-MEM>
</TOTALS>
</PROV>
<PROV>
<PR-NO>1</PR-NO>
<PR-NAME> pr</PR-NAME>
<REF-NO>I0428202</REF-NO>
<CLM>
<REF>I0428202</REF>
<CL-DEP-NO>03</CL-DEP-NO>
<CL-DEP-NAME>dep</CL-DEP-NAME>
<CL-DOS>10-APR-11</CL-DOS>
<CC>21</CC>
<YY>11</YY>
<MM>04</MM>
<DD>10</DD>
<CL-TAR-DRUG-CD>2</CL-TAR-DRUG-CD>
<CL-TAR-DRUG-DESC>desc</CL-TAR-DRUG-DESC>
<CL-NO>112153</CL-NO>
<CL-LINE>217615</CL-LINE>
<CL-AMT>31.58</CL-AMT>
<CL-TAR-AMT>0</CL-TAR-AMT>
<CL-PAID-PROV>31.58</CL-PAID-PROV>
<CL-PAID-MEM>0</CL-PAID-MEM>
<CL-RSN/>
</CLM>
<TOTALS>
<TOT-AMT>31.58</TOT-AMT>
<TOT-TAR-AMT>0</TOT-TAR-AMT>
<TOT-PAID-PROV>31.58</TOT-PAID-PROV>
<TOT-PAID-MEM>0</TOT-PAID-MEM>
</TOTALS>
</PROV>
<PROV>
<PR-NO>1</PR-NO>
<PR-NAME> pr</PR-NAME>
<REF-NO>0027579</REF-NO>
<CLM>
<REF>1</REF>
<CL-DEP-NO>04</CL-DEP-NO>
<CL-DEP-NAME>dep</CL-DEP-NAME>
<CL-DOS>09-JUN-11</CL-DOS>
<CC>21</CC>
<YY>11</YY>
<MM>06</MM>
<DD>09</DD>
<CL-TAR-DRUG-CD>99200 </CL-TAR-DRUG-CD>
<CL-TAR-DRUG-DESC>desc</CL-TAR-DRUG-DESC>
<CL-NO>1</CL-NO>
<CL-LINE>1</CL-LINE>
<CL-AMT>12</CL-AMT>
<CL-TAR-AMT>0</CL-TAR-AMT>
<CL-PAID-PROV>12</CL-PAID-PROV>
<CL-PAID-MEM>0</CL-PAID-MEM>
<CL-RSN/>
</CLM>
<TOTALS>
<TOT-AMT>12</TOT-AMT>
<TOT-TAR-AMT>0</TOT-TAR-AMT>
<TOT-PAID-PROV>12</TOT-PAID-PROV>
<TOT-PAID-MEM>0</TOT-PAID-MEM>
</TOTALS>
</PROV>
</ACC>
<RSN-LIST>
<RSN-ERR>????</RSN-ERR>
<RSN-DESC/>
</RSN-LIST>
<FIN-OTHER>
<FIN-DATE/>
<FIN-AMT>0</FIN-AMT>
<FIN-TT/>
</FIN-OTHER>
<GTOTALS>
<GTOT-AMT>125.78</GTOT-AMT>
<GTOT-TAR-AMT>67.2</GTOT-TAR-AMT>
<GTOT-PAID-PROV>125.78</GTOT-PAID-PROV>
<GTOT-PAID-MEM>0</GTOT-PAID-MEM>
</GTOTALS>
<MEM-GTOT>
<M-MESSAGE/>
<M-TOT-PAID-MEM>0</M-TOT-PAID-MEM>
<M-PMT-METH/>
</MEM-GTOT>
<FIN-BAL>
<FIN-BDATE>21-JUL-11</FIN-BDATE>
<FIN-BAMT>0</FIN-BAMT>
<FIN-BTT/>
</FIN-BAL>
</MEM-STMT>
</ROOT>
& I'd like to split the records returned from it using the logic below:
If the xml file has 30 or more PROV-or-CLM-or-TOTATALS nodes then process only 30 PROV-or-CLM-or-TOTATALS nodes. Do this for the entire xml file in case where the number of remaining nodes is less than 30 process them to complete the transformation.
I'm using the following xsl to do this:
<xsl:template name="PROVIDER">
<fo:page-sequence master-reference="global">
<fo:flow flow-name="xsl-region-body">
<fo:wrapper font-size="7pt" font-family="Helvetica">
<fo:block-container >
<xsl:variable name="CURRENCYSYMBOL"><xsl:value-of select="ROOT/MEM-STMT/CURRENCY"/></xsl:variable>
<xsl:for-each select="ROOT/MEM-STMT/ACC/PROV">
<xsl:if test="(position() mod 30 = 1)">
<fo:block >
<fo:table table-layout="fixed" width="190mm" border-style="solid">
<fo:table-column column-width="22mm"/>
<fo:table-column column-width="16mm"/>
<fo:table-column column-width="18mm"/>
<fo:table-column column-width="39mm"/>
<!-- <fo:table-column column-width="15mm"/> -->
<fo:table-column column-width="20mm"/>
<fo:table-column column-width="20mm"/>
<fo:table-column column-width="20mm"/>
<fo:table-column column-width="20mm"/>
<fo:table-column column-width="15mm"/>
<fo:table-header border="solid" >
<fo:table-row border-style="solid">
<fo:table-cell background-color="{$HeaderGray}" number-columns-spanned="9" padding="2pt">
<fo:block font-size="7pt" text-align="left" font-weight="bold">Provider:
<xsl:value-of select="PR-NO"/>-
<xsl:value-of select="PR-NAME"/>
<xsl:text>  </xsl:text> Ref No:
<xsl:value-of select="REF-NO"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row border-style="solid">
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold">Patient</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold">Serv Date</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold">Tariff/Drug</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold">Description</fo:block>
</fo:table-cell>
<!-- <fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold">Claim No</fo:block>
</fo:table-cell> -->
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold">Claim Amount</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold">Tariff Amount</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold">Paid Provider</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold">Paid Member</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold">Reason</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<xsl:for-each select="./CLM">
<xsl:if test="(position() mod 30 = 1)">
<fo:table-body font-size="7pt">
<fo:table-row>
<fo:table-cell padding="2pt" >
<fo:block>
<xsl:value-of select="CL-DEP-NAME"/><xsl:text>  </xsl:text>
<xsl:value-of select="CL-DEP-NO"/>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt" >
<fo:block>
<xsl:value-of select="CL-DOS"/>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt" >
<fo:block>
<xsl:value-of select="CL-TAR-DRUG-CD"/>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt" >
<fo:block>
<xsl:value-of select="CL-TAR-DRUG-DESC"/>
</fo:block>
</fo:table-cell>
<!-- <fo:table-cell padding="2pt">
<fo:block>
<xsl:value-of select="CL-NO"/>
</fo:block>
</fo:table-cell> -->
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<xsl:if test="CL-AMT != '0'">
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of select="format-number(CL-AMT,'#,##0.00')"/>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<xsl:if test="CL-TAR-AMT != '0'">
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of select="format-number(CL-TAR-AMT,'#,##0.00')"/>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt" >
<fo:block text-align="right">
<xsl:if test="CL-PAID-PROV != '0'">
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of select="format-number(CL-PAID-PROV,'#,##0.00')"/>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<xsl:if test="CL-PAID-MEM != '0'">
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of select="format-number(CL-PAID-MEM,'#,##0.00')"/>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<xsl:if test="CL-RSN != '????'">
<xsl:value-of select="CL-RSN"/>
</xsl:if>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</xsl:if>
</xsl:for-each>
<xsl:for-each select="./TOTALS">
<xsl:if test="(position() mod 30 = 1)">
<fo:table-body font-size="7pt">
<fo:table-row border-style="solid">
<fo:table-cell padding="2pt" number-columns-spanned="4" >
<fo:block >Totals for Invoice</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt" >
<fo:block text-align="right">
<!-- <xsl:if test="TOT-AMT != '0'"> -->
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of select="format-number(TOT-AMT,'#,##0.00')"/>
<!-- </xsl:if> -->
</fo:block>
</fo:table-cell >
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<!-- <xsl:if test="TOT-TAR-AMT != '0'"> -->
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of select="format-number(TOT-TAR-AMT,'#,##0.00')"/>
<!-- </xsl:if> -->
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<!-- <xsl:if test="TOT-PAID-PROV != '0'"> -->
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of select="format-number(TOT-PAID-PROV,'#,##0.00')"/>
<!-- </xsl:if> -->
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<!-- <xsl:if test="TOT-PAID-MEM != '0'"> -->
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of select="format-number(TOT-PAID-MEM,'#,##0.00')"/>
<!-- </xsl:if> -->
</fo:block>
</fo:table-cell>
<fo:table-cell >
<fo:block>
</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</xsl:if>
</xsl:for-each>
</fo:table>
</fo:block>
</xsl:if>
</xsl:for-each>
</fo:block-container>
</fo:wrapper>
</fo:flow>
</fo:page-sequence>
My current scenario is such that the split doesn't work & I get the exception: Exception in thread "AWT-EventQueue-2" java.lang.OutOfMemoryError: Java heap space despite allocating -Xms/-Xmx2G memory.
Kamza, you had part of it right, but there are a few flaws in your approach. You start with a for-each on PROV elements, and within the for-each you have an if that causes output to be written only for PROV elements 1, 31, 61, etc. The nested for-each loops have a similar problem. Only CLM element 1, 31, 61, .. is written, like only TOTALS 1, 31, 61, ..
(Actually, I suspect there will only be one TOTALS within each PROV, so that would ok in your code.)
Furthermore, from what I understand from your description and the comments is that you are trying to write out 30 rows at a time, and start a new table, or even a new page after that, with another 30 rows, or what is left. Since no rows are written for the PROV element itself, I presume that it is just about CLM and TOTALS rows, where the count of 30 should include both.
What you need for that is an outer for-each loop that walks along all CLM and TOTALS elements. You can use this expression for that:
<xsl:for-each select="ROOT/MEM-STMT/ACC/PROV/*[self::CLM or self::TOTALS]">
Then use the if you already have to create a new table for row 1, 31, 61, ...
To fill the table with the first-next 30 items, you will need to look forward 30 positions. The PROV element is a bit of a problem here. Assuming CLM and TOTALS only occur within PROV, and PROV is not used elsewhere, you can reasonably safely use the following axis for that:
<xsl:for-each select="(following::*[self::CLM or self::TOTALS])[30 >= position()]">
That returns 30 items, both CLM and TOTALS mixed, but in document order. You need two extra if's (or a choose) to distinguish between these two, and output the appropriate table row:
<xsl:if test="self::CLM">
...
</xsl:if>
<xsl:if test="self::TOTALS">
...
</xsl:if>
In your code you have fo:table-body within the inner for-each loops, causing each table-row to be wrapped in a new table-body. That is unnecessary. Move the table-body to outside the inner loops. You would need only one wrapping both rows of CLM and TOTALS.
Finally, you write a new table for each 30th item. I think you want to start a new page-sequence as well. That will cause each table to be shown on a separate page. Putting things together, you get an XSLT similar to this:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:variable name="HeaderGray" select="'gray'"/>
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="global">
<fo:region-body/>
</fo:simple-page-master>
</fo:layout-master-set>
<xsl:apply-templates select="/" mode="PROVIDER"/>
</fo:root>
</xsl:template>
<xsl:template match="/" mode="PROVIDER">
<xsl:variable name="CURRENCYSYMBOL" select="string(ROOT/MEM-STMT/CURRENCY)"/>
<xsl:for-each select="ROOT/MEM-STMT/ACC/PROV/*[self::CLM or self::TOTALS]">
<xsl:if test="position() mod 30 = 1">
<fo:page-sequence master-reference="global">
<fo:flow flow-name="xsl-region-body">
<fo:wrapper font-size="7pt" font-family="Helvetica">
<fo:block-container>
<fo:block>
<fo:table table-layout="fixed" width="190mm"
border-style="solid">
<fo:table-column column-width="22mm"/>
<fo:table-column column-width="16mm"/>
<fo:table-column column-width="18mm"/>
<fo:table-column column-width="39mm"/>
<!-- <fo:table-column column-width="15mm"/> -->
<fo:table-column column-width="20mm"/>
<fo:table-column column-width="20mm"/>
<fo:table-column column-width="20mm"/>
<fo:table-column column-width="20mm"/>
<fo:table-column column-width="15mm"/>
<fo:table-header border="solid">
<fo:table-row border-style="solid">
<fo:table-cell background-color="{$HeaderGray}"
number-columns-spanned="9" padding="2pt">
<fo:block font-size="7pt" text-align="left"
font-weight="bold">Provider: <xsl:value-of
select="PR-NO"/>- <xsl:value-of select="PR-NAME"/>
<xsl:text>  </xsl:text> Ref No:
<xsl:value-of select="REF-NO"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row border-style="solid">
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold"
>Patient</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold"
>Serv Date</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold"
>Tariff/Drug</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold"
>Description</fo:block>
</fo:table-cell>
<!-- <fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold">Claim No</fo:block>
</fo:table-cell> -->
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold"
>Claim Amount</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold"
>Tariff Amount</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold"
>Paid Provider</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold"
>Paid Member</fo:block>
</fo:table-cell>
<fo:table-cell border-style="solid" padding="2pt">
<fo:block text-align="center" font-weight="bold"
>Reason</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body font-size="7pt">
<xsl:for-each
select="(following::*[self::CLM or self::TOTALS])[30 >= position()]">
<xsl:if test="self::CLM">
<fo:table-row>
<fo:table-cell padding="2pt">
<fo:block>
<xsl:value-of select="CL-DEP-NAME"/>
<xsl:text>  </xsl:text>
<xsl:value-of select="CL-DEP-NO"/>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block>
<xsl:value-of select="CL-DOS"/>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block>
<xsl:value-of select="CL-TAR-DRUG-CD"/>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block>
<xsl:value-of select="CL-TAR-DRUG-DESC"/>
</fo:block>
</fo:table-cell>
<!-- <fo:table-cell padding="2pt">
<fo:block>
<xsl:value-of select="CL-NO"/>
</fo:block>
</fo:table-cell> -->
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<xsl:if test="CL-AMT != '0'">
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of
select="format-number(CL-AMT,'#,##0.00')"/>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<xsl:if test="CL-TAR-AMT != '0'">
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of
select="format-number(CL-TAR-AMT,'#,##0.00')"/>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<xsl:if test="CL-PAID-PROV != '0'">
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of
select="format-number(CL-PAID-PROV,'#,##0.00')"/>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<xsl:if test="CL-PAID-MEM != '0'">
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of
select="format-number(CL-PAID-MEM,'#,##0.00')"/>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<xsl:if test="CL-RSN != '????'">
<xsl:value-of select="CL-RSN"/>
</xsl:if>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<xsl:if test="self::TOTALS">
<fo:table-row border-style="solid">
<fo:table-cell padding="2pt"
number-columns-spanned="4">
<fo:block>Totals for Invoice</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<!-- <xsl:if test="TOT-AMT != '0'"> -->
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of
select="format-number(TOT-AMT,'#,##0.00')"/>
<!-- </xsl:if> -->
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<!-- <xsl:if test="TOT-TAR-AMT != '0'"> -->
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of
select="format-number(TOT-TAR-AMT,'#,##0.00')"/>
<!-- </xsl:if> -->
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<!-- <xsl:if test="TOT-PAID-PROV != '0'"> -->
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of
select="format-number(TOT-PAID-PROV,'#,##0.00')"/>
<!-- </xsl:if> -->
</fo:block>
</fo:table-cell>
<fo:table-cell padding="2pt">
<fo:block text-align="right">
<!-- <xsl:if test="TOT-PAID-MEM != '0'"> -->
<xsl:value-of select="$CURRENCYSYMBOL"/>
<xsl:value-of
select="format-number(TOT-PAID-MEM,'#,##0.00')"/>
<!-- </xsl:if> -->
</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block> </fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</fo:block-container>
</fo:wrapper>
</fo:flow>
</fo:page-sequence>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Note: I am not entirely convinced this will prevent you from getting an exception. You gave the impression it is because of your for-each loops, but it may be caused by something else. A table that is simply to big, or an fo document that is too large to render might be the cause as well, for instance. The above code should be fairly efficient. If it is still giving you trouble, try processing things from the command-line, perhaps even using different parsers.
hm.. I don't have time to look at your xslt in detail, but your logic should be possible using something like this:
<xsl:template match="(//PROV | //CLM | //TOTALS)[position() <= 30]">
<xsl:if test="local-name() = 'PROV'">
<!-- do stuff with PROV node -->
</xsl:if>
<xsl:if test="local-name() = 'CLM'">
<!-- do stuff with CLM node -->
</xsl:if>
<xsl:if test="local-name() = 'TOTALS'">
<!-- do stuff with TOTALS node -->
</xsl:if>
</xsl:template>
You could modify your xsl:for-each statements, to restrict them to the first 30 items:
<xsl:for-each select="ROOT/MEM-STMT/ACC/PROV[position()<=30]">
Or you could extract the xsl:for-each logic out into templates and then select only the first 30 to apply templates to:
<xsl:apply-templates select="ROOT/MEM-STMT/ACC/PROV[position()<=30]"/>