Question

I have some XML that I am trying to convert into a report, suitable for printing. So far, everything is going well, except for one part.

This involves the current page number the row in question is currently being outputted to. I am using <fo:page-number/> to get the current page number, but I have run head long into a wall about using the information in relation to the current rows siblings after I found out that I could not have a variable with a scope across the for-each, let alone be changed.

So, I am currently toying with the idea that on each iteration, the current node being used has a new element (or attribute) introduced that contains the value for fo:page-number as it appeared at the time. Then, in the next iteration, I would fetch the element/attribute from preceding-sibling::, then test if that the current fo:page-number is different from that value.

Sadly, I am not having much luck in finding a way to do this, and all I get from googling is reams of results from w3fools. Does anyone know if this is possible, and if so, how to do it?

Was it helpful?

Solution

For the sake of an answer, no, this is not possible.

Basically, repeating headers at the top of every page is possible in XSL-FO, when the attribute omit-header-at-break is set to "false". See http://www.schemacentral.com/sc/fo11/a-table-omit-header-at-break-1.html and http://www.w3.org/TR/xsl/#table-omit-header-at-break for more information on this. I know that this is implemented in Apache FOP, but should also be available with other FO processors.

But of course, this solution assumes that your table header is classified as a header, that is, is semantically a header as opposed to superficially looking like a header while simply being the first row of a table. I understand that the latter is true in your case.

(However, I cannot imagine what kind of specification could keep you from defining the first row of each table as the header which could be repeated.)

Also, while XML data is transformed to XSL-FO, the outcome of a fo:page-number instruction is not available yet. Thus, you cannot use it in your stylesheet (this part of the answer is contributed by @Ian Roberts). This is because an XSLT stylesheet it processed by an XSLT processor like Saxon that has no concept of FO instructions. fo:page-number is interpreted only by the FO processor.


The only solution I see is to alter your specification to allow fo:table-header elements. By using only table rows and cells, you effectively "sideline" header repetitions after page breaks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top