XSL-FO Document: Inserting a break-before=“page” attribute in a concrete fo:table-row











up vote
0
down vote

favorite












I have an XSL-FO document. This document has a lot of fo:table nested.
There is an inner fo:table that has 9 columns and a lot of rows, in this example, first row for table header and other rows, from 1 to 20 for content. In the example below you can see that as a comment, for each FOPTable (fo:table) it is indicated a unique identifier, but this identifier is not always the same for the same table. It is generated randomly by the application that creates this XSL-FO document.



My question is: I want to find the table which has its first column header value set to HEADER_COL1 (this value is always the same), in this example, table identified with id:997 (rember that I cannot search for table according to this identifier since it changes randomly each time application creates the XSL-FO document). Once I have found the desired table I want below:




  1. How can I insert an attribute break-before="page" for a concrete
    fo:table-row item?

  2. I want to get the number of rows that this inner table has.


For example:



For example, If I want to insert this attribute for the 15th fo:table-row item, how can I do this? I want a parametrized generic method that take as an argument a number indicating the fo:table-row where to put this attribute.



I know that I can read the XSL-FO document using below:



string xmlFile = File.ReadAllText(@"C:TempMyXSLFO.xml");
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(xmlFile);


But once loaded i have no idea on how to do this.



Note: I am using Visual Studio 2008, C# and .NET 3.5.



<?xml version="1.0" encoding="ISO-8859-1" ?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<!-- begin table FOPTable { id: 987 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:4 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<!-- endof table id FOPTable { id: 987 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 5 flow:FOPFlow: { type: BodyFlow size:4 region:FOPRegion: { type:3 extent:0.0}} }
-->
<!-- begin table FOPTable { id: 992 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:3 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<!-- endof table id FOPTable { id: 992 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 4 flow:FOPFlow: { type: BodyFlow size:3 region:FOPRegion: { type:3 extent:0.0}} }
-->
<!-- begin table FOPTable { id: 995 cur_size: 28.7 prv_size: 0.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:2 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">

<!-- begin table FOPTable { id: 996 cur_size: 0.0 prv_size: 20.41 prev: 995 cols: 1 locks: 2 flow:null }
-->
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">

<!-- begin table FOPTable { id: 997 cur_size: 0.0 prv_size: 20.409999999999997 prev: 996 cols: 9 locks: 5 flow:null }
-->
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="4.709999999999996cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="3.9cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL1_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL2_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL3_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL4_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL5_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL6_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-right="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block text-align="end">ROW1_COL7_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL8_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL9_VALUE</fo:block>
</fo:table-cell>
</fo:table-row>


<!-- A LOT OF ROWS HERE -->

<!-- I want to insert a break-before attribute as below -->
<fo:table-row break-before="page">
<!-- columns here -->
</fo:table-row>

<!-- MORE ROWS HERE -->

<!-- LAST ROW NEXT -->
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL1_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL2_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL3_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL4_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL5_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL6_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-right="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block text-align="end">ROW20_COL7_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL8_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL9_VALUE</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- endof table id FOPTable { id: 997 cur_size: 28.7 prv_size: 20.409999999999997 prev: 996 cols: 9 locks: 6 flow:null }
-->
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>









share|improve this question
























  • I would use XSLT. Since you're using VS2008, see w3.org/TR/1999/REC-xslt-19991116. You could make a template for your context that adds the attribute for the property, and make an identity template that copies the rest of the document to the result tree.
    – Tony Graham
    Nov 12 at 21:58










  • It seems overly complicated to nest tables 3 levels deep. Is this really necessary?
    – Hobbes
    Nov 15 at 8:39















up vote
0
down vote

favorite












I have an XSL-FO document. This document has a lot of fo:table nested.
There is an inner fo:table that has 9 columns and a lot of rows, in this example, first row for table header and other rows, from 1 to 20 for content. In the example below you can see that as a comment, for each FOPTable (fo:table) it is indicated a unique identifier, but this identifier is not always the same for the same table. It is generated randomly by the application that creates this XSL-FO document.



My question is: I want to find the table which has its first column header value set to HEADER_COL1 (this value is always the same), in this example, table identified with id:997 (rember that I cannot search for table according to this identifier since it changes randomly each time application creates the XSL-FO document). Once I have found the desired table I want below:




  1. How can I insert an attribute break-before="page" for a concrete
    fo:table-row item?

  2. I want to get the number of rows that this inner table has.


For example:



For example, If I want to insert this attribute for the 15th fo:table-row item, how can I do this? I want a parametrized generic method that take as an argument a number indicating the fo:table-row where to put this attribute.



I know that I can read the XSL-FO document using below:



string xmlFile = File.ReadAllText(@"C:TempMyXSLFO.xml");
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(xmlFile);


But once loaded i have no idea on how to do this.



Note: I am using Visual Studio 2008, C# and .NET 3.5.



<?xml version="1.0" encoding="ISO-8859-1" ?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<!-- begin table FOPTable { id: 987 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:4 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<!-- endof table id FOPTable { id: 987 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 5 flow:FOPFlow: { type: BodyFlow size:4 region:FOPRegion: { type:3 extent:0.0}} }
-->
<!-- begin table FOPTable { id: 992 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:3 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<!-- endof table id FOPTable { id: 992 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 4 flow:FOPFlow: { type: BodyFlow size:3 region:FOPRegion: { type:3 extent:0.0}} }
-->
<!-- begin table FOPTable { id: 995 cur_size: 28.7 prv_size: 0.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:2 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">

<!-- begin table FOPTable { id: 996 cur_size: 0.0 prv_size: 20.41 prev: 995 cols: 1 locks: 2 flow:null }
-->
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">

<!-- begin table FOPTable { id: 997 cur_size: 0.0 prv_size: 20.409999999999997 prev: 996 cols: 9 locks: 5 flow:null }
-->
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="4.709999999999996cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="3.9cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL1_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL2_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL3_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL4_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL5_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL6_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-right="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block text-align="end">ROW1_COL7_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL8_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL9_VALUE</fo:block>
</fo:table-cell>
</fo:table-row>


<!-- A LOT OF ROWS HERE -->

<!-- I want to insert a break-before attribute as below -->
<fo:table-row break-before="page">
<!-- columns here -->
</fo:table-row>

<!-- MORE ROWS HERE -->

<!-- LAST ROW NEXT -->
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL1_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL2_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL3_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL4_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL5_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL6_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-right="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block text-align="end">ROW20_COL7_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL8_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL9_VALUE</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- endof table id FOPTable { id: 997 cur_size: 28.7 prv_size: 20.409999999999997 prev: 996 cols: 9 locks: 6 flow:null }
-->
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>









share|improve this question
























  • I would use XSLT. Since you're using VS2008, see w3.org/TR/1999/REC-xslt-19991116. You could make a template for your context that adds the attribute for the property, and make an identity template that copies the rest of the document to the result tree.
    – Tony Graham
    Nov 12 at 21:58










  • It seems overly complicated to nest tables 3 levels deep. Is this really necessary?
    – Hobbes
    Nov 15 at 8:39













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have an XSL-FO document. This document has a lot of fo:table nested.
There is an inner fo:table that has 9 columns and a lot of rows, in this example, first row for table header and other rows, from 1 to 20 for content. In the example below you can see that as a comment, for each FOPTable (fo:table) it is indicated a unique identifier, but this identifier is not always the same for the same table. It is generated randomly by the application that creates this XSL-FO document.



My question is: I want to find the table which has its first column header value set to HEADER_COL1 (this value is always the same), in this example, table identified with id:997 (rember that I cannot search for table according to this identifier since it changes randomly each time application creates the XSL-FO document). Once I have found the desired table I want below:




  1. How can I insert an attribute break-before="page" for a concrete
    fo:table-row item?

  2. I want to get the number of rows that this inner table has.


For example:



For example, If I want to insert this attribute for the 15th fo:table-row item, how can I do this? I want a parametrized generic method that take as an argument a number indicating the fo:table-row where to put this attribute.



I know that I can read the XSL-FO document using below:



string xmlFile = File.ReadAllText(@"C:TempMyXSLFO.xml");
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(xmlFile);


But once loaded i have no idea on how to do this.



Note: I am using Visual Studio 2008, C# and .NET 3.5.



<?xml version="1.0" encoding="ISO-8859-1" ?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<!-- begin table FOPTable { id: 987 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:4 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<!-- endof table id FOPTable { id: 987 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 5 flow:FOPFlow: { type: BodyFlow size:4 region:FOPRegion: { type:3 extent:0.0}} }
-->
<!-- begin table FOPTable { id: 992 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:3 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<!-- endof table id FOPTable { id: 992 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 4 flow:FOPFlow: { type: BodyFlow size:3 region:FOPRegion: { type:3 extent:0.0}} }
-->
<!-- begin table FOPTable { id: 995 cur_size: 28.7 prv_size: 0.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:2 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">

<!-- begin table FOPTable { id: 996 cur_size: 0.0 prv_size: 20.41 prev: 995 cols: 1 locks: 2 flow:null }
-->
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">

<!-- begin table FOPTable { id: 997 cur_size: 0.0 prv_size: 20.409999999999997 prev: 996 cols: 9 locks: 5 flow:null }
-->
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="4.709999999999996cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="3.9cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL1_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL2_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL3_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL4_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL5_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL6_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-right="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block text-align="end">ROW1_COL7_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL8_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL9_VALUE</fo:block>
</fo:table-cell>
</fo:table-row>


<!-- A LOT OF ROWS HERE -->

<!-- I want to insert a break-before attribute as below -->
<fo:table-row break-before="page">
<!-- columns here -->
</fo:table-row>

<!-- MORE ROWS HERE -->

<!-- LAST ROW NEXT -->
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL1_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL2_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL3_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL4_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL5_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL6_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-right="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block text-align="end">ROW20_COL7_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL8_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL9_VALUE</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- endof table id FOPTable { id: 997 cur_size: 28.7 prv_size: 20.409999999999997 prev: 996 cols: 9 locks: 6 flow:null }
-->
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>









share|improve this question















I have an XSL-FO document. This document has a lot of fo:table nested.
There is an inner fo:table that has 9 columns and a lot of rows, in this example, first row for table header and other rows, from 1 to 20 for content. In the example below you can see that as a comment, for each FOPTable (fo:table) it is indicated a unique identifier, but this identifier is not always the same for the same table. It is generated randomly by the application that creates this XSL-FO document.



My question is: I want to find the table which has its first column header value set to HEADER_COL1 (this value is always the same), in this example, table identified with id:997 (rember that I cannot search for table according to this identifier since it changes randomly each time application creates the XSL-FO document). Once I have found the desired table I want below:




  1. How can I insert an attribute break-before="page" for a concrete
    fo:table-row item?

  2. I want to get the number of rows that this inner table has.


For example:



For example, If I want to insert this attribute for the 15th fo:table-row item, how can I do this? I want a parametrized generic method that take as an argument a number indicating the fo:table-row where to put this attribute.



I know that I can read the XSL-FO document using below:



string xmlFile = File.ReadAllText(@"C:TempMyXSLFO.xml");
XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(xmlFile);


But once loaded i have no idea on how to do this.



Note: I am using Visual Studio 2008, C# and .NET 3.5.



<?xml version="1.0" encoding="ISO-8859-1" ?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<!-- begin table FOPTable { id: 987 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:4 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<!-- endof table id FOPTable { id: 987 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 5 flow:FOPFlow: { type: BodyFlow size:4 region:FOPRegion: { type:3 extent:0.0}} }
-->
<!-- begin table FOPTable { id: 992 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:3 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<!-- endof table id FOPTable { id: 992 cur_size: 28.7 prv_size: 20.0 prev: <none> cols: 2 locks: 4 flow:FOPFlow: { type: BodyFlow size:3 region:FOPRegion: { type:3 extent:0.0}} }
-->
<!-- begin table FOPTable { id: 995 cur_size: 28.7 prv_size: 0.0 prev: <none> cols: 2 locks: 2 flow:FOPFlow: { type: BodyFlow size:2 region:FOPRegion: { type:3 extent:0.0}} }
-->
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">

<!-- begin table FOPTable { id: 996 cur_size: 0.0 prv_size: 20.41 prev: 995 cols: 1 locks: 2 flow:null }
-->
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">

<!-- begin table FOPTable { id: 997 cur_size: 0.0 prv_size: 20.409999999999997 prev: 996 cols: 9 locks: 5 flow:null }
-->
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="4.709999999999996cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="3.9cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL1_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL2_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL3_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL4_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL5_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL6_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-right="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block text-align="end">ROW1_COL7_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL8_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW1_COL9_VALUE</fo:block>
</fo:table-cell>
</fo:table-row>


<!-- A LOT OF ROWS HERE -->

<!-- I want to insert a break-before attribute as below -->
<fo:table-row break-before="page">
<!-- columns here -->
</fo:table-row>

<!-- MORE ROWS HERE -->

<!-- LAST ROW NEXT -->
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL1_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL2_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL3_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL4_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL5_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL6_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-right="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block text-align="end">ROW20_COL7_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL8_VALUE</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" font-family="sans-serif" font-size="7pt">
<fo:block>ROW20_COL9_VALUE</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- endof table id FOPTable { id: 997 cur_size: 28.7 prv_size: 20.409999999999997 prev: 996 cols: 9 locks: 6 flow:null }
-->
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>






c# xml visual-studio-2008 .net-3.5 xsl-fo






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 10 at 18:41

























asked Nov 10 at 18:25









user1624552

2,887851102




2,887851102












  • I would use XSLT. Since you're using VS2008, see w3.org/TR/1999/REC-xslt-19991116. You could make a template for your context that adds the attribute for the property, and make an identity template that copies the rest of the document to the result tree.
    – Tony Graham
    Nov 12 at 21:58










  • It seems overly complicated to nest tables 3 levels deep. Is this really necessary?
    – Hobbes
    Nov 15 at 8:39


















  • I would use XSLT. Since you're using VS2008, see w3.org/TR/1999/REC-xslt-19991116. You could make a template for your context that adds the attribute for the property, and make an identity template that copies the rest of the document to the result tree.
    – Tony Graham
    Nov 12 at 21:58










  • It seems overly complicated to nest tables 3 levels deep. Is this really necessary?
    – Hobbes
    Nov 15 at 8:39
















I would use XSLT. Since you're using VS2008, see w3.org/TR/1999/REC-xslt-19991116. You could make a template for your context that adds the attribute for the property, and make an identity template that copies the rest of the document to the result tree.
– Tony Graham
Nov 12 at 21:58




I would use XSLT. Since you're using VS2008, see w3.org/TR/1999/REC-xslt-19991116. You could make a template for your context that adds the attribute for the property, and make an identity template that copies the rest of the document to the result tree.
– Tony Graham
Nov 12 at 21:58












It seems overly complicated to nest tables 3 levels deep. Is this really necessary?
– Hobbes
Nov 15 at 8:39




It seems overly complicated to nest tables 3 levels deep. Is this really necessary?
– Hobbes
Nov 15 at 8:39












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










Taking your data and removing all the cells and other non-important content, one could simply apply an identity XSL to the XSL FO and modify only the target row.



starting with this XML:



<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="4.709999999999996cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="3.9cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
</fo:table-body>
</fo:table>
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>


And applying this XSL which outputs everything as is, except for a template that inserts a page-break on the 12th row in the target table:



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
<xsl:param name="breakrow" select="12"/>

<xsl:template match="fo:table-row">
<xsl:variable name="rowcnt" select="count(preceding-sibling::fo:table-row)"/>
<xsl:choose>
<xsl:when test="parent::fo:table-header">
<fo:table-row>
<xsl:apply-templates/>
</fo:table-row>
</xsl:when>
<xsl:when test="$rowcnt = $breakrow and ancestor::fo:table[1]/fo:table-header/fo:table-row[1]/fo:table-cell[1]/fo:block/text() = 'HEADER_COL1'">
<fo:table-row break-before="page"/>
</xsl:when>
<xsl:otherwise>
<fo:table-row/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>


The result is this:



<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="4.709999999999996cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="3.9cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row break-before="page"/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
</fo:table-body>
</fo:table>
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>


I passed in 12 as a parameter and assumed that you had only one place ... the 12th row. You can certainly use "mod" and do every 12th row or whatever you desire.



Like for instance:



 <xsl:when test="$rowcnt mod $breakrow = $breakrow - 1 and ancestor::fo:table[1]/fo:table-header/fo:table-row[1]/fo:table-cell[1]/fo:block/text() = 'HEADER_COL1'">


And of course you can just add to the rows to get all the cell content output.






share|improve this answer























  • Great approach, out of curiosity can I apply more <xsl:when>? for example: if $rowcnt >10 and $rowcnt <20 then apply $rowcnt = $breakrow else if $rowcnt >=20 and $rowcnt <50 then apply $rowcnt = $AnotherBreakrow else apply $rowcnt mod $breakrow = $breakrow - 1
    – user1624552
    yesterday












  • Of course but typically one would do what i wrote last using mod which inserts a break every "x" rows
    – Kevin Brown
    yesterday












  • If the answer helped you consider marking the question appropriately.
    – Kevin Brown
    yesterday










  • The answer helped but can you indicate me on how to do what explained in my previous comment please?
    – user1624552
    yesterday











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242091%2fxsl-fo-document-inserting-a-break-before-page-attribute-in-a-concrete-fotabl%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










Taking your data and removing all the cells and other non-important content, one could simply apply an identity XSL to the XSL FO and modify only the target row.



starting with this XML:



<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="4.709999999999996cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="3.9cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
</fo:table-body>
</fo:table>
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>


And applying this XSL which outputs everything as is, except for a template that inserts a page-break on the 12th row in the target table:



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
<xsl:param name="breakrow" select="12"/>

<xsl:template match="fo:table-row">
<xsl:variable name="rowcnt" select="count(preceding-sibling::fo:table-row)"/>
<xsl:choose>
<xsl:when test="parent::fo:table-header">
<fo:table-row>
<xsl:apply-templates/>
</fo:table-row>
</xsl:when>
<xsl:when test="$rowcnt = $breakrow and ancestor::fo:table[1]/fo:table-header/fo:table-row[1]/fo:table-cell[1]/fo:block/text() = 'HEADER_COL1'">
<fo:table-row break-before="page"/>
</xsl:when>
<xsl:otherwise>
<fo:table-row/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>


The result is this:



<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="4.709999999999996cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="3.9cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row break-before="page"/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
</fo:table-body>
</fo:table>
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>


I passed in 12 as a parameter and assumed that you had only one place ... the 12th row. You can certainly use "mod" and do every 12th row or whatever you desire.



Like for instance:



 <xsl:when test="$rowcnt mod $breakrow = $breakrow - 1 and ancestor::fo:table[1]/fo:table-header/fo:table-row[1]/fo:table-cell[1]/fo:block/text() = 'HEADER_COL1'">


And of course you can just add to the rows to get all the cell content output.






share|improve this answer























  • Great approach, out of curiosity can I apply more <xsl:when>? for example: if $rowcnt >10 and $rowcnt <20 then apply $rowcnt = $breakrow else if $rowcnt >=20 and $rowcnt <50 then apply $rowcnt = $AnotherBreakrow else apply $rowcnt mod $breakrow = $breakrow - 1
    – user1624552
    yesterday












  • Of course but typically one would do what i wrote last using mod which inserts a break every "x" rows
    – Kevin Brown
    yesterday












  • If the answer helped you consider marking the question appropriately.
    – Kevin Brown
    yesterday










  • The answer helped but can you indicate me on how to do what explained in my previous comment please?
    – user1624552
    yesterday















up vote
0
down vote



accepted










Taking your data and removing all the cells and other non-important content, one could simply apply an identity XSL to the XSL FO and modify only the target row.



starting with this XML:



<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="4.709999999999996cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="3.9cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
</fo:table-body>
</fo:table>
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>


And applying this XSL which outputs everything as is, except for a template that inserts a page-break on the 12th row in the target table:



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
<xsl:param name="breakrow" select="12"/>

<xsl:template match="fo:table-row">
<xsl:variable name="rowcnt" select="count(preceding-sibling::fo:table-row)"/>
<xsl:choose>
<xsl:when test="parent::fo:table-header">
<fo:table-row>
<xsl:apply-templates/>
</fo:table-row>
</xsl:when>
<xsl:when test="$rowcnt = $breakrow and ancestor::fo:table[1]/fo:table-header/fo:table-row[1]/fo:table-cell[1]/fo:block/text() = 'HEADER_COL1'">
<fo:table-row break-before="page"/>
</xsl:when>
<xsl:otherwise>
<fo:table-row/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>


The result is this:



<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="4.709999999999996cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="3.9cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row break-before="page"/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
</fo:table-body>
</fo:table>
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>


I passed in 12 as a parameter and assumed that you had only one place ... the 12th row. You can certainly use "mod" and do every 12th row or whatever you desire.



Like for instance:



 <xsl:when test="$rowcnt mod $breakrow = $breakrow - 1 and ancestor::fo:table[1]/fo:table-header/fo:table-row[1]/fo:table-cell[1]/fo:block/text() = 'HEADER_COL1'">


And of course you can just add to the rows to get all the cell content output.






share|improve this answer























  • Great approach, out of curiosity can I apply more <xsl:when>? for example: if $rowcnt >10 and $rowcnt <20 then apply $rowcnt = $breakrow else if $rowcnt >=20 and $rowcnt <50 then apply $rowcnt = $AnotherBreakrow else apply $rowcnt mod $breakrow = $breakrow - 1
    – user1624552
    yesterday












  • Of course but typically one would do what i wrote last using mod which inserts a break every "x" rows
    – Kevin Brown
    yesterday












  • If the answer helped you consider marking the question appropriately.
    – Kevin Brown
    yesterday










  • The answer helped but can you indicate me on how to do what explained in my previous comment please?
    – user1624552
    yesterday













up vote
0
down vote



accepted







up vote
0
down vote



accepted






Taking your data and removing all the cells and other non-important content, one could simply apply an identity XSL to the XSL FO and modify only the target row.



starting with this XML:



<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="4.709999999999996cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="3.9cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
</fo:table-body>
</fo:table>
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>


And applying this XSL which outputs everything as is, except for a template that inserts a page-break on the 12th row in the target table:



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
<xsl:param name="breakrow" select="12"/>

<xsl:template match="fo:table-row">
<xsl:variable name="rowcnt" select="count(preceding-sibling::fo:table-row)"/>
<xsl:choose>
<xsl:when test="parent::fo:table-header">
<fo:table-row>
<xsl:apply-templates/>
</fo:table-row>
</xsl:when>
<xsl:when test="$rowcnt = $breakrow and ancestor::fo:table[1]/fo:table-header/fo:table-row[1]/fo:table-cell[1]/fo:block/text() = 'HEADER_COL1'">
<fo:table-row break-before="page"/>
</xsl:when>
<xsl:otherwise>
<fo:table-row/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>


The result is this:



<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="4.709999999999996cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="3.9cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row break-before="page"/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
</fo:table-body>
</fo:table>
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>


I passed in 12 as a parameter and assumed that you had only one place ... the 12th row. You can certainly use "mod" and do every 12th row or whatever you desire.



Like for instance:



 <xsl:when test="$rowcnt mod $breakrow = $breakrow - 1 and ancestor::fo:table[1]/fo:table-header/fo:table-row[1]/fo:table-cell[1]/fo:block/text() = 'HEADER_COL1'">


And of course you can just add to the rows to get all the cell content output.






share|improve this answer














Taking your data and removing all the cells and other non-important content, one could simply apply an identity XSL to the XSL FO and modify only the target row.



starting with this XML:



<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="4.709999999999996cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="3.9cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-column column-width="2.87cm" />
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
</fo:table-body>
</fo:table>
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>


And applying this XSL which outputs everything as is, except for a template that inserts a page-break on the 12th row in the target table:



<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="2.0">
<xsl:param name="breakrow" select="12"/>

<xsl:template match="fo:table-row">
<xsl:variable name="rowcnt" select="count(preceding-sibling::fo:table-row)"/>
<xsl:choose>
<xsl:when test="parent::fo:table-header">
<fo:table-row>
<xsl:apply-templates/>
</fo:table-row>
</xsl:when>
<xsl:when test="$rowcnt = $breakrow and ancestor::fo:table[1]/fo:table-header/fo:table-row[1]/fo:table-cell[1]/fo:block/text() = 'HEADER_COL1'">
<fo:table-row break-before="page"/>
</xsl:when>
<xsl:otherwise>
<fo:table-row/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>


The result is this:



<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

<fo:page-sequence force-page-count="no-force" master-reference="first" initial-page-number="1">
<fo:flow flow-name="xsl-region-body">
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
</fo:table>
<fo:table font-size="8pt" font-family="sans-serif" space-before.optimum="0.05cm" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table font-size="8pt" font-family="sans-serif" table-layout="fixed">
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="4.709999999999996cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="3.9cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-column column-width="2.87cm"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL1</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL2</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL3</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL4</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL5</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL6</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL7</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL8</fo:block>
</fo:table-cell>
<fo:table-cell padding-top="2.0pt" padding-left="2.0pt" border-style="solid" border-width="0.5pt" border-color="#000000" background-color="#D6DEE7" font-family="sans-serif">
<fo:block>HEADER_COL9</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row break-before="page"/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
<fo:table-row/>
</fo:table-body>
</fo:table>
</fo:table>

</fo:table>

</fo:flow>
</fo:page-sequence>
</fo:root>


I passed in 12 as a parameter and assumed that you had only one place ... the 12th row. You can certainly use "mod" and do every 12th row or whatever you desire.



Like for instance:



 <xsl:when test="$rowcnt mod $breakrow = $breakrow - 1 and ancestor::fo:table[1]/fo:table-header/fo:table-row[1]/fo:table-cell[1]/fo:block/text() = 'HEADER_COL1'">


And of course you can just add to the rows to get all the cell content output.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 16 at 22:06

























answered Nov 16 at 21:50









Kevin Brown

6,76721128




6,76721128












  • Great approach, out of curiosity can I apply more <xsl:when>? for example: if $rowcnt >10 and $rowcnt <20 then apply $rowcnt = $breakrow else if $rowcnt >=20 and $rowcnt <50 then apply $rowcnt = $AnotherBreakrow else apply $rowcnt mod $breakrow = $breakrow - 1
    – user1624552
    yesterday












  • Of course but typically one would do what i wrote last using mod which inserts a break every "x" rows
    – Kevin Brown
    yesterday












  • If the answer helped you consider marking the question appropriately.
    – Kevin Brown
    yesterday










  • The answer helped but can you indicate me on how to do what explained in my previous comment please?
    – user1624552
    yesterday


















  • Great approach, out of curiosity can I apply more <xsl:when>? for example: if $rowcnt >10 and $rowcnt <20 then apply $rowcnt = $breakrow else if $rowcnt >=20 and $rowcnt <50 then apply $rowcnt = $AnotherBreakrow else apply $rowcnt mod $breakrow = $breakrow - 1
    – user1624552
    yesterday












  • Of course but typically one would do what i wrote last using mod which inserts a break every "x" rows
    – Kevin Brown
    yesterday












  • If the answer helped you consider marking the question appropriately.
    – Kevin Brown
    yesterday










  • The answer helped but can you indicate me on how to do what explained in my previous comment please?
    – user1624552
    yesterday
















Great approach, out of curiosity can I apply more <xsl:when>? for example: if $rowcnt >10 and $rowcnt <20 then apply $rowcnt = $breakrow else if $rowcnt >=20 and $rowcnt <50 then apply $rowcnt = $AnotherBreakrow else apply $rowcnt mod $breakrow = $breakrow - 1
– user1624552
yesterday






Great approach, out of curiosity can I apply more <xsl:when>? for example: if $rowcnt >10 and $rowcnt <20 then apply $rowcnt = $breakrow else if $rowcnt >=20 and $rowcnt <50 then apply $rowcnt = $AnotherBreakrow else apply $rowcnt mod $breakrow = $breakrow - 1
– user1624552
yesterday














Of course but typically one would do what i wrote last using mod which inserts a break every "x" rows
– Kevin Brown
yesterday






Of course but typically one would do what i wrote last using mod which inserts a break every "x" rows
– Kevin Brown
yesterday














If the answer helped you consider marking the question appropriately.
– Kevin Brown
yesterday




If the answer helped you consider marking the question appropriately.
– Kevin Brown
yesterday












The answer helped but can you indicate me on how to do what explained in my previous comment please?
– user1624552
yesterday




The answer helped but can you indicate me on how to do what explained in my previous comment please?
– user1624552
yesterday


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242091%2fxsl-fo-document-inserting-a-break-before-page-attribute-in-a-concrete-fotabl%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma